]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/palmos/window.h | |
3 | // Purpose: wxWindow class | |
e1d63b79 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
db101bd3 | 5 | // Modified by: Wlodzimierz ABX Skiba - more than minimal functionality |
ffecfa5a | 6 | // Created: 10/13/04 |
e1d63b79 | 7 | // RCS-ID: $Id$ |
db101bd3 | 8 | // Copyright: (c) William Osborne, Wlodzimierz Skiba |
ffecfa5a JS |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_WINDOW_H_ | |
13 | #define _WX_WINDOW_H_ | |
14 | ||
ffecfa5a JS |
15 | // --------------------------------------------------------------------------- |
16 | // headers | |
17 | // --------------------------------------------------------------------------- | |
18 | ||
ffecfa5a JS |
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 | |
21 | // define below to 1 | |
22 | // | |
23 | // a better solution should be found later... | |
24 | #define wxUSE_MOUSEEVENT_HACK 0 | |
25 | ||
ffecfa5a JS |
26 | // --------------------------------------------------------------------------- |
27 | // wxWindow declaration for Palm | |
28 | // --------------------------------------------------------------------------- | |
29 | ||
30 | class WXDLLEXPORT wxWindowPalm : public wxWindowBase | |
31 | { | |
32 | public: | |
33 | wxWindowPalm() { Init(); } | |
34 | ||
35 | wxWindowPalm(wxWindow *parent, | |
36 | wxWindowID id, | |
37 | const wxPoint& pos = wxDefaultPosition, | |
38 | const wxSize& size = wxDefaultSize, | |
39 | long style = 0, | |
40 | const wxString& name = wxPanelNameStr) | |
41 | { | |
42 | Init(); | |
43 | Create(parent, id, pos, size, style, name); | |
44 | } | |
45 | ||
46 | virtual ~wxWindowPalm(); | |
47 | ||
48 | bool Create(wxWindow *parent, | |
49 | wxWindowID id, | |
50 | const wxPoint& pos = wxDefaultPosition, | |
51 | const wxSize& size = wxDefaultSize, | |
52 | long style = 0, | |
53 | const wxString& name = wxPanelNameStr); | |
54 | ||
55 | // implement base class pure virtuals | |
0ab48d64 WS |
56 | |
57 | virtual void SetLabel( const wxString& label); | |
58 | virtual wxString GetLabel() const; | |
ffecfa5a JS |
59 | |
60 | virtual void Raise(); | |
61 | virtual void Lower(); | |
62 | ||
e951b8e4 WS |
63 | virtual bool Show( bool show = true ); |
64 | virtual bool Enable( bool enable = true ); | |
ffecfa5a JS |
65 | |
66 | virtual void SetFocus(); | |
67 | virtual void SetFocusFromKbd(); | |
68 | ||
69 | virtual bool Reparent(wxWindowBase *newParent); | |
70 | ||
71 | virtual void WarpPointer(int x, int y); | |
72 | ||
e951b8e4 | 73 | virtual void Refresh( bool eraseBackground = true, |
324eeecb | 74 | const wxRect *rect = NULL ); |
ffecfa5a JS |
75 | virtual void Update(); |
76 | virtual void Freeze(); | |
77 | virtual void Thaw(); | |
78 | ||
ffecfa5a JS |
79 | virtual bool SetCursor( const wxCursor &cursor ); |
80 | virtual bool SetFont( const wxFont &font ); | |
81 | ||
82 | virtual int GetCharHeight() const; | |
83 | virtual int GetCharWidth() const; | |
84 | virtual void GetTextExtent(const wxString& string, | |
85 | int *x, int *y, | |
86 | int *descent = (int *) NULL, | |
87 | int *externalLeading = (int *) NULL, | |
88 | const wxFont *theFont = (const wxFont *) NULL) | |
89 | const; | |
90 | ||
91 | #if wxUSE_MENUS_NATIVE | |
92 | virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); | |
93 | #endif // wxUSE_MENUS_NATIVE | |
94 | ||
95 | virtual void SetScrollbar( int orient, int pos, int thumbVisible, | |
e951b8e4 WS |
96 | int range, bool refresh = true ); |
97 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ); | |
ffecfa5a JS |
98 | virtual int GetScrollPos( int orient ) const; |
99 | virtual int GetScrollThumb( int orient ) const; | |
100 | virtual int GetScrollRange( int orient ) const; | |
101 | virtual void ScrollWindow( int dx, int dy, | |
102 | const wxRect* rect = (wxRect *) NULL ); | |
103 | ||
104 | virtual bool ScrollLines(int lines); | |
105 | virtual bool ScrollPages(int pages); | |
106 | ||
107 | #if wxUSE_DRAG_AND_DROP | |
108 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
109 | #endif // wxUSE_DRAG_AND_DROP | |
110 | ||
111 | // Accept files for dragging | |
112 | virtual void DragAcceptFiles(bool accept); | |
113 | ||
ffecfa5a JS |
114 | #ifndef __WXUNIVERSAL__ |
115 | // Native resource loading (implemented in src/Palm/nativdlg.cpp) | |
116 | // FIXME: should they really be all virtual? | |
117 | virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); | |
118 | virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); | |
119 | wxWindow* GetWindowChild1(wxWindowID id); | |
120 | wxWindow* GetWindowChild(wxWindowID id); | |
121 | #endif // __WXUNIVERSAL__ | |
122 | ||
123 | #if wxUSE_HOTKEY | |
124 | // install and deinstall a system wide hotkey | |
125 | virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode); | |
126 | virtual bool UnregisterHotKey(int hotkeyId); | |
127 | #endif // wxUSE_HOTKEY | |
128 | ||
129 | // implementation from now on | |
130 | // -------------------------- | |
131 | ||
132 | // simple accessors | |
133 | // ---------------- | |
134 | ||
e2fc40b4 VZ |
135 | WXHWND GetHWND() const { return m_hWnd; } |
136 | void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } | |
137 | virtual WXWidget GetHandle() const { return GetHWND(); } | |
ffecfa5a JS |
138 | |
139 | // event handlers | |
140 | // -------------- | |
141 | ||
142 | void OnEraseBackground(wxEraseEvent& event); | |
143 | void OnPaint(wxPaintEvent& event); | |
144 | ||
145 | public: | |
ffecfa5a | 146 | wxWindow *FindItem(long id) const; |
324eeecb | 147 | wxWindow *FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly = false) const; |
ffecfa5a | 148 | |
e951b8e4 | 149 | // Palm only: true if this control is part of the main control |
324eeecb | 150 | virtual bool ContainsWinHandle(WXWINHANDLE WXUNUSED(handle)) const { return false; }; |
ffecfa5a JS |
151 | |
152 | // translate wxWidgets style flags for this control into the Windows style | |
153 | // and optional extended style for the corresponding native control | |
154 | // | |
155 | // this is the function that should be overridden in the derived classes, | |
156 | // but you will mostly use PalmGetCreateWindowFlags() below | |
157 | virtual WXDWORD PalmGetStyle(long flags, WXDWORD *exstyle = NULL) const ; | |
158 | ||
159 | // get the Palm window flags corresponding to wxWidgets ones | |
160 | // | |
161 | // the functions returns the flags (WS_XXX) directly and puts the ext | |
162 | // (WS_EX_XXX) flags into the provided pointer if not NULL | |
163 | WXDWORD PalmGetCreateWindowFlags(WXDWORD *exflags = NULL) const | |
164 | { return PalmGetStyle(GetWindowStyle(), exflags); } | |
165 | ||
166 | // translate wxWidgets coords into Windows ones suitable to be passed to | |
167 | // ::CreateWindow() | |
168 | // | |
e951b8e4 | 169 | // returns true if non default coords are returned, false otherwise |
ffecfa5a JS |
170 | bool PalmGetCreateWindowCoords(const wxPoint& pos, |
171 | const wxSize& size, | |
172 | int& x, int& y, | |
173 | int& w, int& h) const; | |
174 | ||
ffecfa5a JS |
175 | // creates the window of specified Windows class with given style, extended |
176 | // style, title and geometry (default values | |
177 | // | |
e951b8e4 | 178 | // returns true if the window has been created, false if creation failed |
ffecfa5a JS |
179 | bool PalmCreate(const wxChar *wclass, |
180 | const wxChar *title = NULL, | |
181 | const wxPoint& pos = wxDefaultPosition, | |
182 | const wxSize& size = wxDefaultSize, | |
183 | WXDWORD style = 0, | |
184 | WXDWORD exendedStyle = 0); | |
185 | ||
ffecfa5a | 186 | #ifndef __WXUNIVERSAL__ |
324eeecb WS |
187 | // Create an appropriate wxWindow from a WinHandle |
188 | virtual wxWindow* CreateWindowFromWinHandle(wxWindow* parent, WXWINHANDLE handle); | |
ffecfa5a | 189 | |
324eeecb WS |
190 | // Make sure the window style reflects the WinHandle style (roughly) |
191 | virtual void AdoptAttributesFromWinHandle(); | |
ffecfa5a JS |
192 | #endif // __WXUNIVERSAL__ |
193 | ||
194 | // Setup background and foreground colours correctly | |
195 | virtual void SetupColours(); | |
196 | ||
ffecfa5a JS |
197 | // ------------------------------------------------------------------------ |
198 | // internal handlers for Palm messages: all handlers return a boolean value: | |
e951b8e4 | 199 | // true means that the handler processed the event and false that it didn't |
ffecfa5a JS |
200 | // ------------------------------------------------------------------------ |
201 | ||
ffecfa5a JS |
202 | // scroll event (both horizontal and vertical) |
203 | virtual bool PalmOnScroll(int orientation, WXWORD nSBCode, | |
324eeecb | 204 | WXWORD pos, WXWINHANDLE control); |
ffecfa5a JS |
205 | |
206 | // virtual function for implementing internal idle | |
207 | // behaviour | |
208 | virtual void OnInternalIdle() ; | |
209 | ||
210 | protected: | |
211 | // the window handle | |
e2fc40b4 | 212 | WXHWND m_hWnd; |
20bc5ad8 | 213 | WXFORMPTR FrameForm; |
e951b8e4 | 214 | |
20bc5ad8 WS |
215 | WXFORMPTR GetFormPtr(); |
216 | void SetFormPtr(WXFORMPTR FormPtr); | |
ffecfa5a | 217 | |
ffecfa5a JS |
218 | // additional (Palm specific) flags |
219 | bool m_mouseInWindow:1; | |
220 | bool m_lastKeydownProcessed:1; | |
221 | ||
222 | // the size of one page for scrolling | |
223 | int m_xThumbSize; | |
224 | int m_yThumbSize; | |
225 | ||
226 | #if wxUSE_MOUSEEVENT_HACK | |
227 | // the coordinates of the last mouse event and the type of it | |
228 | long m_lastMouseX, | |
229 | m_lastMouseY; | |
230 | int m_lastMouseEvent; | |
231 | #endif // wxUSE_MOUSEEVENT_HACK | |
232 | ||
233 | WXHMENU m_hMenu; // Menu, if any | |
234 | ||
235 | // implement the base class pure virtuals | |
236 | virtual void DoClientToScreen( int *x, int *y ) const; | |
237 | virtual void DoScreenToClient( int *x, int *y ) const; | |
238 | virtual void DoGetPosition( int *x, int *y ) const; | |
239 | virtual void DoGetSize( int *width, int *height ) const; | |
240 | virtual void DoGetClientSize( int *width, int *height ) const; | |
241 | virtual void DoSetSize(int x, int y, | |
242 | int width, int height, | |
243 | int sizeFlags = wxSIZE_AUTO); | |
244 | virtual void DoSetClientSize(int width, int height); | |
245 | ||
246 | virtual void DoCaptureMouse(); | |
247 | virtual void DoReleaseMouse(); | |
248 | ||
249 | // move the window to the specified location and resize it: this is called | |
250 | // from both DoSetSize() and DoSetClientSize() and would usually just call | |
251 | // ::MoveWindow() except for composite controls which will want to arrange | |
252 | // themselves inside the given rectangle | |
253 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
254 | ||
255 | #if wxUSE_TOOLTIPS | |
256 | virtual void DoSetToolTip( wxToolTip *tip ); | |
257 | ||
258 | // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in | |
259 | // comctl32.dll in our code -- see the function body for more info) | |
260 | bool HandleTooltipNotify(WXUINT code, | |
261 | WXLPARAM lParam, | |
262 | const wxString& ttip); | |
263 | #endif // wxUSE_TOOLTIPS | |
264 | ||
ffecfa5a JS |
265 | private: |
266 | // common part of all ctors | |
267 | void Init(); | |
268 | ||
269 | // the (non-virtual) handlers for the events | |
270 | bool HandleMove(int x, int y); | |
271 | bool HandleMoving(wxRect& rect); | |
272 | bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags); | |
273 | ||
ffecfa5a JS |
274 | // number of calls to Freeze() minus number of calls to Thaw() |
275 | unsigned int m_frozenness; | |
276 | ||
277 | DECLARE_DYNAMIC_CLASS(wxWindowPalm) | |
278 | DECLARE_NO_COPY_CLASS(wxWindowPalm) | |
279 | DECLARE_EVENT_TABLE() | |
280 | }; | |
281 | ||
ffecfa5a JS |
282 | // ---------------------------------------------------------------------------- |
283 | // global objects | |
284 | // ---------------------------------------------------------------------------- | |
285 | ||
286 | // notice that this hash must be defined after wxWindow declaration as it | |
287 | // needs to "see" its dtor and not just forward declaration | |
288 | #include "wx/hash.h" | |
289 | ||
324eeecb | 290 | // pseudo-template WinHandle <-> wxWindow hash table |
ffecfa5a | 291 | WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable); |
ffecfa5a JS |
292 | |
293 | extern wxWinHashTable *wxWinHandleHash; | |
294 | ||
295 | #endif | |
296 | // _WX_WINDOW_H_ |