changed/centralized window creation code to allow wxTLW work in wxUniv
[wxWidgets.git] / include / wx / msw / frame.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/frame.h
3 // Purpose: wxFrameMSW class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
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 class WXDLLEXPORT wxFrameMSW : public wxFrameBase
20 {
21 public:
22 // construction
23 wxFrameMSW() { Init(); }
24 wxFrameMSW(wxWindow *parent,
25 wxWindowID id,
26 const wxString& title,
27 const wxPoint& pos = wxDefaultPosition,
28 const wxSize& size = wxDefaultSize,
29 long style = wxDEFAULT_FRAME_STYLE,
30 const wxString& name = wxFrameNameStr)
31 {
32 Init();
33
34 Create(parent, id, title, pos, size, style, name);
35 }
36
37 bool Create(wxWindow *parent,
38 wxWindowID id,
39 const wxString& title,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = wxDEFAULT_FRAME_STYLE,
43 const wxString& name = wxFrameNameStr);
44
45 virtual ~wxFrameMSW();
46
47 // implement base class pure virtuals
48 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
49 virtual bool IsFullScreen() const { return m_fsIsShowing; };
50 virtual void Raise();
51
52 // implementation only from now on
53 // -------------------------------
54
55 // event handlers
56 void OnActivate(wxActivateEvent& event);
57 void OnSysColourChanged(wxSysColourChangedEvent& event);
58
59 // Toolbar
60 #if wxUSE_TOOLBAR
61 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
62 wxWindowID id = -1,
63 const wxString& name = wxToolBarNameStr);
64
65 virtual void PositionToolBar();
66 #endif // wxUSE_TOOLBAR
67
68 // Status bar
69 #if wxUSE_STATUSBAR
70 virtual wxStatusBar* OnCreateStatusBar(int number = 1,
71 long style = wxST_SIZEGRIP,
72 wxWindowID id = 0,
73 const wxString& name = wxStatusLineNameStr);
74
75 virtual void PositionStatusBar();
76
77 // Hint to tell framework which status bar to use: the default is to use
78 // native one for the platforms which support it (Win32), the generic one
79 // otherwise
80
81 // TODO: should this go into a wxFrameworkSettings class perhaps?
82 static void UseNativeStatusBar(bool useNative)
83 { m_useNativeStatusBar = useNative; };
84 static bool UsesNativeStatusBar()
85 { return m_useNativeStatusBar; };
86 #endif // wxUSE_STATUSBAR
87
88 WXHMENU GetWinMenu() const { return m_hMenu; }
89
90 // event handlers
91 bool HandlePaint();
92 bool HandleSize(int x, int y, WXUINT flag);
93 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
94 bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu);
95
96 // tooltip management
97 #if wxUSE_TOOLTIPS
98 WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
99 void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
100 #endif // tooltips
101
102 // a MSW only function which sends a size event to the window using its
103 // current size - this has an effect of refreshing the window layout
104 void SendSizeEvent();
105
106 // called by wxWindow whenever it gets focus
107 void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
108 wxWindow *GetLastFocus() const { return m_winLastFocused; }
109
110 protected:
111 // common part of all ctors
112 void Init();
113
114 // override base class virtuals
115 virtual void DoGetClientSize(int *width, int *height) const;
116 virtual void DoSetClientSize(int width, int height);
117
118 #if wxUSE_MENUS_NATIVE
119 // perform MSW-specific action when menubar is changed
120 virtual void AttachMenuBar(wxMenuBar *menubar);
121
122 // a plug in for MDI frame classes which need to do something special when
123 // the menubar is set
124 virtual void InternalSetMenuBar();
125 #endif // wxUSE_MENUS_NATIVE
126
127 // propagate our state change to all child frames
128 void IconizeChildFrames(bool bIconize);
129
130 // we add menu bar accel processing
131 bool MSWTranslateMessage(WXMSG* pMsg);
132
133 // window proc for the frames
134 long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
135
136 virtual bool IsMDIChild() const { return FALSE; }
137
138 // get default (wxWindows) icon for the frame
139 virtual WXHICON GetDefaultIcon() const;
140
141 #if wxUSE_STATUSBAR
142 static bool m_useNativeStatusBar;
143 #endif // wxUSE_STATUSBAR
144
145 // the last focused child: we restore focus to it on activation
146 wxWindow *m_winLastFocused;
147
148 // Data to save/restore when calling ShowFullScreen
149 long m_fsStyle; // Passed to ShowFullScreen
150 wxRect m_fsOldSize;
151 long m_fsOldWindowStyle;
152 int m_fsStatusBarFields; // 0 for no status bar
153 int m_fsStatusBarHeight;
154 int m_fsToolBarHeight;
155 // WXHMENU m_fsMenu;
156 bool m_fsIsMaximized;
157 bool m_fsIsShowing;
158
159 private:
160 #if wxUSE_TOOLTIPS
161 WXHWND m_hwndToolTip;
162 #endif // tooltips
163
164 DECLARE_EVENT_TABLE()
165 };
166
167 #endif
168 // _WX_FRAME_H_