]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/palmos/window.cpp
Small bug fixes
[wxWidgets.git] / src / palmos / window.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/palmos/window.cpp
3// Purpose: wxWindow
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// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#include "wx/window.h"
28
29#ifndef WX_PRECOMP
30 #include "wx/accel.h"
31 #include "wx/menu.h"
32 #include "wx/dc.h"
33 #include "wx/dcclient.h"
34 #include "wx/dcmemory.h"
35 #include "wx/utils.h"
36 #include "wx/app.h"
37 #include "wx/layout.h"
38 #include "wx/dialog.h"
39 #include "wx/frame.h"
40 #include "wx/listbox.h"
41 #include "wx/button.h"
42 #include "wx/msgdlg.h"
43 #include "wx/settings.h"
44 #include "wx/statbox.h"
45 #include "wx/intl.h"
46 #include "wx/log.h"
47 #include "wx/textctrl.h"
48 #include "wx/menuitem.h"
49 #include "wx/module.h"
50#endif
51
52#if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
53 #include "wx/ownerdrw.h"
54#endif
55
56#if wxUSE_DRAG_AND_DROP
57 #include "wx/dnd.h"
58#endif
59
60#if wxUSE_ACCESSIBILITY
61 #include "wx/access.h"
62#endif
63
64#if wxUSE_TOOLTIPS
65 #include "wx/tooltip.h"
66#endif
67
68#if wxUSE_CARET
69 #include "wx/caret.h"
70#endif // wxUSE_CARET
71
72#if wxUSE_SPINCTRL
73 #include "wx/spinctrl.h"
74#endif // wxUSE_SPINCTRL
75
76#include "wx/notebook.h"
77#include "wx/listctrl.h"
78
79#include <Window.h>
80
81// ---------------------------------------------------------------------------
82// global variables
83// ---------------------------------------------------------------------------
84
85#if wxUSE_MENUS_NATIVE
86wxMenu *wxCurrentPopupMenu = NULL;
87#endif // wxUSE_MENUS_NATIVE
88
89// ---------------------------------------------------------------------------
90// private functions
91// ---------------------------------------------------------------------------
92
93// ---------------------------------------------------------------------------
94// event tables
95// ---------------------------------------------------------------------------
96
97// in wxUniv/Palm this class is abstract because it doesn't have DoPopupMenu()
98// method
99#ifdef __WXUNIVERSAL__
100 IMPLEMENT_ABSTRACT_CLASS(wxWindowPalm, wxWindowBase)
101#else // __WXPalm__
102#if wxUSE_EXTENDED_RTTI
103
104// windows that are created from a parent window during its Create method, eg. spin controls in a calendar controls
105// must never been streamed out separately otherwise chaos occurs. Right now easiest is to test for negative ids, as
106// windows with negative ids never can be recreated anyway
107
108bool wxWindowStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & )
109{
110 return false;
111}
112
113IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxWindow, wxWindowBase,"wx/window.h", wxWindowStreamingCallback)
114
115// make wxWindowList known before the property is used
116
117wxCOLLECTION_TYPE_INFO( wxWindow* , wxWindowList ) ;
118
119template<> void wxCollectionToVariantArray( wxWindowList const &theList, wxxVariantArray &value)
120{
121 wxListCollectionToVariantArray<wxWindowList::compatibility_iterator>( theList , value ) ;
122}
123
124WX_DEFINE_FLAGS( wxWindowStyle )
125
126wxBEGIN_FLAGS( wxWindowStyle )
127 // new style border flags, we put them first to
128 // use them for streaming out
129
130 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
131 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
132 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
133 wxFLAGS_MEMBER(wxBORDER_RAISED)
134 wxFLAGS_MEMBER(wxBORDER_STATIC)
135 wxFLAGS_MEMBER(wxBORDER_NONE)
136
137 // old style border flags
138 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
139 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
140 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
141 wxFLAGS_MEMBER(wxRAISED_BORDER)
142 wxFLAGS_MEMBER(wxSTATIC_BORDER)
143 wxFLAGS_MEMBER(wxBORDER)
144
145 // standard window styles
146 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
147 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
148 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
149 wxFLAGS_MEMBER(wxWANTS_CHARS)
150 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
151 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
152 wxFLAGS_MEMBER(wxVSCROLL)
153 wxFLAGS_MEMBER(wxHSCROLL)
154
155wxEND_FLAGS( wxWindowStyle )
156
157wxBEGIN_PROPERTIES_TABLE(wxWindow)
158 wxEVENT_PROPERTY( Close , wxEVT_CLOSE_WINDOW , wxCloseEvent)
159 wxEVENT_PROPERTY( Create , wxEVT_CREATE , wxWindowCreateEvent )
160 wxEVENT_PROPERTY( Destroy , wxEVT_DESTROY , wxWindowDestroyEvent )
161 // Always constructor Properties first
162
163 wxREADONLY_PROPERTY( Parent,wxWindow*, GetParent, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
164 wxPROPERTY( Id,wxWindowID, SetId, GetId, wxID_ANY, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
165 wxPROPERTY( Position,wxPoint, SetPosition , GetPosition, wxDefaultPosition , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // pos
166 wxPROPERTY( Size,wxSize, SetSize, GetSize, wxDefaultSize , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // size
167 wxPROPERTY( WindowStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
168
169 // Then all relations of the object graph
170
171 wxREADONLY_PROPERTY_COLLECTION( Children , wxWindowList , wxWindowBase* , GetWindowChildren , wxPROP_OBJECT_GRAPH /*flags*/ , wxT("Helpstring") , wxT("group"))
172
173 // and finally all other properties
174
175 wxPROPERTY( ExtraStyle , long , SetExtraStyle , GetExtraStyle , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // extstyle
176 wxPROPERTY( BackgroundColour , wxColour , SetBackgroundColour , GetBackgroundColour , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // bg
177 wxPROPERTY( ForegroundColour , wxColour , SetForegroundColour , GetForegroundColour , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // fg
178 wxPROPERTY( Enabled , bool , Enable , IsEnabled , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
179 wxPROPERTY( Shown , bool , Show , IsShown , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
180#if 0
181 // possible property candidates (not in xrc) or not valid in all subclasses
182 wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxT("") )
183 wxPROPERTY( Font , wxFont , SetFont , GetWindowFont , )
184 wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxT("") )
185 // MaxHeight, Width , MinHeight , Width
186 // TODO switch label to control and title to toplevels
187
188 wxPROPERTY( ThemeEnabled , bool , SetThemeEnabled , GetThemeEnabled , )
189 //wxPROPERTY( Cursor , wxCursor , SetCursor , GetCursor , )
190 // wxPROPERTY( ToolTip , wxString , SetToolTip , GetToolTipText , )
191 wxPROPERTY( AutoLayout , bool , SetAutoLayout , GetAutoLayout , )
192
193
194
195#endif
196wxEND_PROPERTIES_TABLE()
197
198wxBEGIN_HANDLERS_TABLE(wxWindow)
199wxEND_HANDLERS_TABLE()
200
201wxCONSTRUCTOR_DUMMY(wxWindow)
202
203#else
204 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
205#endif
206#endif // __WXUNIVERSAL__/__WXPalm__
207
208BEGIN_EVENT_TABLE(wxWindowPalm, wxWindowBase)
209 EVT_ERASE_BACKGROUND(wxWindowPalm::OnEraseBackground)
210 EVT_INIT_DIALOG(wxWindowPalm::OnInitDialog)
211END_EVENT_TABLE()
212
213// ===========================================================================
214// implementation
215// ===========================================================================
216
217// ---------------------------------------------------------------------------
218// wxWindow utility functions
219// ---------------------------------------------------------------------------
220
221// Find an item given the MS Windows id
222wxWindow *wxWindowPalm::FindItem(long id) const
223{
224 return NULL;
225}
226
227// Find an item given the MS Windows handle
228wxWindow *wxWindowPalm::FindItemByWinHandle(WXWINHANDLE handle, bool controlOnly) const
229{
230 // TODO
231 return NULL;
232}
233
234bool wxGetKeyState(wxKeyCode key)
235{
236 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
237 WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
238
239 // TODO
240
241 return false;
242}
243
244// ----------------------------------------------------------------------------
245// constructors and such
246// ----------------------------------------------------------------------------
247
248void wxWindowPalm::Init()
249{
250 m_handle = 0;
251}
252
253// Destructor
254wxWindowPalm::~wxWindowPalm()
255{
256}
257
258// real construction (Init() must have been called before!)
259bool wxWindowPalm::Create(wxWindow *parent,
260 wxWindowID id,
261 const wxPoint& pos,
262 const wxSize& size,
263 long style,
264 const wxString& name)
265{
266 wxCHECK_MSG( parent, false, wxT("can't create wxWindow without parent") );
267
268 if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
269 return false;
270
271 parent->AddChild(this);
272
273 InheritAttributes();
274
275 return true;
276}
277
278WXFORMPTR wxWindowPalm::GetFormPtr()
279{
280 return FrameForm;
281}
282void wxWindowPalm::SetFormPtr(WXFORMPTR FormPtr)
283{
284 FrameForm = FormPtr;
285}
286
287// ---------------------------------------------------------------------------
288// basic operations
289// ---------------------------------------------------------------------------
290
291void wxWindowPalm::SetFocus()
292{
293}
294
295void wxWindowPalm::SetFocusFromKbd()
296{
297}
298
299// Get the window with the focus
300wxWindow *wxWindowBase::DoFindFocus()
301{
302 return NULL;
303}
304
305bool wxWindowPalm::Enable(bool enable)
306{
307 return false;
308}
309
310bool wxWindowPalm::Show(bool show)
311{
312 return false;
313}
314
315// Raise the window to the top of the Z order
316void wxWindowPalm::Raise()
317{
318}
319
320// Lower the window to the bottom of the Z order
321void wxWindowPalm::Lower()
322{
323}
324
325void wxWindowPalm::SetLabel( const wxString& WXUNUSED(label))
326{
327}
328
329wxString wxWindowPalm::GetLabel() const
330{
331 return wxEmptyString;
332}
333
334void wxWindowPalm::DoCaptureMouse()
335{
336}
337
338void wxWindowPalm::DoReleaseMouse()
339{
340}
341
342/* static */ wxWindow *wxWindowBase::GetCapture()
343{
344 return NULL;
345}
346
347bool wxWindowPalm::SetFont(const wxFont& font)
348{
349 return false;
350}
351bool wxWindowPalm::SetCursor(const wxCursor& cursor)
352{
353 return false;
354}
355
356void wxWindowPalm::WarpPointer (int x, int y)
357{
358}
359
360// ---------------------------------------------------------------------------
361// scrolling stuff
362// ---------------------------------------------------------------------------
363
364// convert wxHORIZONTAL/wxVERTICAL to SB_HORZ/SB_VERT
365static inline int wxDirToWinStyle(int orient)
366{
367 return 0;
368}
369
370int wxWindowPalm::GetScrollPos(int orient) const
371{
372 return 0;
373}
374
375// This now returns the whole range, not just the number
376// of positions that we can scroll.
377int wxWindowPalm::GetScrollRange(int orient) const
378{
379 return 0;
380}
381
382int wxWindowPalm::GetScrollThumb(int orient) const
383{
384 return 0;
385}
386
387void wxWindowPalm::SetScrollPos(int orient, int pos, bool refresh)
388{
389}
390
391// New function that will replace some of the above.
392void wxWindowPalm::SetScrollbar(int orient,
393 int pos,
394 int pageSize,
395 int range,
396 bool refresh)
397{
398}
399
400void wxWindowPalm::ScrollWindow(int dx, int dy, const wxRect *prect)
401{
402}
403
404bool wxWindowPalm::ScrollLines(int lines)
405{
406 return false;
407}
408
409bool wxWindowPalm::ScrollPages(int pages)
410{
411 return false;
412}
413
414// ----------------------------------------------------------------------------
415// Style handling
416// ----------------------------------------------------------------------------
417
418WXDWORD wxWindowPalm::PalmGetStyle(long flags, WXDWORD *exstyle) const
419{
420 return 0;
421}
422
423// Setup background and foreground colours correctly
424void wxWindowPalm::SetupColours()
425{
426}
427
428void wxWindowPalm::OnInternalIdle()
429{
430}
431
432// Set this window to be the child of 'parent'.
433bool wxWindowPalm::Reparent(wxWindowBase *parent)
434{
435 return false;
436}
437
438void wxWindowPalm::Freeze()
439{
440}
441
442void wxWindowPalm::Thaw()
443{
444}
445
446void wxWindowPalm::Refresh(bool eraseBack, const wxRect *rect)
447{
448 WinHandle handle = (WinHandle)GetWinHandle();
449 if(handle)
450 {
451 if(rect)
452 {
453 RectangleType dirtyRect;
454 dirtyRect.topLeft.x = rect->GetX() - 1;
455 dirtyRect.topLeft.y = rect->GetY() - 1;
456 dirtyRect.extent.x = rect->GetWidth() + 1;
457 dirtyRect.extent.y = rect->GetHeight() + 1;
458 WinInvalidateRect(handle, &dirtyRect);
459 }
460 else
461 {
462 WinInvalidateWindow(handle);
463 }
464 }
465}
466
467void wxWindowPalm::Update()
468{
469}
470
471// ---------------------------------------------------------------------------
472// drag and drop
473// ---------------------------------------------------------------------------
474
475
476#if wxUSE_DRAG_AND_DROP
477void wxWindowPalm::SetDropTarget(wxDropTarget *pDropTarget)
478{
479}
480#endif // wxUSE_DRAG_AND_DROP
481
482// old style file-manager drag&drop support: we retain the old-style
483// DragAcceptFiles in parallel with SetDropTarget.
484void wxWindowPalm::DragAcceptFiles(bool accept)
485{
486}
487
488// ----------------------------------------------------------------------------
489// tooltips
490// ----------------------------------------------------------------------------
491
492#if wxUSE_TOOLTIPS
493
494void wxWindowPalm::DoSetToolTip(wxToolTip *tooltip)
495{
496}
497
498#endif // wxUSE_TOOLTIPS
499
500// ---------------------------------------------------------------------------
501// moving and resizing
502// ---------------------------------------------------------------------------
503
504// Get total size
505void wxWindowPalm::DoGetSize(int *x, int *y) const
506{
507}
508
509// Get size *available for subwindows* i.e. excluding menu bar etc.
510void wxWindowPalm::DoGetClientSize(int *x, int *y) const
511{
512}
513
514void wxWindowPalm::DoGetPosition(int *x, int *y) const
515{
516 if(x)
517 *x = 0;
518 if(y)
519 *y = 0;
520}
521
522void wxWindowPalm::DoScreenToClient(int *x, int *y) const
523{
524}
525
526void wxWindowPalm::DoClientToScreen(int *x, int *y) const
527{
528}
529
530void wxWindowPalm::DoMoveWindow(int x, int y, int width, int height)
531{
532}
533
534// set the size of the window: if the dimensions are positive, just use them,
535// but if any of them is equal to -1, it means that we must find the value for
536// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
537// which case -1 is a valid value for x and y)
538//
539// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
540// the width/height to best suit our contents, otherwise we reuse the current
541// width/height
542void wxWindowPalm::DoSetSize(int x, int y, int width, int height, int sizeFlags)
543{
544 // get the current size and position...
545 int currentX, currentY;
546 GetPosition(&currentX, &currentY);
547 int currentW,currentH;
548 GetSize(&currentW, &currentH);
549
550 // ... and don't do anything (avoiding flicker) if it's already ok
551 if ( x == currentX && y == currentY &&
552 width == currentW && height == currentH )
553 {
554 return;
555 }
556
557 if ( x == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
558 x = currentX;
559 if ( y == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
560 y = currentY;
561
562 AdjustForParentClientOrigin(x, y, sizeFlags);
563
564 wxSize size = wxDefaultSize;
565 if ( width == wxDefaultCoord )
566 {
567 if ( sizeFlags & wxSIZE_AUTO_WIDTH )
568 {
569 size = DoGetBestSize();
570 width = size.x;
571 }
572 else
573 {
574 // just take the current one
575 width = currentW;
576 }
577 }
578
579 if ( height == wxDefaultCoord )
580 {
581 if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
582 {
583 if ( size.x == wxDefaultCoord )
584 {
585 size = DoGetBestSize();
586 }
587 //else: already called DoGetBestSize() above
588
589 height = size.y;
590 }
591 else
592 {
593 // just take the current one
594 height = currentH;
595 }
596 }
597
598 DoMoveWindow(x, y, width, height);
599}
600
601void wxWindowPalm::DoSetClientSize(int width, int height)
602{
603}
604
605// ---------------------------------------------------------------------------
606// text metrics
607// ---------------------------------------------------------------------------
608
609int wxWindowPalm::GetCharHeight() const
610{
611 return 0;
612}
613
614int wxWindowPalm::GetCharWidth() const
615{
616 return 0;
617}
618
619void wxWindowPalm::GetTextExtent(const wxString& string,
620 int *x, int *y,
621 int *descent, int *externalLeading,
622 const wxFont *theFont) const
623{
624}
625
626// ---------------------------------------------------------------------------
627// popup menu
628// ---------------------------------------------------------------------------
629
630#if wxUSE_MENUS_NATIVE
631
632// yield for WM_COMMAND events only, i.e. process all WM_COMMANDs in the queue
633// immediately, without waiting for the next event loop iteration
634//
635// NB: this function should probably be made public later as it can almost
636// surely replace wxYield() elsewhere as well
637static void wxYieldForCommandsOnly()
638{
639}
640
641bool wxWindowPalm::DoPopupMenu(wxMenu *menu, int x, int y)
642{
643 return false;
644}
645
646#endif // wxUSE_MENUS_NATIVE
647
648// ----------------------------------------------------------------------------
649// wxWindow <-> HWND map
650// ----------------------------------------------------------------------------
651
652wxWinHashTable *wxWinHandleHash = NULL;
653
654wxWindow *wxFindWinFromWinHandle(WXWINHANDLE handle)
655{
656 // TODO
657 return NULL;
658}
659
660void wxRemoveHandleAssociation(wxWindowPalm *win)
661{
662}
663
664// ----------------------------------------------------------------------------
665// various Palm specific class dependent functions
666// ----------------------------------------------------------------------------
667
668bool wxWindowPalm::PalmGetCreateWindowCoords(const wxPoint& pos,
669 const wxSize& size,
670 int& x, int& y,
671 int& w, int& h) const
672{
673 return false;
674}
675
676bool wxWindowPalm::PalmCreate(const wxChar *wclass,
677 const wxChar *title,
678 const wxPoint& pos,
679 const wxSize& size,
680 WXDWORD style,
681 WXDWORD extendedStyle)
682{
683 return false;
684}
685
686// ===========================================================================
687// Palm message handlers
688// ===========================================================================
689
690// ---------------------------------------------------------------------------
691// painting
692// ---------------------------------------------------------------------------
693
694// Can be called from an application's OnPaint handler
695void wxWindowPalm::OnPaint(wxPaintEvent& event)
696{
697}
698
699void wxWindowPalm::OnEraseBackground(wxEraseEvent& event)
700{
701}
702
703// ---------------------------------------------------------------------------
704// moving and resizing
705// ---------------------------------------------------------------------------
706
707bool wxWindowPalm::HandleMove(int x, int y)
708{
709 return false;
710}
711
712bool wxWindowPalm::HandleMoving(wxRect& rect)
713{
714 return false;
715}
716
717// ---------------------------------------------------------------------------
718// joystick
719// ---------------------------------------------------------------------------
720
721bool wxWindowPalm::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
722{
723 return false;
724}
725
726// ---------------------------------------------------------------------------
727// scrolling
728// ---------------------------------------------------------------------------
729
730bool wxWindowPalm::PalmOnScroll(int orientation, WXWORD wParam,
731 WXWORD pos, WXWINHANDLE control)
732{
733 // TODO
734 return false;
735}
736
737// ===========================================================================
738// global functions
739// ===========================================================================
740
741void wxGetCharSize(WXWINHANDLE wnd, int *x, int *y, const wxFont *the_font)
742{
743 // TODO
744}
745
746#if wxUSE_HOTKEY
747
748bool wxWindowPalm::RegisterHotKey(int hotkeyId, int modifiers, int keycode)
749{
750 return false;
751}
752
753bool wxWindowPalm::UnregisterHotKey(int hotkeyId)
754{
755 return false;
756}
757
758#endif // wxUSE_HOTKEY