1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/window.h
3 // Purpose: wxWindow class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - more than minimal functionality
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // [at least] some version of Windows send extra mouse move messages after
20 // a mouse click or a key press - to temporarily fix this problem, set the
23 // a better solution should be found later...
24 #define wxUSE_MOUSEEVENT_HACK 0
26 // ---------------------------------------------------------------------------
27 // wxWindow declaration for Palm
28 // ---------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxWindowPalm
: public wxWindowBase
33 wxWindowPalm() { Init(); }
35 wxWindowPalm(wxWindow
*parent
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
40 const wxString
& name
= wxPanelNameStr
)
43 Create(parent
, id
, pos
, size
, style
, name
);
46 virtual ~wxWindowPalm();
48 bool Create(wxWindow
*parent
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
53 const wxString
& name
= wxPanelNameStr
);
55 // implement base class pure virtuals
57 virtual void SetLabel( const wxString
& label
);
58 virtual wxString
GetLabel() const;
63 virtual bool Show( bool show
= true );
64 virtual bool Enable( bool enable
= true );
66 virtual void SetFocus();
67 virtual void SetFocusFromKbd();
69 virtual bool Reparent(wxWindowBase
*newParent
);
71 virtual void WarpPointer(int x
, int y
);
73 virtual void Refresh( bool eraseBackground
= true,
74 const wxRect
*rect
= NULL
);
75 virtual void Update();
77 virtual bool SetCursor( const wxCursor
&cursor
);
78 virtual bool SetFont( const wxFont
&font
);
80 virtual int GetCharHeight() const;
81 virtual int GetCharWidth() const;
82 virtual void GetTextExtent(const wxString
& string
,
84 int *descent
= (int *) NULL
,
85 int *externalLeading
= (int *) NULL
,
86 const wxFont
*theFont
= (const wxFont
*) NULL
)
89 #if wxUSE_MENUS_NATIVE
90 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
91 #endif // wxUSE_MENUS_NATIVE
93 virtual void SetScrollbar( int orient
, int pos
, int thumbVisible
,
94 int range
, bool refresh
= true );
95 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= true );
96 virtual int GetScrollPos( int orient
) const;
97 virtual int GetScrollThumb( int orient
) const;
98 virtual int GetScrollRange( int orient
) const;
99 virtual void ScrollWindow( int dx
, int dy
,
100 const wxRect
* rect
= (wxRect
*) NULL
);
102 virtual bool ScrollLines(int lines
);
103 virtual bool ScrollPages(int pages
);
105 #if wxUSE_DRAG_AND_DROP
106 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
107 #endif // wxUSE_DRAG_AND_DROP
109 // Accept files for dragging
110 virtual void DragAcceptFiles(bool accept
);
112 #ifndef __WXUNIVERSAL__
113 // Native resource loading (implemented in src/Palm/nativdlg.cpp)
114 // FIXME: should they really be all virtual?
115 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
116 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
117 wxWindow
* GetWindowChild1(wxWindowID id
);
118 wxWindow
* GetWindowChild(wxWindowID id
);
119 #endif // __WXUNIVERSAL__
122 // install and deinstall a system wide hotkey
123 virtual bool RegisterHotKey(int hotkeyId
, int modifiers
, int keycode
);
124 virtual bool UnregisterHotKey(int hotkeyId
);
125 #endif // wxUSE_HOTKEY
127 // implementation from now on
128 // --------------------------
133 WXHWND
GetHWND() const { return m_hWnd
; }
134 void SetHWND(WXHWND hWnd
) { m_hWnd
= hWnd
; }
135 virtual WXWidget
GetHandle() const { return GetHWND(); }
140 void OnEraseBackground(wxEraseEvent
& event
);
141 void OnPaint(wxPaintEvent
& event
);
144 wxWindow
*FindItem(long id
) const;
145 wxWindow
*FindItemByWinHandle(WXWINHANDLE handle
, bool controlOnly
= false) const;
147 // Palm only: true if this control is part of the main control
148 virtual bool ContainsWinHandle(WXWINHANDLE
WXUNUSED(handle
)) const { return false; };
150 // translate wxWidgets style flags for this control into the Windows style
151 // and optional extended style for the corresponding native control
153 // this is the function that should be overridden in the derived classes,
154 // but you will mostly use PalmGetCreateWindowFlags() below
155 virtual WXDWORD
PalmGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const ;
157 // get the Palm window flags corresponding to wxWidgets ones
159 // the functions returns the flags (WS_XXX) directly and puts the ext
160 // (WS_EX_XXX) flags into the provided pointer if not NULL
161 WXDWORD
PalmGetCreateWindowFlags(WXDWORD
*exflags
= NULL
) const
162 { return PalmGetStyle(GetWindowStyle(), exflags
); }
164 // translate wxWidgets coords into Windows ones suitable to be passed to
167 // returns true if non default coords are returned, false otherwise
168 bool PalmGetCreateWindowCoords(const wxPoint
& pos
,
171 int& w
, int& h
) const;
173 // creates the window of specified Windows class with given style, extended
174 // style, title and geometry (default values
176 // returns true if the window has been created, false if creation failed
177 bool PalmCreate(const wxChar
*wclass
,
178 const wxChar
*title
= NULL
,
179 const wxPoint
& pos
= wxDefaultPosition
,
180 const wxSize
& size
= wxDefaultSize
,
182 WXDWORD exendedStyle
= 0);
184 #ifndef __WXUNIVERSAL__
185 // Create an appropriate wxWindow from a WinHandle
186 virtual wxWindow
* CreateWindowFromWinHandle(wxWindow
* parent
, WXWINHANDLE handle
);
188 // Make sure the window style reflects the WinHandle style (roughly)
189 virtual void AdoptAttributesFromWinHandle();
190 #endif // __WXUNIVERSAL__
192 // Setup background and foreground colours correctly
193 virtual void SetupColours();
195 // ------------------------------------------------------------------------
196 // internal handlers for Palm messages: all handlers return a boolean value:
197 // true means that the handler processed the event and false that it didn't
198 // ------------------------------------------------------------------------
200 // scroll event (both horizontal and vertical)
201 virtual bool PalmOnScroll(int orientation
, WXWORD nSBCode
,
202 WXWORD pos
, WXWINHANDLE control
);
204 // virtual function for implementing internal idle
206 virtual void OnInternalIdle() ;
213 WXFORMPTR
GetFormPtr();
214 void SetFormPtr(WXFORMPTR FormPtr
);
216 // additional (Palm specific) flags
217 bool m_mouseInWindow
:1;
218 bool m_lastKeydownProcessed
:1;
220 // the size of one page for scrolling
224 #if wxUSE_MOUSEEVENT_HACK
225 // the coordinates of the last mouse event and the type of it
228 int m_lastMouseEvent
;
229 #endif // wxUSE_MOUSEEVENT_HACK
231 WXHMENU m_hMenu
; // Menu, if any
233 // implement the base class pure virtuals
234 virtual void DoClientToScreen( int *x
, int *y
) const;
235 virtual void DoScreenToClient( int *x
, int *y
) const;
236 virtual void DoGetPosition( int *x
, int *y
) const;
237 virtual void DoGetSize( int *width
, int *height
) const;
238 virtual void DoGetClientSize( int *width
, int *height
) const;
239 virtual void DoSetSize(int x
, int y
,
240 int width
, int height
,
241 int sizeFlags
= wxSIZE_AUTO
);
242 virtual void DoSetClientSize(int width
, int height
);
244 virtual void DoCaptureMouse();
245 virtual void DoReleaseMouse();
247 // move the window to the specified location and resize it: this is called
248 // from both DoSetSize() and DoSetClientSize() and would usually just call
249 // ::MoveWindow() except for composite controls which will want to arrange
250 // themselves inside the given rectangle
251 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
254 virtual void DoSetToolTip( wxToolTip
*tip
);
256 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
257 // comctl32.dll in our code -- see the function body for more info)
258 bool HandleTooltipNotify(WXUINT code
,
260 const wxString
& ttip
);
261 #endif // wxUSE_TOOLTIPS
264 // common part of all ctors
267 // the (non-virtual) handlers for the events
268 bool HandleMove(int x
, int y
);
269 bool HandleMoving(wxRect
& rect
);
270 bool HandleJoystickEvent(WXUINT msg
, int x
, int y
, WXUINT flags
);
272 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
273 DECLARE_NO_COPY_CLASS(wxWindowPalm
)
274 DECLARE_EVENT_TABLE()
277 // ----------------------------------------------------------------------------
279 // ----------------------------------------------------------------------------
281 // notice that this hash must be defined after wxWindow declaration as it
282 // needs to "see" its dtor and not just forward declaration
285 // pseudo-template WinHandle <-> wxWindow hash table
286 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
288 extern wxWinHashTable
*wxWinHandleHash
;