]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: frame.h | |
3 | // Purpose: wxFrame class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
af0bb3b1 | 9 | // Licence: wxWindows licence |
9b6dbb09 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_FRAME_H_ | |
13 | #define _WX_FRAME_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "frame.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/window.h" | |
20 | #include "wx/toolbar.h" | |
21 | #include "wx/accel.h" | |
af0bb3b1 | 22 | #include "wx/icon.h" |
9b6dbb09 JS |
23 | |
24 | WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; | |
25 | WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; | |
26 | ||
27 | class WXDLLEXPORT wxMenuBar; | |
28 | class WXDLLEXPORT wxStatusBar; | |
29 | ||
bfc6fde4 VZ |
30 | class WXDLLEXPORT wxFrame : public wxWindow |
31 | { | |
32 | DECLARE_DYNAMIC_CLASS(wxFrame) | |
9b6dbb09 JS |
33 | |
34 | public: | |
bfc6fde4 VZ |
35 | wxFrame(); |
36 | wxFrame(wxWindow *parent, | |
37 | wxWindowID id, | |
38 | const wxString& title, | |
39 | const wxPoint& pos = wxDefaultPosition, | |
40 | const wxSize& size = wxDefaultSize, | |
41 | long style = wxDEFAULT_FRAME_STYLE, | |
42 | const wxString& name = wxFrameNameStr) | |
43 | { | |
44 | Create(parent, id, title, pos, size, style, name); | |
45 | } | |
46 | ||
47 | ~wxFrame(); | |
48 | ||
49 | bool Create(wxWindow *parent, | |
50 | wxWindowID id, | |
51 | const wxString& title, | |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | long style = wxDEFAULT_FRAME_STYLE, | |
55 | const wxString& name = wxFrameNameStr); | |
56 | ||
57 | virtual bool Destroy(); | |
58 | ||
bfc6fde4 VZ |
59 | void ClientToScreen(int *x, int *y) const; |
60 | wxPoint ClientToScreen(const wxPoint& pt) const { return wxWindow::ClientToScreen(pt); } | |
61 | ||
62 | void ScreenToClient(int *x, int *y) const; | |
63 | wxPoint ScreenToClient(const wxPoint& pt) const { return wxWindow::ScreenToClient(pt); } | |
64 | ||
65 | void OnSize(wxSizeEvent& event); | |
66 | void OnMenuHighlight(wxMenuEvent& event); | |
67 | void OnActivate(wxActivateEvent& event); | |
68 | void OnIdle(wxIdleEvent& event); | |
69 | void OnCloseWindow(wxCloseEvent& event); | |
70 | ||
71 | bool Show(bool show); | |
72 | ||
73 | // Set menu bar | |
74 | void SetMenuBar(wxMenuBar *menu_bar); | |
75 | virtual wxMenuBar *GetMenuBar() const ; | |
76 | ||
77 | // Set title | |
78 | void SetTitle(const wxString& title); | |
79 | wxString GetTitle() const { return m_title; } | |
80 | ||
8487f887 RR |
81 | virtual bool IsTopLevel() const { return TRUE; } |
82 | ||
bfc6fde4 VZ |
83 | void Centre(int direction = wxBOTH); |
84 | ||
85 | // Call this to simulate a menu command | |
86 | virtual void Command(int id); | |
87 | virtual void ProcessCommand(int id); | |
88 | ||
89 | // Set icon | |
90 | virtual void SetIcon(const wxIcon& icon); | |
91 | ||
92 | // Create status line | |
93 | virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, | |
94 | const wxString& name = "statusBar"); | |
95 | wxStatusBar *GetStatusBar() const { return m_frameStatusBar; } | |
96 | virtual void PositionStatusBar(); | |
97 | virtual wxStatusBar *OnCreateStatusBar(int number, long style, wxWindowID id, | |
98 | const wxString& name); | |
99 | ||
100 | // Create toolbar | |
1ccbb61a | 101 | #if wxUSE_TOOLBAR |
bfc6fde4 VZ |
102 | virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr); |
103 | virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name); | |
104 | // If made known to the frame, the frame will manage it automatically. | |
105 | virtual void SetToolBar(wxToolBar *toolbar) ; | |
106 | virtual wxToolBar *GetToolBar() const ; | |
107 | virtual void PositionToolBar(); | |
1ccbb61a | 108 | #endif // wxUSE_TOOLBAR |
9b6dbb09 | 109 | |
bfc6fde4 VZ |
110 | // Set status line text |
111 | virtual void SetStatusText(const wxString& text, int number = 0); | |
9b6dbb09 | 112 | |
bfc6fde4 VZ |
113 | // Set status line widths |
114 | virtual void SetStatusWidths(int n, const int widths_field[]); | |
9b6dbb09 | 115 | |
bfc6fde4 VZ |
116 | // Hint to tell framework which status bar to use |
117 | // TODO: should this go into a wxFrameworkSettings class perhaps? | |
118 | static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; }; | |
119 | static bool UsesNativeStatusBar() { return m_useNativeStatusBar; }; | |
9b6dbb09 | 120 | |
bfc6fde4 VZ |
121 | // Fit frame around subwindows |
122 | virtual void Fit(); | |
9b6dbb09 | 123 | |
bfc6fde4 VZ |
124 | // Iconize |
125 | virtual void Iconize(bool iconize); | |
9b6dbb09 | 126 | |
bfc6fde4 | 127 | virtual bool IsIconized() const ; |
9b6dbb09 | 128 | |
bfc6fde4 VZ |
129 | // Compatibility |
130 | bool Iconized() const { return IsIconized(); } | |
9b6dbb09 | 131 | |
bfc6fde4 VZ |
132 | // Is the frame maximized? Returns FALSE under Motif (but TRUE for |
133 | // wxMDIChildFrame due to the tabbed implementation). | |
134 | virtual bool IsMaximized(void) const ; | |
6f63ec3f | 135 | |
bfc6fde4 | 136 | virtual void Maximize(bool maximize); |
9b6dbb09 | 137 | |
bfc6fde4 VZ |
138 | // Responds to colour changes |
139 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
9b6dbb09 | 140 | |
bfc6fde4 VZ |
141 | // Query app for menu item updates (called from OnIdle) |
142 | void DoMenuUpdates(); | |
e702ff0f | 143 | void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); |
9b6dbb09 | 144 | |
bfc6fde4 VZ |
145 | // Checks if there is a toolbar, and returns the first free client position |
146 | virtual wxPoint GetClientAreaOrigin() const; | |
9b6dbb09 | 147 | |
bfc6fde4 VZ |
148 | virtual void Raise(); |
149 | virtual void Lower(); | |
9b6dbb09 | 150 | |
bfc6fde4 VZ |
151 | virtual void CaptureMouse(); |
152 | virtual void ReleaseMouse(); | |
9b6dbb09 | 153 | |
bfc6fde4 VZ |
154 | // Implementation |
155 | virtual void ChangeFont(bool keepOriginalSize = TRUE); | |
156 | virtual void ChangeBackgroundColour(); | |
157 | virtual void ChangeForegroundColour(); | |
158 | WXWidget GetMenuBarWidget() const ; | |
159 | WXWidget GetShellWidget() const { return m_frameShell; } | |
160 | WXWidget GetWorkAreaWidget() const { return m_workArea; } | |
161 | WXWidget GetClientAreaWidget() const { return m_clientArea; } | |
162 | WXWidget GetTopWidget() const { return m_frameShell; } | |
163 | WXWidget GetMainWindowWidget() const { return m_frameWidget; } | |
50414e24 | 164 | |
bfc6fde4 VZ |
165 | // The widget that can have children on it |
166 | WXWidget GetClientWidget() const; | |
167 | bool GetVisibleStatus() const { return m_visibleStatus; } | |
9b6dbb09 | 168 | |
bfc6fde4 | 169 | bool PreResize(); |
9b6dbb09 | 170 | |
449f38b5 JS |
171 | protected: |
172 | void DoGetClientSize(int *width, int *height) const; | |
173 | void DoGetSize(int *width, int *height) const ; | |
174 | void DoGetPosition(int *x, int *y) const ; | |
175 | ||
9b6dbb09 | 176 | protected: |
bfc6fde4 VZ |
177 | wxMenuBar * m_frameMenuBar; |
178 | wxStatusBar * m_frameStatusBar; | |
179 | wxIcon m_icon; | |
180 | bool m_iconized; | |
181 | static bool m_useNativeStatusBar; | |
1ccbb61a VZ |
182 | |
183 | #if wxUSE_TOOLBAR | |
bfc6fde4 | 184 | wxToolBar * m_frameToolBar ; |
1ccbb61a | 185 | #endif // wxUSE_TOOLBAR |
9b6dbb09 | 186 | |
bfc6fde4 VZ |
187 | //// Motif-specific |
188 | ||
189 | WXWidget m_frameShell; | |
190 | WXWidget m_frameWidget; | |
191 | WXWidget m_workArea; | |
192 | WXWidget m_clientArea; | |
193 | // WXWidget m_menuBarWidget; | |
194 | bool m_visibleStatus; | |
195 | wxString m_title; | |
196 | ||
197 | virtual void DoSetSize(int x, int y, | |
198 | int width, int height, | |
199 | int sizeFlags = wxSIZE_AUTO); | |
9b6dbb09 | 200 | |
bfc6fde4 | 201 | virtual void DoSetClientSize(int width, int height); |
9b6dbb09 | 202 | |
bfc6fde4 VZ |
203 | private: |
204 | DECLARE_EVENT_TABLE() | |
9b6dbb09 JS |
205 | }; |
206 | ||
207 | #endif | |
208 | // _WX_FRAME_H_ |