From 555f645a40d21b575f6154e484e2cddcb950a341 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Fri, 31 Dec 2004 07:08:11 +0000 Subject: [PATCH] wxDialog::Show is virtual as elsewhere. Native PalmOS progress dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31194 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/palmos/makefile | 1 + docs/changes.txt | 1 + include/wx/chkconf.h | 11 +-- include/wx/cocoa/dialog.h | 4 +- include/wx/generic/progdlgg.h | 8 +-- include/wx/mac/carbon/dialog.h | 2 +- include/wx/mac/classic/dialog.h | 2 +- include/wx/palmos/progdlg.h | 60 ++++++++++++++++ include/wx/progdlg.h | 9 ++- include/wx/univ/dialog.h | 2 +- src/palmos/progdlg.cpp | 119 ++++++++++++++++++++++++++++++++ 11 files changed, 203 insertions(+), 16 deletions(-) create mode 100644 include/wx/palmos/progdlg.h create mode 100644 src/palmos/progdlg.cpp diff --git a/build/palmos/makefile b/build/palmos/makefile index 20d2ca89c0..ce31ae88be 100644 --- a/build/palmos/makefile +++ b/build/palmos/makefile @@ -247,6 +247,7 @@ SOURCES = ../../samples/minimal/minimal.cpp \ ../../src/palmos/prefconf.cpp \ ../../src/palmos/printdlg.cpp \ ../../src/palmos/printpalm.cpp \ +../../src/palmos/progdlg.cpp \ ../../src/palmos/radiobox.cpp \ ../../src/palmos/radiobut.cpp \ ../../src/palmos/region.cpp \ diff --git a/docs/changes.txt b/docs/changes.txt index c40943cf5c..4b701423c5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -100,6 +100,7 @@ wxPalmOS: all wxMSW specific code which was base for the new port) - enumeration of available volumes - native wxPrefConfig around Preferences database +- native wxProgressDialog implementation 2.5.3 diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index bf26c9d780..341dc163b5 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -1460,20 +1460,21 @@ # endif #endif /* wxUSE_FILEDLG */ -#if !wxUSE_GAUGE -# if wxUSE_PROGRESSDLG +#if !wxUSE_GAUGE || !wxUSE_BUTTON +# if wxUSE_PROGRESSDLG && !defined(__WXPALMOS__) # ifdef wxABORT_ON_CONFIG_ERROR -# error "Progress dialog require wxUSE_GAUGE" +# error "Generic progress dialog requires wxUSE_GAUGE and wxUSE_BUTTON" # else # undef wxUSE_GAUGE +# undef wxUSE_BUTTON # define wxUSE_GAUGE 1 +# define wxUSE_BUTTON 1 # endif # endif #endif /* !wxUSE_GAUGE */ #if !wxUSE_BUTTON -# if wxUSE_PROGRESSDLG || \ - wxUSE_FONTDLG || \ +# if wxUSE_FONTDLG || \ wxUSE_FILEDLG || \ wxUSE_CHOICEDLG || \ wxUSE_NUMBERDLG || \ diff --git a/include/wx/cocoa/dialog.h b/include/wx/cocoa/dialog.h index 50785849f8..b4e0145e91 100644 --- a/include/wx/cocoa/dialog.h +++ b/include/wx/cocoa/dialog.h @@ -6,7 +6,7 @@ // Created: 2002/12/15 // RCS-ID: $Id: // Copyright: David Elliott -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_COCOA_DIALOG_H_ @@ -81,7 +81,7 @@ protected: // Implementation // ------------------------------------------------------------------------ public: - bool Show(bool show = true); + virtual bool Show(bool show = true); void SetModal(bool flag); virtual bool IsModal() const { return m_isModal; } diff --git a/include/wx/generic/progdlgg.h b/include/wx/generic/progdlgg.h index 6444697cec..5f16104d84 100644 --- a/include/wx/generic/progdlgg.h +++ b/include/wx/generic/progdlgg.h @@ -63,7 +63,7 @@ public: */ void Resume(); - bool Show( bool show = true ); + virtual bool Show( bool show = true ); protected: // callback for optional abort button @@ -150,7 +150,7 @@ private: DECLARE_NO_COPY_CLASS(wxProgressDialog) }; -#endif -#endif - // __PROGDLGH_G__ +#endif // wxUSE_PROGRESSDLG + +#endif // __PROGDLGH_G__ diff --git a/include/wx/mac/carbon/dialog.h b/include/wx/mac/carbon/dialog.h index 490cd0af5c..5a5a28675f 100644 --- a/include/wx/mac/carbon/dialog.h +++ b/include/wx/mac/carbon/dialog.h @@ -67,7 +67,7 @@ public: ~wxDialog(); // virtual bool Destroy(); - bool Show(bool show = true); + virtual bool Show(bool show = true); void SetModal(bool flag); virtual bool IsModal() const; diff --git a/include/wx/mac/classic/dialog.h b/include/wx/mac/classic/dialog.h index 490cd0af5c..5a5a28675f 100644 --- a/include/wx/mac/classic/dialog.h +++ b/include/wx/mac/classic/dialog.h @@ -67,7 +67,7 @@ public: ~wxDialog(); // virtual bool Destroy(); - bool Show(bool show = true); + virtual bool Show(bool show = true); void SetModal(bool flag); virtual bool IsModal() const; diff --git a/include/wx/palmos/progdlg.h b/include/wx/palmos/progdlg.h new file mode 100644 index 0000000000..8381b44bcf --- /dev/null +++ b/include/wx/palmos/progdlg.h @@ -0,0 +1,60 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/palmos/progdlg.h +// Purpose: wxProgressDialog interface +// Author: Wlodzimierz ABX Skiba +// Modified by: +// Created: 29.12.2004 +// RCS-ID: $Id$ +// Copyright: (c) Wlodzimierz Skiba +// License: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _PREFCONF_H_ +#define _PREFCONF_H_ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma interface "progdlg.h" +#endif + +#include "wx/defs.h" + +#if wxUSE_PROGRESSDLG + +#include "wx/dialog.h" + +class WXDLLEXPORT wxProgressDialog : public wxDialog +{ +DECLARE_DYNAMIC_CLASS(wxProgressDialog) +public: + wxProgressDialog(const wxString &title, + wxString const &message, + int maximum = 100, + wxWindow *parent = NULL, + int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE); + ~wxProgressDialog(); + + virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL); + void Resume(); + virtual bool Show( bool show = true ); + + wxString GetMessage(){return m_msg;} + void SetMessage(wxString const &message){m_msg = message;} + + int GetMaxValue(){return m_max;} + int GetCurValue(){return m_cur;} +private: + + ProgressType *m_prgFrame; + wxString m_msg; + int m_max,m_cur; + + // Virtual function hiding supression + virtual void Update() { wxDialog::Update(); } + + DECLARE_NO_COPY_CLASS(wxProgressDialog) +}; + +#endif // wxUSE_PROGRESSDLG + +#endif // _PREFCONF_H_ + diff --git a/include/wx/progdlg.h b/include/wx/progdlg.h index 38e3b0d18d..8e600c0780 100644 --- a/include/wx/progdlg.h +++ b/include/wx/progdlg.h @@ -1,7 +1,12 @@ #ifndef _WX_PROGDLG_H_BASE_ #define _WX_PROGDLG_H_BASE_ -#include "wx/generic/progdlgg.h" +#include "wx/defs.h" +#ifdef __WXPALMOS__ + #include "wx/palmos/progdlg.h" +#else + #include "wx/generic/progdlgg.h" #endif - // _WX_PROGDLG_H_BASE_ + +#endif // _WX_PROGDLG_H_BASE_ diff --git a/include/wx/univ/dialog.h b/include/wx/univ/dialog.h index 0892d2f950..f4a1c331b1 100644 --- a/include/wx/univ/dialog.h +++ b/include/wx/univ/dialog.h @@ -58,7 +58,7 @@ public: // returns true if we're in a modal loop bool IsModalShowing() const; - bool Show(bool show = true); + virtual bool Show(bool show = true); // implementation only from now on // ------------------------------- diff --git a/src/palmos/progdlg.cpp b/src/palmos/progdlg.cpp new file mode 100644 index 0000000000..29da0fa77d --- /dev/null +++ b/src/palmos/progdlg.cpp @@ -0,0 +1,119 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/palmos/progdlg.cpp +// Purpose: wxProgressDialog implementation +// Author: Wlodzimierz ABX Skiba +// Modified by: +// Created: 29.12.2004 +// RCS-ID: $Id$ +// Copyright: (c) Wlodzimierz Skiba +// License: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "progdlg.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/string.h" +#endif //WX_PRECOMP + +#if wxUSE_PROGRESSDLG + +//**************** +//* NEEDS DEBUGING +//**************** + +#include "wx/progdlg.h" +#include "wx/msgdlg.h" + +IMPLEMENT_CLASS(wxProgressDialog, wxDialog) + +static Boolean wxProgressCallback(PrgCallbackData *data) +{ + if(!data) + return false; + + wxProgressDialog *dialog = (wxProgressDialog *)data->userDataP; + + if(!dialog) + return false; + +// /* uint16_t */ data->bitmapId = 0; +// /* DmOpenRef */ data->bitmapDatabase = 0; + /* char * */ data->textP = "test"; +// /* status_t */ data->error; +// /* uint16_t */ data->canceled; + /* uint16_t */ data->textChanged = false; + /* uint16_t */ data->displaySkipBtn = true; +// /* uint16_t */ data->skipped:1; +// /* uint32_t */ data->timeout; + /* uint32_t */ data->barMaxValue = (uint32_t)dialog->GetMaxValue(); + /* uint32_t */ data->barCurValue = (uint32_t)dialog->GetCurValue(); + /* uint16_t */ data->delay = false ; + + /* NOT USED + data->spareBits1:10; + data->padding1; + data->padding2; + data->barMessage; + data->barFlags; + data->spareBits2:15; + */ + + return true; +} + +wxProgressDialog::wxProgressDialog(const wxString &title, + wxString const &message, + int maximum, + wxWindow *parent, + int style) + :wxDialog(parent, wxID_ANY, title), + m_prgFrame(NULL), + m_msg(message), + m_cur(0), + m_max(maximum) +{ + wxString prgTitle = title.Mid(0, progressMaxTitle); + + m_prgFrame = PrgStartDialog(prgTitle.ToAscii(), wxProgressCallback, this); +} + +wxProgressDialog::~wxProgressDialog() +{ + if(m_prgFrame) + { + PrgStopDialog(m_prgFrame, false); + m_prgFrame = NULL; + } +} + +bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip) +{ + if(!m_prgFrame) + return false; + if(!newmsg.empty()) + SetMessage(newmsg); + m_cur = value; + // PrgUpdateDialog crashes, needs debugging + // PrgUpdateDialog(m_prgFrame, 0, 1, newmsg.ToAscii(), true); + return true; +} + +void wxProgressDialog::Resume() +{ +} + +bool wxProgressDialog::Show(bool show) +{ + return false; +} + +#endif // wxUSE_PROGRESSDLG -- 2.45.2