]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/frame.h
Added menu_highlight behaviour as in wxMSW (statusbar)
[wxWidgets.git] / include / wx / motif / frame.h
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
58 void SetClientSize(int width, int height);
59 void SetClientSize(const wxSize& size) { wxWindow::SetClientSize(size); }
60
61 void GetClientSize(int *width, int *height) const;
62 wxSize GetClientSize() const { return wxWindow::GetClientSize(); }
63
64 void GetSize(int *width, int *height) const ;
65 wxSize GetSize() const { return wxWindow::GetSize(); }
66
67 void GetPosition(int *x, int *y) const ;
68 wxPoint GetPosition() const { return wxWindow::GetPosition(); }
69
70 void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
71 virtual void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
72 { wxWindow::SetSize(rect, sizeFlags); }
73 virtual void SetSize(const wxSize& size) { wxWindow::SetSize(size); }
74 virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
75
76 void ClientToScreen(int *x, int *y) const;
77 wxPoint ClientToScreen(const wxPoint& pt) const { return wxWindow::ClientToScreen(pt); }
78
79 void ScreenToClient(int *x, int *y) const;
80 wxPoint ScreenToClient(const wxPoint& pt) const { return wxWindow::ScreenToClient(pt); }
81
82 virtual bool OnClose();
83
84 void OnSize(wxSizeEvent& event);
85 void OnMenuHighlight(wxMenuEvent& event);
86 void OnActivate(wxActivateEvent& event);
87 void OnIdle(wxIdleEvent& event);
88 void OnCloseWindow(wxCloseEvent& event);
89
90 bool Show(bool show);
91
92 // Set menu bar
93 void SetMenuBar(wxMenuBar *menu_bar);
94 virtual wxMenuBar *GetMenuBar() const ;
95
96 // Set title
97 void SetTitle(const wxString& title);
98 inline wxString GetTitle() const { return m_title; }
99
100 void Centre(int direction = wxBOTH);
101
102 // Call this to simulate a menu command
103 virtual void Command(int id);
104 virtual void ProcessCommand(int id);
105
106 // Set icon
107 virtual void SetIcon(const wxIcon& icon);
108
109 // Create status line
110 virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
111 const wxString& name = "statusBar");
112 inline wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
113 virtual void PositionStatusBar();
114 virtual wxStatusBar *OnCreateStatusBar(int number, long style, wxWindowID id,
115 const wxString& name);
116
117 // Create toolbar
118 #if wxUSE_TOOLBAR
119 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr);
120 virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name);
121 // If made known to the frame, the frame will manage it automatically.
122 virtual void SetToolBar(wxToolBar *toolbar) ;
123 virtual wxToolBar *GetToolBar() const ;
124 virtual void PositionToolBar();
125 #endif // wxUSE_TOOLBAR
126
127 // Set status line text
128 virtual void SetStatusText(const wxString& text, int number = 0);
129
130 // Set status line widths
131 virtual void SetStatusWidths(int n, const int widths_field[]);
132
133 // Hint to tell framework which status bar to use
134 // TODO: should this go into a wxFrameworkSettings class perhaps?
135 static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
136 static bool UsesNativeStatusBar() { return m_useNativeStatusBar; };
137
138 // Fit frame around subwindows
139 virtual void Fit();
140
141 // Iconize
142 virtual void Iconize(bool iconize);
143
144 virtual bool IsIconized() const ;
145
146 // Compatibility
147 inline bool Iconized() const { return IsIconized(); }
148
149 // Is the frame maximized? Returns FALSE under Motif (but TRUE for
150 // wxMDIChildFrame due to the tabbed implementation).
151 virtual bool IsMaximized(void) const ;
152
153 virtual void Maximize(bool maximize);
154
155 // Responds to colour changes
156 void OnSysColourChanged(wxSysColourChangedEvent& event);
157
158 // Query app for menu item updates (called from OnIdle)
159 void DoMenuUpdates();
160 void DoMenuUpdates(wxMenu* menu);
161
162 // Checks if there is a toolbar, and returns the first free client position
163 virtual wxPoint GetClientAreaOrigin() const;
164
165 virtual void Raise();
166 virtual void Lower();
167
168 virtual void CaptureMouse();
169 virtual void ReleaseMouse();
170
171 // Implementation
172 virtual void ChangeFont(bool keepOriginalSize = TRUE);
173 virtual void ChangeBackgroundColour();
174 virtual void ChangeForegroundColour();
175 WXWidget GetMenuBarWidget() const ;
176 inline WXWidget GetShellWidget() const { return m_frameShell; }
177 inline WXWidget GetWorkAreaWidget() const { return m_workArea; }
178 inline WXWidget GetClientAreaWidget() const { return m_clientArea; }
179 inline WXWidget GetTopWidget() const { return m_frameShell; }
180 inline WXWidget GetMainWindowWidget() const { return m_frameWidget; }
181
182 // The widget that can have children on it
183 WXWidget GetClientWidget() const;
184 bool GetVisibleStatus() const { return m_visibleStatus; }
185
186 bool PreResize();
187
188 protected:
189 wxMenuBar * m_frameMenuBar;
190 wxStatusBar * m_frameStatusBar;
191 wxIcon m_icon;
192 bool m_iconized;
193 static bool m_useNativeStatusBar;
194
195 #if wxUSE_TOOLBAR
196 wxToolBar * m_frameToolBar ;
197 #endif // wxUSE_TOOLBAR
198
199 //// Motif-specific
200
201 WXWidget m_frameShell;
202 WXWidget m_frameWidget;
203 WXWidget m_workArea;
204 WXWidget m_clientArea;
205 // WXWidget m_menuBarWidget;
206 bool m_visibleStatus;
207 wxString m_title;
208
209 DECLARE_EVENT_TABLE()
210 };
211
212 #endif
213 // _WX_FRAME_H_