]>
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 | |
9 | // Licence: wxWindows licence | |
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" | |
22 | ||
23 | WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; | |
24 | WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; | |
25 | ||
26 | class WXDLLEXPORT wxMenuBar; | |
27 | class WXDLLEXPORT wxStatusBar; | |
28 | ||
29 | class WXDLLEXPORT wxFrame: public wxWindow { | |
30 | ||
31 | DECLARE_DYNAMIC_CLASS(wxFrame) | |
32 | ||
33 | public: | |
34 | wxFrame(); | |
35 | inline wxFrame(wxWindow *parent, | |
36 | wxWindowID id, | |
37 | const wxString& title, | |
38 | const wxPoint& pos = wxDefaultPosition, | |
39 | const wxSize& size = wxDefaultSize, | |
40 | long style = wxDEFAULT_FRAME_STYLE, | |
41 | const wxString& name = wxFrameNameStr) | |
42 | { | |
43 | Create(parent, id, title, pos, size, style, name); | |
44 | } | |
45 | ||
46 | ~wxFrame(); | |
47 | ||
48 | bool Create(wxWindow *parent, | |
49 | wxWindowID id, | |
50 | const wxString& title, | |
51 | const wxPoint& pos = wxDefaultPosition, | |
52 | const wxSize& size = wxDefaultSize, | |
53 | long style = wxDEFAULT_FRAME_STYLE, | |
54 | const wxString& name = wxFrameNameStr); | |
55 | ||
56 | virtual bool Destroy(); | |
57 | void SetClientSize(int width, int height); | |
58 | void GetClientSize(int *width, int *height) const; | |
59 | ||
60 | void GetSize(int *width, int *height) const ; | |
61 | void GetPosition(int *x, int *y) const ; | |
62 | void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
87d1e11f JS |
63 | void ClientToScreen(int *x, int *y) const; |
64 | void ScreenToClient(int *x, int *y) const; | |
9b6dbb09 JS |
65 | |
66 | virtual bool OnClose(); | |
67 | ||
68 | void OnSize(wxSizeEvent& event); | |
69 | void OnMenuHighlight(wxMenuEvent& event); | |
70 | void OnActivate(wxActivateEvent& event); | |
71 | void OnIdle(wxIdleEvent& event); | |
72 | void OnCloseWindow(wxCloseEvent& event); | |
73 | ||
74 | bool Show(bool show); | |
75 | ||
76 | // Set menu bar | |
77 | void SetMenuBar(wxMenuBar *menu_bar); | |
78 | virtual wxMenuBar *GetMenuBar() const ; | |
79 | ||
80 | // Set title | |
81 | void SetTitle(const wxString& title); | |
82 | inline wxString GetTitle() const { return m_title; } | |
83 | ||
84 | void Centre(int direction = wxBOTH); | |
85 | ||
86 | // Call this to simulate a menu command | |
87 | virtual void Command(int id); | |
88 | virtual void ProcessCommand(int id); | |
89 | ||
90 | // Set icon | |
91 | virtual void SetIcon(const wxIcon& icon); | |
92 | ||
93 | // Create status line | |
94 | virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, | |
95 | const wxString& name = "statusBar"); | |
96 | inline wxStatusBar *GetStatusBar() const { return m_frameStatusBar; } | |
97 | virtual void PositionStatusBar(); | |
98 | virtual wxStatusBar *OnCreateStatusBar(int number, long style, wxWindowID id, | |
99 | const wxString& name); | |
100 | ||
101 | // Create toolbar | |
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(); | |
108 | ||
109 | // Set status line text | |
110 | virtual void SetStatusText(const wxString& text, int number = 0); | |
111 | ||
112 | // Set status line widths | |
113 | virtual void SetStatusWidths(int n, const int widths_field[]); | |
114 | ||
115 | // Hint to tell framework which status bar to use | |
116 | // TODO: should this go into a wxFrameworkSettings class perhaps? | |
117 | static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; }; | |
118 | static bool UsesNativeStatusBar() { return m_useNativeStatusBar; }; | |
119 | ||
120 | // Fit frame around subwindows | |
121 | virtual void Fit(); | |
122 | ||
123 | // Iconize | |
124 | virtual void Iconize(bool iconize); | |
125 | ||
126 | virtual bool IsIconized() const ; | |
127 | ||
128 | // Compatibility | |
129 | inline bool Iconized() const { return IsIconized(); } | |
130 | ||
131 | virtual void Maximize(bool maximize); | |
132 | ||
133 | // Responds to colour changes | |
134 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
135 | ||
136 | // Query app for menu item updates (called from OnIdle) | |
137 | void DoMenuUpdates(); | |
138 | void DoMenuUpdates(wxMenu* menu); | |
139 | ||
140 | // Checks if there is a toolbar, and returns the first free client position | |
141 | virtual wxPoint GetClientAreaOrigin() const; | |
142 | ||
143 | virtual void Raise(); | |
144 | virtual void Lower(); | |
145 | ||
146 | virtual void CaptureMouse(); | |
147 | virtual void ReleaseMouse(); | |
148 | ||
0d57be45 | 149 | // Implementation |
4b5f3fe6 | 150 | virtual void ChangeFont(bool keepOriginalSize = TRUE); |
0d57be45 JS |
151 | virtual void ChangeBackgroundColour(); |
152 | virtual void ChangeForegroundColour(); | |
9b6dbb09 | 153 | WXWidget GetMenuBarWidget() const ; |
50414e24 JS |
154 | inline WXWidget GetShellWidget() const { return m_frameShell; } |
155 | inline WXWidget GetWorkAreaWidget() const { return m_workArea; } | |
156 | inline WXWidget GetClientAreaWidget() const { return m_clientArea; } | |
dfc54541 | 157 | inline WXWidget GetTopWidget() const { return m_frameShell; } |
621793f4 | 158 | inline WXWidget GetMainWindowWidget() const { return m_frameWidget; } |
50414e24 JS |
159 | |
160 | // The widget that can have children on it | |
161 | WXWidget GetClientWidget() const; | |
9b6dbb09 JS |
162 | bool GetVisibleStatus() const { return m_visibleStatus; } |
163 | ||
164 | bool PreResize(); | |
165 | ||
166 | protected: | |
167 | wxMenuBar * m_frameMenuBar; | |
168 | wxStatusBar * m_frameStatusBar; | |
169 | wxIcon m_icon; | |
170 | bool m_iconized; | |
171 | static bool m_useNativeStatusBar; | |
172 | wxToolBar * m_frameToolBar ; | |
173 | ||
174 | //// Motif-specific | |
175 | ||
176 | WXWidget m_frameShell; | |
177 | WXWidget m_frameWidget; | |
178 | WXWidget m_workArea; | |
179 | WXWidget m_clientArea; | |
180 | // WXWidget m_menuBarWidget; | |
181 | bool m_visibleStatus; | |
182 | wxString m_title; | |
183 | ||
184 | DECLARE_EVENT_TABLE() | |
185 | }; | |
186 | ||
187 | #endif | |
188 | // _WX_FRAME_H_ |