]>
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 - 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 WXDLLEXPORT 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();
76 virtual void Freeze();
79 virtual bool SetCursor( const wxCursor
&cursor
);
80 virtual bool SetFont( const wxFont
&font
);
82 virtual int GetCharHeight() const;
83 virtual int GetCharWidth() const;
84 virtual void GetTextExtent(const wxString
& string
,
86 int *descent
= (int *) NULL
,
87 int *externalLeading
= (int *) NULL
,
88 const wxFont
*theFont
= (const wxFont
*) NULL
)
91 #if wxUSE_MENUS_NATIVE
92 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
);
93 #endif // wxUSE_MENUS_NATIVE
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
);
104 virtual bool ScrollLines(int lines
);
105 virtual bool ScrollPages(int pages
);
107 #if wxUSE_DRAG_AND_DROP
108 virtual void SetDropTarget( wxDropTarget
*dropTarget
);
109 #endif // wxUSE_DRAG_AND_DROP
111 // Accept files for dragging
112 virtual void DragAcceptFiles(bool accept
);
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__
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
129 // implementation from now on
130 // --------------------------
135 virtual WXWINHANDLE
GetWinHandle() const { return m_handle
; }
136 virtual WXWidget
GetHandle() const { return GetWinHandle(); }
141 void OnEraseBackground(wxEraseEvent
& event
);
142 void OnPaint(wxPaintEvent
& event
);
145 wxWindow
*FindItem(long id
) const;
146 wxWindow
*FindItemByWinHandle(WXWINHANDLE handle
, bool controlOnly
= false) const;
148 // Palm only: true if this control is part of the main control
149 virtual bool ContainsWinHandle(WXWINHANDLE
WXUNUSED(handle
)) const { return false; };
151 // translate wxWidgets style flags for this control into the Windows style
152 // and optional extended style for the corresponding native control
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 ;
158 // get the Palm window flags corresponding to wxWidgets ones
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
); }
165 // translate wxWidgets coords into Windows ones suitable to be passed to
168 // returns true if non default coords are returned, false otherwise
169 bool PalmGetCreateWindowCoords(const wxPoint
& pos
,
172 int& w
, int& h
) const;
174 // creates the window of specified Windows class with given style, extended
175 // style, title and geometry (default values
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
,
183 WXDWORD exendedStyle
= 0);
185 #ifndef __WXUNIVERSAL__
186 // Create an appropriate wxWindow from a WinHandle
187 virtual wxWindow
* CreateWindowFromWinHandle(wxWindow
* parent
, WXWINHANDLE handle
);
189 // Make sure the window style reflects the WinHandle style (roughly)
190 virtual void AdoptAttributesFromWinHandle();
191 #endif // __WXUNIVERSAL__
193 // Setup background and foreground colours correctly
194 virtual void SetupColours();
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 // ------------------------------------------------------------------------
201 // scroll event (both horizontal and vertical)
202 virtual bool PalmOnScroll(int orientation
, WXWORD nSBCode
,
203 WXWORD pos
, WXWINHANDLE control
);
205 // virtual function for implementing internal idle
207 virtual void OnInternalIdle() ;
211 WXWINHANDLE m_handle
;
214 WXFORMPTR
GetFormPtr();
215 void SetFormPtr(WXFORMPTR FormPtr
);
217 // additional (Palm specific) flags
218 bool m_mouseInWindow
:1;
219 bool m_lastKeydownProcessed
:1;
221 // the size of one page for scrolling
225 #if wxUSE_MOUSEEVENT_HACK
226 // the coordinates of the last mouse event and the type of it
229 int m_lastMouseEvent
;
230 #endif // wxUSE_MOUSEEVENT_HACK
232 WXHMENU m_hMenu
; // Menu, if any
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
);
245 virtual void DoCaptureMouse();
246 virtual void DoReleaseMouse();
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
);
255 virtual void DoSetToolTip( wxToolTip
*tip
);
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
,
261 const wxString
& ttip
);
262 #endif // wxUSE_TOOLTIPS
265 // common part of all ctors
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
);
273 // number of calls to Freeze() minus number of calls to Thaw()
274 unsigned int m_frozenness
;
276 DECLARE_DYNAMIC_CLASS(wxWindowPalm
)
277 DECLARE_NO_COPY_CLASS(wxWindowPalm
)
278 DECLARE_EVENT_TABLE()
281 // ----------------------------------------------------------------------------
283 // ----------------------------------------------------------------------------
285 // notice that this hash must be defined after wxWindow declaration as it
286 // needs to "see" its dtor and not just forward declaration
289 // pseudo-template WinHandle <-> wxWindow hash table
290 WX_DECLARE_HASH(wxWindowPalm
, wxWindowList
, wxWinHashTable
);
292 extern wxWinHashTable
*wxWinHandleHash
;