]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/window.h
Applied FreeBSD patch
[wxWidgets.git] / include / wx / motif / window.h
CommitLineData
9b6dbb09
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: window.h
3// Purpose: wxWindow class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
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#include "wx/gdicmn.h"
20#include "wx/icon.h"
21#include "wx/cursor.h"
22#include "wx/pen.h"
23#include "wx/font.h"
24#include "wx/validate.h"
25#include "wx/event.h"
26#include "wx/string.h"
27#include "wx/list.h"
28#include "wx/region.h"
29#include "wx/accel.h"
dbda9e86 30#include "wx/intl.h"
9b6dbb09
JS
31
32#define wxKEY_SHIFT 1
33#define wxKEY_CTRL 2
34
35/*
36 * Base class for frame, panel, canvas, panel items, dialog box.
37 *
38 */
39
40/*
41 * Event handler: windows have themselves as their event handlers
42 * by default, but their event handlers could be set to another
43 * object entirely. This separation can reduce the amount of
44 * derivation required, and allow alteration of a window's functionality
45 * (e.g. by a resource editor that temporarily switches event handlers).
46 */
47
48class WXDLLEXPORT wxWindow;
49class WXDLLEXPORT wxEvent;
50class WXDLLEXPORT wxCommandEvent;
51class WXDLLEXPORT wxKeyEvent;
52class WXDLLEXPORT wxControl;
53class WXDLLEXPORT wxCursor;
54class WXDLLEXPORT wxColourMap;
55class WXDLLEXPORT wxFont;
56class WXDLLEXPORT wxMenu;
16e93305 57class WXDLLEXPORT wxRect;
9b6dbb09
JS
58class WXDLLEXPORT wxBitmap;
59class WXDLLEXPORT wxSizer;
60class WXDLLEXPORT wxList;
61class WXDLLEXPORT wxLayoutConstraints;
62class WXDLLEXPORT wxMouseEvent;
63class WXDLLEXPORT wxButton;
64class WXDLLEXPORT wxColour;
65class WXDLLEXPORT wxBrush;
66class WXDLLEXPORT wxPen;
67class WXDLLEXPORT wxIcon;
68class WXDLLEXPORT wxDC;
69class WXDLLEXPORT wxValidator;
70
47d67540 71#if wxUSE_DRAG_AND_DROP
9b6dbb09
JS
72class WXDLLEXPORT wxDropTarget;
73#endif
74
47d67540 75#if wxUSE_WX_RESOURCES
9b6dbb09
JS
76class WXDLLEXPORT wxResourceTable;
77class WXDLLEXPORT wxItemResource;
78#endif
79
80WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
81
82WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
83WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
84
3dd4e4e0
JS
85//-----------------------------------------------------------------------------
86// wxClientData
87//-----------------------------------------------------------------------------
88
89class wxClientData
90{
91public:
92 wxClientData() { }
93 virtual ~wxClientData() { }
94};
95
96//-----------------------------------------------------------------------------
97// wxStringClientData
98//-----------------------------------------------------------------------------
99
100class wxStringClientData: public wxClientData
101{
102public:
103 wxStringClientData() { }
104 wxStringClientData( wxString &data ) { m_data = data; }
105 void SetData( wxString &data ) { m_data = data; }
106 wxString GetData() const { return m_data; }
107
108private:
109 wxString m_data;
110};
111
bfc6fde4 112class WXDLLEXPORT wxWindow : public wxEvtHandler
9b6dbb09 113{
bfc6fde4 114 DECLARE_ABSTRACT_CLASS(wxWindow)
9b6dbb09 115
bfc6fde4
VZ
116 friend class WXDLLEXPORT wxDC;
117 friend class WXDLLEXPORT wxWindowDC;
9b6dbb09
JS
118
119public:
bfc6fde4
VZ
120 wxWindow();
121 wxWindow(wxWindow *parent, wxWindowID id,
122 const wxPoint& pos = wxDefaultPosition,
123 const wxSize& size = wxDefaultSize,
124 long style = 0,
125 const wxString& name = wxPanelNameStr)
126 {
127 m_children = new wxList;
128 Create(parent, id, pos, size, style, name);
129 }
130
131 virtual ~wxWindow();
132
133 bool Create(wxWindow *parent, wxWindowID id,
134 const wxPoint& pos = wxDefaultPosition,
135 const wxSize& size = wxDefaultSize,
136 long style = 0,
137 const wxString& name = wxPanelNameStr);
138
139 // Fit the window around the items
140 virtual void Fit();
141
142 // Show or hide the window
143 virtual bool Show(bool show);
144
145 // Is the window shown?
146 virtual bool IsShown() const;
147
148 // Raise the window to the top of the Z order
149 virtual void Raise();
150
151 // Lower the window to the bottom of the Z order
152 virtual void Lower();
153
154 // Is the window enabled?
155 virtual bool IsEnabled() const;
156
157 // For compatibility
158 bool Enabled() const { return IsEnabled(); }
159
160 // Dialog support: override these and call
161 // base class members to add functionality
162 // that can't be done using validators.
163
164 // Transfer values to controls. If returns FALSE,
165 // it's an application error (pops up a dialog)
166 virtual bool TransferDataToWindow();
167
168 // Transfer values from controls. If returns FALSE,
169 // transfer failed: don't quit
170 virtual bool TransferDataFromWindow();
171
172 // Validate controls. If returns FALSE,
173 // validation failed: don't quit
174 virtual bool Validate();
175
176 // Return code for dialogs
177 inline void SetReturnCode(int retCode);
178 inline int GetReturnCode();
179
180 // Set the cursor
181 virtual void SetCursor(const wxCursor& cursor);
182 virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; };
183
184 // Get the window with the focus
185 static wxWindow *FindFocus();
186
187 // Get character size
188 virtual int GetCharHeight() const;
189 virtual int GetCharWidth() const;
190
191 // moving/resizing
192 // ---------------
193
194 // set the window size and/or position
195 void SetSize( int x, int y, int width, int height,
196 int sizeFlags = wxSIZE_AUTO )
197 { DoSetSize(x, y, width, height, sizeFlags); }
198
199 void SetSize( int width, int height )
200 { DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); }
201
202 void SetSize( const wxSize& size )
203 { SetSize( size.x, size.y); }
204
205 void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
206 { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
207
208 void Move( int x, int y )
209 { DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
210
211 void Move(const wxPoint& pt)
212 { Move(pt.x, pt.y); }
213
214 // client size is the size of area available for subwindows
215 void SetClientSize( int width, int height )
216 { DoSetClientSize(width, height); }
217
218 void SetClientSize( const wxSize& size )
219 { DoSetClientSize(size.x, size.y); }
220
221 void SetClientSize(const wxRect& rect)
222 { SetClientSize( rect.width, rect.height ); }
223
224 // get the window position and/or size
225 virtual void GetPosition( int *x, int *y ) const;
226 wxPoint GetPosition() const
227 {
228 int w, h;
229 GetPosition(& w, & h);
230
231 return wxPoint(w, h);
232 }
233
234 virtual void GetSize( int *width, int *height ) const;
235
236 wxSize GetSize() const
237 {
238 int w, h;
239 GetSize(& w, & h);
240 return wxSize(w, h);
241 }
242
243 wxRect GetRect() const
244 {
245 int x, y, w, h;
246 GetPosition(& x, & y);
247 GetSize(& w, & h);
248
249 return wxRect(x, y, w, h);
250 }
251
252 virtual void GetClientSize( int *width, int *height ) const;
253 wxSize GetClientSize() const
254 {
255 int w, h;
256 GetClientSize(& w, & h);
257 return wxSize(w, h);
258 }
259
260 // Convert client to screen coordinates
261 virtual void ClientToScreen(int *x, int *y) const;
262 virtual wxPoint ClientToScreen(const wxPoint& pt) const
4fabb575 263 { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); }
9b6dbb09 264
bfc6fde4
VZ
265 // Convert screen to client coordinates
266 virtual void ScreenToClient(int *x, int *y) const;
267 virtual wxPoint ScreenToClient(const wxPoint& pt) const
4fabb575 268 { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); }
9b6dbb09 269
bfc6fde4
VZ
270 // Set the focus to this window
271 virtual void SetFocus();
9b6dbb09 272
bfc6fde4
VZ
273 // Capture/release mouse
274 virtual void CaptureMouse();
275 virtual void ReleaseMouse();
9b6dbb09 276
bfc6fde4
VZ
277 // Enable or disable the window
278 virtual void Enable(bool enable);
9b6dbb09 279
47d67540 280#if wxUSE_DRAG_AND_DROP
bfc6fde4
VZ
281 // Associate a drop target with this window (if the window already had a drop
282 // target, it's deleted!) and return the current drop target (may be NULL).
283 void SetDropTarget(wxDropTarget *pDropTarget);
284 wxDropTarget *GetDropTarget() const { return m_pDropTarget; }
9b6dbb09
JS
285#endif
286
bfc6fde4
VZ
287 // Accept files for dragging
288 virtual void DragAcceptFiles(bool accept);
9b6dbb09 289
bfc6fde4 290 // tooltips
1f112209 291 // create a tooltip with this text
bfc6fde4 292 void SetToolTip(const wxString& tip);
1f112209 293
bfc6fde4 294 // TODO
98ffbab9 295#if wxUSE_TOOLTIPS
1f112209 296 // pointer may be NULL to remove the tooltip
bfc6fde4 297 void SetToolTip(wxToolTip *tooltip);
1f112209 298 // get the current tooltip (may return NULL if none)
bfc6fde4 299 wxToolTip* GetToolTip() const { return m_tooltip; }
1f112209
JS
300#endif
301
bfc6fde4
VZ
302 // Update region access
303 virtual wxRegion& GetUpdateRegion() const;
304 virtual bool IsExposed(int x, int y, int w, int h) const;
305 virtual bool IsExposed(const wxPoint& pt) const;
306 virtual bool IsExposed(const wxRect& rect) const;
307
308 // Set/get the window title
309 virtual void SetTitle(const wxString& WXUNUSED(title)) {};
310 virtual wxString GetTitle() const { return wxString(""); };
311 // Most windows have the concept of a label; for frames, this is the
312 // title; for items, this is the label or button text.
313 virtual wxString GetLabel() const { return GetTitle(); }
314
315 // Set/get the window name (used for resource setting in X)
316 virtual wxString GetName() const;
317 virtual void SetName(const wxString& name);
318
319 // Centre the window
320 virtual void Centre(int direction) ;
321 void Center(int direction = wxHORIZONTAL) { Centre(direction); }
322
323 // Popup a menu
324 virtual bool PopupMenu(wxMenu *menu, int x, int y);
325
326 // Send the window a refresh event
327 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
328
329 // New functions that will replace the above.
330 virtual void SetScrollbar(int orient, int pos, int thumbVisible,
331 int range, bool refresh = TRUE);
332
333 // Helper functions for Motif
334 void CreateScrollbar(int orientation);
335 void DestroyScrollbar(int orientation);
336
337 virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
338 virtual int GetScrollPos(int orient) const;
339 virtual int GetScrollRange(int orient) const;
340 virtual int GetScrollThumb(int orient) const;
341
342 virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
343
344 // Caret manipulation
345 virtual void CreateCaret(int w, int h);
346 virtual void CreateCaret(const wxBitmap *bitmap);
347 virtual void DestroyCaret();
348 virtual void ShowCaret(bool show);
349 virtual void SetCaretPos(int x, int y);
350 virtual void GetCaretPos(int *x, int *y) const;
351
352 // Tell window how much it can be sized
353 virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1);
354
355 // Set/get the window's identifier
356 inline int GetId() const;
357 inline void SetId(int id);
358
359 virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
360 virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; }
361
362 // Make the window modal (all other windows unresponsive)
363 virtual void MakeModal(bool modal);
364
365 // Get the private handle (platform-dependent)
366 inline void *GetHandle() const;
367
368 // Set/get the window's relatives
369 inline wxWindow *GetParent() const;
370 inline void SetParent(wxWindow *p) ;
371 inline wxWindow *GetGrandParent() const;
372 inline wxList& GetChildren() const;
373 // Reparents this window to have the new parent.
374 virtual bool Reparent(wxWindow* parent);
375
376 // Set/get the window's font
377 virtual void SetFont(const wxFont& f);
378 virtual wxFont& GetFont() const;
379
380 // Set/get the window's validator
381 void SetValidator(const wxValidator& validator);
382 inline wxValidator *GetValidator() const;
383
384 virtual void SetClientObject( wxClientData *data );
385 virtual wxClientData *GetClientObject();
386
387 virtual void SetClientData( void *data );
388 virtual void *GetClientData();
389
390 // Set/get the window's style
391 inline void SetWindowStyleFlag(long flag);
392 inline long GetWindowStyleFlag() const;
393
394 // Handle a control command
395 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
396
397 // Set/get event handler
398 inline void SetEventHandler(wxEvtHandler *handler);
399 inline wxEvtHandler *GetEventHandler() const;
400
401 // Push/pop event handler (i.e. allow a chain of event handlers
402 // be searched)
403 void PushEventHandler(wxEvtHandler *handler) ;
404 wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
405
406 // Close the window by calling OnClose, posting a deletion
407 virtual bool Close(bool force = FALSE);
408
409 // Destroy the window (delayed, if a managed window)
410 virtual bool Destroy() ;
411
412 // Mode for telling default OnSize members to
413 // call Layout(), if not using Sizers, just top-down constraints
414 inline void SetAutoLayout(bool a);
415 inline bool GetAutoLayout() const;
416
417 // Set/get constraints
418 inline wxLayoutConstraints *GetConstraints() const;
419 void SetConstraints(wxLayoutConstraints *c);
420
421 // Set/get window background colour
422 virtual void SetBackgroundColour(const wxColour& col);
423 virtual wxColour GetBackgroundColour() const;
424
425 // Set/get window foreground colour
426 virtual void SetForegroundColour(const wxColour& col);
427 virtual wxColour GetForegroundColour() const;
428
429 // Get the default button, if there is one
430 virtual wxButton *GetDefaultItem() const;
431 virtual void SetDefaultItem(wxButton *but);
432
433 // Override to define new behaviour for default action (e.g. double clicking
434 // on a listbox)
435 virtual void OnDefaultAction(wxControl *initiatingItem);
436
437 // Resource loading
47d67540 438#if wxUSE_WX_RESOURCES
bfc6fde4
VZ
439 virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL);
440 virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
441 const wxResourceTable *table = (const wxResourceTable *) NULL);
9b6dbb09
JS
442#endif
443
bfc6fde4
VZ
444 virtual void GetTextExtent(const wxString& string, int *x, int *y,
445 int *descent = NULL,
446 int *externalLeading = NULL,
447 const wxFont *theFont = NULL, bool use16 = FALSE) const;
9b6dbb09 448
bfc6fde4
VZ
449 // Is the window retained?
450 inline bool IsRetained() const;
9b6dbb09 451
bfc6fde4
VZ
452 // Warp the pointer the given position
453 virtual void WarpPointer(int x_pos, int y_pos) ;
9b6dbb09 454
bfc6fde4
VZ
455 // Clear the window
456 virtual void Clear();
9b6dbb09 457
bfc6fde4
VZ
458 // Find a window by id or name
459 virtual wxWindow *FindWindow(long id);
460 virtual wxWindow *FindWindow(const wxString& name);
9b6dbb09 461
bfc6fde4
VZ
462 // Constraint operations
463 bool Layout();
464 void SetSizer(wxSizer *sizer); // Adds sizer child to this window
465 inline wxSizer *GetSizer() const ;
466 inline wxWindow *GetSizerParent() const ;
467 inline void SetSizerParent(wxWindow *win);
9b6dbb09 468
bfc6fde4
VZ
469 // Do Update UI processing for controls
470 void UpdateWindowUI();
9b6dbb09 471
bfc6fde4
VZ
472 void OnEraseBackground(wxEraseEvent& event);
473 void OnChar(wxKeyEvent& event);
474 void OnKeyDown(wxKeyEvent& event);
475 void OnKeyUp(wxKeyEvent& event);
476 void OnPaint(wxPaintEvent& event);
477 void OnIdle(wxIdleEvent& event);
9b6dbb09 478
bfc6fde4
VZ
479 // Does this window want to accept keyboard focus?
480 virtual bool AcceptsFocus() const;
9b6dbb09 481
bfc6fde4 482 virtual void PrepareDC( wxDC & WXUNUSED(dc) ) {};
9b6dbb09
JS
483
484
485public:
bfc6fde4
VZ
486 ////////////////////////////////////////////////////////////////////////
487 //// IMPLEMENTATION
488
489 // For implementation purposes - sometimes decorations make the client area
490 // smaller
491 virtual wxPoint GetClientAreaOrigin() const;
492
493 // Makes an adjustment to the window position (for example, a frame that has
494 // a toolbar that it manages itself).
495 virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
496
497 // Executes the default message
498 virtual long Default();
499
500 /* TODO: you may need something like this
501 // Determine whether 3D effects are wanted
502 virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
503 */
504
505 virtual void AddChild(wxWindow *child); // Adds reference to the child object
506 virtual void RemoveChild(wxWindow *child); // Removes reference to child
507 // (but doesn't delete the child object)
508 virtual void DestroyChildren(); // Removes and destroys all children
509
510 bool IsBeingDeleted() const { return FALSE; } // TODO: Should probably eliminate this
511
512 // Constraint implementation
513 void UnsetConstraints(wxLayoutConstraints *c);
514 inline wxList *GetConstraintsInvolvedIn() const ;
515 // Back-pointer to other windows we're involved with, so if we delete
516 // this window, we must delete any constraints we're involved with.
517 void AddConstraintReference(wxWindow *otherWin);
518 void RemoveConstraintReference(wxWindow *otherWin);
519 void DeleteRelatedConstraints();
520
521 virtual void ResetConstraints();
522 virtual void SetConstraintSizes(bool recurse = TRUE);
523 virtual bool LayoutPhase1(int *noChanges);
524 virtual bool LayoutPhase2(int *noChanges);
525 virtual bool DoPhase(int);
526 // Transforms from sizer coordinate space to actual
527 // parent coordinate space
528 virtual void TransformSizerToActual(int *x, int *y) const ;
529
530 // Set size with transformation to actual coordinates if nec.
531 virtual void SizerSetSize(int x, int y, int w, int h);
532 virtual void SizerMove(int x, int y);
533
534 // Only set/get the size/position of the constraint (if any)
535 virtual void SetSizeConstraint(int x, int y, int w, int h);
536 virtual void MoveConstraint(int x, int y);
537 virtual void GetSizeConstraint(int *w, int *h) const ;
538 virtual void GetClientSizeConstraint(int *w, int *h) const ;
539 virtual void GetPositionConstraint(int *x, int *y) const ;
540
541 // Dialog units translations. Implemented in wincmn.cpp.
542 wxPoint ConvertPixelsToDialog(const wxPoint& pt) ;
543 wxPoint ConvertDialogToPixels(const wxPoint& pt) ;
544 inline wxSize ConvertPixelsToDialog(const wxSize& sz)
545 { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
546 inline wxSize ConvertDialogToPixels(const wxSize& sz)
547 { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
548
549 wxObject *GetChild(int number) const ;
550
551 // Generates a new id for controls
552 static int NewControlId();
553
554 // Responds to colour changes: passes event on to children.
555 void OnSysColourChanged(wxSysColourChangedEvent& event);
556
557 // Transfers data to any child controls
558 void OnInitDialog(wxInitDialogEvent& event);
559
560 // Sends an OnInitDialog event, which in turns transfers data to
561 // to the window via validators.
562 virtual void InitDialog();
563
564 /// Motif-specific
565
566 void ClearUpdateRects();
567 void CanvasGetSize(int* width, int* height) const; // If have drawing area
568 void CanvasGetClientSize(int *width, int *height) const;
569 void CanvasGetPosition(int *x, int *y) const; // If have drawing area
570 void CanvasSetClientSize(int width, int size);
571 void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
572
573 // Gives window a chance to do something in response to a size
574 // message, e.g. arrange status bar, toolbar etc.
575 virtual bool PreResize() { return TRUE; }
576
577 // Get main widget for this window, e.g. a text widget
578 virtual WXWidget GetMainWidget() const;
579 // Get the widget that corresponds to the label (for font setting, label setting etc.)
580 virtual WXWidget GetLabelWidget() const { return GetMainWidget(); }
581 // Get the client widget for this window (something we can
582 // create other windows on)
583 virtual WXWidget GetClientWidget() const;
584 // Get the top widget for this window, e.g. the scrolled widget parent
585 // of a multi-line text widget. Top means, top in the window hierarchy
586 // that implements this window.
587 virtual WXWidget GetTopWidget() const;
588 virtual void SetMainWidget(WXWidget w) { m_mainWidget = w; }
589 bool CanAddEventHandler() const { return m_canAddEventHandler; }
590 void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; }
591
592 // Get the underlying X window and display
593 virtual WXWindow GetXWindow() const;
594 virtual WXDisplay *GetXDisplay() const;
595
596 virtual WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
597 int GetPixmapWidth() const { return m_pixmapWidth; }
598 int GetPixmapHeight() const { return m_pixmapHeight; }
599
600 // Change properties
601 virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden)
602 virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
603 virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
604 // These to be overridden as needed (may change several widgets)
605 virtual void ChangeBackgroundColour(); // Change background and foreground colour using current
606 // background colour setting (Motif generates
607 // foreground based on background)
608 virtual void ChangeForegroundColour(); // Change foreground colour using current
609 // foreground colour setting
610
611 // Adds the widget to the hash table and adds event handlers.
612 bool AttachWidget (wxWindow* parent, WXWidget mainWidget,
613 WXWidget formWidget, int x, int y, int width, int height);
614 bool DetachWidget(WXWidget widget);
615
616 // Generates a paint event
617 virtual void DoPaint();
618
619 // How to implement accelerators. If we find a key event,
620 // translate to wxWindows wxKeyEvent form. Find a widget for the window.
621 // Now find a wxWindow for the widget. If there isn't one, go up the widget hierarchy
622 // trying to find one. Once one is found, call ProcessAccelerator for the
623 // window. If it returns TRUE (processed the event), skip the X event,
624 // otherwise carry on up the wxWindows window hierarchy calling ProcessAccelerator.
625 // If all return FALSE, process the X event as normal.
626 // Eventually we can implement OnCharHook the same way, but concentrate on accelerators
627 // for now.
628 // ProcessAccelerator must look at the current accelerator table, and try to find
629 // what menu id or window (beneath it) has this ID. Then construct an appropriate command
630 // event and send it.
631 virtual bool ProcessAccelerator(wxKeyEvent& event);
632
633 ////////////////////////////////////////////////////////////////////////
634 //// PROTECTED DATA
9b6dbb09 635protected:
bfc6fde4
VZ
636 int m_windowId;
637 long m_windowStyle; // Store the window's style
638 wxEvtHandler * m_windowEventHandler; // Usually is 'this'
639 wxLayoutConstraints * m_constraints; // Constraints for this window
640 wxList * m_constraintsInvolvedIn; // List of constraints we're involved in
641 wxSizer * m_windowSizer; // Window's top-level sizer (if any)
642 wxWindow * m_sizerParent; // Window's parent sizer (if any)
643 bool m_autoLayout; // Whether to call Layout() in OnSize
644 wxWindow * m_windowParent; // Each window always knows its parent
645 wxValidator * m_windowValidator;
646 int m_minSizeX;
647 int m_minSizeY;
648 int m_maxSizeX;
649 int m_maxSizeY;
650
651 // Caret data
652 int m_caretWidth;
653 int m_caretHeight;
654 bool m_caretEnabled;
655 bool m_caretShown;
656 wxFont m_windowFont; // Window's font
657 wxCursor m_windowCursor; // Window's cursor
658 wxString m_windowName; // Window name
659
660 wxButton * m_defaultItem;
661
662 wxColour m_backgroundColour ;
663 wxColour m_foregroundColour ;
664 wxAcceleratorTable m_acceleratorTable;
665 wxClientData* m_clientObject;
666 void* m_clientData;
9b6dbb09 667
47d67540 668#if wxUSE_DRAG_AND_DROP
bfc6fde4 669 wxDropTarget *m_pDropTarget; // the current drop target or NULL
9b6dbb09
JS
670#endif //USE_DRAG_AND_DROP
671
672public:
bfc6fde4
VZ
673 wxRegion m_updateRegion;
674 wxList * m_children; // Window's children
675 int m_returnCode;
9b6dbb09
JS
676
677public:
bfc6fde4
VZ
678 /// Motif-specific
679 bool m_needsRefresh; // Do we need to repaint the backing store?
680 bool m_canAddEventHandler;
681 bool m_button1Pressed;
682 bool m_button2Pressed;
683 bool m_button3Pressed;
684 // For double-click detection
685 long m_lastTS; // last timestamp
686 int m_lastButton; // last pressed button
687 wxList m_updateRects; // List of wxRects representing damaged region
688 bool m_isShown;
9b6dbb09 689protected:
bfc6fde4
VZ
690 WXWidget m_mainWidget;
691 WXWidget m_hScrollBar;
692 WXWidget m_vScrollBar;
693 WXWidget m_borderWidget;
694 WXWidget m_scrolledWindow;
695 WXWidget m_drawingArea;
696 bool m_winCaptured;
697 bool m_hScroll;
698 bool m_vScroll;
699 WXPixmap m_backingPixmap;
700 int m_pixmapWidth;
701 int m_pixmapHeight;
702 int m_pixmapOffsetX;
703 int m_pixmapOffsetY;
704 int m_scrollPosX; // Store the last scroll pos,
705 int m_scrollPosY; // since in wxWin the pos isn't
706 // set automatically by system
707
708 // this is the virtual function to be overriden in any derived class which
709 // wants to change how SetSize() or Move() works - it is called by all
710 // versions of these functions in the base class
711 virtual void DoSetSize(int x, int y,
712 int width, int height,
713 int sizeFlags = wxSIZE_AUTO);
714
715 // same as DoSetSize() for the client size
716 virtual void DoSetClientSize(int width, int height);
717
718private:
719 DECLARE_EVENT_TABLE()
9b6dbb09
JS
720};
721
722////////////////////////////////////////////////////////////////////////
723//// INLINES
724
725inline void *wxWindow::GetHandle() const { return (void *)NULL; }
726inline int wxWindow::GetId() const { return m_windowId; }
727inline void wxWindow::SetId(int id) { m_windowId = id; }
728inline wxWindow *wxWindow::GetParent() const { return m_windowParent; }
729inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
730inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); }
c0ed460c
JS
731inline wxList& wxWindow::GetChildren() const { return (wxList&) * m_children; }
732inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; }
9b6dbb09
JS
733inline wxString wxWindow::GetName() const { return m_windowName; }
734inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
735inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; }
736inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; }
737inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; }
738inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; }
739inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; }
740inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; }
741inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; }
9b6dbb09 742inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; };
9b6dbb09 743inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; };
9b6dbb09
JS
744
745inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
746inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
747inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
748
749inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; }
750inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; }
751inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; }
752inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; }
753inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; }
754inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
755inline int wxWindow::GetReturnCode() { return m_returnCode; }
756
757// Get the active window.
758wxWindow* WXDLLEXPORT wxGetActiveWindow();
759
e146b8c8 760WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
9b6dbb09 761
88150e60
JS
762// A little class to switch off size optimization while an instance of the object
763// exists
764class WXDLLEXPORT wxNoOptimize: public wxObject
765{
766public:
767 wxNoOptimize();
768 ~wxNoOptimize();
769
770 static bool CanOptimize();
771
772protected:
773 static int m_count;
774};
775
9b6dbb09
JS
776#endif
777 // _WX_WINDOW_H_