]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/window.h
3 // Purpose: wxWindow class
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
20 // ---------------------------------------------------------------------------
22 // ---------------------------------------------------------------------------
24 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
25 #pragma interface "window.h"
28 // [at least] some version of Windows send extra mouse move messages after
29 // a mouse click or a key press - to temporarily fix this problem, set the
32 // a better solution should be found later...
33 #define wxUSE_MOUSEEVENT_HACK 0
35 // ---------------------------------------------------------------------------
37 // ---------------------------------------------------------------------------
39 // FIXME does anybody use those? they're unused by wxWidgets...
46 // ---------------------------------------------------------------------------
47 // wxWindow declaration for Palm
48 // ---------------------------------------------------------------------------
50 class WXDLLEXPORT wxWindowPalm
: public wxWindowBase
53 wxWindowPalm() { Init(); }
55 wxWindowPalm(wxWindow
*parent
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
,
60 const wxString
& name
= wxPanelNameStr
)
63 Create(parent
, id
, pos
, size
, style
, name
);
66 virtual ~wxWindowPalm();
68 bool Create(wxWindow
*parent
,
70 const wxPoint
& pos
= wxDefaultPosition
,
71 const wxSize
& size
= wxDefaultSize
,
73 const wxString
& name
= wxPanelNameStr
);
75 // implement base class pure virtuals
76 virtual void SetTitle( const wxString
& title
);
77 virtual wxString
GetTitle() const;
82 virtual bool Show( bool show
= TRUE
);
83 virtual bool Enable( bool enable
= TRUE
);
85 virtual void SetFocus();
86 virtual void SetFocusFromKbd();
88 virtual bool Reparent(wxWindowBase
*newParent
);
90 virtual void WarpPointer(int x
, int y
);
92 virtual void Refresh( bool eraseBackground
= TRUE
,
93 const wxRect
*rect
= (const wxRect
*) NULL
);
94 virtual void Update();
95 virtual void Freeze();
98 virtual void SetWindowStyleFlag( long style
);
99 virtual bool SetCursor( const wxCursor
&cursor
);
100 virtual bool SetFont( const wxFont
&font
);
102 virtual int GetCharHeight() const;
103 virtual int GetCharWidth() const;
104 virtual void GetTextExtent(const wxString
& string
,
106 int *descent
= (int *) NULL
,
107 int *externalLeading
= (int *) NULL
,
108 const wxFont
*theFont
= (const wxFont
*) NULL
)
111 #if wxUSE_MENUS_NATIVE
112 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
113 #endif // wxUSE_MENUS_NATIVE
115 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
116 int range
, bool refresh
= TRUE
);
117 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
);
118 virtual int GetScrollPos( int orient
) const;
119 virtual int GetScrollThumb( int orient
) const;
120 virtual int GetScrollRange( int orient
) const;
121 virtual void ScrollWindow( int dx
, int dy
,
122 const wxRect
* rect
= (wxRect
*) NULL
);
124 virtual bool ScrollLines(int lines
);
125 virtual bool ScrollPages(int pages
);
127 #if wxUSE_DRAG_AND_DROP
128 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
129 #endif // wxUSE_DRAG_AND_DROP
131 // Accept files for dragging
132 virtual void DragAcceptFiles(bool accept
);
134 #if WXWIN_COMPATIBILITY_2_4
135 wxDEPRECATED( bool GetUseCtl3D() const );
136 wxDEPRECATED( bool GetTransparentBackground() const );
137 wxDEPRECATED( void SetTransparent(bool t
= TRUE
) );
138 #endif // WXWIN_COMPATIBILITY_2_4
140 #ifndef __WXUNIVERSAL__
141 // Native resource loading (implemented in src/Palm/nativdlg.cpp)
142 // FIXME: should they really be all virtual?
143 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
144 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
145 wxWindow
* GetWindowChild1(wxWindowID id
);
146 wxWindow
* GetWindowChild(wxWindowID id
);
147 #endif // __WXUNIVERSAL__
150 // install and deinstall a system wide hotkey
151 virtual bool RegisterHotKey(int hotkeyId
, int modifiers
, int keycode
);
152 virtual bool UnregisterHotKey(int hotkeyId
);
153 #endif // wxUSE_HOTKEY
155 // implementation from now on
156 // --------------------------
161 WXHWND
GetHWND() const { return m_hWnd
; }
162 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
163 virtual WXWidget
GetHandle() const { return GetHWND(); }
168 void OnEraseBackground(wxEraseEvent
& event
);
169 void OnPaint(wxPaintEvent
& event
);
172 // For implementation purposes - sometimes decorations make the client area
174 virtual wxPoint
GetClientAreaOrigin() const;
176 // Windows subclassing
177 void SubclassWin(WXHWND hWnd
);
178 void UnsubclassWin();
180 WXFARPROC
PalmGetOldWndProc() const { return m_oldWndProc
; }
181 void PalmSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
183 // return TRUE if the window is of a standard (i.e. not wxWidgets') class
185 // to understand why does it work, look at SubclassWin() code and comments
186 bool IsOfStandardClass() const { return m_oldWndProc
!= NULL
; }
188 wxWindow
*FindItem(long id
) const;
189 wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const;
191 // Palm only: TRUE if this control is part of the main control
192 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
194 // translate wxWidgets style flags for this control into the Windows style
195 // and optional extended style for the corresponding native control
197 // this is the function that should be overridden in the derived classes,
198 // but you will mostly use PalmGetCreateWindowFlags() below
199 virtual WXDWORD
PalmGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const ;
201 // get the Palm window flags corresponding to wxWidgets ones
203 // the functions returns the flags (WS_XXX) directly and puts the ext
204 // (WS_EX_XXX) flags into the provided pointer if not NULL
205 WXDWORD
PalmGetCreateWindowFlags(WXDWORD
*exflags
= NULL
) const
206 { return PalmGetStyle(GetWindowStyle(), exflags
); }
208 // translate wxWidgets coords into Windows ones suitable to be passed to
211 // returns TRUE if non default coords are returned, FALSE otherwise
212 bool PalmGetCreateWindowCoords(const wxPoint
& pos
,
215 int& w
, int& h
) const;
217 // get the HWND to be used as parent of this window with CreateWindow()
218 virtual WXHWND
PalmGetParent() const;
220 // creates the window of specified Windows class with given style, extended
221 // style, title and geometry (default values
223 // returns TRUE if the window has been created, FALSE if creation failed
224 bool PalmCreate(const wxChar
*wclass
,
225 const wxChar
*title
= NULL
,
226 const wxPoint
& pos
= wxDefaultPosition
,
227 const wxSize
& size
= wxDefaultSize
,
229 WXDWORD exendedStyle
= 0);
231 virtual bool PalmCommand(WXUINT param
, WXWORD id
);
233 #ifndef __WXUNIVERSAL__
234 // Create an appropriate wxWindow from a HWND
235 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
237 // Make sure the window style reflects the HWND style (roughly)
238 virtual void AdoptAttributesFromHWND();
239 #endif // __WXUNIVERSAL__
241 // Setup background and foreground colours correctly
242 virtual void SetupColours();
244 // ------------------------------------------------------------------------
245 // helpers for message handlers: these perform the same function as the
246 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
247 // the correct parameters
248 // ------------------------------------------------------------------------
250 void UnpackCommand(WXWPARAM wParam
, WXLPARAM lParam
,
251 WXWORD
*id
, WXHWND
*hwnd
, WXWORD
*cmd
);
252 void UnpackActivate(WXWPARAM wParam
, WXLPARAM lParam
,
253 WXWORD
*state
, WXWORD
*minimized
, WXHWND
*hwnd
);
254 void UnpackScroll(WXWPARAM wParam
, WXLPARAM lParam
,
255 WXWORD
*code
, WXWORD
*pos
, WXHWND
*hwnd
);
256 void UnpackCtlColor(WXWPARAM wParam
, WXLPARAM lParam
,
257 WXWORD
*nCtlColor
, WXHDC
*hdc
, WXHWND
*hwnd
);
258 void UnpackMenuSelect(WXWPARAM wParam
, WXLPARAM lParam
,
259 WXWORD
*item
, WXWORD
*flags
, WXHMENU
*hmenu
);
261 // ------------------------------------------------------------------------
262 // internal handlers for Palm messages: all handlers return a boolean value:
263 // TRUE means that the handler processed the event and FALSE that it didn't
264 // ------------------------------------------------------------------------
266 // there are several cases where we have virtual functions for Windows
267 // message processing: this is because these messages often require to be
268 // processed in a different manner in the derived classes. For all other
269 // messages, however, we do *not* have corresponding PalmOnXXX() function
270 // and if the derived class wants to process them, it should override
271 // PalmWindowProc() directly.
273 // scroll event (both horizontal and vertical)
274 virtual bool PalmOnScroll(int orientation
, WXWORD nSBCode
,
275 WXWORD pos
, WXHWND control
);
277 // child control notifications
279 virtual bool PalmOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
282 // owner-drawn controls need to process these messages
283 virtual bool PalmOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
284 virtual bool PalmOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
286 // the rest are not virtual
287 bool HandleCreate(WXLPCREATESTRUCT cs
, bool *mayCreate
);
288 bool HandleInitDialog(WXHWND hWndFocus
);
289 bool HandleDestroy();
292 bool HandleEraseBkgnd(WXHDC pDC
);
294 bool HandleMinimize();
295 bool HandleMaximize();
296 bool HandleSize(int x
, int y
, WXUINT flag
);
297 bool HandleSizing(wxRect
& rect
);
298 bool HandleGetMinMaxInfo(void *mmInfo
);
300 bool HandleShow(bool show
, int status
);
301 bool HandleActivate(int flag
, bool minimized
, WXHWND activate
);
303 bool HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
305 bool HandleCtlColor(WXHBRUSH
*hBrush
,
313 bool HandlePaletteChanged(WXHWND hWndPalChange
);
314 bool HandleQueryNewPalette();
315 bool HandleSysColorChange();
316 bool HandleDisplayChange();
317 bool HandleCaptureChanged(WXHWND gainedCapture
);
319 bool HandleQueryEndSession(long logOff
, bool *mayEnd
);
320 bool HandleEndSession(bool endSession
, long logOff
);
322 bool HandleSetFocus(WXHWND wnd
);
323 bool HandleKillFocus(WXHWND wnd
);
325 bool HandleDropFiles(WXWPARAM wParam
);
327 bool HandleMouseEvent(WXUINT msg
, int x
, int y
, WXUINT flags
);
328 bool HandleMouseMove(int x
, int y
, WXUINT flags
);
329 bool HandleMouseWheel(WXWPARAM wParam
, WXLPARAM lParam
);
331 bool HandleChar(WXWPARAM wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
332 bool HandleKeyDown(WXWPARAM wParam
, WXLPARAM lParam
);
333 bool HandleKeyUp(WXWPARAM wParam
, WXLPARAM lParam
);
335 bool HandleHotKey(WXWPARAM wParam
, WXLPARAM lParam
);
338 int HandleMenuChar(int chAccel
, WXLPARAM lParam
);
341 bool HandleQueryDragIcon(WXHICON
*hIcon
);
343 bool HandleSetCursor(WXHWND hWnd
, short nHitTest
, int mouseMsg
);
346 virtual WXLRESULT
PalmWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
348 // Calls an appropriate default window procedure
349 virtual WXLRESULT
PalmDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
351 // message processing helpers
353 // return FALSE if the message shouldn't be translated/preprocessed but
354 // dispatched normally
355 virtual bool PalmShouldPreProcessMessage(WXMSG
* pMsg
);
357 // return TRUE if the message was preprocessed and shouldn't be dispatched
358 virtual bool PalmProcessMessage(WXMSG
* pMsg
);
360 // return TRUE if the message was translated and shouldn't be dispatched
361 virtual bool PalmTranslateMessage(WXMSG
* pMsg
);
363 // called when the window is about to be destroyed
364 virtual void PalmDestroyWindow();
366 // this function should return the brush to paint the window background
367 // with or 0 for the default brush
368 virtual WXHBRUSH
OnCtlColor(WXHDC hDC
,
375 // Responds to colour changes: passes event on to children.
376 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
378 // initialize various fields of wxMouseEvent (common part of PalmOnMouseXXX)
379 void InitMouseEvent(wxMouseEvent
& event
, int x
, int y
, WXUINT flags
);
381 // check if mouse is in the window
382 bool IsMouseInWindow() const;
384 // virtual function for implementing internal idle
386 virtual void OnInternalIdle() ;
393 FormType
*GetFormPtr();
394 void SetFormPtr(FormType
*FormPtr
);
396 // the old window proc (we subclass all windows)
397 WXFARPROC m_oldWndProc
;
399 // additional (Palm specific) flags
400 bool m_mouseInWindow
:1;
401 bool m_lastKeydownProcessed
:1;
403 // the size of one page for scrolling
407 #if wxUSE_MOUSEEVENT_HACK
408 // the coordinates of the last mouse event and the type of it
411 int m_lastMouseEvent
;
412 #endif // wxUSE_MOUSEEVENT_HACK
414 WXHMENU m_hMenu
; // Menu, if any
416 // implement the base class pure virtuals
417 virtual void DoClientToScreen( int *x
, int *y
) const;
418 virtual void DoScreenToClient( int *x
, int *y
) const;
419 virtual void DoGetPosition( int *x
, int *y
) const;
420 virtual void DoGetSize( int *width
, int *height
) const;
421 virtual void DoGetClientSize( int *width
, int *height
) const;
422 virtual void DoSetSize(int x
, int y
,
423 int width
, int height
,
424 int sizeFlags
= wxSIZE_AUTO
);
425 virtual void DoSetClientSize(int width
, int height
);
427 virtual void DoCaptureMouse();
428 virtual void DoReleaseMouse();
430 // move the window to the specified location and resize it: this is called
431 // from both DoSetSize() and DoSetClientSize() and would usually just call
432 // ::MoveWindow() except for composite controls which will want to arrange
433 // themselves inside the given rectangle
434 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
437 virtual void DoSetToolTip( wxToolTip
*tip
);
439 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
440 // comctl32.dll in our code -- see the function body for more info)
441 bool HandleTooltipNotify(WXUINT code
,
443 const wxString
& ttip
);
444 #endif // wxUSE_TOOLTIPS
446 // the helper functions used by HandleChar/KeyXXX methods
447 wxKeyEvent
CreateKeyEvent(wxEventType evType
, int id
,
448 WXLPARAM lParam
= 0, WXWPARAM wParam
= 0) const;
451 // common part of all ctors
454 // the (non-virtual) handlers for the events
455 bool HandleMove(int x
, int y
);
456 bool HandleMoving(wxRect
& rect
);
457 bool HandleJoystickEvent(WXUINT msg
, int x
, int y
, WXUINT flags
);
460 bool HandleNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
463 // list of disabled children before last call to our Disable()
464 wxWindowList
*m_childrenDisabled
;
466 // number of calls to Freeze() minus number of calls to Thaw()
467 unsigned int m_frozenness
;
469 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
470 DECLARE_NO_COPY_CLASS(wxWindowPalm
)
471 DECLARE_EVENT_TABLE()
474 // ----------------------------------------------------------------------------
476 // ----------------------------------------------------------------------------
478 #if WXWIN_COMPATIBILITY_2_4
480 inline bool wxWindowPalm::GetUseCtl3D() const { return false; }
481 inline bool wxWindowPalm::GetTransparentBackground() const { return false; }
482 inline void wxWindowPalm::SetTransparent(bool WXUNUSED(t
)) { }
484 #endif // WXWIN_COMPATIBILITY_2_4
486 // ---------------------------------------------------------------------------
488 // ---------------------------------------------------------------------------
490 // kbd code translation
491 WXDLLEXPORT
int wxCharCodePalmToWX(int keySym
, WXLPARAM lParam
= 0);
492 WXDLLEXPORT
int wxCharCodeWXToPalm(int id
, bool *IsVirtual
);
494 // window creation helper class: before creating a new HWND, instantiate an
495 // object of this class on stack - this allows to process the messages sent to
496 // the window even before CreateWindow() returns
497 class wxWindowCreationHook
500 wxWindowCreationHook(wxWindowPalm
*winBeingCreated
);
501 ~wxWindowCreationHook();
504 // ----------------------------------------------------------------------------
506 // ----------------------------------------------------------------------------
508 // notice that this hash must be defined after wxWindow declaration as it
509 // needs to "see" its dtor and not just forward declaration
512 // pseudo-template HWND <-> wxWindow hash table
513 #if WXWIN_COMPATIBILITY_2_4
514 WX_DECLARE_HASH(wxWindow
, wxWindowList
, wxWinHashTable
);
516 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
519 extern wxWinHashTable
*wxWinHandleHash
;