]> git.saurik.com Git - wxWidgets.git/blame - include/wx/palmos/window.h
wxMGL revitalised with OpenWatcom.
[wxWidgets.git] / include / wx / palmos / window.h
CommitLineData
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
30class WXDLLEXPORT wxWindowPalm : public wxWindowBase
31{
32public:
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
56 virtual void SetTitle( const wxString& title);
57 virtual wxString GetTitle() const;
58
59 virtual void Raise();
60 virtual void Lower();
61
e951b8e4
WS
62 virtual bool Show( bool show = true );
63 virtual bool Enable( bool enable = true );
ffecfa5a
JS
64
65 virtual void SetFocus();
66 virtual void SetFocusFromKbd();
67
68 virtual bool Reparent(wxWindowBase *newParent);
69
70 virtual void WarpPointer(int x, int y);
71
e951b8e4 72 virtual void Refresh( bool eraseBackground = true,
324eeecb 73 const wxRect *rect = NULL );
ffecfa5a
JS
74 virtual void Update();
75 virtual void Freeze();
76 virtual void Thaw();
77
ffecfa5a
JS
78 virtual bool SetCursor( const wxCursor &cursor );
79 virtual bool SetFont( const wxFont &font );
80
81 virtual int GetCharHeight() const;
82 virtual int GetCharWidth() const;
83 virtual void GetTextExtent(const wxString& string,
84 int *x, int *y,
85 int *descent = (int *) NULL,
86 int *externalLeading = (int *) NULL,
87 const wxFont *theFont = (const wxFont *) NULL)
88 const;
89
90#if wxUSE_MENUS_NATIVE
91 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
92#endif // wxUSE_MENUS_NATIVE
93
94 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
e951b8e4
WS
95 int range, bool refresh = true );
96 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
ffecfa5a
JS
97 virtual int GetScrollPos( int orient ) const;
98 virtual int GetScrollThumb( int orient ) const;
99 virtual int GetScrollRange( int orient ) const;
100 virtual void ScrollWindow( int dx, int dy,
101 const wxRect* rect = (wxRect *) NULL );
102
103 virtual bool ScrollLines(int lines);
104 virtual bool ScrollPages(int pages);
105
106#if wxUSE_DRAG_AND_DROP
107 virtual void SetDropTarget( wxDropTarget *dropTarget );
108#endif // wxUSE_DRAG_AND_DROP
109
110 // Accept files for dragging
111 virtual void DragAcceptFiles(bool accept);
112
ffecfa5a
JS
113#ifndef __WXUNIVERSAL__
114 // Native resource loading (implemented in src/Palm/nativdlg.cpp)
115 // FIXME: should they really be all virtual?
116 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
117 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
118 wxWindow* GetWindowChild1(wxWindowID id);
119 wxWindow* GetWindowChild(wxWindowID id);
120#endif // __WXUNIVERSAL__
121
122#if wxUSE_HOTKEY
123 // install and deinstall a system wide hotkey
124 virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode);
125 virtual bool UnregisterHotKey(int hotkeyId);
126#endif // wxUSE_HOTKEY
127
128 // implementation from now on
129 // --------------------------
130
131 // simple accessors
132 // ----------------
133
324eeecb
WS
134 virtual WXWINHANDLE GetWinHandle() const { return m_handle; }
135 virtual WXWidget GetHandle() const { return GetWinHandle(); }
ffecfa5a
JS
136
137 // event handlers
138 // --------------
139
140 void OnEraseBackground(wxEraseEvent& event);
141 void OnPaint(wxPaintEvent& event);
142
143public:
ffecfa5a 144 wxWindow *FindItem(long id) const;
324eeecb 145 wxWindow *FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly = false) const;
ffecfa5a 146
e951b8e4 147 // Palm only: true if this control is part of the main control
324eeecb 148 virtual bool ContainsWinHandle(WXWINHANDLE WXUNUSED(handle)) const { return false; };
ffecfa5a
JS
149
150 // translate wxWidgets style flags for this control into the Windows style
151 // and optional extended style for the corresponding native control
152 //
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 ;
156
157 // get the Palm window flags corresponding to wxWidgets ones
158 //
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); }
163
164 // translate wxWidgets coords into Windows ones suitable to be passed to
165 // ::CreateWindow()
166 //
e951b8e4 167 // returns true if non default coords are returned, false otherwise
ffecfa5a
JS
168 bool PalmGetCreateWindowCoords(const wxPoint& pos,
169 const wxSize& size,
170 int& x, int& y,
171 int& w, int& h) const;
172
ffecfa5a
JS
173 // creates the window of specified Windows class with given style, extended
174 // style, title and geometry (default values
175 //
e951b8e4 176 // returns true if the window has been created, false if creation failed
ffecfa5a
JS
177 bool PalmCreate(const wxChar *wclass,
178 const wxChar *title = NULL,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 WXDWORD style = 0,
182 WXDWORD exendedStyle = 0);
183
ffecfa5a 184#ifndef __WXUNIVERSAL__
324eeecb
WS
185 // Create an appropriate wxWindow from a WinHandle
186 virtual wxWindow* CreateWindowFromWinHandle(wxWindow* parent, WXWINHANDLE handle);
ffecfa5a 187
324eeecb
WS
188 // Make sure the window style reflects the WinHandle style (roughly)
189 virtual void AdoptAttributesFromWinHandle();
ffecfa5a
JS
190#endif // __WXUNIVERSAL__
191
192 // Setup background and foreground colours correctly
193 virtual void SetupColours();
194
ffecfa5a
JS
195 // ------------------------------------------------------------------------
196 // internal handlers for Palm messages: all handlers return a boolean value:
e951b8e4 197 // true means that the handler processed the event and false that it didn't
ffecfa5a
JS
198 // ------------------------------------------------------------------------
199
ffecfa5a
JS
200 // scroll event (both horizontal and vertical)
201 virtual bool PalmOnScroll(int orientation, WXWORD nSBCode,
324eeecb 202 WXWORD pos, WXWINHANDLE control);
ffecfa5a
JS
203
204 // virtual function for implementing internal idle
205 // behaviour
206 virtual void OnInternalIdle() ;
207
208protected:
209 // the window handle
20bc5ad8
WS
210 WXWINHANDLE m_handle;
211 WXFORMPTR FrameForm;
e951b8e4 212
20bc5ad8
WS
213 WXFORMPTR GetFormPtr();
214 void SetFormPtr(WXFORMPTR FormPtr);
ffecfa5a 215
ffecfa5a
JS
216 // additional (Palm specific) flags
217 bool m_mouseInWindow:1;
218 bool m_lastKeydownProcessed:1;
219
220 // the size of one page for scrolling
221 int m_xThumbSize;
222 int m_yThumbSize;
223
224#if wxUSE_MOUSEEVENT_HACK
225 // the coordinates of the last mouse event and the type of it
226 long m_lastMouseX,
227 m_lastMouseY;
228 int m_lastMouseEvent;
229#endif // wxUSE_MOUSEEVENT_HACK
230
231 WXHMENU m_hMenu; // Menu, if any
232
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);
243
244 virtual void DoCaptureMouse();
245 virtual void DoReleaseMouse();
246
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);
252
253#if wxUSE_TOOLTIPS
254 virtual void DoSetToolTip( wxToolTip *tip );
255
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,
259 WXLPARAM lParam,
260 const wxString& ttip);
261#endif // wxUSE_TOOLTIPS
262
ffecfa5a
JS
263private:
264 // common part of all ctors
265 void Init();
266
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);
271
ffecfa5a
JS
272 // list of disabled children before last call to our Disable()
273 wxWindowList *m_childrenDisabled;
274
275 // number of calls to Freeze() minus number of calls to Thaw()
276 unsigned int m_frozenness;
277
278 DECLARE_DYNAMIC_CLASS(wxWindowPalm)
279 DECLARE_NO_COPY_CLASS(wxWindowPalm)
280 DECLARE_EVENT_TABLE()
281};
282
ffecfa5a
JS
283// ----------------------------------------------------------------------------
284// global objects
285// ----------------------------------------------------------------------------
286
287// notice that this hash must be defined after wxWindow declaration as it
288// needs to "see" its dtor and not just forward declaration
289#include "wx/hash.h"
290
324eeecb 291// pseudo-template WinHandle <-> wxWindow hash table
ffecfa5a 292WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable);
ffecfa5a
JS
293
294extern wxWinHashTable *wxWinHandleHash;
295
296#endif
297 // _WX_WINDOW_H_