]>
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
);
72 void SetMenuBar(wxMenuBar
*menu_bar
);
73 virtual wxMenuBar
*GetMenuBar() const;
75 // Call this to simulate a menu command
76 bool Command(int id
) { return ProcessCommand(id
); }
78 // process menu command: returns TRUE if processed
79 bool ProcessCommand(int id
);
81 // make the window modal (all other windows unresponsive)
82 virtual void MakeModal(bool modal
= TRUE
);
85 virtual void SetIcon(const wxIcon
& icon
);
89 virtual wxToolBar
* CreateToolBar(long style
= wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_FLAT
,
91 const wxString
& name
= wxToolBarNameStr
);
93 virtual wxToolBar
*OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
);
95 virtual void SetToolBar(wxToolBar
*toolbar
) { m_frameToolBar
= toolbar
; }
96 virtual wxToolBar
*GetToolBar() const { return m_frameToolBar
; }
98 virtual void PositionToolBar();
99 #endif // wxUSE_TOOLBAR
103 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
104 long style
= wxST_SIZEGRIP
,
106 const wxString
& name
= wxStatusLineNameStr
);
108 wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
109 void SetStatusBar(wxStatusBar
*statusBar
) { m_frameStatusBar
= statusBar
; }
111 virtual void PositionStatusBar();
112 virtual wxStatusBar
*OnCreateStatusBar(int number
,
115 const wxString
& name
);
117 // Set status line text
118 virtual void SetStatusText(const wxString
& text
, int number
= 0);
120 // Set status line widths
121 virtual void SetStatusWidths(int n
, const int widths_field
[]);
123 // Hint to tell framework which status bar to use
124 // TODO: should this go into a wxFrameworkSettings class perhaps?
125 static void UseNativeStatusBar(bool useNative
) { m_useNativeStatusBar
= useNative
; };
126 static bool UsesNativeStatusBar() { return m_useNativeStatusBar
; };
127 #endif // wxUSE_STATUSBAR
130 virtual void Iconize(bool iconize
);
132 virtual bool IsIconized() const;
135 virtual bool IsMaximized() const;
138 bool Iconized() const { return IsIconized(); }
140 virtual void Maximize(bool maximize
);
141 // virtual bool LoadAccelerators(const wxString& table);
143 // Responds to colour changes
144 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
146 // Query app for menu item updates (called from OnIdle)
147 void DoMenuUpdates();
148 void DoMenuUpdates(wxMenu
* menu
, wxWindow
* focusWin
);
150 WXHMENU
GetWinMenu() const { return m_hMenu
; }
152 // Returns the origin of client area (may be different from (0,0) if the
153 // frame has a toolbar)
154 virtual wxPoint
GetClientAreaOrigin() const;
156 // Implementation only from here
159 bool HandleSize(int x
, int y
, WXUINT flag
);
160 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
161 bool HandleMenuSelect(WXWORD nItem
, WXWORD nFlags
, WXHMENU hMenu
);
163 bool MSWCreate(int id
, wxWindow
*parent
, const char *wclass
,
164 wxWindow
*wx_win
, const char *title
,
165 int x
, int y
, int width
, int height
, long style
);
167 // tooltip management
169 WXHWND
GetToolTipCtrl() const { return m_hwndToolTip
; }
170 void SetToolTipCtrl(WXHWND hwndTT
) { m_hwndToolTip
= hwndTT
; }
174 // override base class virtuals
175 virtual void DoGetClientSize(int *width
, int *height
) const;
176 virtual void DoGetSize(int *width
, int *height
) const;
177 virtual void DoGetPosition(int *x
, int *y
) const;
179 virtual void DoSetSize(int x
, int y
,
180 int width
, int height
,
181 int sizeFlags
= wxSIZE_AUTO
);
182 virtual void DoSetClientSize(int width
, int height
);
184 // a plug in for MDI frame classes which need to do something special when
185 // the menubar is set
186 virtual void InternalSetMenuBar();
188 // propagate our state change to all child frames
189 void IconizeChildFrames(bool bIconize
);
191 // we add menu bar accel processing
192 bool MSWTranslateMessage(WXMSG
* pMsg
);
194 // window proc for the frames
195 long MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
197 wxMenuBar
* m_frameMenuBar
;
200 WXHICON m_defaultIcon
;
203 wxStatusBar
* m_frameStatusBar
;
205 static bool m_useNativeStatusBar
;
206 #endif // wxUSE_STATUSBAR
209 wxToolBar
* m_frameToolBar
;
210 #endif // wxUSE_TOOLBAR
214 WXHWND m_hwndToolTip
;
217 DECLARE_EVENT_TABLE()