// 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
#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
// ----------------------------------------------------------------------------
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckBox)
+ // current state of the checkbox
+ wxCheckBoxState m_state;
};
#endif
* 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
#define wxUSE_DATAOBJ 0
#undef wxUSE_DIRDLG
-#define wxUSE_DIRDLG 0
+#define wxUSE_DIRDLG 1
#undef wxUSE_DISPLAY
#define wxUSE_DISPLAY 0
#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
#undef wxUSE_TOOLBOOK
#define wxUSE_TOOLBOOK 0
+#undef wxUSE_SELECT_DISPATCHER
+#define wxUSE_SELECT_DISPATCHER 1
+
#endif
/* _WX_PALMOS_CHKCONF_H_ */
// 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
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);
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)
// 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
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;
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)
// 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
// 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;
};
// 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
* 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
// 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
// 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.
// 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
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)
#ifndef _WX_TIMER_H_
#define _WX_TIMER_H_
-#include "wx/private/timerimpl.h"
+#include "wx/private/timer.h"
class WXDLLEXPORT wxPalmOSTimerImpl : public wxTimerImpl
{
// 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
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
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; }
// 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);
// 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)
// 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
// 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
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
#include "wx/dcmemory.h"
#endif
-#include "wx/palmos/private.h"
-
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
FormType* form = (FormType* )GetParentForm();
if(form==NULL)
return NULL;
+#ifdef __WXPALMOS6__
FrmSetDefaultButtonID(form,GetId());
+#endif // __WXPALMOS6__
return wxButtonBase::SetDefault();
}
if(!wxControl::Create(parent, id, pos, size, style, validator, name))
return false;
+ m_state = wxCHK_UNCHECKED;
return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
}
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
#include "wx/settings.h"
#endif
-#include "wx/palmos/private.h"
-
#if wxUSE_EXTENDED_RTTI
WX_DEFINE_FLAGS( wxChoiceStyle )
return false;
}
-bool wxChoice::MSWShouldPreProcessMessage(WXMSG *pMsg)
-{
- return false;
-}
-
-WXDWORD wxChoice::MSWGetStyle(long style, WXDWORD *exstyle) const
-{
- return 0;
-}
-
wxChoice::~wxChoice()
{
}
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
#include <Control.h>
#include <Form.h>
-#include <StatusBar.h>
+#ifdef __WXPALMOS6__
+ #include <StatusBar.h>
+#else
+ #include <PenInputMgr.h>
+#endif // __WXPALMOS6__
// ----------------------------------------------------------------------------
// wxWin macros
// show dialog modally
int wxDialog::ShowModal()
{
- if (show && CanDoLayoutAdaptation())
- DoLayoutAdaptation();
+ Show (true);
if (errNone == FrmDoDialog ((FormType *)wxTopLevelWindow::GetForm())) {
return 0;
#include "wx/dir.h"
#include "wx/filefn.h" // for wxDirExists()
+#include "pfall.h"
+
// ----------------------------------------------------------------------------
// define the types and functions used for file searching
// ----------------------------------------------------------------------------
// 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
// ----------------------------------------------------------------------------
/* static */
bool wxDir::Exists(const wxString& dir)
{
- return false;
+ return wxDirExists(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;
}
// ----------------------------------------------------------------------------
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);
}
#include "wx/math.h"
#endif
-#include "wx/palmos/private.h"
-
#include <stdlib.h>
#include <string.h>
// ----------------------------------------------------------------------------
// 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()
{
return false;
}
-void wxFont::Unshare()
-{
-}
-
// ----------------------------------------------------------------------------
// change font attribute: we recreate font when doing it
// ----------------------------------------------------------------------------
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;
#include "wx/filefn.h"
-#include <time.h>
-
-#include "wx/palmos/private.h"
-
-#include <string.h>
-
IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
#include "wx/log.h"
#endif
-#include "wx/palmos/imaglist.h"
-#include "wx/palmos/private.h"
-
+#include "wx/imaglist.h"
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask)
-
+{
return 0;
}
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;
#include "wx/ownerdrw.h"
#endif
+#ifdef __WXPALMOS6__
#include <Loader.h>
+#else // __WXPALMOS5__
+#include <UIResources.h> // MenuRscType
+#endif
+
#include <Form.h>
#include <Menu.h>
{
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();
// 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
{
// 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.
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;
}
// 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
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));
}
}
#include "wx/msgdlg.h"
#endif
+#ifdef __WXPALMOS6__
#include <Loader.h>
+#else // __WXPALMOS5__
+#include <UIResources.h> // alertRscType
+#endif
+
#include <Form.h>
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
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)
// 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;
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)
return false;
}
-void wxPen::Unshare()
-{
-}
-
void wxPen::SetColour(const wxColour& col)
{
}
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));
+}
+
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);
AdjustForParentClientOrigin(x, y);
+#ifdef __WXPALMOS6__
SliderControlType *slider = CtlNewSliderControl (
(void **)&form,
GetId(),
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;
#include "wx/log.h"
#endif
-#include <StatusBar.h>
+#ifdef __WXPALMOS6__
+ #include <StatusBar.h>
+#else
+ #include <PenInputMgr.h>
+#endif // __WXPALMOS6__
// ----------------------------------------------------------------------------
// macros
+/******************************************************************************
+ * 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 <Preferences.h> // Core/System/
#include <DateTime.h> //Core/System/, DateToAscii() etc.
#include <TimeMgr.h> //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
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]);
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;}
#include "wx/textfile.h"
-#include "wx/palmos/private.h"
-#include "wx/palmos/winundef.h"
-
#include <string.h>
#if wxUSE_RICHEDIT
return false;
}
-WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
-{
- return 0;
-}
-
// ----------------------------------------------------------------------------
// set/get the controls text
// ----------------------------------------------------------------------------
wxString wxTextCtrl::GetValue() const
{
wxString res;
+ return res;
+}
+wxString wxTextCtrl::GetRange(long from, long to) const
+{
+ wxString res;
return res;
}
{
}
-void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly)
+void wxTextCtrl::DoWriteText(const wxString& text, int flags)
{
}
{
}
-bool wxTextCtrl::HasSelection() const
-{
- return false;
-}
-
bool wxTextCtrl::CanCopy() const
{
return false;
{
}
-void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret)
+void wxTextCtrl::DoSetSelection(long from, long to, int flags)
{
}
}
wxTextCtrlHitTestResult
-wxTextCtrl::HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const
+wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const
{
return wxTE_HT_UNKNOWN;
}
bool wxTextCtrl::CanUndo() const
{
+ return false;
}
bool wxTextCtrl::CanRedo() const
{
+ return false;
}
// ----------------------------------------------------------------------------
// 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
// ----------------------------------------------------------------------------
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);
{
}
-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)
{
}
}
// ----------------------------------------------------------------------------
-// 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;
}
#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
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
-void WINAPI wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
-
// ============================================================================
// implementation
// ============================================================================
{
}
-void WINAPI wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD)
-{
-}
-
#endif // wxUSE_TIMER
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
constraints.y_min = winUndefConstraint;
constraints.y_max = winMaxConstraint;
constraints.y_pref = ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y;
-
FrameForm = FrmNewFormWithConstraints(
GetId(),
title.c_str(),
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);
bool wxTopLevelWindowPalm::Show(bool show)
{
if (true != show) {
- return true;
+ return true;
}
FrmDrawForm((FormType *)FrameForm);
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)
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();
#include "wx/settings.h"
#endif
-#include "wx/palmos/private.h"
-
#include "wx/imaglist.h"
// macros to hide the cast ugliness
wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const
{
- return wxString;
+ return wxString(wxT(""));
}
void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text)
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
void wxTreeCtrl::Delete(const wxTreeItemId& item)
{
- return 0;
}
// delete all children (but don't delete the item itself)
// sorting stuff
// ----------------------------------------------------------------------------
+/*
// this is just a tiny namespace which is friend to wxTreeCtrl and so can use
// functions such as IsDataIndirect()
class wxTreeSortHelper
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();
}
};
return tree->OnCompareItems(GetIdFromData(tree, pItem1),
GetIdFromData(tree, pItem2));
}
-
+*/
int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
const wxTreeItemId& item2)
{
{
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 */);
- }
}
// ----------------------------------------------------------------------------
#include "wx/confbase.h"
#include "wx/power.h"
+#include <PalmTypes.h>
#include <MemoryMgr.h>
#include <DLServer.h>
#include <SoundMgr.h>
+#include <SystemMgr.h> // SysDoze()...
#include <SysUtils.h>
+#ifdef defined (__WXPALMOS6__)
+extern void SysReset (void);
+extern UInt32 SysTaskID (void);
+#endif
+
// ============================================================================
// implementation
// ============================================================================
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)
// 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;
}
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;
}
// ----------------------------------------------------------------------------
uint32_t freeChunk;
// executed twice: for the dynamic heap, and for the non-secure RAM storage heap
- for ( uint16_t i=0; i<MemNumRAMHeaps(); i++)
+ for ( uint16_t i = 0; i < POS_MemNumRAMHeaps(); i ++)
{
status_t err = MemHeapFreeBytes(i, &freeHeap, &freeChunk);
if( err != errNone )
unsigned long wxGetProcessId()
{
- return 0;
+ return SysTaskID ();
}
// Emit a beeeeeep
{
wxString strOS = _T("PalmOS");
+ //err = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
+ //if (romVersion >= 0x02000000) v20 = true;
char *version = SysGetOSVersionString();
if(version)
{
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
{
// TODO
-
- return wxOS_UNKNOWN;
+ return wxOS_PALM_OS;
}
// ----------------------------------------------------------------------------
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);
+ }
}
// ----------------------------------------------------------------------------
#endif // WX_PRECOMP
#include <VFSMgr.h>
+#ifdef __WXPALMOS6__
#include <PalmTypesCompatibility.h>
+#else
+#include <PalmCompatibility.h>
+#endif
#if wxUSE_BASE
WinHandle handle = (WinHandle)GetHWND();
if(handle)
{
+#ifdef __WXPALMOS6__
if(rect)
{
RectangleType dirtyRect;
{
WinInvalidateWindow(handle);
}
+#else // __WXPALMOS5__
+ WinSetActiveWindow (handle);
+#endif
+
}
}