]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/window.h
I got tired of some of the memory leak messages related to html and
[wxWidgets.git] / include / wx / os2 / window.h
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose: wxWindow class
54da4255 4// Author: David Webster
0e320a79 5// Modified by:
54da4255 6// Created: ??/??/98
0e320a79 7// RCS-ID: $Id$
54da4255
DW
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_WINDOW_H_
13#define _WX_WINDOW_H_
14
0e320a79 15#ifdef __GNUG__
54da4255 16#pragma interface "window.h"
0e320a79
DW
17#endif
18
54da4255
DW
19#define INCL_DOS
20#define INCL_PM
21#include <os2.h>
0e320a79 22
54da4255
DW
23#define wxKEY_SHIFT 1
24#define wxKEY_CTRL 2
0e320a79
DW
25
26// ---------------------------------------------------------------------------
27// forward declarations
28// ---------------------------------------------------------------------------
29
54da4255 30class WXDLLEXPORT wxWindow;
0e320a79
DW
31class WXDLLEXPORT wxButton;
32
54da4255
DW
33#if wxUSE_DRAG_AND_DROP
34class WXDLLEXPORT wxDropTarget;
35#endif
0e320a79 36
54da4255
DW
37#if wxUSE_WX_RESOURCES
38class WXDLLEXPORT wxResourceTable;
39class WXDLLEXPORT wxItemResource;
40#endif
0e320a79 41
54da4255
DW
42WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
43
44WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
45WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
46
47class WXDLLEXPORT wxWindow: public wxWindowBase
0e320a79 48{
54da4255
DW
49 DECLARE_ABSTRACT_CLASS(wxWindow)
50
51 friend class wxDC;
52 friend class wxPaintDC;
0e320a79
DW
53
54public:
54da4255
DW
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 )
0e320a79
DW
63 {
64 Init();
65 Create(parent, id, pos, size, style, name);
66 }
67
68 virtual ~wxWindow();
69
54da4255
DW
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 );
0e320a79 77
54da4255
DW
78// ---------------------------------------------------------------------------
79// wxWindowBase pure virtual implementations
80// ---------------------------------------------------------------------------
0e320a79 81
54da4255 82 // Z order
0e320a79
DW
83 virtual void Raise();
84 virtual void Lower();
54da4255
DW
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;
0e320a79 133
54da4255
DW
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;
0e320a79 138
54da4255
DW
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);
0e320a79 145
54da4255
DW
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 );
0e320a79 149
54da4255
DW
150// ---------------------------------------------------------------------------
151// wxWindowBase virtual implementations that need to be overriden
152// ---------------------------------------------------------------------------
0e320a79 153
54da4255
DW
154 // Fit the window around the items
155 virtual void Fit();
156 // Show or hide the window
157 virtual bool Show(bool show); // check if base implementation is OK
158 // Enable or disable the window
159 virtual bool Enable(bool enable); // check if base implementation is OK
160 // Set the cursor
161 virtual bool SetCursor(const wxCursor& cursor); // check if base implementation is OK
0e320a79 162
54da4255
DW
163// ---------------------------------------------------------------------------
164// additional functions
165// ---------------------------------------------------------------------------
0e320a79 166
54da4255
DW
167 // Dialog support: override these and call
168 // base class members to add functionality
169 // that can't be done using validators.
1408104d
DW
170 void SetClientSize( int width, int height )
171 { DoSetClientSize(width, height); }
172
173 void SetClientSize( const wxSize& size )
174 { DoSetClientSize(size.x, size.y); }
175
176 void SetClientSize(const wxRect& rect)
177 { SetClientSize( rect.width, rect.height ); }
0e320a79 178
54da4255
DW
179 // Validate controls. If returns FALSE,
180 // validation failed: don't quit
181 virtual bool Validate();
0e320a79 182
54da4255
DW
183 // Return code for dialogs
184 inline void SetReturnCode(int retCode);
185 inline int GetReturnCode();
0e320a79 186
0e320a79 187
54da4255
DW
188 // Get the window with the focus
189 static wxWindow *FindFocus();
0e320a79
DW
190
191 // Accept files for dragging
192 virtual void DragAcceptFiles(bool accept);
193
54da4255
DW
194 // Most windows have the concept of a label; for frames, this is the
195 // title; for items, this is the label or button text.
196 inline virtual wxString GetLabel() const { return GetTitle(); }
197
849949b1 198#if wxUSE_CARET && WXWIN_COMPATIBILITY
54da4255
DW
199 // Caret manipulation
200 virtual void CreateCaret(int w, int h);
201 virtual void CreateCaret(const wxBitmap *bitmap);
202 virtual void DestroyCaret();
203 virtual void ShowCaret(bool show);
204 virtual void SetCaretPos(int x, int y);
205 virtual void GetCaretPos(int *x, int *y) const;
849949b1 206#endif
0e320a79 207
54da4255 208 // Handle a control command
0e320a79
DW
209 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
210
54da4255
DW
211 // Get the default button, if there is one
212 inline virtual wxButton *GetDefaultItem() const;
213 inline virtual void SetDefaultItem(wxButton *but);
214
215 // Override to define new behaviour for default action (e.g. double clicking
216 // on a listbox)
217 virtual void OnDefaultAction(wxControl *initiatingItem);
218
de44a9f0 219 // EventHandlers
0e320a79 220 void OnEraseBackground(wxEraseEvent& event);
54da4255
DW
221 void OnChar(wxKeyEvent& event);
222 void OnKeyDown(wxKeyEvent& event);
223 void OnKeyUp(wxKeyEvent& event);
224 void OnPaint(wxPaintEvent& event);
0e320a79
DW
225 void OnIdle(wxIdleEvent& event);
226
86de7616
DW
227 // Accessors
228
229 WXHWND GetHWND() const { return m_hWnd; }
230 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
231 virtual WXWidget GetHandle() const { return GetHWND(); }
54da4255 232
0e320a79 233public:
54da4255
DW
234// ---------------------------------------------------------------------------
235// IMPLEMENTATION
236// ---------------------------------------------------------------------------
237
0e320a79
DW
238 // For implementation purposes - sometimes decorations make the client area
239 // smaller
240 virtual wxPoint GetClientAreaOrigin() const;
241
242 // Makes an adjustment to the window position (for example, a frame that has
243 // a toolbar that it manages itself).
244 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
245
86de7616
DW
246 // Windows subclassing
247 void SubclassWin(WXHWND hWnd);
248 void UnsubclassWin();
249
250 WXFARPROC OS2GetOldWndProc() const { return m_oldWndProc; }
251 void OS2SetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
252
253 wxWindow *FindItem(long id) const;
254 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
255
256 // Determine whether 3D effects are wanted
257 WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
258
259 // PM only: TRUE if this control is part of the main control
260 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
261
54da4255
DW
262 // Executes the default message
263 virtual long Default();
0e320a79 264
54da4255
DW
265 // Constraint implementation
266 void UnsetConstraints(wxLayoutConstraints *c);
267 // Back-pointer to other windows we're involved with, so if we delete
268 // this window, we must delete any constraints we're involved with.
0e320a79 269
54da4255 270 wxObject *GetChild(int number) const ;
0e320a79 271
54da4255
DW
272 // Transfers data to any child controls
273 void OnInitDialog(wxInitDialogEvent& event);
0e320a79 274
54da4255 275protected:
0e320a79 276
54da4255
DW
277 // Caret data
278 int m_caretWidth;
279 int m_caretHeight;
280 bool m_caretEnabled;
281 bool m_caretShown;
0e320a79 282
54da4255 283 wxButton * m_defaultItem;
0e320a79 284
54da4255 285public:
86de7616 286 WXFARPROC m_oldWndProc;
54da4255 287 int m_returnCode;
849949b1
DW
288 bool m_isBeingDeleted;
289 bool m_isShown;
290 bool m_winCaptured;
291 bool m_mouseInWindow;
292 bool m_backgroundTransparent;
293 // handles
294 WXHWND m_hWnd;
295 WXHMENU m_hMenu; // Menu, if any
296
297 // the size of one page for scrolling
298 int m_xThumbSize;
299 int m_yThumbSize;
300 long m_lDlgCode;
0e320a79 301
54da4255 302DECLARE_EVENT_TABLE()
0e320a79 303private:
de44a9f0
DW
304 void Init();
305 void PMDetachWindowMenu();
0e320a79
DW
306};
307
54da4255
DW
308////////////////////////////////////////////////////////////////////////
309//// INLINES
310
311inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
312inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
313inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
314inline int wxWindow::GetReturnCode() { return m_returnCode; }
0e320a79 315
54da4255
DW
316// Get the active window.
317wxWindow* WXDLLEXPORT wxGetActiveWindow();
0e320a79
DW
318
319#endif
320 // _WX_WINDOW_H_