]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/frame.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFrame class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "frame.h"
19 #include "wx/window.h"
20 #include "wx/toolbar.h"
21 #include "wx/msw/accel.h"
24 WXDLLEXPORT_DATA(extern const wxChar
*) wxFrameNameStr
;
25 WXDLLEXPORT_DATA(extern const wxChar
*) wxToolBarNameStr
;
26 WXDLLEXPORT_DATA(extern const wxChar
*) wxStatusLineNameStr
;
28 class WXDLLEXPORT wxMenuBar
;
29 class WXDLLEXPORT wxStatusBar
;
31 class WXDLLEXPORT wxFrame
: public wxWindow
33 DECLARE_DYNAMIC_CLASS(wxFrame
)
37 wxFrame(wxWindow
*parent
,
39 const wxString
& title
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
42 long style
= wxDEFAULT_FRAME_STYLE
,
43 const wxString
& name
= wxFrameNameStr
)
45 Create(parent
, id
, title
, pos
, size
, style
, name
);
50 bool Create(wxWindow
*parent
,
52 const wxString
& title
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
55 long style
= wxDEFAULT_FRAME_STYLE
,
56 const wxString
& name
= wxFrameNameStr
);
58 virtual bool Destroy();
60 virtual void ClientToScreen(int *x
, int *y
) const;
61 virtual void ScreenToClient(int *x
, int *y
) const;
63 void OnSize(wxSizeEvent
& event
);
64 void OnMenuHighlight(wxMenuEvent
& event
);
65 void OnActivate(wxActivateEvent
& event
);
66 void OnIdle(wxIdleEvent
& event
);
67 void OnCloseWindow(wxCloseEvent
& event
);
73 void SetMenuBar(wxMenuBar
*menu_bar
);
74 virtual wxMenuBar
*GetMenuBar() const;
76 // Call this to simulate a menu command
77 bool Command(int id
) { return ProcessCommand(id
); }
79 // process menu command: returns TRUE if processed
80 bool ProcessCommand(int id
);
82 // make the window modal (all other windows unresponsive)
83 virtual void MakeModal(bool modal
= TRUE
);
86 virtual void SetIcon(const wxIcon
& icon
);
90 virtual wxToolBar
* CreateToolBar(long style
= wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_FLAT
,
92 const wxString
& name
= wxToolBarNameStr
);
94 virtual wxToolBar
*OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
);
96 virtual void SetToolBar(wxToolBar
*toolbar
) { m_frameToolBar
= toolbar
; }
97 virtual wxToolBar
*GetToolBar() const { return m_frameToolBar
; }
99 virtual void PositionToolBar();
100 #endif // wxUSE_TOOLBAR
104 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
105 long style
= wxST_SIZEGRIP
,
107 const wxString
& name
= wxStatusLineNameStr
);
109 wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
110 void SetStatusBar(wxStatusBar
*statusBar
) { m_frameStatusBar
= statusBar
; }
112 virtual void PositionStatusBar();
113 virtual wxStatusBar
*OnCreateStatusBar(int number
,
116 const wxString
& name
);
118 // Set status line text
119 virtual void SetStatusText(const wxString
& text
, int number
= 0);
121 // Set status line widths
122 virtual void SetStatusWidths(int n
, const int widths_field
[]);
124 // Hint to tell framework which status bar to use
125 // TODO: should this go into a wxFrameworkSettings class perhaps?
126 static void UseNativeStatusBar(bool useNative
) { m_useNativeStatusBar
= useNative
; };
127 static bool UsesNativeStatusBar() { return m_useNativeStatusBar
; };
128 #endif // wxUSE_STATUSBAR
131 virtual void Iconize(bool iconize
);
133 virtual bool IsIconized() const;
136 virtual bool IsMaximized() const;
139 bool Iconized() const { return IsIconized(); }
141 virtual void Maximize(bool maximize
);
142 // virtual bool LoadAccelerators(const wxString& table);
144 // Responds to colour changes
145 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
147 // Query app for menu item updates (called from OnIdle)
148 void DoMenuUpdates();
149 void DoMenuUpdates(wxMenu
* menu
, wxWindow
* focusWin
);
151 WXHMENU
GetWinMenu() const { return m_hMenu
; }
153 // Returns the origin of client area (may be different from (0,0) if the
154 // frame has a toolbar)
155 virtual wxPoint
GetClientAreaOrigin() const;
157 // Implementation only from here
160 bool HandleSize(int x
, int y
, WXUINT flag
);
161 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
162 bool HandleMenuSelect(WXWORD nItem
, WXWORD nFlags
, WXHMENU hMenu
);
164 bool MSWCreate(int id
, wxWindow
*parent
, const wxChar
*wclass
,
165 wxWindow
*wx_win
, const wxChar
*title
,
166 int x
, int y
, int width
, int height
, long style
);
168 // tooltip management
170 WXHWND
GetToolTipCtrl() const { return m_hwndToolTip
; }
171 void SetToolTipCtrl(WXHWND hwndTT
) { m_hwndToolTip
= hwndTT
; }
175 // override base class virtuals
176 virtual void DoGetClientSize(int *width
, int *height
) const;
177 virtual void DoGetSize(int *width
, int *height
) const;
178 virtual void DoGetPosition(int *x
, int *y
) const;
180 virtual void DoSetSize(int x
, int y
,
181 int width
, int height
,
182 int sizeFlags
= wxSIZE_AUTO
);
183 virtual void DoSetClientSize(int width
, int height
);
185 // a plug in for MDI frame classes which need to do something special when
186 // the menubar is set
187 virtual void InternalSetMenuBar();
189 // propagate our state change to all child frames
190 void IconizeChildFrames(bool bIconize
);
192 // we add menu bar accel processing
193 bool MSWTranslateMessage(WXMSG
* pMsg
);
195 // window proc for the frames
196 long MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
198 wxMenuBar
* m_frameMenuBar
;
201 WXHICON m_defaultIcon
;
204 wxStatusBar
* m_frameStatusBar
;
206 static bool m_useNativeStatusBar
;
207 #endif // wxUSE_STATUSBAR
210 wxToolBar
* m_frameToolBar
;
211 #endif // wxUSE_TOOLBAR
215 WXHWND m_hwndToolTip
;
218 DECLARE_EVENT_TABLE()