]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/window.h
corrected to allow drag and drop for mingw32/gcc295
[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 );
c3d43472 149 virtual WXWidget GetHandle() const;
0e320a79 150
54da4255
DW
151// ---------------------------------------------------------------------------
152// wxWindowBase virtual implementations that need to be overriden
153// ---------------------------------------------------------------------------
0e320a79 154
54da4255
DW
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
0e320a79 163
54da4255
DW
164// ---------------------------------------------------------------------------
165// additional functions
166// ---------------------------------------------------------------------------
0e320a79 167
54da4255
DW
168 // Dialog support: override these and call
169 // base class members to add functionality
170 // that can't be done using validators.
1408104d
DW
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 ); }
0e320a79 179
54da4255
DW
180 // Validate controls. If returns FALSE,
181 // validation failed: don't quit
182 virtual bool Validate();
0e320a79 183
54da4255
DW
184 // Return code for dialogs
185 inline void SetReturnCode(int retCode);
186 inline int GetReturnCode();
0e320a79 187
0e320a79 188
54da4255
DW
189 // Get the window with the focus
190 static wxWindow *FindFocus();
0e320a79
DW
191
192 // Accept files for dragging
193 virtual void DragAcceptFiles(bool accept);
194
54da4255
DW
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
849949b1 199#if wxUSE_CARET && WXWIN_COMPATIBILITY
54da4255
DW
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;
849949b1 207#endif
0e320a79 208
54da4255 209 // Handle a control command
0e320a79
DW
210 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
211
54da4255
DW
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
de44a9f0 220 // EventHandlers
0e320a79 221 void OnEraseBackground(wxEraseEvent& event);
54da4255
DW
222 void OnChar(wxKeyEvent& event);
223 void OnKeyDown(wxKeyEvent& event);
224 void OnKeyUp(wxKeyEvent& event);
225 void OnPaint(wxPaintEvent& event);
0e320a79
DW
226 void OnIdle(wxIdleEvent& event);
227
54da4255 228
0e320a79 229public:
54da4255
DW
230// ---------------------------------------------------------------------------
231// IMPLEMENTATION
232// ---------------------------------------------------------------------------
233
0e320a79
DW
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
54da4255
DW
242 // Executes the default message
243 virtual long Default();
0e320a79 244
54da4255
DW
245/* TODO: you may need something like this
246 // Determine whether 3D effects are wanted
247 virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
248*/
0e320a79 249
54da4255
DW
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.
0e320a79 254
54da4255 255 wxObject *GetChild(int number) const ;
0e320a79 256
54da4255
DW
257 // Transfers data to any child controls
258 void OnInitDialog(wxInitDialogEvent& event);
0e320a79 259
54da4255 260protected:
0e320a79 261
54da4255
DW
262 // Caret data
263 int m_caretWidth;
264 int m_caretHeight;
265 bool m_caretEnabled;
266 bool m_caretShown;
0e320a79 267
54da4255 268 wxButton * m_defaultItem;
0e320a79 269
54da4255
DW
270public:
271 int m_returnCode;
849949b1
DW
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;
0e320a79 285
54da4255 286DECLARE_EVENT_TABLE()
0e320a79 287private:
de44a9f0
DW
288 void Init();
289 void PMDetachWindowMenu();
290 WXHWND GetHwnd() const { return m_hWnd; }
291 void SetHwnd(WXHWND hWnd) { m_hWnd = hWnd; }
0e320a79
DW
292};
293
54da4255
DW
294////////////////////////////////////////////////////////////////////////
295//// INLINES
296
297inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
298inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
299inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
300inline int wxWindow::GetReturnCode() { return m_returnCode; }
0e320a79 301
54da4255
DW
302// Get the active window.
303wxWindow* WXDLLEXPORT wxGetActiveWindow();
0e320a79
DW
304
305#endif
306 // _WX_WINDOW_H_