]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/window.h
allow passing URL to wxURLDataObject ctor
[wxWidgets.git] / include / wx / palmos / window.h
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
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_
13 #define _WX_WINDOW_H_
14
15 // ---------------------------------------------------------------------------
16 // headers
17 // ---------------------------------------------------------------------------
18
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
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
56
57 virtual void SetLabel( const wxString& label);
58 virtual wxString GetLabel() const;
59
60 virtual void Raise();
61 virtual void Lower();
62
63 virtual bool Show( bool show = true );
64 virtual bool Enable( bool enable = true );
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
73 virtual void Refresh( bool eraseBackground = true,
74 const wxRect *rect = NULL );
75 virtual void Update();
76 virtual void Freeze();
77 virtual void Thaw();
78
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,
96 int range, bool refresh = true );
97 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
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
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
135 virtual WXWINHANDLE GetWinHandle() const { return m_handle; }
136 virtual WXWidget GetHandle() const { return GetWinHandle(); }
137
138 // event handlers
139 // --------------
140
141 void OnEraseBackground(wxEraseEvent& event);
142 void OnPaint(wxPaintEvent& event);
143
144 public:
145 wxWindow *FindItem(long id) const;
146 wxWindow *FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly = false) const;
147
148 // Palm only: true if this control is part of the main control
149 virtual bool ContainsWinHandle(WXWINHANDLE WXUNUSED(handle)) const { return false; };
150
151 // translate wxWidgets style flags for this control into the Windows style
152 // and optional extended style for the corresponding native control
153 //
154 // this is the function that should be overridden in the derived classes,
155 // but you will mostly use PalmGetCreateWindowFlags() below
156 virtual WXDWORD PalmGetStyle(long flags, WXDWORD *exstyle = NULL) const ;
157
158 // get the Palm window flags corresponding to wxWidgets ones
159 //
160 // the functions returns the flags (WS_XXX) directly and puts the ext
161 // (WS_EX_XXX) flags into the provided pointer if not NULL
162 WXDWORD PalmGetCreateWindowFlags(WXDWORD *exflags = NULL) const
163 { return PalmGetStyle(GetWindowStyle(), exflags); }
164
165 // translate wxWidgets coords into Windows ones suitable to be passed to
166 // ::CreateWindow()
167 //
168 // returns true if non default coords are returned, false otherwise
169 bool PalmGetCreateWindowCoords(const wxPoint& pos,
170 const wxSize& size,
171 int& x, int& y,
172 int& w, int& h) const;
173
174 // creates the window of specified Windows class with given style, extended
175 // style, title and geometry (default values
176 //
177 // returns true if the window has been created, false if creation failed
178 bool PalmCreate(const wxChar *wclass,
179 const wxChar *title = NULL,
180 const wxPoint& pos = wxDefaultPosition,
181 const wxSize& size = wxDefaultSize,
182 WXDWORD style = 0,
183 WXDWORD exendedStyle = 0);
184
185 #ifndef __WXUNIVERSAL__
186 // Create an appropriate wxWindow from a WinHandle
187 virtual wxWindow* CreateWindowFromWinHandle(wxWindow* parent, WXWINHANDLE handle);
188
189 // Make sure the window style reflects the WinHandle style (roughly)
190 virtual void AdoptAttributesFromWinHandle();
191 #endif // __WXUNIVERSAL__
192
193 // Setup background and foreground colours correctly
194 virtual void SetupColours();
195
196 // ------------------------------------------------------------------------
197 // internal handlers for Palm messages: all handlers return a boolean value:
198 // true means that the handler processed the event and false that it didn't
199 // ------------------------------------------------------------------------
200
201 // scroll event (both horizontal and vertical)
202 virtual bool PalmOnScroll(int orientation, WXWORD nSBCode,
203 WXWORD pos, WXWINHANDLE control);
204
205 // virtual function for implementing internal idle
206 // behaviour
207 virtual void OnInternalIdle() ;
208
209 protected:
210 // the window handle
211 WXWINHANDLE m_handle;
212 WXFORMPTR FrameForm;
213
214 WXFORMPTR GetFormPtr();
215 void SetFormPtr(WXFORMPTR FormPtr);
216
217 // additional (Palm specific) flags
218 bool m_mouseInWindow:1;
219 bool m_lastKeydownProcessed:1;
220
221 // the size of one page for scrolling
222 int m_xThumbSize;
223 int m_yThumbSize;
224
225 #if wxUSE_MOUSEEVENT_HACK
226 // the coordinates of the last mouse event and the type of it
227 long m_lastMouseX,
228 m_lastMouseY;
229 int m_lastMouseEvent;
230 #endif // wxUSE_MOUSEEVENT_HACK
231
232 WXHMENU m_hMenu; // Menu, if any
233
234 // implement the base class pure virtuals
235 virtual void DoClientToScreen( int *x, int *y ) const;
236 virtual void DoScreenToClient( int *x, int *y ) const;
237 virtual void DoGetPosition( int *x, int *y ) const;
238 virtual void DoGetSize( int *width, int *height ) const;
239 virtual void DoGetClientSize( int *width, int *height ) const;
240 virtual void DoSetSize(int x, int y,
241 int width, int height,
242 int sizeFlags = wxSIZE_AUTO);
243 virtual void DoSetClientSize(int width, int height);
244
245 virtual void DoCaptureMouse();
246 virtual void DoReleaseMouse();
247
248 // move the window to the specified location and resize it: this is called
249 // from both DoSetSize() and DoSetClientSize() and would usually just call
250 // ::MoveWindow() except for composite controls which will want to arrange
251 // themselves inside the given rectangle
252 virtual void DoMoveWindow(int x, int y, int width, int height);
253
254 #if wxUSE_TOOLTIPS
255 virtual void DoSetToolTip( wxToolTip *tip );
256
257 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
258 // comctl32.dll in our code -- see the function body for more info)
259 bool HandleTooltipNotify(WXUINT code,
260 WXLPARAM lParam,
261 const wxString& ttip);
262 #endif // wxUSE_TOOLTIPS
263
264 private:
265 // common part of all ctors
266 void Init();
267
268 // the (non-virtual) handlers for the events
269 bool HandleMove(int x, int y);
270 bool HandleMoving(wxRect& rect);
271 bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
272
273 // list of disabled children before last call to our Disable()
274 wxWindowList *m_childrenDisabled;
275
276 // number of calls to Freeze() minus number of calls to Thaw()
277 unsigned int m_frozenness;
278
279 DECLARE_DYNAMIC_CLASS(wxWindowPalm)
280 DECLARE_NO_COPY_CLASS(wxWindowPalm)
281 DECLARE_EVENT_TABLE()
282 };
283
284 // ----------------------------------------------------------------------------
285 // global objects
286 // ----------------------------------------------------------------------------
287
288 // notice that this hash must be defined after wxWindow declaration as it
289 // needs to "see" its dtor and not just forward declaration
290 #include "wx/hash.h"
291
292 // pseudo-template WinHandle <-> wxWindow hash table
293 WX_DECLARE_HASH(wxWindowPalm, wxWindowList, wxWinHashTable);
294
295 extern wxWinHashTable *wxWinHandleHash;
296
297 #endif
298 // _WX_WINDOW_H_