]> git.saurik.com Git - wxWidgets.git/blame - src/os2/window.cpp
*** empty log message ***
[wxWidgets.git] / src / os2 / window.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: windows.cpp
3// Purpose: wxWindow
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "window.h"
14#endif
15
849949b1
DW
16#ifndef WX_PRECOMP
17 #define INCL_DOS
18 #define INCL_PM
19 #include <os2.h>
20 #include "wx/window.h"
21 #include "wx/accel.h"
22 #include "wx/setup.h"
23 #include "wx/menu.h"
24 #include "wx/dc.h"
25 #include "wx/dcclient.h"
26 #include "wx/utils.h"
27 #include "wx/app.h"
28 #include "wx/panel.h"
29 #include "wx/layout.h"
30 #include "wx/dialog.h"
31 #include "wx/frame.h"
32 #include "wx/listbox.h"
33 #include "wx/button.h"
34 #include "wx/msgdlg.h"
35
36 #include <stdio.h>
37#endif
38
39#if wxUSE_OWNER_DRAWN
40 #include "wx/ownerdrw.h"
41#endif
42
43#if wxUSE_DRAG_AND_DROP
44 #include "wx/dnd.h"
45#endif
0e320a79
DW
46
47#include "wx/menuitem.h"
48#include "wx/log.h"
49
849949b1
DW
50#if wxUSE_TOOLTIPS
51 #include "wx/tooltip.h"
0e320a79
DW
52#endif
53
849949b1
DW
54#if wxUSE_CARET
55 #include "wx/caret.h"
56#endif // wxUSE_CARET
57
58#include "wx/intl.h"
59#include "wx/log.h"
60
61
62#include "wx/textctrl.h"
63
0e320a79
DW
64#include <string.h>
65
849949b1
DW
66// place compiler, OS specific includes here
67
68
69// standard macros -- these are for OS/2 PM, but most GUI's have something similar
70#ifndef GET_X_LPARAM
71// SHORT1FROMMP -- LOWORD
72 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
73// SHORT2FROMMP -- HIWORD
74 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
75#endif // GET_X_LPARAM
76
77// ---------------------------------------------------------------------------
78// global variables
79// ---------------------------------------------------------------------------
80
81// the last Windows message we got (MT-UNSAFE)
82extern WXMSGID s_currentMsg;
83extern wxList WXDLLEXPORT wxPendingDelete;
84extern wxChar wxCanvasClassName[];
85
86wxMenu *wxCurrentPopupMenu = NULL;
87wxList *wxWinHandleList = NULL;
88
89// ---------------------------------------------------------------------------
90// private functions
91// ---------------------------------------------------------------------------
92// the window proc for all our windows; most gui's have something similar
93MRESULT wxWndProc( HWND hWnd
94 ,ULONG message
95 ,MPARAM mp1
96 ,MPARAM mp2
97 );
98void wxRemoveHandleAssociation(wxWindow *win);
99void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
100wxWindow *wxFindWinFromHandle(WXHWND hWnd);
101
102// ---------------------------------------------------------------------------
103// event tables
104// ---------------------------------------------------------------------------
0e320a79
DW
105
106#if !USE_SHARED_LIBRARY
849949b1 107 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
0e320a79
DW
108#endif
109
849949b1
DW
110BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
111 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
112 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
113 EVT_INIT_DIALOG(wxWindow::OnInitDialog)
114 EVT_IDLE(wxWindow::OnIdle)
115END_EVENT_TABLE()
0e320a79 116
849949b1
DW
117// ===========================================================================
118// implementation
119// ===========================================================================
0e320a79 120
849949b1 121void wxWindow::Init()
0e320a79 122{
849949b1
DW
123 // generic
124 InitBase();
0e320a79 125
849949b1
DW
126 // PM specific
127 m_winCaptured = FALSE;
128 m_isBeingDeleted = FALSE;
129 m_mouseInWindow = FALSE;
130 m_backgroundTransparent = FALSE;
0e320a79 131
849949b1
DW
132 // wxWnd
133 m_hMenu = 0;
0e320a79 134
849949b1 135 m_hWnd = 0;
0e320a79 136
849949b1
DW
137 // pass WM_GETDLGCODE to DefWindowProc()
138 m_lDlgCode = 0;
0e320a79 139
849949b1
DW
140 m_xThumbSize = 0;
141 m_yThumbSize = 0;
0e320a79 142
849949b1
DW
143 // as all windows are created with WS_VISIBLE style...
144 m_isShown = TRUE;
0e320a79 145
0e320a79
DW
146}
147
0e320a79 148bool wxWindow::Create(wxWindow *parent, wxWindowID id,
849949b1
DW
149 const wxPoint& pos,
150 const wxSize& size,
151 long style,
152 const wxString& name)
0e320a79 153{
849949b1 154 wxCHECK_MSG( parent, FALSE, _T("can't create wxWindow without parent") );
0e320a79 155
849949b1 156 if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
0e320a79
DW
157 return FALSE;
158
849949b1
DW
159 // TODO: PM Specific initialization
160 parent->AddChild(this);
0e320a79
DW
161 return TRUE;
162}
163
849949b1
DW
164// Destructor
165wxWindow::~wxWindow()
0e320a79 166{
849949b1 167 m_isBeingDeleted = TRUE;
0e320a79 168
849949b1
DW
169 PMDetachWindowMenu();
170 // delete handlers?
171 if (m_parent)
172 m_parent->RemoveChild(this);
173 DestroyChildren();
174 if (m_hWnd)
175 {
176 if(!WinDestroyWindow(GetHwnd()))
177 wxLogLastError("DestroyWindow");
178 // remove hWnd <-> wxWindow association
179 wxRemoveHandleAssociation(this);
180 }
0e320a79
DW
181}
182
849949b1
DW
183// ---------------------------------------------------------------------------
184// basic operations
185// ---------------------------------------------------------------------------
0e320a79 186
849949b1 187void wxWindow::Raise()
0e320a79 188{
849949b1 189 // TODO:
0e320a79
DW
190}
191
849949b1 192void wxWindow::Lower()
0e320a79 193{
849949b1 194 // TODO:
0e320a79
DW
195}
196
849949b1 197void wxWindow::SetFocus()
0e320a79 198{
849949b1 199 // TODO:
0e320a79
DW
200}
201
849949b1 202void wxWindow::WarpPointer(int x_pos, int y_pos)
0e320a79 203{
849949b1 204 // TODO:
0e320a79
DW
205}
206
849949b1 207void wxWindow::CaptureMouse()
0e320a79 208{
849949b1 209 // TODO:
0e320a79
DW
210}
211
849949b1 212void wxWindow::ReleaseMouse()
0e320a79 213{
849949b1 214 // TODO:
0e320a79
DW
215}
216
de44a9f0 217void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
0e320a79 218{
849949b1 219 // TODO:
0e320a79
DW
220}
221
849949b1 222void wxWindow::Clear()
0e320a79 223{
849949b1 224 // TODO:
0e320a79
DW
225}
226
849949b1 227bool wxWindow::SetFont(const wxFont& f)
0e320a79 228{
849949b1
DW
229 // TODO:
230 return(TRUE);
0e320a79
DW
231}
232
849949b1 233int wxWindow::GetCharHeight() const
0e320a79 234{
849949b1
DW
235 // TODO:
236 return(1);
0e320a79
DW
237}
238
849949b1 239int wxWindow::GetCharWidth() const
0e320a79 240{
849949b1
DW
241 // TODO:
242 return(1);
0e320a79
DW
243}
244
849949b1
DW
245void wxWindow::GetTextExtent( const wxString& string
246 ,int* x
247 ,int* y
de44a9f0
DW
248 ,int* descent
249 ,int* externalLeading
250 ,const wxFont* theFont
849949b1 251 ) const
0e320a79 252{
849949b1 253 // TODO:
0e320a79
DW
254}
255
849949b1
DW
256void wxWindow::SetScrollbar( int orient
257 ,int pos
258 ,int thumbVisible
259 ,int range
de44a9f0 260 ,bool refresh
849949b1 261 )
0e320a79 262{
849949b1 263 // TODO:
0e320a79
DW
264}
265
849949b1
DW
266void wxWindow::SetScrollPos( int orient
267 ,int pos
de44a9f0 268 ,bool refresh
849949b1 269 )
0e320a79 270{
849949b1 271 // TODO:
0e320a79
DW
272}
273
849949b1 274int wxWindow::GetScrollPos(int orient) const
0e320a79 275{
849949b1
DW
276 // TODO:
277 return(1);
0e320a79
DW
278}
279
849949b1 280int wxWindow::GetScrollRange(int orient) const
0e320a79 281{
849949b1
DW
282 // TODO:
283 return(1);
0e320a79
DW
284}
285
849949b1 286int wxWindow::GetScrollThumb(int orient) const
0e320a79 287{
849949b1
DW
288 // TODO:
289 return(1);
0e320a79
DW
290}
291
849949b1
DW
292void wxWindow::ScrollWindow( int dx
293 ,int dy
de44a9f0 294 ,const wxRect* rect
849949b1 295 )
0e320a79 296{
849949b1 297 // TODO:
0e320a79
DW
298}
299
849949b1
DW
300#if wxUSE_DRAG_AND_DROP
301void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
0e320a79 302{
849949b1 303 // TODO:
0e320a79 304}
849949b1 305#endif
0e320a79 306
849949b1 307void wxWindow::DoClientToScreen( int *x, int *y ) const
0e320a79 308{
849949b1 309 // TODO:
0e320a79
DW
310}
311
849949b1 312void wxWindow::DoScreenToClient( int *x, int *y ) const
0e320a79 313{
849949b1 314 // TODO:
0e320a79
DW
315}
316
849949b1 317void wxWindow::DoGetPosition( int *x, int *y ) const
0e320a79 318{
849949b1 319 // TODO:
0e320a79
DW
320}
321
849949b1 322void wxWindow::DoGetSize( int *width, int *height ) const
0e320a79 323{
849949b1 324 // TODO:
0e320a79
DW
325}
326
849949b1 327void wxWindow::DoGetClientSize( int *width, int *height ) const
0e320a79 328{
849949b1 329 // TODO:
0e320a79
DW
330}
331
849949b1
DW
332void wxWindow::DoSetSize(int x, int y,
333 int width, int height,
de44a9f0 334 int sizeFlags)
0e320a79 335{
849949b1 336 // TODO:
0e320a79
DW
337}
338
849949b1 339void wxWindow::DoSetClientSize(int width, int height)
0e320a79 340{
849949b1 341 // TODO:
0e320a79
DW
342}
343
849949b1 344bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
0e320a79 345{
849949b1
DW
346 // TODO:
347 return(TRUE);
0e320a79
DW
348}
349
849949b1 350void wxWindow::Fit()
0e320a79 351{
849949b1 352 // TODO:
0e320a79
DW
353}
354
849949b1 355bool wxWindow::Show(bool show) // check if base implementation is OK
0e320a79 356{
849949b1
DW
357 // TODO:
358 return(TRUE);
0e320a79
DW
359}
360
849949b1 361bool wxWindow::Enable(bool enable) // check if base implementation is OK
0e320a79 362{
849949b1
DW
363 // TODO:
364 return(TRUE);
0e320a79
DW
365}
366
849949b1 367bool wxWindow::SetCursor(const wxCursor& cursor) // check if base implementation is OK
0e320a79 368{
849949b1
DW
369 // TODO:
370 return(TRUE);
0e320a79
DW
371}
372
849949b1 373bool wxWindow::Validate()
0e320a79 374{
849949b1
DW
375 // TODO:
376 return(TRUE);
0e320a79
DW
377}
378
849949b1 379wxWindow* wxWindow::FindFocus()
0e320a79 380{
de44a9f0 381 wxWindow* window = NULL;
849949b1 382 // TODO:
de44a9f0 383 return(window);
0e320a79
DW
384}
385
849949b1 386void wxWindow::DragAcceptFiles(bool accept)
0e320a79 387{
849949b1 388 // TODO:
0e320a79
DW
389}
390
849949b1
DW
391#if wxUSE_CARET && WXWIN_COMPATIBILITY
392void wxWindow::CreateCaret(int w, int h)
0e320a79 393{
849949b1 394 // TODO:
0e320a79
DW
395}
396
849949b1 397void wxWindow::CreateCaret(const wxBitmap *bitmap)
0e320a79 398{
849949b1 399 // TODO:
0e320a79
DW
400}
401
849949b1 402void wxWindow::DestroyCaret()
0e320a79 403{
849949b1 404 // TODO:
0e320a79
DW
405}
406
849949b1 407void wxWindow::ShowCaret(bool show)
0e320a79 408{
849949b1 409 // TODO:
0e320a79
DW
410}
411
849949b1 412void wxWindow::SetCaretPos(int x, int y)
0e320a79 413{
849949b1 414 // TODO:
0e320a79
DW
415}
416
849949b1 417void wxWindow::GetCaretPos(int *x, int *y) const
0e320a79 418{
849949b1 419 // TODO:
0e320a79
DW
420}
421
849949b1
DW
422#endif
423
424void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
0e320a79 425{
849949b1 426 // TODO:
0e320a79
DW
427}
428
849949b1 429void wxWindow::OnDefaultAction(wxControl *initiatingItem)
0e320a79 430{
849949b1 431 // TODO:
0e320a79
DW
432}
433
849949b1 434void wxWindow::OnEraseBackground(wxEraseEvent& event)
0e320a79 435{
849949b1 436 // TODO:
0e320a79
DW
437}
438
439void wxWindow::OnChar(wxKeyEvent& event)
440{
849949b1 441 // TODO:
0e320a79
DW
442}
443
444void wxWindow::OnKeyDown(wxKeyEvent& event)
445{
849949b1 446 // TODO:
0e320a79
DW
447}
448
449void wxWindow::OnKeyUp(wxKeyEvent& event)
450{
849949b1 451 // TODO:
0e320a79
DW
452}
453
454void wxWindow::OnPaint(wxPaintEvent& event)
455{
849949b1 456 // TODO:
0e320a79
DW
457}
458
849949b1 459void wxWindow::OnIdle(wxIdleEvent& event)
0e320a79 460{
849949b1 461 // TODO:
0e320a79
DW
462}
463
849949b1 464void wxWindow::OnInitDialog(wxInitDialogEvent& event)
0e320a79 465{
849949b1 466 // TODO:
0e320a79
DW
467}
468
0e320a79 469
849949b1 470wxPoint wxWindow::GetClientAreaOrigin() const
0e320a79 471{
849949b1
DW
472 // TODO:
473 return wxPoint(0, 0);
0e320a79
DW
474}
475
849949b1 476void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
0e320a79 477{
849949b1 478 // TODO:
0e320a79
DW
479}
480
849949b1 481long wxWindow::Default()
0e320a79 482{
849949b1
DW
483 // TODO:
484 return(1);
0e320a79
DW
485}
486
0e320a79
DW
487void wxWindow::UnsetConstraints(wxLayoutConstraints *c)
488{
849949b1 489 // TODO:
0e320a79
DW
490}
491
849949b1 492wxObject* wxWindow::GetChild(int number) const
0e320a79 493{
849949b1 494 // TODO:
de44a9f0 495 return((wxObject*)this);
0e320a79
DW
496}
497
c3d43472
DW
498WXWidget wxWindow::GetHandle() const
499{
500 // TODO:
501 return((WXWidget)m_hWnd);
502}
503
849949b1 504void wxWindow::PMDetachWindowMenu()
0e320a79 505{
849949b1 506 if ( m_hMenu )
0e320a79 507 {
849949b1 508 HMENU hMenu = (HMENU)m_hMenu;
0e320a79 509
de44a9f0 510 int N = (int)WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
849949b1
DW
511 int i;
512 for (i = 0; i < N; i++)
0e320a79 513 {
849949b1 514 wxChar buf[100];
de44a9f0 515 int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf);
849949b1 516 if ( !chars )
0e320a79 517 {
849949b1 518 wxLogLastError(_T("GetMenuString"));
0e320a79 519
849949b1
DW
520 continue;
521 }
0e320a79 522
849949b1
DW
523 if ( wxStrcmp(buf, _T("&Window")) == 0 )
524 {
de44a9f0 525 WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
849949b1
DW
526 break;
527 }
0e320a79
DW
528 }
529 }
0e320a79 530}
de44a9f0 531
849949b1 532void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
0e320a79 533{
849949b1
DW
534 // adding NULL hWnd is (first) surely a result of an error and
535 // (secondly) breaks menu command processing
536 wxCHECK_RET( hWnd != (HWND)NULL,
537 _T("attempt to add a NULL hWnd to window list ignored") );
0e320a79 538
849949b1
DW
539 if ( !wxWinHandleList->Find((long)hWnd) )
540 wxWinHandleList->Append((long)hWnd, win);
0e320a79
DW
541}
542
849949b1 543wxWindow *wxFindWinFromHandle(WXHWND hWnd)
0e320a79 544{
849949b1
DW
545 wxNode *node = wxWinHandleList->Find((long)hWnd);
546 if ( !node )
547 return NULL;
548 return (wxWindow *)node->Data();
0e320a79
DW
549}
550
849949b1 551void wxRemoveHandleAssociation(wxWindow *win)
0e320a79 552{
849949b1 553 wxWinHandleList->DeleteObject(win);
0e320a79
DW
554}
555