]> git.saurik.com Git - wxWidgets.git/blame - include/wx/frame.h
test
[wxWidgets.git] / include / wx / frame.h
CommitLineData
7c0ea335
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/frame.h
3// Purpose: wxFrame class interface
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 15.11.99
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_FRAME_H_BASE_
13#define _WX_FRAME_H_BASE_
c801d85f 14
7c0ea335
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#ifdef __GNUG__
20 #pragma interface "framebase.h"
21#endif
22
23#include "wx/window.h" // the base class
24#include "wx/icon.h" // for m_icon
25
26// the default names for various classs
27WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
28WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
29WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
30
31class WXDLLEXPORT wxMenuBar;
32class WXDLLEXPORT wxStatusBar;
33class WXDLLEXPORT wxToolBar;
34
35// ----------------------------------------------------------------------------
36// wxFrame is a top-level window with optional menubar, statusbar and toolbar
37//
38// For each of *bars, a frame may have several of them, but only one is
39// managed by the frame, i.e. resized/moved when the frame is and whose size
40// is accounted for in client size calculations - all others should be taken
41// care of manually. The CreateXXXBar() functions create this, main, XXXBar,
42// but the actual creation is done in OnCreateXXXBar() functions which may be
43// overridden to create custom objects instead of standard ones when
44// CreateXXXBar() is called.
45// ----------------------------------------------------------------------------
46
47class WXDLLEXPORT wxFrameBase : public wxWindow
48{
49public:
50 // construction
51 wxFrameBase();
52
53 wxFrame *New(wxWindow *parent,
54 wxWindowID id,
55 const wxString& title,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 long style = wxDEFAULT_FRAME_STYLE,
59 const wxString& name = wxFrameNameStr);
60
61 // frame state
62 // -----------
63
64 // maximize = TRUE => maximize, otherwise - restore
65 virtual void Maximize(bool maximize = TRUE) = 0;
66
67 // undo Maximize() or Iconize()
68 virtual void Restore() = 0;
69
70 // iconize = TRUE => iconize, otherwise - restore
71 virtual void Iconize(bool iconize = TRUE) = 0;
72
73 // return TRUE if the frame is maximized
74 virtual bool IsMaximized() const = 0;
75
76 // return TRUE if the frame is iconized
77 virtual bool IsIconized() const = 0;
78
79 // get the frame icon
80 const wxIcon& GetIcon() const { return m_icon; }
81
82 // set the frame icon
83 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
84
85 // make the window modal (all other windows unresponsive)
86 virtual void MakeModal(bool modal = TRUE);
87
88 // menu bar functions
89 // ------------------
90
91 virtual void SetMenuBar(wxMenuBar *menubar) = 0;
92 virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
93
94 // call this to simulate a menu command
95 bool Command(int id) { return ProcessCommand(id); }
96
97 // process menu command: returns TRUE if processed
98 bool ProcessCommand(int id);
99
100 // status bar functions
101 // --------------------
102#if wxUSE_STATUSBAR
103 // create the main status bar by calling OnCreateStatusBar()
104 virtual wxStatusBar* CreateStatusBar(int number = 1,
105 long style = wxST_SIZEGRIP,
106 wxWindowID id = 0,
107 const wxString& name =
108 wxStatusLineNameStr);
109 // return a new status bar
110 virtual wxStatusBar *OnCreateStatusBar(int number,
111 long style,
112 wxWindowID id,
113 const wxString& name);
114 // get the main status bar
115 virtual wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
116
117 // sets the main status bar
118 void SetStatusBar(wxStatusBar *statBar) { m_frameStatusBar = statBar; }
119
120 // forward these to status bar
121 virtual void SetStatusText(const wxString &text, int number = 0);
122 virtual void SetStatusWidths(int n, const int widths_field[]);
123#endif // wxUSE_STATUSBAR
124
125 // toolbar functions
126 // -----------------
127#if wxUSE_TOOLBAR
128 // create main toolbar bycalling OnCreateToolBar()
129 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL,
130 wxWindowID id = -1,
131 const wxString& name = wxToolBarNameStr);
132 // return a new toolbar
133 virtual wxToolBar *OnCreateToolBar(long style,
134 wxWindowID id,
135 const wxString& name );
136
137 // get/set the main toolbar
138 virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
139 virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
140#endif // wxUSE_TOOLBAR
141
142 // old functions, use the new ones instead!
143#if WXWIN_COMPATIBILITY_2
144 bool Iconized() const { return IsIconized(); }
145#endif // WXWIN_COMPATIBILITY_2
146
147 // implementation only from now on
148 // -------------------------------
149
150 // override some base class virtuals
151 virtual bool Destroy();
152 virtual bool IsTopLevel() const { return TRUE; }
153
154 // event handlers
155 void OnIdle(wxIdleEvent& event);
156 void OnCloseWindow(wxCloseEvent& event);
157 void OnMenuHighlight(wxMenuEvent& event);
158 void OnSize(wxSizeEvent& event);
159 // this should go away, but for now it's called from docview.cpp,
160 // so should be there for all platforms
161 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
162
163 // send wxUpdateUIEvents for all menu items (called from OnIdle())
164 void DoMenuUpdates();
165 void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
166
167protected:
168 // the frame main menu/status/tool bars
169 // ------------------------------------
170
171 // this (non virtual!) function should be called from dtor to delete the
172 // main menubar, statusbar and toolbar (if any)
173 void DeleteAllBars();
174
175 wxMenuBar *m_frameMenuBar;
176
177#if wxUSE_STATUSBAR
178 // override to update status bar position (or anything else) when
179 // something changes
180 virtual void PositionStatusBar() { }
181
182 wxStatusBar *m_frameStatusBar;
183#endif // wxUSE_STATUSBAR
184
185#if wxUSE_TOOLBAR
186 // override to update status bar position (or anything else) when
187 // something changes
188 virtual void PositionToolBar() { }
189
190 wxToolBar *m_frameToolBar;
191#endif // wxUSE_TOOLBAR
192
193 // the frame icon
194 wxIcon m_icon;
195
196 DECLARE_EVENT_TABLE()
197};
198
199// include the real class declaration
2049ba38 200#if defined(__WXMSW__)
7c0ea335 201 #include "wx/msw/frame.h"
2049ba38 202#elif defined(__WXMOTIF__)
7c0ea335 203 #include "wx/motif/frame.h"
2049ba38 204#elif defined(__WXGTK__)
7c0ea335 205 #include "wx/gtk/frame.h"
b4e76e0d 206#elif defined(__WXQT__)
7c0ea335 207 #include "wx/qt/frame.h"
34138703 208#elif defined(__WXMAC__)
7c0ea335 209 #include "wx/mac/frame.h"
1777b9bb 210#elif defined(__WXPM__)
7c0ea335 211 #include "wx/os2/frame.h"
34138703 212#elif defined(__WXSTUBS__)
7c0ea335 213 #include "wx/stubs/frame.h"
c801d85f
KB
214#endif
215
216#endif
34138703 217 // _WX_FRAME_H_BASE_