From 6afc1b46650ee234868fd4f38526e22a664b6638 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Mar 2008 00:53:32 +0000 Subject: [PATCH] compilation fixes for PalmOS and implementations of missing standard functions (pflib.diff part of patch 1894861) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/palmos/apptrait.h | 6 +- include/wx/palmos/checkbox.h | 2 + include/wx/palmos/chkconf.h | 11 +- include/wx/palmos/choice.h | 9 +- include/wx/palmos/font.h | 10 +- include/wx/palmos/gdiimage.h | 10 +- include/wx/palmos/imaglist.h | 15 +- include/wx/palmos/listctrl.h | 5 +- include/wx/palmos/pen.h | 9 +- include/wx/palmos/private/timer.h | 2 +- include/wx/palmos/textctrl.h | 184 ++++++---- src/palmos/bmpbuttn.cpp | 2 - src/palmos/button.cpp | 2 + src/palmos/checkbox.cpp | 29 +- src/palmos/choice.cpp | 22 -- src/palmos/control.cpp | 6 +- src/palmos/dialog.cpp | 3 +- src/palmos/dir.cpp | 171 +++++++++- src/palmos/filedlg.cpp | 2 - src/palmos/font.cpp | 31 +- src/palmos/help.cpp | 6 - src/palmos/imaglist.cpp | 6 +- src/palmos/main.cpp | 11 +- src/palmos/menu.cpp | 46 +-- src/palmos/msgdlg.cpp | 11 +- src/palmos/pen.cpp | 15 +- src/palmos/progdlg.cpp | 2 + src/palmos/slider.cpp | 12 + src/palmos/statbrpalm.cpp | 6 +- src/palmos/stdall.c | 551 ++++++++++++++++++++++++++++-- src/palmos/textctrl.cpp | 104 +++--- src/palmos/timer.cpp | 12 - src/palmos/toplevel.cpp | 34 +- src/palmos/treectrl.cpp | 39 +-- src/palmos/utils.cpp | 78 ++++- src/palmos/volume.cpp | 4 + src/palmos/window.cpp | 5 + 37 files changed, 1149 insertions(+), 324 deletions(-) diff --git a/include/wx/palmos/apptrait.h b/include/wx/palmos/apptrait.h index 1a2f4b4522..b6238ebd67 100644 --- a/include/wx/palmos/apptrait.h +++ b/include/wx/palmos/apptrait.h @@ -2,7 +2,7 @@ // Name: wx/palmos/apptrait.h // Purpose: class implementing wxAppTraits for Palm OS // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -12,6 +12,10 @@ #ifndef _WX_PALM_APPTRAIT_H_ #define _WX_PALM_APPTRAIT_H_ +#if wxUSE_TIMER +#include "wx/palmos/private/timer.h" // wxPalmOSTimerImpl +#endif // wxUSE_TIMER + // ---------------------------------------------------------------------------- // wxGUI/ConsoleAppTraits: must derive from wxAppTraits, not wxAppTraitsBase // ---------------------------------------------------------------------------- diff --git a/include/wx/palmos/checkbox.h b/include/wx/palmos/checkbox.h index edc46aa9f0..ff4cd9a8d6 100644 --- a/include/wx/palmos/checkbox.h +++ b/include/wx/palmos/checkbox.h @@ -55,6 +55,8 @@ protected: private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckBox) + // current state of the checkbox + wxCheckBoxState m_state; }; #endif diff --git a/include/wx/palmos/chkconf.h b/include/wx/palmos/chkconf.h index 6cb458fdfd..f02e3b52e3 100644 --- a/include/wx/palmos/chkconf.h +++ b/include/wx/palmos/chkconf.h @@ -2,7 +2,7 @@ * Name: wx/palmos/chkconf.h * Purpose: Compiler-specific configuration checking * Author: William Osborne - minimal working wxPalmOS port - * Modified by: + * Modified by: Yunhui Fu * Created: 10/13/04 * RCS-ID: $Id$ * Copyright: (c) William Osborne @@ -55,7 +55,7 @@ #define wxUSE_DATAOBJ 0 #undef wxUSE_DIRDLG -#define wxUSE_DIRDLG 0 +#define wxUSE_DIRDLG 1 #undef wxUSE_DISPLAY #define wxUSE_DISPLAY 0 @@ -82,13 +82,13 @@ #define wxUSE_FFILE 0 #undef wxUSE_FILE -#define wxUSE_FILE 0 +#define wxUSE_FILE 1 #undef wxUSE_FILECONFIG #define wxUSE_FILECONFIG 0 #undef wxUSE_FILEDLG -#define wxUSE_FILEDLG 0 +#define wxUSE_FILEDLG 1 #undef wxUSE_FILESYSTEM #define wxUSE_FILESYSTEM 0 @@ -333,5 +333,8 @@ #undef wxUSE_TOOLBOOK #define wxUSE_TOOLBOOK 0 +#undef wxUSE_SELECT_DISPATCHER +#define wxUSE_SELECT_DISPATCHER 1 + #endif /* _WX_PALMOS_CHKCONF_H_ */ diff --git a/include/wx/palmos/choice.h b/include/wx/palmos/choice.h index 1cffe80f7b..7398c9d5f7 100644 --- a/include/wx/palmos/choice.h +++ b/include/wx/palmos/choice.h @@ -2,7 +2,7 @@ // Name: wx/palmos/choice.h // Purpose: wxChoice class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -77,10 +77,6 @@ public: virtual wxString GetString(unsigned int n) const; virtual void SetString(unsigned int n, const wxString& s); - // MSW only - virtual bool MSWCommand(WXUINT param, WXWORD id); - WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); - protected: virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoSetItemClientData(unsigned int n, void* clientData); @@ -93,9 +89,6 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual bool MSWShouldPreProcessMessage(WXMSG *pMsg); - - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; // update the height of the drop down list to fit the number of items we // have (without changing the visible height) diff --git a/include/wx/palmos/font.h b/include/wx/palmos/font.h index 31fc7dba5d..17385a29a9 100644 --- a/include/wx/palmos/font.h +++ b/include/wx/palmos/font.h @@ -2,7 +2,7 @@ // Name: wx/palmos/font.h // Purpose: wxFont class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/14/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -82,6 +82,10 @@ public: virtual ~wxFont(); + // wxFontBase overridden functions + virtual wxString GetNativeFontInfoDesc() const; + virtual wxString GetNativeFontInfoUserDesc() const; + // implement base class pure virtuals virtual int GetPointSize() const; virtual wxSize GetPixelSize() const; @@ -127,7 +131,9 @@ protected: virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); - void Unshare(); + // implement wxObject virtuals which are used by AllocExclusive() + virtual wxGDIRefData *CreateGDIRefData() const; + virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; private: DECLARE_DYNAMIC_CLASS(wxFont) diff --git a/include/wx/palmos/gdiimage.h b/include/wx/palmos/gdiimage.h index 3d5253328b..debcecebfa 100644 --- a/include/wx/palmos/gdiimage.h +++ b/include/wx/palmos/gdiimage.h @@ -3,7 +3,7 @@ // Purpose: wxGDIImage class: base class for wxBitmap, wxIcon, wxCursor // under Palm OS // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -170,6 +170,14 @@ protected: // create the data for the derived class here virtual wxGDIImageRefData *CreateData() const = 0; virtual wxGDIRefData *CreateGDIRefData() const { return CreateData(); } + // we can't [efficiently] clone objects of this class + virtual wxGDIRefData * + CloneGDIRefData(const wxGDIRefData *WXUNUSED(data)) const + { + wxFAIL_MSG( _T("must be implemented if used") ); + + return NULL; + } static wxGDIImageHandlerList ms_handlers; }; diff --git a/include/wx/palmos/imaglist.h b/include/wx/palmos/imaglist.h index 415eb65ddf..5b1cc588ce 100644 --- a/include/wx/palmos/imaglist.h +++ b/include/wx/palmos/imaglist.h @@ -2,7 +2,7 @@ // Name: wx/palmos/imaglist.h // Purpose: wxImageList class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -28,19 +28,6 @@ * used. */ -// Flags for Draw -#define wxIMAGELIST_DRAW_NORMAL 0x0001 -#define wxIMAGELIST_DRAW_TRANSPARENT 0x0002 -#define wxIMAGELIST_DRAW_SELECTED 0x0004 -#define wxIMAGELIST_DRAW_FOCUSED 0x0008 - -// Flag values for Set/GetImageList -enum { - wxIMAGE_LIST_NORMAL, // Normal icons - wxIMAGE_LIST_SMALL, // Small icons - wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation) -}; - // Eventually we'll make this a reference-counted wxGDIObject. For // now, the app must take care of ownership issues. That is, the // image lists must be explicitly deleted after the control(s) that uses them diff --git a/include/wx/palmos/listctrl.h b/include/wx/palmos/listctrl.h index c7e6f6d2e2..7309d66b70 100644 --- a/include/wx/palmos/listctrl.h +++ b/include/wx/palmos/listctrl.h @@ -2,7 +2,7 @@ // Name: wx/palmos/listctrl.h // Purpose: wxListCtrl class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -376,9 +376,6 @@ protected: // return the text for the given column of the given item virtual wxString OnGetItemText(long item, long column) const; - // return the text for the given column of the given item - virtual wxString OnGetItemText(long item, long column) const; - // return the icon for the given item. In report view, OnGetItemImage will // only be called for the first column. See OnGetItemColumnImage for // details. diff --git a/include/wx/palmos/pen.h b/include/wx/palmos/pen.h index 91731fcf51..61b1f94dbc 100644 --- a/include/wx/palmos/pen.h +++ b/include/wx/palmos/pen.h @@ -2,7 +2,7 @@ // Name: wx/palmos/pen.h // Purpose: wxPen class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -120,7 +120,12 @@ public: bool FreeResource(bool force = false); WXHANDLE GetResourceHandle() const; bool IsFree() const; - void Unshare(); + +protected: + virtual wxGDIRefData* CreateGDIRefData() const; + virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const; + // same as FreeResource() + RealizeResource() + bool Recreate(); private: DECLARE_DYNAMIC_CLASS(wxPen) diff --git a/include/wx/palmos/private/timer.h b/include/wx/palmos/private/timer.h index d6e73ac3c1..08847ee28b 100644 --- a/include/wx/palmos/private/timer.h +++ b/include/wx/palmos/private/timer.h @@ -12,7 +12,7 @@ #ifndef _WX_TIMER_H_ #define _WX_TIMER_H_ -#include "wx/private/timerimpl.h" +#include "wx/private/timer.h" class WXDLLEXPORT wxPalmOSTimerImpl : public wxTimerImpl { diff --git a/include/wx/palmos/textctrl.h b/include/wx/palmos/textctrl.h index 98d73a6be2..930890eee8 100644 --- a/include/wx/palmos/textctrl.h +++ b/include/wx/palmos/textctrl.h @@ -2,7 +2,7 @@ // Name: wx/palmos/textctrl.h // Purpose: wxTextCtrl class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Yunhui Fu // Created: 10/13/04 // RCS-ID: $Id$ // Copyright: (c) William Osborne @@ -41,41 +41,73 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); - // implement base class pure virtuals - // ---------------------------------- + // overridden wxTextEntry methods + // ------------------------------ virtual wxString GetValue() const; + virtual wxString GetRange(long from, long to) const; + + virtual bool IsEmpty() const; virtual int GetLineLength(long lineNo) const; virtual wxString GetLineText(long lineNo) const; virtual int GetNumberOfLines() const; - virtual bool IsModified() const; - virtual bool IsEditable() const; - - virtual void GetSelection(long* from, long* to) const; + virtual void SetMaxLength(unsigned long len); - // operations + virtual void GetSelection(long *from, long *to) const; + // + // Operations // ---------- + // + virtual void Clear(void); + virtual void Replace( long lFrom + ,long lTo + ,const wxString& rsValue + ); + virtual void Remove( long lFrom + ,long lTo + ); - // editing - virtual void Clear(); - virtual void Replace(long from, long to, const wxString& value); - virtual void Remove(long from, long to); - - // load the control's contents from the file - virtual bool DoLoadFile(const wxString& file, int fileType); + //virtual bool DoLoadFile(const wxString& rsFile, int fileType); - // clears the dirty flag virtual void MarkDirty(); - virtual void DiscardEdits(); + virtual void DiscardEdits(void); - virtual void SetMaxLength(unsigned long len); + virtual void WriteText(const wxString& rsText); + virtual void AppendText(const wxString& rsText); + virtual bool EmulateKeyPress(const wxKeyEvent& rEvent); + + virtual void Copy(void); + virtual void Cut(void); + virtual void Paste(void); - // writing text inserts it at the current position, appending always - // inserts it at the end - virtual void WriteText(const wxString& text); - virtual void AppendText(const wxString& text); + virtual bool CanCopy(void) const; + virtual bool CanCut(void) const; + virtual bool CanPaste(void) const; + + virtual void Undo(void); + virtual void Redo(); + + virtual bool CanUndo(void) const; + virtual bool CanRedo(void) const; + + virtual void SetInsertionPoint(long lPos); + virtual void SetInsertionPointEnd(void); + virtual long GetInsertionPoint(void) const; + virtual wxTextPos GetLastPosition(void) const; + + virtual void SetSelection( long lFrom + ,long lTo + ); + virtual void SetEditable(bool bEditable); + virtual void SetWindowStyleFlag(long lStyle); + + // implement base class pure virtuals + // ---------------------------------- + + virtual bool IsModified() const; + virtual bool IsEditable(void) const; #if wxUSE_RICHEDIT // apply text attribute to the range of text (only works with richedit @@ -92,48 +124,28 @@ public: virtual bool PositionToXY(long pos, long *x, long *y) const; virtual void ShowPosition(long pos); + virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, - wxTextCoord *row) const; - - // Clipboard operations - virtual void Copy(); - virtual void Cut(); - virtual void Paste(); - - virtual bool CanCopy() const; - virtual bool CanCut() const; - virtual bool CanPaste() const; - - // Undo/redo - virtual void Undo(); - virtual void Redo(); - - virtual bool CanUndo() const; - virtual bool CanRedo() const; - - // Insertion point - virtual void SetInsertionPoint(long pos); - virtual void SetInsertionPointEnd(); - virtual long GetInsertionPoint() const; - virtual wxTextPos GetLastPosition() const; - - virtual void SetSelection(long from, long to); - virtual void SetEditable(bool editable); + wxTextCoord *row) const + { + return wxTextCtrlBase::HitTest(pt, col, row); + } // Caret handling (Windows only) - bool ShowNativeCaret(bool show = true); bool HideNativeCaret() { return ShowNativeCaret(false); } // Implementation from now on // -------------------------- + +#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT + virtual void SetDropTarget(wxDropTarget *dropTarget); +#endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT virtual void Command(wxCommandEvent& event); - virtual bool MSWCommand(WXUINT param, WXWORD id); #if wxUSE_RICHEDIT - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); int GetRichVersion() const { return m_verRichEdit; } bool IsRich() const { return m_verRichEdit != 0; } @@ -142,9 +154,22 @@ public: // the colours for them otherwise virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); +#else + bool IsRich() const { return false; } #endif // wxUSE_RICHEDIT - virtual bool AcceptsFocus() const; +#if wxUSE_INKEDIT && wxUSE_RICHEDIT + bool IsInkEdit() const { return m_isInkEdit != 0; } +#else + bool IsInkEdit() const { return false; } +#endif + + virtual void AdoptAttributesFromHWND(); + + virtual bool AcceptsFocusFromKeyboard() const; + + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const; // callbacks void OnDropFiles(wxDropFilesEvent& event); @@ -168,21 +193,34 @@ public: // Show a context menu for Rich Edit controls (the standard // EDIT control has one already) - void OnRightClick(wxMouseEvent& event); + void OnContextMenu(wxContextMenuEvent& event); // be sure the caret remains invisible if the user // called HideNativeCaret() before void OnSetFocus(wxFocusEvent& event); + virtual wxVisualAttributes GetDefaultAttributes() const; + protected: // common part of all ctors void Init(); - virtual void DoSetValue(const wxString& value, int flags = 0); + virtual bool DoLoadFile(const wxString& file, int fileType); + + // creates the control of appropriate class (plain or rich edit) with the + // styles corresponding to m_windowStyle + // + // this is used by ctor/Create() and when we need to recreate the control + // later + bool MSWCreateText(const wxString& value, + const wxPoint& pos, + const wxSize& size); + virtual void DoSetValue(const wxString &value, int flags = 0); - // intercept WM_GETDLGCODE - virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); + // return true if this control has a user-set limit on amount of text (i.e. + // the limit is due to a previous call to SetMaxLength() and not built in) + bool HasSpaceLimit(unsigned int *len) const; // call this to increase the size limit (will do nothing if the current // limit is big enough) @@ -202,13 +240,11 @@ protected: // replace the contents of the selection or of the entire control with the // given text - void DoWriteText(const wxString& text, bool selectionOnly = true); + void DoWriteText(const wxString& text, + int flags = SetValue_SendEvent | SetValue_SelectionOnly); - // set the selection possibly without scrolling the caret into view - void DoSetSelection(long from, long to, bool scrollCaret = true); - - // return true if there is a non empty selection in the control - bool HasSelection() const; + // set the selection (possibly without scrolling the caret into view) + void DoSetSelection(long from, long to, int flags); // get the length of the line containing the character at the given // position @@ -217,12 +253,8 @@ protected: // send TEXT_UPDATED event, return true if it was handled, false otherwise bool SendUpdateEvent(); - // override some base class virtuals - virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg); virtual wxSize DoGetBestSize() const; - virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - #if wxUSE_RICHEDIT // we're using RICHEDIT (and not simple EDIT) control if this field is not // 0, it also gives the version of the RICHEDIT control being used (1, 2 or @@ -230,17 +262,31 @@ protected: int m_verRichEdit; #endif // wxUSE_RICHEDIT - // if true, SendUpdateEvent() will eat the next event (see comments in the - // code as to why this is needed) - bool m_suppressNextUpdate; + // number of EN_UPDATE events sent by Windows when we change the controls + // text ourselves: we want this to be exactly 1 + int m_updatesCount; private: + virtual void EnableTextChangedEvents(bool enable) + { + m_updatesCount = enable ? -1 : -2; + } + + // implement wxTextEntry pure virtual: it implements all the operations for + // the simple EDIT controls + virtual WXHWND GetEditHWND() const { return m_hWnd; } + DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl) wxMenu* m_privateContextMenu; bool m_isNativeCaretShown; + +#if wxUSE_INKEDIT && wxUSE_RICHEDIT + int m_isInkEdit; +#endif + }; #endif diff --git a/src/palmos/bmpbuttn.cpp b/src/palmos/bmpbuttn.cpp index 07523034e4..72b08d0953 100644 --- a/src/palmos/bmpbuttn.cpp +++ b/src/palmos/bmpbuttn.cpp @@ -25,8 +25,6 @@ #include "wx/dcmemory.h" #endif -#include "wx/palmos/private.h" - // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- diff --git a/src/palmos/button.cpp b/src/palmos/button.cpp index 94dae6c81c..93fd0d6690 100644 --- a/src/palmos/button.cpp +++ b/src/palmos/button.cpp @@ -201,7 +201,9 @@ wxWindow *wxButton::SetDefault() FormType* form = (FormType* )GetParentForm(); if(form==NULL) return NULL; +#ifdef __WXPALMOS6__ FrmSetDefaultButtonID(form,GetId()); +#endif // __WXPALMOS6__ return wxButtonBase::SetDefault(); } diff --git a/src/palmos/checkbox.cpp b/src/palmos/checkbox.cpp index 1e1d14d925..8a74d28126 100644 --- a/src/palmos/checkbox.cpp +++ b/src/palmos/checkbox.cpp @@ -108,6 +108,7 @@ bool wxCheckBox::Create(wxWindow *parent, if(!wxControl::Create(parent, id, pos, size, style, validator, name)) return false; + m_state = wxCHK_UNCHECKED; return wxControl::PalmCreateControl(checkboxCtl, label, pos, size); } @@ -136,15 +137,41 @@ bool wxCheckBox::SendClickEvent() void wxCheckBox::Command(wxCommandEvent& event) { + int state = event.GetInt(); + wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED) + || (state == wxCHK_UNDETERMINED), + wxT("event.GetInt() returned an invalid checkbox state") ); + + Set3StateValue((wxCheckBoxState) state); + ProcessCommand(event); } void wxCheckBox::DoSet3StateValue(wxCheckBoxState state) { + Int16 newValue; + ControlType *control = (ControlType *)GetObjectPtr(); + if(NULL == control) { + return; + } + m_state = state; + switch (state) { + case wxCHK_UNCHECKED: + newValue = 0; + break; + case wxCHK_CHECKED: + newValue = 1; + break; + case wxCHK_UNDETERMINED: + default: + return; + break; + } + CtlSetValue (control, newValue); } wxCheckBoxState wxCheckBox::DoGet3StateValue() const { - return (wxCheckBoxState) 0; + return m_state; } #endif // wxUSE_CHECKBOX diff --git a/src/palmos/choice.cpp b/src/palmos/choice.cpp index 7fbc1096f1..36613fe84f 100644 --- a/src/palmos/choice.cpp +++ b/src/palmos/choice.cpp @@ -34,8 +34,6 @@ #include "wx/settings.h" #endif -#include "wx/palmos/private.h" - #if wxUSE_EXTENDED_RTTI WX_DEFINE_FLAGS( wxChoiceStyle ) @@ -132,16 +130,6 @@ bool wxChoice::Create(wxWindow *parent, return false; } -bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg) -{ - return false; -} - -WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const -{ - return 0; -} - wxChoice::~wxChoice() { } @@ -241,14 +229,4 @@ wxSize wxChoice::DoGetBestSize() const return wxSize(0,0); } -WXLRESULT wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) -{ - return 0; -} - -bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) -{ - return false; -} - #endif // wxUSE_CHOICE diff --git a/src/palmos/control.cpp b/src/palmos/control.cpp index 8fc1e73810..39033e863d 100644 --- a/src/palmos/control.cpp +++ b/src/palmos/control.cpp @@ -45,7 +45,11 @@ #include #include -#include +#ifdef __WXPALMOS6__ + #include +#else + #include +#endif // __WXPALMOS6__ // ---------------------------------------------------------------------------- // wxWin macros diff --git a/src/palmos/dialog.cpp b/src/palmos/dialog.cpp index c368c78f56..971d771aae 100644 --- a/src/palmos/dialog.cpp +++ b/src/palmos/dialog.cpp @@ -181,8 +181,7 @@ void wxDialog::Raise() // show dialog modally int wxDialog::ShowModal() { - if (show && CanDoLayoutAdaptation()) - DoLayoutAdaptation(); + Show (true); if (errNone == FrmDoDialog ((FormType *)wxTopLevelWindow::GetForm())) { return 0; diff --git a/src/palmos/dir.cpp b/src/palmos/dir.cpp index 7fa7d61f86..e041f2f001 100644 --- a/src/palmos/dir.cpp +++ b/src/palmos/dir.cpp @@ -32,6 +32,8 @@ #include "wx/dir.h" #include "wx/filefn.h" // for wxDirExists() +#include "pfall.h" + // ---------------------------------------------------------------------------- // define the types and functions used for file searching // ---------------------------------------------------------------------------- @@ -54,10 +56,148 @@ // private classes // ---------------------------------------------------------------------------- +// this class stores everything we need to enumerate the files +class wxDirData +{ +public: + wxDirData(const wxString& dirname); + ~wxDirData(); + + bool IsOk() const { return m_dir != NULL; } + + void SetFileSpec(const wxString& filespec) { m_filespec = filespec; } + void SetFlags(int flags) { m_flags = flags; } + + void Close(); + bool Read(wxString *filename); + + const wxString& GetName() const { return m_dirname; } + +private: + void *m_dir; + + wxString m_dirname; + wxString m_filespec; + + int m_flags; +}; + // ============================================================================ // implementation // ============================================================================ +// ---------------------------------------------------------------------------- +// wxDirData +// ---------------------------------------------------------------------------- + +wxDirData::wxDirData(const wxString& dirname) + : m_dirname(dirname) +{ + m_dir = NULL; + + // throw away the trailing slashes + size_t n = m_dirname.length(); + wxCHECK_RET( n, _T("empty dir name in wxDir") ); + + while ( n > 0 && m_dirname[--n] == '/' ) + ; + + m_dirname.Truncate(n + 1); + + // do open the dir + //m_dir = opendir(m_dirname.fn_str()); +} + +wxDirData::~wxDirData() +{ + Close (); +} + +void wxDirData::Close() +{ + if ( m_dir ) + { + if ( svfs_dir_endfind (m_dir) != 0 ) + { + wxLogLastError(_T("svfs_dir_endfind")); + } + m_dir = NULL; + } +} + +bool wxDirData::Read(wxString *filename) +{ + //dirent *de = (dirent *)NULL; // just to silence compiler warnings + int ret; + char tmpbuf[300]; + bool matches = false; + size_t flags_search; + + // speed up string concatenation in the loop a bit + wxString path = m_dirname; + path += _T('/'); + path.reserve(path.length() + 255); + + wxString de_d_name; + de_d_name.reserve(500); + flags_search = 0; + if (wxDIR_DIRS & m_flags) { + flags_search |= SDIR_DIRS; + } + if (wxDIR_FILES & m_flags) { + flags_search |= SDIR_FILES; + } + if (NULL == m_dir) { +#ifdef _PACC_VER +// walk around the PalmOS pacc compiler bug + ret = svfs_dir_findfirst (m_dirname.fn_str().data(), &m_dir, tmpbuf, sizeof (tmpbuf), flags_search); +#else + ret = svfs_dir_findfirst (m_dirname.fn_str(), &m_dir, tmpbuf, sizeof (tmpbuf), flags_search); +#endif + } else { + ret = svfs_dir_findnext (m_dir, tmpbuf, sizeof (tmpbuf)); + } + for (; ret > 0; ) { + +#if wxUSE_UNICODE + de_d_name = wxString(tmpbuf, *wxConvFileName); +#else + de_d_name = tmpbuf; +#endif + + // don't return "." and ".." unless asked for + if ( tmpbuf[0] == '.' && + ((tmpbuf[1] == '.' && tmpbuf[2] == '\0') || + (tmpbuf[1] == '\0')) ) + { + if ( !(m_flags & wxDIR_DOTDOT) ) + continue; + + // we found a valid match + break; + } + + // check the name + if ( m_filespec.empty() ) + { + matches = m_flags & wxDIR_HIDDEN ? true : tmpbuf[0] != '.'; + } + else + { + // test against the pattern + matches = wxMatchWild(m_filespec, de_d_name, + !(m_flags & wxDIR_HIDDEN)); + } + if (matches) + break; + ret = svfs_dir_findnext (m_dir, tmpbuf, sizeof (tmpbuf)); + } + + *filename = de_d_name; + + return true; +} + // ---------------------------------------------------------------------------- // wxDir helpers // ---------------------------------------------------------------------------- @@ -65,7 +205,7 @@ /* static */ bool wxDir::Exists(const wxString& dir) { - return false; + return wxDirExists(dir); } // ---------------------------------------------------------------------------- @@ -74,27 +214,42 @@ bool wxDir::Exists(const wxString& dir) wxDir::wxDir(const wxString& dirname) { + m_data = NULL; + (void)Open(dirname); } bool wxDir::Open(const wxString& dirname) { - return false; + delete M_DIR; + m_data = new wxDirData(dirname); + + return true; } bool wxDir::IsOpened() const { - return false; + return m_data != NULL; } wxString wxDir::GetName() const { wxString name; + if ( m_data ) + { + name = M_DIR->GetName(); + if ( !name.empty() && (name.Last() == _T('/')) ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } + } return name; } wxDir::~wxDir() { + delete M_DIR; } // ---------------------------------------------------------------------------- @@ -105,11 +260,17 @@ bool wxDir::GetFirst(wxString *filename, const wxString& filespec, int flags) const { - return false; + wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") ); + M_DIR->Close(); + M_DIR->SetFileSpec(filespec); + M_DIR->SetFlags(flags); + return GetNext(filename); } bool wxDir::GetNext(wxString *filename) const { - return false; + wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") ); + wxCHECK_MSG( filename, false, _T("bad pointer in wxDir::GetNext()") ); + return M_DIR->Read(filename); } diff --git a/src/palmos/filedlg.cpp b/src/palmos/filedlg.cpp index 412f8fe98a..d03ec1b742 100644 --- a/src/palmos/filedlg.cpp +++ b/src/palmos/filedlg.cpp @@ -38,8 +38,6 @@ #include "wx/math.h" #endif -#include "wx/palmos/private.h" - #include #include diff --git a/src/palmos/font.cpp b/src/palmos/font.cpp index c2f192cbca..305441e788 100644 --- a/src/palmos/font.cpp +++ b/src/palmos/font.cpp @@ -398,6 +398,15 @@ wxFont::~wxFont() // ---------------------------------------------------------------------------- // real implementation // ---------------------------------------------------------------------------- +wxGDIRefData *wxFont::CreateGDIRefData() const +{ + return new wxFontRefData(); +} + +wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data)); +} bool wxFont::RealizeResource() { @@ -419,10 +428,6 @@ bool wxFont::IsFree() const return false; } -void wxFont::Unshare() -{ -} - // ---------------------------------------------------------------------------- // change font attribute: we recreate font when doing it // ---------------------------------------------------------------------------- @@ -518,6 +523,24 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const return NULL; } +wxString wxFont::GetNativeFontInfoDesc() const +{ + wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") ); + + // be sure we have an HFONT associated... + wxConstCast(this, wxFont)->RealizeResource(); + return wxFontBase::GetNativeFontInfoDesc(); +} + +wxString wxFont::GetNativeFontInfoUserDesc() const +{ + wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") ); + + // be sure we have an HFONT associated... + wxConstCast(this, wxFont)->RealizeResource(); + return wxFontBase::GetNativeFontInfoUserDesc(); +} + bool wxFont::IsFixedWidth() const { return false; diff --git a/src/palmos/help.cpp b/src/palmos/help.cpp index 5fee68e840..6264c29822 100644 --- a/src/palmos/help.cpp +++ b/src/palmos/help.cpp @@ -23,12 +23,6 @@ #include "wx/filefn.h" -#include - -#include "wx/palmos/private.h" - -#include - IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase) diff --git a/src/palmos/imaglist.cpp b/src/palmos/imaglist.cpp index 1616e05e2d..c683b43e81 100644 --- a/src/palmos/imaglist.cpp +++ b/src/palmos/imaglist.cpp @@ -34,9 +34,7 @@ #include "wx/log.h" #endif -#include "wx/palmos/imaglist.h" -#include "wx/palmos/private.h" - +#include "wx/imaglist.h" // ---------------------------------------------------------------------------- // wxWin macros @@ -91,7 +89,7 @@ bool wxImageList::GetSize(int WXUNUSED(index), int &width, int &height) const // ---------------------------------------------------------------------------- int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) - +{ return 0; } diff --git a/src/palmos/main.cpp b/src/palmos/main.cpp index 2c4f957771..4e75c85aff 100644 --- a/src/palmos/main.cpp +++ b/src/palmos/main.cpp @@ -43,18 +43,11 @@ int wxEntry() { - /* There is no command line in PalmOS. For now generate a fake arument + /* There is no command line in PalmOS. For now generate a fake argument * list. Later this may be changed to reflect the application launch code */ - wxArrayString args; - int argc = args.GetCount(); - // +1 here for the terminating NULL + static const int argc = 0; wxChar **argv = new wxChar *[argc + 1]; - for ( int i = 0; i < argc; i++ ) - { - //argv[i] = wxStrdup(args[i]); - argv[i] = wxStrdup(wxConvLibc.cMB2WX(args[i])); - } // argv[] must be NULL-terminated argv[argc] = NULL; diff --git a/src/palmos/menu.cpp b/src/palmos/menu.cpp index 05adc26c67..2725ce1448 100644 --- a/src/palmos/menu.cpp +++ b/src/palmos/menu.cpp @@ -39,7 +39,12 @@ #include "wx/ownerdrw.h" #endif +#ifdef __WXPALMOS6__ #include +#else // __WXPALMOS5__ +#include // MenuRscType +#endif + #include #include @@ -537,12 +542,13 @@ void wxMenuBar::LoadMenu() { int i=0; int j=0; - +#ifdef __WXPALMOS6__ // Handle to the currently running application database DmOpenRef AppDB; // Get app database reference - needed for some Palm OS Menu API calls. SysGetModuleDatabase(SysGetRefNum(), NULL, &AppDB); +#endif // __WXPALMOS6__ // Get the number of menus int NumMenus=GetMenuCount(); @@ -554,24 +560,24 @@ void wxMenuBar::LoadMenu() // Load the menu template and set up the menu pointers if(NumMenus==1) { - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',1000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 1000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=74; + PalmOSMenuBarPtr += 74; } else if(NumMenus==2) { - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',2000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 2000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=116; + PalmOSMenuBarPtr += 116; } else if(NumMenus==3) { - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',3000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 3000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=158; + PalmOSMenuBarPtr += 158; } else { @@ -579,10 +585,10 @@ void wxMenuBar::LoadMenu() // more than we can handle. NumMenus=4; - PalmOSMenuBar=DmGetResource(AppDB,'MBAR',4000); - PalmOSMenuBarPtr=(char *)MemHandleLock(PalmOSMenuBar); + PalmOSMenuBar = POS_DmGetResource (AppDB, MenuRscType, 4000); + PalmOSMenuBarPtr = (char *)MemHandleLock (PalmOSMenuBar); - PalmOSMenuBarPtr+=200; + PalmOSMenuBarPtr += 200; } // Set the proper names for the drop-down triggers. @@ -595,11 +601,11 @@ void wxMenuBar::LoadMenu() wxString MenuTitle=m_titles.Item(i); // Make sure we don't copy more than 8 bytes for the label - int LengthToCopy=MenuTitle.length(); - if(LengthToCopy>8) - LengthToCopy=8; + int LengthToCopy = MenuTitle.length(); + if(LengthToCopy > 8) + LengthToCopy = 8; - MemMove(PalmOSMenuBarPtr,MenuTitle,LengthToCopy); + MemMove(PalmOSMenuBarPtr,(char*)(&MenuTitle),LengthToCopy); PalmOSMenuBarPtr+=11; } @@ -609,7 +615,7 @@ void wxMenuBar::LoadMenu() // We must make the menu active before we can add items to the drop-down // triggers. - FrmSetMenu(FrmGetActiveForm(),AppDB,NumMenus*1000); + POS_FrmSetMenu (FrmGetActiveForm(), AppDB, NumMenus * 1000); /* Add the menu items to the drop-down triggers. This must be done after * setting the triggers, because setting the names of drop-down triggers @@ -637,9 +643,9 @@ void wxMenuBar::LoadMenu() else { if(j==0) - MenuAddItem(9000+i,((i*1000)+1000)+j,0x00,ItemLabel); + MenuAddItem(9000+i,((i*1000)+1000)+j,0x00,(char *)(&ItemLabel)); else - MenuAddItem(((i*1000)+1000)+j-1,((i*1000)+1000)+j,0x00,ItemLabel); + MenuAddItem(((i*1000)+1000)+j-1,((i*1000)+1000)+j,0x00,(char *)(&ItemLabel)); } } diff --git a/src/palmos/msgdlg.cpp b/src/palmos/msgdlg.cpp index bde9907eb2..48445b23c5 100644 --- a/src/palmos/msgdlg.cpp +++ b/src/palmos/msgdlg.cpp @@ -23,7 +23,12 @@ #include "wx/msgdlg.h" #endif +#ifdef __WXPALMOS6__ #include +#else // __WXPALMOS5__ +#include // alertRscType +#endif + #include IMPLEMENT_CLASS(wxMessageDialog, wxDialog) @@ -35,9 +40,11 @@ int wxMessageDialog::ShowModal() int wxResult=wxID_OK; const long style = GetMessageDialogStyle(); +#ifdef __WXPALMOS6__ // Handle to the currently running application database DmOpenRef AppDB; SysGetModuleDatabase(SysGetRefNum(), NULL, &AppDB); +#endif // __WXPALMOS6__ // Translate wx styles into Palm OS styles if (style & wxYES_NO) @@ -71,7 +78,7 @@ int wxMessageDialog::ShowModal() // Get the alert resource char *AlertPtr; MemHandle AlertHandle; - AlertHandle=DmGetResource(AppDB,'Talt',AlertID); + AlertHandle = POS_DmGetResource (AppDB, alertRscType, AlertID); AlertPtr=(char *)MemHandleLock(AlertHandle); AlertPtr+=8; @@ -99,7 +106,7 @@ int wxMessageDialog::ShowModal() DmReleaseResource(AlertHandle); // Display the dialog - Result=FrmCustomAlert(AppDB,AlertID,GetFullMessage().c_str(),"",""); + Result = POS_FrmCustomAlert (AppDB, AlertID, m_message.c_str(), "", ""); // Convert the Palm OS result to wxResult if(AlertID<1100) diff --git a/src/palmos/pen.cpp b/src/palmos/pen.cpp index af9311f7c2..4ed1a1abd1 100644 --- a/src/palmos/pen.cpp +++ b/src/palmos/pen.cpp @@ -80,10 +80,6 @@ bool wxPen::IsFree() const return false; } -void wxPen::Unshare() -{ -} - void wxPen::SetColour(const wxColour& col) { } @@ -115,3 +111,14 @@ void wxPen::SetJoin(int Join) void wxPen::SetCap(int Cap) { } + +wxGDIRefData *wxPen::CreateGDIRefData() const +{ + return new wxPenRefData(); +} + +wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxPenRefData(*wx_static_cast(const wxPenRefData *, data)); +} + diff --git a/src/palmos/progdlg.cpp b/src/palmos/progdlg.cpp index f2432a5450..4b57a09fc0 100644 --- a/src/palmos/progdlg.cpp +++ b/src/palmos/progdlg.cpp @@ -111,7 +111,9 @@ Boolean wxProgressDialog::Callback(void *data) PrgCallbackData *palmData = (PrgCallbackData *)data; strncpy( palmData->textP, m_msg.ToAscii() , palmData->textLen - 1 ); palmData->textChanged = true; +#ifdef __WXPALMOS6__ palmData->displaySkipBtn = m_canSkip; +#endif // __WXPALMOS6__ palmData->barMaxValue = (uint32_t)m_max; palmData->barCurValue = (uint32_t)m_cur; palmData->delay = (m_max == m_cur); diff --git a/src/palmos/slider.cpp b/src/palmos/slider.cpp index 22b64317c5..ed0f238bd9 100644 --- a/src/palmos/slider.cpp +++ b/src/palmos/slider.cpp @@ -135,6 +135,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, AdjustForParentClientOrigin(x, y); +#ifdef __WXPALMOS6__ SliderControlType *slider = CtlNewSliderControl ( (void **)&form, GetId(), @@ -151,6 +152,17 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, 1, value ); +#else // __WXPALMOS5__ + //SliderControlType *CtlNewSliderControl (void **formPP, UInt16 ID, ControlStyleType style, DmResID thumbID, + // DmResID backgroundID, Coord x, Coord y, Coord width, Coord height, UInt16 minValue, UInt16 maxValue, + // UInt16 pageSize, UInt16 value); + SliderControlType *slider = CtlNewSliderControl ((void **)&form, + GetId(), + feedbackSliderCtl,//style + 0,//thumbID + 0,//backgroundid + x, y, w, h, minValue, maxValue, 1, value); +#endif // __WXPALMOS6__/__WXPALMOS5__ if(slider==NULL) return false; diff --git a/src/palmos/statbrpalm.cpp b/src/palmos/statbrpalm.cpp index 679433f1b9..62c8d6615e 100644 --- a/src/palmos/statbrpalm.cpp +++ b/src/palmos/statbrpalm.cpp @@ -28,7 +28,11 @@ #include "wx/log.h" #endif -#include +#ifdef __WXPALMOS6__ + #include +#else + #include +#endif // __WXPALMOS6__ // ---------------------------------------------------------------------------- // macros diff --git a/src/palmos/stdall.c b/src/palmos/stdall.c index c4a0d054b6..3db7e369c6 100644 --- a/src/palmos/stdall.c +++ b/src/palmos/stdall.c @@ -1,15 +1,31 @@ +/****************************************************************************** + * Name: src/palmos/stdall.c + * Purpose: the missing functions of Palm OS for wxPalm + * Author: Yunhui Fu + * Created: 2007-10-18 + * Modified by: + * RCS-ID: $Id$ + * Copyright: (c) 2007 Yunhui Fu + * Licence: wxWindows licence + ******************************************************************************/ #include // Core/System/ #include //Core/System/, DateToAscii() etc. #include //Core/System/, TimGetTicks() #include "wx/defs.h" +#define PALMOS_TRACE(msg) ErrFatalErrorInContext(__FILE__, __LINE__, msg) #if __WXPALMOS6__ + +#ifdef TARGET_PLATFORM +#if TARGET_PLATFORM != TARGET_PLATFORM_PALMSIM_WIN32 void exit (int exitno) { } +#endif +#endif #else @@ -150,7 +166,7 @@ strftime (char *buf, size_t sz_buf, const char *fmt, const struct tm *ptm) if (*p == '\0') { break; } - // FIXME: Åжϻº³åÊÇ·ñÒç³ö + // FIXME: test the overflow of the buffer switch (*p) { case 'a': strcpy (pret, g_strftime_wdayconv[ptm->tm_wday % 7][SFCONV_ABBR]); @@ -336,25 +352,516 @@ wint_t towlower(wint_t C) {return 0;} wint_t towupper(wint_t C) {return 0;} size_t wcsftime(wchar_t *strDest, size_t maxsize, const wchar_t *format, const struct tm *timeptr) {return 0;} -size_t wcslen (const wchar_t * str) {return 0;} -wchar_t * wcscpy (wchar_t * dst, const wchar_t * src) {return NULL;} -wchar_t * wcsncpy (wchar_t * dst, const wchar_t * src, size_t n) {return NULL;} -wchar_t * wcscat (wchar_t * dst, const wchar_t * src) {return NULL;} -wchar_t * wcsncat (wchar_t * dst, const wchar_t * src, size_t n) {return NULL;} -int wcscmp (const wchar_t * str1, const wchar_t * str2) {return 0;} -int wcsncmp (const wchar_t * str1, const wchar_t * str2, size_t n) {return 0;} -wchar_t * wcschr (const wchar_t * str, const wchar_t chr) {return NULL;} -int wcscoll (const wchar_t *str1, const wchar_t * str2) {return 0;} -size_t wcsxfrm (wchar_t * str1, const wchar_t * str2, size_t n) {return 0;} -wchar_t * wcsrchr (const wchar_t * str, wchar_t chr) {return NULL;} -wchar_t * wcspbrk (const wchar_t * str, const wchar_t * set) {return NULL;} -size_t wcsspn (const wchar_t * str, const wchar_t * set) {return 0;} -size_t wcscspn (const wchar_t * str, const wchar_t * set) {return 0;} -wchar_t * wcsstr (const wchar_t * str, const wchar_t * pat) {return NULL;} -wchar_t * wcstok (wchar_t * str, const wchar_t * set, wchar_t ** a) {return NULL;} - -unsigned long wcstoul (const wchar_t * a, wchar_t ** b, int c) {return 0;} -double wcstod (const wchar_t * a, wchar_t ** b) {return 0.0;} - -long wcstol (const wchar_t * str, wchar_t ** end, int base) {return 0;} +size_t +wcslen (const wchar_t * str) +{ + size_t i; + for (i = 0; str[i] != 0; i ++); + return i; +} + +wchar_t * +wcscpy (wchar_t * dst, const wchar_t * src) +{ + size_t len; + len = wcslen (src); + if (len < 1) { + return NULL; + } + memmove (dst, src, len * sizeof (wchar_t)); + dst[len] = 0; + return dst; +} + +wchar_t * +wcsncpy (wchar_t * dst, const wchar_t * src, size_t len_max) +{ + size_t len; + len = wcslen (src); + if (len < 1) { + return NULL; + } + if (len_max < len + 1) { + len = len_max - 1; + } + if (len > 0) { + memmove (dst, src, len * sizeof (wchar_t)); + } + dst[len] = 0; + return dst; +} + +wchar_t * +wcscat (wchar_t * dst, const wchar_t * src) +{ + size_t len_dst; + len_dst = wcslen (dst); + return wcscpy (dst + len_dst, src); +} + +wchar_t * +wcsncat (wchar_t * dst, const wchar_t * src, size_t n) +{ + size_t len_dst; + len_dst = wcslen (dst); + return wcsncpy (dst + len_dst, src, n); +} + +#define SYS_IS_BIGENDIAN 0 + +#if SYS_IS_BIGENDIAN +#define _wcmcmp(a,b,len) memcmp((a),(b),(len) * sizeof (wchar_t)) +#else // SYS_IS_BIGENDIAN +int +_wcmcmp (const wchar_t * str1, const wchar_t * str2, size_t len) +{ + size_t i; + for (i = 0; i < len; i ++) { + if (str1[i] == str2[i]) { + continue; + } else if (str1[i] < str2[i]) { + return -1; + } + return 1; + } + return 0; +} +#endif // SYS_IS_BIGENDIAN + +int +wcscmp (const wchar_t * str1, const wchar_t * str2) +{ + int ret; + size_t len; + size_t len1; + size_t len2; + len1 = wcslen (str1); + len2 = wcslen (str2); + len = len1; + if (len > len2) { + len = len2; + } + ret = _wcmcmp (str1, str2, len); + if (0 == ret) { + if (len1 > len2) { + return -1; + } else if (len1 == len2) { + return 0; + } + return 1; + } + return ret; +} + +int +wcsncmp (const wchar_t * str1, const wchar_t * str2, size_t n) +{ + int ret; + size_t len; + size_t len1; + size_t len2; + len1 = wcslen (str1); + len2 = wcslen (str2); + len = len1; + if (len > len2) { + len = len2; + } + if (len > n) { + len = n; + } + ret = _wcmcmp (str1, str2, len); + if (0 == ret) { + if (len >= n) { + return 0; + } + if (len1 > len2) { + return -1; + } else if (len1 == len2) { + return 0; + } + return 1; + } + return ret; +} + +wchar_t * +wcschr (const wchar_t * str, const wchar_t chr) +{ + wchar_t * str2 = (wchar_t *)str; + size_t i; + size_t len; + len = wcslen (str2); + for (i = 0; i < len; i ++) { + if (str2[i] == chr) { + str2 += i; + return str2; + } + } + return NULL; +} + +int wcscoll (const wchar_t *str1, const wchar_t * str2) {return wcscmp(str1, str2);} + +//wcsxfrm: ¸ù¾Ýָ֨µĵØÓòÉèÖã̰Ñ×ַûԮstrSourceÖÐָ֨ÊýÁߵĿí×ַûתۻΪ +// ×ַûԮstrDest ,Èô³ɹ¦Ôò·µ»Ø±Â»×ªÛ»Ã—ַûµijĶȣ̷ñÔò·µ»Ã˜-1 +// ºÍstrxfrmگÊýÀàËÆ +size_t +wcsxfrm (wchar_t * str1, const wchar_t * str2, size_t n) +{ + wcsncpy (str1, str2, n); + return wcslen (str1); +} + +wchar_t * +wcsrchr (const wchar_t * str, wchar_t chr) +{ + wchar_t * str2 = (wchar_t *)str; + ssize_t i; + i = wcslen (str2); + for (; i >= 0; i ++) { + if (str2[i] == chr) { + str2 += i; + return str2; + } + } + return NULL; +} + +wchar_t * +wcspbrk (const wchar_t * str, const wchar_t * set) +{ + wchar_t * str2 = (wchar_t *)str; + size_t i; + size_t j; + size_t len; + size_t len_set; + len = wcslen (str2); + len_set = wcslen (set); + for (i = 0; i < len; i ++) { + for (j = 0; j < len_set; j ++) { + if (str2[i] == set[j]) { + str2 += i; + return str2; + } + } + } + return NULL; +} + +// ²éÕÒÔڼϺÏsetËùָ֨µÄÄÇЩ×ַûÔÚstrµĿªʼԦ³öÏֵÄ×î´ó¸öÊý +// Èçstr="13134abcde", set="1234567890", wcsspn(str,set)==5 +// Èçstr="abcde", set="1234567890", wcsspn(str,set)==0 +size_t +wcsspn (const wchar_t * str, const wchar_t * set) +{ + size_t i; + size_t j; + size_t len; + size_t len_set; + len = wcslen (str); + len_set = wcslen (set); + for (i = 0; i < len; i ++) { + for (j = 0; j < len_set; j ++) { + if (str[i] == set[j]) { + break; + } + } + if (j >= len_set) { + return i; + } + } + return i; +} + +// ²éÕÒÔڼϺÏsetËùָ֨µÄÄÇЩ×ַûÔÚstrµĿªʼԦһ³öÏֵÄ×î´ó¸öÊý +// Èçstr="13134abcde", set="1234567890", wcsspn(str,set)==0 +// Èçstr="abcde123", set="1234567890", wcsspn(str,set)==5 +size_t +wcscspn (const wchar_t * str, const wchar_t * set) +{ + size_t i; + size_t j; + size_t len; + size_t len_set; + len = wcslen (str); + len_set = wcslen (set); + for (i = 0; i < len; i ++) { + for (j = 0; j < len_set; j ++) { + if (str[i] == set[j]) { + break; + } + } + if (j < len_set) { + return i; + } + } + return i; +} + +wchar_t * +wcsstr (const wchar_t * str, const wchar_t * pat) +{ + // TODO: improvement the alg for search + wchar_t *p; + p = wcschr (str, pat[0]); + for (; NULL != p;) { + if (0 == wcscmp (p, pat)) { + return p; + } + p = wcschr (p, pat[0]); + } + return NULL; +} + +wchar_t * +wcstok (wchar_t * str, const wchar_t * set, wchar_t ** a) +{ + wchar_t * p; + if (NULL == str) { + if (NULL == a) { + return NULL; + } + str = *a; + } + if (NULL == str) { + return NULL; + } + p = wcspbrk (str, set); + if (NULL == p) { + return NULL; + } + *p = 0; + *a = p; + return str; +} + +#define iswblank iswspace +//#define ULONG_MAX INT_MAX +unsigned long +wcstoul (const wchar_t *nptr, wchar_t **endptr, int base) +{ + int flg_overflow; + //int val_remain; + unsigned long val_ch; + unsigned long val_old; + unsigned long val; + /* check the base */ + if ((1 == base) || (base > 36) || (base < 0)) { + // error + return 0; + } + // skip blank + while (iswblank (*nptr)) {nptr ++;} + if (0 == *nptr) { + return 0; + } + if (0 == base) { + // auto detect + switch (*nptr) { + case '0': + if (('x' == *(nptr + 1)) || ('X' == *(nptr + 1))) { + base = 16; + nptr += 2; + } else { + nptr += 1; + base = 8; + } + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + base = 10; + break; + } + } else { + if (16 == base) { + // detect if it has '0x' or '0X' + if (('0' == *nptr) && (('x' == *(nptr + 1)) || ('x' == *(nptr + 1)))) { + nptr += 2; + } + } + } + if (0 == base) { + // error + return 0; + } + val = 0; + val_old = 0; + flg_overflow = 0; + //val_remain = ULONG_MAX % base; + for (; '\0' != *nptr; nptr ++) { + val_ch = *nptr; + if (('0' <= val_ch) && (val_ch <= '9')) { + val_ch -= '0'; + } else if (('a' <= val_ch) && (val_ch <= 'z')) { + val_ch = val_ch - 'a' + 10; + } else if (('A' <= val_ch) && (val_ch <= 'Z')) { + val_ch = val_ch - 'A' + 10; + } else { + // val_ch = base + 1; + break; + } + if (val_ch >= base) { + break; + } + if (flg_overflow) continue; + val_old = val; + val *= base; + val += val_ch; + if (val_old > val) { + flg_overflow = 1; + } + } + if (flg_overflow) { + val = ULONG_MAX; + } + if (0L != endptr) { + *endptr = (wchar_t *)nptr; + } + return val; +} + +long +wcstol (const wchar_t * str, wchar_t ** end, int base) +{ + int sign = 0; + unsigned long val0; + long val; + wchar_t ch; + // skip blank + for (; iswblank (*str); str ++) { + } + for (ch = *str; (ch == '-') || (ch == '+'); str ++) { + } + // the sign + if ('-' == ch) { + sign = 1; + str ++; + } + val0 = wcstoul (str, end, base); + if (val0 >= LONG_MAX) { + // overflow + val = LONG_MAX; + if (sign) { + val = LONG_MIN; + } + } else { + val = val0; + if (sign) { + val = -val0; + } + } + return val; +} + +double +wcstod (const wchar_t * str, wchar_t ** end) +{ + double val; + double mantissa; + unsigned long divisor; + unsigned long power; + int sign; + int sign_power; + wchar_t *pend; + wchar_t ch; + // skip blank + for (; iswblank (*str); str ++) { + } + for (ch = *str; (ch == '-') || (ch == '+'); str ++) { + } + // the sign + sign = 0; + if ('-' == ch) { + sign = 1; + str ++; + } + // skip leading zero + for (; '0' == (*str); str ++) { + } + val = 0.0; + mantissa = 0.0; + divisor = 0; + power = 0.0; + // integer part + for (ch = *str; ('0' <= ch) && (ch <= '9'); str ++) { + ch -= '0'; + val *= 10; + val += ch; + } + // floating point & mantissa + if ('.' == *str) { + str ++; + for (ch = *str; ('0' <= ch) && (ch <= '9'); str ++) { + ch -= '0'; + mantissa *= 10.0; + mantissa += ch; + divisor ++; + } + } + for (; divisor > 0; divisor --) { + mantissa /= 10.0; + } + val += mantissa; + sign_power = 0; + if (('e' == *str) || ('E' == *str)) { + str ++; + if ('-' == ch) { + sign_power = 1; + str ++; + } + pend = NULL; + power = wcstoul (str, &pend, 10); + if (NULL != pend) { + str = pend; + } + } + if (power > 0) { + if (sign_power) { + for (; power > 0; power --) { + val /= 10.0; + } + } else { + for (; power > 0; power --) { + val *= 10.0; + } + } + } + if (sign) { + val = - val; + } + if (end) { + *end = (wchar_t *)str; + } + return val; +} + char * setlocale (int category, const char *locale) {return NULL;} + +int +eof (int fd) +{ + return 0; +} + +int +remove (const char *fn) +{ + return svfs_filedelete (fn); +} + +// access(): check access permissions of a file or pathname +// R_OK: read permission +// W_OK: write permission +// X_OK: execute/search permission +// F_OK: existence test +//All components of the pathname path are checked for access permissions (including F_OK) +int access(const char *path, int amode) {return amode;} + +off_t lseek(int fildes, off_t offset, int whence) {return 0;} diff --git a/src/palmos/textctrl.cpp b/src/palmos/textctrl.cpp index e925b130c6..febb66a683 100644 --- a/src/palmos/textctrl.cpp +++ b/src/palmos/textctrl.cpp @@ -45,9 +45,6 @@ #include "wx/textfile.h" -#include "wx/palmos/private.h" -#include "wx/palmos/winundef.h" - #include #if wxUSE_RICHEDIT @@ -213,11 +210,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, return false; } -WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const -{ - return 0; -} - // ---------------------------------------------------------------------------- // set/get the controls text // ---------------------------------------------------------------------------- @@ -225,7 +217,12 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const wxString wxTextCtrl::GetValue() const { wxString res; + return res; +} +wxString wxTextCtrl::GetRange(long from, long to) const +{ + wxString res; return res; } @@ -237,7 +234,7 @@ void wxTextCtrl::WriteText(const wxString& value) { } -void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly) +void wxTextCtrl::DoWriteText(const wxString& text, int flags) { } @@ -265,11 +262,6 @@ void wxTextCtrl::Paste() { } -bool wxTextCtrl::HasSelection() const -{ - return false; -} - bool wxTextCtrl::CanCopy() const { return false; @@ -330,7 +322,7 @@ void wxTextCtrl::SetSelection(long from, long to) { } -void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret) +void wxTextCtrl::DoSetSelection(long from, long to, int flags) { } @@ -388,7 +380,7 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const } wxTextCtrlHitTestResult -wxTextCtrl::HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const +wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const { return wxTE_HT_UNKNOWN; } @@ -436,10 +428,12 @@ void wxTextCtrl::Redo() bool wxTextCtrl::CanUndo() const { + return false; } bool wxTextCtrl::CanRedo() const { + return false; } // ---------------------------------------------------------------------------- @@ -467,20 +461,10 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) // kbd input processing // ---------------------------------------------------------------------------- -bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* pMsg) -{ - return false; -} - void wxTextCtrl::OnChar(wxKeyEvent& event) { } -WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) -{ - return 0; -} - // ---------------------------------------------------------------------------- // text control event processing // ---------------------------------------------------------------------------- @@ -490,21 +474,11 @@ bool wxTextCtrl::SendUpdateEvent() return false; } -bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) -{ - return false; -} - bool wxTextCtrl::AdjustSpaceLimit() { return false; } -bool wxTextCtrl::AcceptsFocus() const -{ - return false; -} - wxSize wxTextCtrl::DoGetBestSize() const { return wxSize(0,0); @@ -570,11 +544,39 @@ void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event) { } -void wxTextCtrl::OnRightClick(wxMouseEvent& event) +void wxTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event)) { } -void wxTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event)) +wxVisualAttributes wxTextCtrl::GetDefaultAttributes() const +{ + wxVisualAttributes attrs; + attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); //white + return attrs; +} + +bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& rEvent) +{ + return false; +} +bool wxTextCtrl::CanApplyThemeBorder() const +{ + return false; +} +bool wxTextCtrl::IsEmpty() const +{ + return false; +} +bool wxTextCtrl::AcceptsFocusFromKeyboard() const +{ + return false; +} +void wxTextCtrl::AdoptAttributesFromHWND() +{ +} +void wxTextCtrl::SetWindowStyleFlag(long lStyle) { } @@ -605,43 +607,43 @@ bool wxTextCtrl::SetForegroundColour(const wxColour& colour) } // ---------------------------------------------------------------------------- -// styling support for rich edit controls +// wxRichEditModule // ---------------------------------------------------------------------------- -#if wxUSE_RICHEDIT - -bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) +bool wxRichEditModule::OnInit() { return false; } -bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style) +void wxRichEditModule::OnExit() { - return false; } -bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) +/* static */ +bool wxRichEditModule::Load(int version) { return false; } -#endif +#endif // wxUSE_RICHEDIT // ---------------------------------------------------------------------------- -// wxRichEditModule +// styling support for rich edit controls // ---------------------------------------------------------------------------- -bool wxRichEditModule::OnInit() +#if wxUSE_RICHEDIT + +bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) { return false; } -void wxRichEditModule::OnExit() +bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style) { + return false; } -/* static */ -bool wxRichEditModule::Load(int version) +bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) { return false; } diff --git a/src/palmos/timer.cpp b/src/palmos/timer.cpp index 8b7241b828..37ec7bd3d9 100644 --- a/src/palmos/timer.cpp +++ b/src/palmos/timer.cpp @@ -30,12 +30,6 @@ #include "wx/hashmap.h" #endif -#include "wx/palmos/private.h" - -// from utils.cpp -extern "C" WXDLLIMPEXP_BASE HWND -wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc); - // ---------------------------------------------------------------------------- // private globals // ---------------------------------------------------------------------------- @@ -51,8 +45,6 @@ static wxTimerMap g_timerMap; // private functions // ---------------------------------------------------------------------------- -void WINAPI wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD); - // ============================================================================ // implementation // ============================================================================ @@ -86,8 +78,4 @@ void wxProcessTimer(wxPalmOSTimerImpl& timer) { } -void WINAPI wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD) -{ -} - #endif // wxUSE_TIMER diff --git a/src/palmos/toplevel.cpp b/src/palmos/toplevel.cpp index 2863573c9e..643d0dcc55 100644 --- a/src/palmos/toplevel.cpp +++ b/src/palmos/toplevel.cpp @@ -92,18 +92,21 @@ bool wxTopLevelWindowPalm::Create(wxWindow *parent, const wxString& name) { // this is a check for limitation mentioned before FrameFormHandleEvent() code - if(wxTopLevelWindows.GetCount()>0) + if(wxTopLevelWindows.GetCount() > 0) { return false; + } ActiveParentFrame=NULL; wxTopLevelWindows.Append(this); - if ( parent ) + if ( parent ) { parent->AddChild(this); + } SetId( id == wxID_ANY ? NewControlId() : id ); +#ifdef __WXPALMOS6__ WinConstraintsType constraints; memset(&constraints, 0, sizeof(WinConstraintsType)); // position @@ -116,7 +119,6 @@ bool wxTopLevelWindowPalm::Create(wxWindow *parent, constraints.y_min = winUndefConstraint; constraints.y_max = winMaxConstraint; constraints.y_pref = ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y; - FrameForm = FrmNewFormWithConstraints( GetId(), title.c_str(), @@ -128,11 +130,22 @@ bool wxTopLevelWindowPalm::Create(wxWindow *parent, NULL, 0 ); - - if(FrameForm==NULL) +#else // __WXPALMOS5__ +#define winUndefConstraint 0xFFFF +#define winMaxConstraint 288 + // FormType *FrmNewForm (UInt16 formID, const Char *titleStrP, Coord x, Coord y, Coord width, Coord height, + // Boolean modal, UInt16 defaultButton, UInt16 helpRscID, UInt16 menuRscID); + FrameForm = FrmNewForm (GetId(), title.c_str(), + (( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x), + (( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y), + winMaxConstraint, winMaxConstraint, + false, 0, 0, 0); +#endif + if(NULL == FrameForm) { return false; + } - FrmSetEventHandler((FormType *)FrameForm,FrameFormHandleEvent); + FrmSetEventHandler((FormType *)FrameForm, FrameFormHandleEvent); FrmSetActiveForm((FormType *)FrameForm); @@ -168,7 +181,7 @@ void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd) bool wxTopLevelWindowPalm::Show(bool show) { if (true != show) { - return true; + return true; } FrmDrawForm((FormType *)FrameForm); @@ -328,12 +341,17 @@ bool wxTopLevelWindowPalm::HandleControlRepeat(WXEVENTPTR event) bool wxTopLevelWindowPalm::HandleSize(WXEVENTPTR event) { +#ifdef __WXPALMOS6__ const EventType *palmEvent = (EventType *)event; wxSize newSize(palmEvent->data.winResized.newBounds.extent.x, palmEvent->data.winResized.newBounds.extent.y); wxSizeEvent eventWx(newSize,GetId()); eventWx.SetEventObject(this); return HandleWindowEvent(eventWx); +#else // __WXPALMOS5__ + return false; +#endif + } void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event) @@ -369,9 +387,11 @@ static Boolean FrameFormHandleEvent(EventType *event) case ctlRepeatEvent: handled = tlw->HandleControlRepeat(event); break; +#ifdef __WXPALMOS6__ case winResizedEvent: handled = tlw->HandleSize(event); break; +#endif // __WXPALMOS6__ #if wxUSE_MENUS_NATIVE case menuOpenEvent: handled = frame->HandleMenuOpen(); diff --git a/src/palmos/treectrl.cpp b/src/palmos/treectrl.cpp index 821620c2ae..bf2efa8613 100644 --- a/src/palmos/treectrl.cpp +++ b/src/palmos/treectrl.cpp @@ -35,8 +35,6 @@ #include "wx/settings.h" #endif -#include "wx/palmos/private.h" - #include "wx/imaglist.h" // macros to hide the cast ugliness @@ -286,7 +284,7 @@ bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const { - return wxString; + return wxString(wxT("")); } void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) @@ -421,11 +419,7 @@ bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const wxTreeItemId wxTreeCtrl::GetRootItem() const { - // Root may be real (visible) or virtual (hidden). - if ( GET_VIRTUAL_ROOT() ) - return TVI_ROOT; - - return wxTreeItemId(TreeView_GetRoot(GetHwnd())); + return wxTreeItemId(); } wxTreeItemId wxTreeCtrl::GetSelection() const @@ -554,7 +548,6 @@ wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, void wxTreeCtrl::Delete(const wxTreeItemId& item) { - return 0; } // delete all children (but don't delete the item itself) @@ -650,6 +643,7 @@ bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item, // sorting stuff // ---------------------------------------------------------------------------- +/* // this is just a tiny namespace which is friend to wxTreeCtrl and so can use // functions such as IsDataIndirect() class wxTreeSortHelper @@ -658,15 +652,9 @@ public: static int CALLBACK Compare(LPARAM data1, LPARAM data2, LPARAM tree); private: - static wxTreeItemId GetIdFromData(wxTreeCtrl *tree, LPARAM item) + static wxTreeItemId GetIdFromData(LPARAM lParam) { - wxTreeItemData *data = (wxTreeItemData *)item; - if ( tree->IsDataIndirect(data) ) - { - data = ((wxTreeItemIndirectData *)data)->GetData(); - } - - return data->GetId(); + return ((wxTreeItemParam*)lParam)->GetItem(); } }; @@ -682,7 +670,7 @@ int CALLBACK wxTreeSortHelper::Compare(LPARAM pItem1, return tree->OnCompareItems(GetIdFromData(tree, pItem1), GetIdFromData(tree, pItem2)); } - +*/ int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2) { @@ -693,21 +681,6 @@ void wxTreeCtrl::SortChildren(const wxTreeItemId& item) { wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); - // rely on the fact that TreeView_SortChildren does the same thing as our - // default behaviour, i.e. sorts items alphabetically and so call it - // directly if we're not in derived class (much more efficient!) - if ( GetClassInfo() == CLASSINFO(wxTreeCtrl) ) - { - TreeView_SortChildren(GetHwnd(), HITEM(item), 0); - } - else - { - TV_SORTCB tvSort; - tvSort.hParent = HITEM(item); - tvSort.lpfnCompare = wxTreeSortHelper::Compare; - tvSort.lParam = (LPARAM)this; - TreeView_SortChildrenCB(GetHwnd(), &tvSort, 0 /* reserved */); - } } // ---------------------------------------------------------------------------- diff --git a/src/palmos/utils.cpp b/src/palmos/utils.cpp index f63cfb67ee..3af6a90c6b 100644 --- a/src/palmos/utils.cpp +++ b/src/palmos/utils.cpp @@ -37,11 +37,18 @@ #include "wx/confbase.h" #include "wx/power.h" +#include #include #include #include +#include // SysDoze()... #include +#ifdef defined (__WXPALMOS6__) +extern void SysReset (void); +extern UInt32 SysTaskID (void); +#endif + // ============================================================================ // implementation // ============================================================================ @@ -100,12 +107,15 @@ bool wxGetUserName(wxChar *buf, int maxSize) const wxChar* wxGetHomeDir(wxString *pstr) { - return NULL; + if (NULL != pstr) { + *pstr = "/palmos"; + } + return wxT("/palmos"); } wxString wxGetUserHome(const wxString& WXUNUSED(user)) { - return wxString(); + return wxString("/palmos"); } bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree) @@ -152,6 +162,24 @@ bool wxShell(const wxString& command) // Shutdown or reboot the PC bool wxShutdown(wxShutdownFlags wFlags) { + switch (wFlags) { + case wxSHUTDOWN_POWEROFF: + // TODO: turn off lamps +#ifdef defined (__WXPALMOS6__) + //extern void SysReset (void); + //extern UInt32 SysTaskID (void); + #define SysReset() + #define SysTaskID() (0) + SysSleep (); +#else + //SysSleep (false, false);// undocument API + SysDoze (true); +#endif + break; + case wxSHUTDOWN_REBOOT: + SysReset (); + break; + } return false; } @@ -161,13 +189,25 @@ bool wxShutdown(wxShutdownFlags wFlags) wxPowerType wxGetPowerType() { + //SysBatteryKind kind; + //POS_SysBatteryInfo (false, NULL, NULL, NULL, NULL, NULL, &kind, NULL); + //return wxPOWER_SOCKET; return wxPOWER_BATTERY; } wxBatteryState wxGetBatteryState() { - // TODO - return wxBATTERY_UNKNOWN_STATE; + //#include "SystemMgr.h" + UInt8 percent; + POS_SysBatteryInfo (false, NULL, NULL, NULL, NULL, NULL, NULL, &percent); + if (percent < 3) + return wxBATTERY_SHUTDOWN_STATE; + else if (percent < 5) + return wxBATTERY_CRITICAL_STATE; + else if (percent < 15) + return wxBATTERY_LOW_STATE; + //return wxBATTERY_UNKNOWN_STATE; + return wxBATTERY_NORMAL_STATE; } // ---------------------------------------------------------------------------- @@ -182,7 +222,7 @@ wxMemorySize wxGetFreeMemory() uint32_t freeChunk; // executed twice: for the dynamic heap, and for the non-secure RAM storage heap - for ( uint16_t i=0; i= 0x02000000) v20 = true; char *version = SysGetOSVersionString(); if(version) { @@ -230,8 +272,7 @@ wxString wxGetOsDescription() wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) { // TODO - - return wxOS_UNKNOWN; + return wxOS_PALM_OS; } // ---------------------------------------------------------------------------- @@ -240,14 +281,35 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) void wxMilliSleep(unsigned long milliseconds) { + UInt16 ticks_sec; + Int32 delay; + ticks_sec = SysTicksPerSecond (); + delay = milliseconds * ticks_sec / 1000; + if (delay > 0) { + SysTaskDelay (delay); + } } void wxMicroSleep(unsigned long microseconds) { + UInt16 ticks_sec; + Int32 delay; + ticks_sec = SysTicksPerSecond (); + delay = microseconds * ticks_sec / 1000000; + if (delay > 0) { + SysTaskDelay (delay); + } } void wxSleep(int nSecs) { + UInt16 ticks_sec; + Int32 delay; + ticks_sec = SysTicksPerSecond (); + delay = nSecs * ticks_sec; + if (delay > 0) { + SysTaskDelay (delay); + } } // ---------------------------------------------------------------------------- diff --git a/src/palmos/volume.cpp b/src/palmos/volume.cpp index 69137b60ef..ed18fd3840 100644 --- a/src/palmos/volume.cpp +++ b/src/palmos/volume.cpp @@ -37,7 +37,11 @@ #endif // WX_PRECOMP #include +#ifdef __WXPALMOS6__ #include +#else +#include +#endif #if wxUSE_BASE diff --git a/src/palmos/window.cpp b/src/palmos/window.cpp index 9dd143a633..1298d9a5b1 100644 --- a/src/palmos/window.cpp +++ b/src/palmos/window.cpp @@ -437,6 +437,7 @@ void wxWindowPalm::Refresh(bool eraseBack, const wxRect *rect) WinHandle handle = (WinHandle)GetHWND(); if(handle) { +#ifdef __WXPALMOS6__ if(rect) { RectangleType dirtyRect; @@ -450,6 +451,10 @@ void wxWindowPalm::Refresh(bool eraseBack, const wxRect *rect) { WinInvalidateWindow(handle); } +#else // __WXPALMOS5__ + WinSetActiveWindow (handle); +#endif + } } -- 2.45.2