]>
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"
23 WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr
;
24 WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr
;
26 class WXDLLEXPORT wxMenuBar
;
27 class WXDLLEXPORT wxStatusBar
;
29 class WXDLLEXPORT wxFrame
: public wxWindow
{
31 DECLARE_DYNAMIC_CLASS(wxFrame
)
35 inline wxFrame(wxWindow
*parent
,
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
)
43 Create(parent
, id
, title
, pos
, size
, style
, name
);
48 bool Create(wxWindow
*parent
,
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
);
56 virtual bool Destroy(void);
58 void SetClientSize(int width
, int height
);
59 void SetClientSize(const wxSize
& sz
) { wxWindow::SetClientSize(sz
); }
61 void GetClientSize(int *width
, int *height
) const;
62 wxSize
GetClientSize() const { return wxWindow::GetClientSize(); }
64 void GetSize(int *width
, int *height
) const ;
65 wxSize
GetSize() const { return wxWindow::GetSize(); }
67 void GetPosition(int *x
, int *y
) const ;
68 wxPoint
GetPosition() const { return wxWindow::GetPosition(); }
70 void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
71 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
72 { wxWindow::SetSize(rect
, sizeFlags
); }
73 void SetSize(const wxSize
& size
) { wxWindow::SetSize(size
); }
75 void ClientToScreen(int *x
, int *y
) const;
76 wxPoint
ClientToScreen(const wxPoint
& pt
) const { return wxWindow::ClientToScreen(pt
); }
78 void ScreenToClient(int *x
, int *y
) const;
79 wxPoint
ScreenToClient(const wxPoint
& pt
) const { return wxWindow::ScreenToClient(pt
); }
81 virtual bool OnClose(void);
83 void OnSize(wxSizeEvent
& event
);
84 void OnMenuHighlight(wxMenuEvent
& event
);
85 void OnActivate(wxActivateEvent
& event
);
86 void OnIdle(wxIdleEvent
& event
);
87 void OnCloseWindow(wxCloseEvent
& event
);
92 void SetMenuBar(wxMenuBar
*menu_bar
);
93 virtual wxMenuBar
*GetMenuBar(void) const ;
96 void SetTitle(const wxString
& title
);
97 wxString
GetTitle(void) const ;
99 void Centre(int direction
= wxBOTH
);
101 // Call this to simulate a menu command
102 virtual void Command(int id
);
103 virtual void ProcessCommand(int id
);
106 virtual void SetIcon(const wxIcon
& icon
);
108 // Create status line
109 virtual wxStatusBar
* CreateStatusBar(int number
=1, long style
= wxST_SIZEGRIP
, wxWindowID id
= 0,
110 const wxString
& name
= "statusBar");
111 inline wxStatusBar
*GetStatusBar() const { return m_frameStatusBar
; }
112 inline void SetStatusBar(wxStatusBar
*statusBar
) { m_frameStatusBar
= statusBar
; }
113 virtual void PositionStatusBar(void);
114 virtual wxStatusBar
*OnCreateStatusBar(int number
, long style
, wxWindowID id
,
115 const wxString
& name
);
118 virtual wxToolBar
* CreateToolBar(long style
= wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_FLAT
,
120 const wxString
& name
= wxToolBarNameStr
);
121 virtual wxToolBar
*OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
);
122 // If made known to the frame, the frame will manage it automatically.
123 virtual inline void SetToolBar(wxToolBar
*toolbar
) { m_frameToolBar
= toolbar
; }
124 virtual inline wxToolBar
*GetToolBar(void) const { return m_frameToolBar
; }
125 virtual void PositionToolBar(void);
127 // Set status line text
128 virtual void SetStatusText(const wxString
& text
, int number
= 0);
130 // Set status line widths
131 virtual void SetStatusWidths(int n
, const int widths_field
[]);
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(void) { return m_useNativeStatusBar
; };
138 // Fit frame around subwindows
139 virtual void Fit(void);
142 virtual void Iconize(bool iconize
);
144 virtual bool IsIconized(void) const ;
147 inline bool Iconized(void) const { return IsIconized(); }
149 virtual void Maximize(bool maximize
);
150 // virtual bool LoadAccelerators(const wxString& table);
152 // Responds to colour changes
153 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
155 // Query app for menu item updates (called from OnIdle)
156 void DoMenuUpdates(void);
157 void DoMenuUpdates(wxMenu
* menu
);
159 WXHMENU
GetWinMenu(void) const ;
161 // Checks if there is a toolbar, and returns the first free client position
162 virtual wxPoint
GetClientAreaOrigin() const;
165 bool MSWOnPaint(void);
166 WXHICON
MSWOnQueryDragIcon(void);
167 void MSWOnSize(int x
, int y
, WXUINT flag
);
168 bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
169 bool MSWOnClose(void);
170 void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
171 bool MSWProcessMessage(WXMSG
*msg
);
172 bool MSWTranslateMessage(WXMSG
*msg
);
173 void MSWCreate(int id
, wxWindow
*parent
, const char *WXUNUSED(wclass
), wxWindow
*wx_win
, const char *title
,
174 int x
, int y
, int width
, int height
, long style
);
177 // propagate our state change to all child frames
178 void IconizeChildFrames(bool bIconize
);
180 wxMenuBar
* m_frameMenuBar
;
181 wxStatusBar
* m_frameStatusBar
;
184 WXHICON m_defaultIcon
;
185 static bool m_useNativeStatusBar
;
186 wxToolBar
* m_frameToolBar
;
188 DECLARE_EVENT_TABLE()