]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/window.h
Solved problem with wxhInstance name being mangled by MSVC; wxGetInstance is now...
[wxWidgets.git] / include / wx / os2 / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose: wxWindow class
4 // Author: David Webster
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 #ifdef __GNUG__
16 #pragma interface "window.h"
17 #endif
18
19 #define INCL_DOS
20 #define INCL_PM
21 #include <os2.h>
22
23 #define wxKEY_SHIFT 1
24 #define wxKEY_CTRL 2
25
26 // ---------------------------------------------------------------------------
27 // forward declarations
28 // ---------------------------------------------------------------------------
29
30 class WXDLLEXPORT wxWindow;
31 class WXDLLEXPORT wxButton;
32
33 #if wxUSE_DRAG_AND_DROP
34 class WXDLLEXPORT wxDropTarget;
35 #endif
36
37 #if wxUSE_WX_RESOURCES
38 class WXDLLEXPORT wxResourceTable;
39 class WXDLLEXPORT wxItemResource;
40 #endif
41
42 WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
43
44 WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
45 WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
46
47 class WXDLLEXPORT wxWindow: public wxWindowBase
48 {
49 DECLARE_ABSTRACT_CLASS(wxWindow)
50
51 friend class wxDC;
52 friend class wxPaintDC;
53
54 public:
55 wxWindow() { Init(); };
56 inline wxWindow( wxWindow* parent
57 ,wxWindowID id
58 ,const wxPoint& pos = wxDefaultPosition
59 ,const wxSize& size = wxDefaultSize
60 ,long style = 0
61 ,const wxString& name = wxPanelNameStr
62 )
63 {
64 Init();
65 Create(parent, id, pos, size, style, name);
66 }
67
68 virtual ~wxWindow();
69
70 bool Create( wxWindow* parent
71 ,wxWindowID id
72 ,const wxPoint& pos = wxDefaultPosition
73 ,const wxSize& size = wxDefaultSize
74 ,long style = 0
75 ,const wxString& name = wxPanelNameStr
76 );
77
78 // ---------------------------------------------------------------------------
79 // wxWindowBase pure virtual implementations
80 // ---------------------------------------------------------------------------
81
82 // Z order
83 virtual void Raise();
84 virtual void Lower();
85 // Set the focus to this window
86 virtual void SetFocus();
87 // Warp the pointer the given position
88 virtual void WarpPointer(int x_pos, int y_pos) ;
89 // Capture/release mouse
90 virtual void CaptureMouse();
91 virtual void ReleaseMouse();
92 // Send the window a refresh event
93 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
94 // Clear the window
95 virtual void Clear();
96 // Set window's font
97 virtual bool SetFont(const wxFont& f);
98 // Get character size
99 virtual int GetCharHeight() const;
100 virtual int GetCharWidth() const;
101 virtual void GetTextExtent( const wxString& string
102 ,int* x
103 ,int* y
104 ,int* descent = NULL
105 ,int* externalLeading = NULL
106 ,const wxFont* theFont = NULL
107 ) const;
108
109 // Configure the window's scrollbar
110 virtual void SetScrollbar( int orient
111 ,int pos
112 ,int thumbVisible
113 ,int range
114 ,bool refresh = TRUE
115 );
116 virtual void SetScrollPos( int orient
117 ,int pos
118 ,bool refresh = TRUE
119 );
120 virtual int GetScrollPos(int orient) const;
121 virtual int GetScrollRange(int orient) const;
122 virtual int GetScrollThumb(int orient) const;
123 virtual void ScrollWindow( int dx
124 ,int dy
125 ,const wxRect* rect = NULL
126 );
127 #if wxUSE_DRAG_AND_DROP
128 void SetDropTarget(wxDropTarget *pDropTarget);
129 #endif
130 // coordinates translation
131 virtual void DoClientToScreen( int *x, int *y ) const;
132 virtual void DoScreenToClient( int *x, int *y ) const;
133
134 // retrieve the position/size of the window
135 virtual void DoGetPosition( int *x, int *y ) const;
136 virtual void DoGetSize( int *width, int *height ) const;
137 virtual void DoGetClientSize( int *width, int *height ) const;
138
139 // this is the virtual function to be overriden in any derived class which
140 // wants to change how SetSize() or Move() works - it is called by all
141 // versions of these functions in the base class
142 virtual void DoSetSize(int x, int y,
143 int width, int height,
144 int sizeFlags = wxSIZE_AUTO);
145
146 // same as DoSetSize() for the client size
147 virtual void DoSetClientSize(int width, int height);
148 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
149 virtual WXWidget GetHandle() const;
150
151 // ---------------------------------------------------------------------------
152 // wxWindowBase virtual implementations that need to be overriden
153 // ---------------------------------------------------------------------------
154
155 // Fit the window around the items
156 virtual void Fit();
157 // Show or hide the window
158 virtual bool Show(bool show); // check if base implementation is OK
159 // Enable or disable the window
160 virtual bool Enable(bool enable); // check if base implementation is OK
161 // Set the cursor
162 virtual bool SetCursor(const wxCursor& cursor); // check if base implementation is OK
163
164 // ---------------------------------------------------------------------------
165 // additional functions
166 // ---------------------------------------------------------------------------
167
168 // Dialog support: override these and call
169 // base class members to add functionality
170 // that can't be done using validators.
171 void SetClientSize( int width, int height )
172 { DoSetClientSize(width, height); }
173
174 void SetClientSize( const wxSize& size )
175 { DoSetClientSize(size.x, size.y); }
176
177 void SetClientSize(const wxRect& rect)
178 { SetClientSize( rect.width, rect.height ); }
179
180 // Validate controls. If returns FALSE,
181 // validation failed: don't quit
182 virtual bool Validate();
183
184 // Return code for dialogs
185 inline void SetReturnCode(int retCode);
186 inline int GetReturnCode();
187
188
189 // Get the window with the focus
190 static wxWindow *FindFocus();
191
192 // Accept files for dragging
193 virtual void DragAcceptFiles(bool accept);
194
195 // Most windows have the concept of a label; for frames, this is the
196 // title; for items, this is the label or button text.
197 inline virtual wxString GetLabel() const { return GetTitle(); }
198
199 #if wxUSE_CARET && WXWIN_COMPATIBILITY
200 // Caret manipulation
201 virtual void CreateCaret(int w, int h);
202 virtual void CreateCaret(const wxBitmap *bitmap);
203 virtual void DestroyCaret();
204 virtual void ShowCaret(bool show);
205 virtual void SetCaretPos(int x, int y);
206 virtual void GetCaretPos(int *x, int *y) const;
207 #endif
208
209 // Handle a control command
210 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
211
212 // Get the default button, if there is one
213 inline virtual wxButton *GetDefaultItem() const;
214 inline virtual void SetDefaultItem(wxButton *but);
215
216 // Override to define new behaviour for default action (e.g. double clicking
217 // on a listbox)
218 virtual void OnDefaultAction(wxControl *initiatingItem);
219
220 // EventHandlers
221 void OnEraseBackground(wxEraseEvent& event);
222 void OnChar(wxKeyEvent& event);
223 void OnKeyDown(wxKeyEvent& event);
224 void OnKeyUp(wxKeyEvent& event);
225 void OnPaint(wxPaintEvent& event);
226 void OnIdle(wxIdleEvent& event);
227
228
229 public:
230 // ---------------------------------------------------------------------------
231 // IMPLEMENTATION
232 // ---------------------------------------------------------------------------
233
234 // For implementation purposes - sometimes decorations make the client area
235 // smaller
236 virtual wxPoint GetClientAreaOrigin() const;
237
238 // Makes an adjustment to the window position (for example, a frame that has
239 // a toolbar that it manages itself).
240 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
241
242 // Executes the default message
243 virtual long Default();
244
245 /* TODO: you may need something like this
246 // Determine whether 3D effects are wanted
247 virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
248 */
249
250 // Constraint implementation
251 void UnsetConstraints(wxLayoutConstraints *c);
252 // Back-pointer to other windows we're involved with, so if we delete
253 // this window, we must delete any constraints we're involved with.
254
255 wxObject *GetChild(int number) const ;
256
257 // Transfers data to any child controls
258 void OnInitDialog(wxInitDialogEvent& event);
259
260 protected:
261
262 // Caret data
263 int m_caretWidth;
264 int m_caretHeight;
265 bool m_caretEnabled;
266 bool m_caretShown;
267
268 wxButton * m_defaultItem;
269
270 public:
271 int m_returnCode;
272 bool m_isBeingDeleted;
273 bool m_isShown;
274 bool m_winCaptured;
275 bool m_mouseInWindow;
276 bool m_backgroundTransparent;
277 // handles
278 WXHWND m_hWnd;
279 WXHMENU m_hMenu; // Menu, if any
280
281 // the size of one page for scrolling
282 int m_xThumbSize;
283 int m_yThumbSize;
284 long m_lDlgCode;
285
286 DECLARE_EVENT_TABLE()
287 private:
288 void Init();
289 void PMDetachWindowMenu();
290 WXHWND GetHwnd() const { return m_hWnd; }
291 void SetHwnd(WXHWND hWnd) { m_hWnd = hWnd; }
292 };
293
294 ////////////////////////////////////////////////////////////////////////
295 //// INLINES
296
297 inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
298 inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
299 inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
300 inline int wxWindow::GetReturnCode() { return m_returnCode; }
301
302 // Get the active window.
303 wxWindow* WXDLLEXPORT wxGetActiveWindow();
304
305 #endif
306 // _WX_WINDOW_H_