From 92afa2b150803da84a4bc7dfa4e580dbbff15c9a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Wed, 11 Aug 1999 11:53:40 +0000 Subject: [PATCH] Did somework on the generic dialogs, Renamed wxBox -> wxBoxSizer Removed old dialog layout code, git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/filelist.txt | 13 +- include/wx/Makefile.am | 1 - include/wx/choicdlg.h | 4 - include/wx/dialog.h | 42 +--- include/wx/extdlg.h | 7 - include/wx/generic/Makefile.am | 1 - include/wx/generic/choicdgg.h | 1 + include/wx/generic/textdlgg.h | 1 + include/wx/gtk/Makefile.am | 3 - include/wx/gtk/choicdlg.h | 101 --------- include/wx/gtk/msgdlg.h | 56 ----- include/wx/gtk/textdlg.h | 52 ----- include/wx/gtk1/Makefile.am | 3 - include/wx/gtk1/choicdlg.h | 101 --------- include/wx/gtk1/msgdlg.h | 56 ----- include/wx/gtk1/textdlg.h | 52 ----- include/wx/msgdlg.h | 2 +- include/wx/sizer.h | 8 +- include/wx/textdlg.h | 4 - samples/dialogs/dialogs.cpp | 40 ---- samples/dialogs/dialogs.h | 2 - src/common/dlgcmn.cpp | 199 +++++++---------- src/common/sizer.cpp | 8 +- src/generic/choicdgg.cpp | 137 ++++-------- src/generic/extdlgg.cpp | 386 --------------------------------- src/generic/msgdlgg.cpp | 186 +++------------- src/generic/numdlgg.cpp | 61 +----- src/generic/textdlgg.cpp | 78 +++---- src/generic/tipdlg.cpp | 83 +++---- src/gtk/Makefile.am | 7 +- src/gtk/button.cpp | 13 +- src/gtk/choicdlg.cpp | 332 ---------------------------- src/gtk/makefile.unx.in | 8 +- src/gtk/msgdlg.cpp | 197 ----------------- src/gtk/textdlg.cpp | 146 ------------- src/gtk1/Makefile.am | 7 +- src/gtk1/button.cpp | 13 +- src/gtk1/choicdlg.cpp | 332 ---------------------------- src/gtk1/makefile.unx.in | 8 +- src/gtk1/msgdlg.cpp | 197 ----------------- src/gtk1/textdlg.cpp | 146 ------------- src/motif/makefile.unx.in | 8 +- 42 files changed, 267 insertions(+), 2835 deletions(-) delete mode 100644 include/wx/extdlg.h delete mode 100644 include/wx/gtk/choicdlg.h delete mode 100644 include/wx/gtk/msgdlg.h delete mode 100644 include/wx/gtk/textdlg.h delete mode 100644 include/wx/gtk1/choicdlg.h delete mode 100644 include/wx/gtk1/msgdlg.h delete mode 100644 include/wx/gtk1/textdlg.h delete mode 100644 src/generic/extdlgg.cpp delete mode 100644 src/gtk/choicdlg.cpp delete mode 100644 src/gtk/msgdlg.cpp delete mode 100644 src/gtk/textdlg.cpp delete mode 100644 src/gtk1/choicdlg.cpp delete mode 100644 src/gtk1/msgdlg.cpp delete mode 100644 src/gtk1/textdlg.cpp diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 2339adff27..1d3b672242 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -46,17 +46,16 @@ busyinfo.cpp G caret.cpp G U -choicdgg.cpp G R +choicdgg.cpp G colrdlgg.cpp G G dirdlgg.cpp G 16 -extdlgg.cpp G fontdlgg.cpp G G gridg.cpp G helpxlp.cpp G G,R imaglist.cpp G 16 laywin.cpp G listctrl.cpp G 16 -msgdlgg.cpp G G,R +msgdlgg.cpp G G notebook.cpp G 16,R panelg.cpp G printps.cpp G PS @@ -71,7 +70,7 @@ splitter.cpp G statusbr.cpp G tabg.cpp G R numdlgg.cpp G -textdlgg.cpp G R +textdlgg.cpp G tipdlg.cpp G treectrl.cpp G 16 @@ -267,7 +266,6 @@ button.cpp R checkbox.cpp R checklst.cpp R choice.cpp R -choicdlg.cpp R clipbrd.cpp R colour.cpp R combobox.cpp R @@ -292,7 +290,6 @@ main.cpp R mdi.cpp R menu.cpp R minifram.cpp R -msgdlg.cpp R notebook.cpp R palette.cpp R pen.cpp R @@ -309,7 +306,6 @@ statline.cpp R stattext.cpp R tbargtk.cpp R textctrl.cpp R -textdlg.cpp R timer.cpp R tooltip.cpp R utilsgtk.cpp R @@ -434,7 +430,6 @@ dynarray.h I WX dynlib.h I WX event.h I WX expr.h I WX -extdlg.h I WX ffile.h I WX file.h I WX fileconf.h I WX @@ -575,7 +570,6 @@ button.h I GTK checkbox.h I GTK checklst.h I GTK choice.h I GTK -choicdlg.h I GTK clipbrd.h I GTK colour.h I GTK combobox.h I GTK @@ -617,7 +611,6 @@ statline.h I GTK stattext.h I GTK tbargtk.h I GTK textctrl.h I GTK -textdlg.h I GTK timer.h I GTK tooltip.h I GTK treectrl.h I GTK diff --git a/include/wx/Makefile.am b/include/wx/Makefile.am index e3e3d0501d..776be6a67a 100644 --- a/include/wx/Makefile.am +++ b/include/wx/Makefile.am @@ -58,7 +58,6 @@ wx_include_HEADERS = \ dynlib.h \ event.h \ expr.h \ - extdlg.h \ ffile.h \ file.h \ fileconf.h \ diff --git a/include/wx/choicdlg.h b/include/wx/choicdlg.h index f9c1fb1fb6..52439ffd71 100644 --- a/include/wx/choicdlg.h +++ b/include/wx/choicdlg.h @@ -1,11 +1,7 @@ #ifndef _WX_CHOICDLG_H_BASE_ #define _WX_CHOICDLG_H_BASE_ -#ifdef __WXGTK__ -#include "wx/gtk/choicdlg.h" -#else #include "wx/generic/choicdgg.h" -#endif #endif // _WX_CHOICDLG_H_BASE_ diff --git a/include/wx/dialog.h b/include/wx/dialog.h index 8a4737c2f4..ac5f9a9672 100644 --- a/include/wx/dialog.h +++ b/include/wx/dialog.h @@ -24,42 +24,12 @@ public: int GetReturnCode() const { return m_returnCode; } protected: - // functions to help with dialog layout - // ------------------------------------ - - // constants used in dialog layout - static const long LAYOUT_X_MARGIN; - static const long LAYOUT_Y_MARGIN; - static const long MARGIN_BETWEEN_BUTTONS; - - // Split the message in lines putting them into the array and calculating - // the maximum line width/height which is returned as wxSize. - wxSize SplitTextMessage(const wxString& message, wxArrayString *lines); - - // Creates the (possibly multiline) message, assuming each line has the - // size sizeText (which can be retrieved from SplitTextMessage). Returns - // the bottom border of the multiline text zone. - long CreateTextMessage(const wxArrayString& lines, - const wxPoint& posText, - const wxSize& sizeText); - - // Returns the preferred size for the buttons in the dialog - wxSize GetStandardButtonSize(bool hasCancel = TRUE); - - // Create the standard [Ok] and [Cancel] (if hasCancel) buttons centering - // them with respect to the dialog width wDialog at vertical position y. - // wButton and hButton is the size of the button (which can be retrieved - // from GetStandardButtonSize) - void CreateStandardButtons(long wDialog, - long y, - long wButton, - long hButton, - bool hasCancel = TRUE); - - // Returns the standard height of single line text ctrl (it's not the same - // as the height of just text which may be retrieved from - // wxGetCharHeight()) - long GetStandardTextHeight(); + // splits text up at newlines and places the + // lines into a vertical wxBoxSizer + wxSizer *CreateTextSizer( const wxString &message ); + + // places buttons into a horizontal wxBoxSizer + wxSizer *CreateButtonSizer( long flags ); // the return code from modal dialog int m_returnCode; diff --git a/include/wx/extdlg.h b/include/wx/extdlg.h deleted file mode 100644 index 3799925eae..0000000000 --- a/include/wx/extdlg.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _WX_EXTDLG_H_BASE_ -#define _WX_EXTDLG_H_BASE_ - -#include "wx/generic/extdlgg.h" - -#endif - // _WX_EXTDLG_H_BASE_ diff --git a/include/wx/generic/Makefile.am b/include/wx/generic/Makefile.am index 145cbb35a7..baebae8cd2 100644 --- a/include/wx/generic/Makefile.am +++ b/include/wx/generic/Makefile.am @@ -11,7 +11,6 @@ wx_generic_include_HEADERS = \ colrdlgg.h \ dcpsg.h \ dirdlgg.h \ - extdlgg.h \ fontdlgg.h \ gridg.h \ helpext.h \ diff --git a/include/wx/generic/choicdgg.h b/include/wx/generic/choicdgg.h index 4e240a0f98..2d817c474c 100644 --- a/include/wx/generic/choicdgg.h +++ b/include/wx/generic/choicdgg.h @@ -80,6 +80,7 @@ public: protected: int m_selection; + int m_dialogStyle; wxString m_stringSelection; wxListBox *m_listbox; diff --git a/include/wx/generic/textdlgg.h b/include/wx/generic/textdlgg.h index 13169fe86a..e95ab6dc2d 100644 --- a/include/wx/generic/textdlgg.h +++ b/include/wx/generic/textdlgg.h @@ -47,6 +47,7 @@ public: protected: wxTextCtrl *m_textctrl; wxString m_value; + int m_dialogStyle; private: DECLARE_EVENT_TABLE() diff --git a/include/wx/gtk/Makefile.am b/include/wx/gtk/Makefile.am index d38b4dff97..304b0416bd 100644 --- a/include/wx/gtk/Makefile.am +++ b/include/wx/gtk/Makefile.am @@ -15,7 +15,6 @@ wx_gtk_include_HEADERS = \ checkbox.h \ checklst.h \ choice.h \ - choicdlg.h \ clipbrd.h \ colour.h \ combobox.h \ @@ -39,7 +38,6 @@ wx_gtk_include_HEADERS = \ mdi.h \ menu.h \ menuitem.h \ - msgdlg.h \ minifram.h \ notebook.h \ palette.h \ @@ -57,7 +55,6 @@ wx_gtk_include_HEADERS = \ stattext.h \ tbargtk.h \ textctrl.h \ - textdlg.h \ timer.h \ tooltip.h \ treectrl.h \ diff --git a/include/wx/gtk/choicdlg.h b/include/wx/gtk/choicdlg.h deleted file mode 100644 index c9f6c4ee66..0000000000 --- a/include/wx/gtk/choicdlg.h +++ /dev/null @@ -1,101 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: choicdgg.h -// Purpose: Generic choice dialogs -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __CHOICEDLGH_G__ -#define __CHOICEDLGH_G__ - -#ifdef __GNUG__ -#pragma interface "choicdgg.h" -#endif - -#include "wx/setup.h" -#include "wx/dialog.h" - -#define wxCHOICE_HEIGHT 150 -#define wxCHOICE_WIDTH 200 - -#define wxID_LISTBOX 3000 - -class WXDLLEXPORT wxSingleChoiceDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog) -public: - wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - bool Create(wxWindow *parent, const wxString& message, const wxString& caption, - int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - bool Create(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - void SetSelection(int sel) ; - int GetSelection() const { return m_selection; } - wxString GetStringSelection() const { return m_stringSelection; } - char *GetSelectionClientData() const { return (char *)m_clientData; } - - void OnOK(wxCommandEvent& event); - void OnListBoxDClick(wxCommandEvent& event); - -DECLARE_EVENT_TABLE() - -protected: - long m_dialogStyle; - int m_selection; - wxString m_stringSelection; -}; - -WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message, const wxString& caption, - int n, const wxString *choices, wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message, const wxString& caption, - int n, wxChar *choices[], wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -// Same as above but gets position in list of strings, instead of string, -// or -1 if no selection -WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, - int n, const wxString *choices, wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, - int n, wxChar *choices[], wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -// Return client data instead -WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption, - int n, const wxString *choices, char **client_data, - wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1, - bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption, - int n, wxChar *choices[], char **client_data, - wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1, - bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -/* -WXDLLEXPORT int wxGetMultipleChoice(const wxString& message, const wxString& caption, - int n, const wxString *choices, - int nsel, int * selection, - wxWindow *parent = NULL, int x = -1 , int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); -*/ - -#endif diff --git a/include/wx/gtk/msgdlg.h b/include/wx/gtk/msgdlg.h deleted file mode 100644 index a545631340..0000000000 --- a/include/wx/gtk/msgdlg.h +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: msgdlgg.h -// Purpose: Generic wxMessageDialog -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __MSGDLGH_G__ -#define __MSGDLGH_G__ - -#ifdef __GNUG__ -#pragma interface "msgdlgg.h" -#endif - -#include "wx/setup.h" -#include "wx/dialog.h" - -// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO -// Returns wxYES/NO/OK/CANCEL - -WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr; - -class WXDLLEXPORT wxGenericMessageDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog) - -public: - wxGenericMessageDialog(wxWindow *parent, const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - void OnYes(wxCommandEvent& event); - void OnNo(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); - -private: - wxList m_buttons; - int m_dialogStyle; - -DECLARE_EVENT_TABLE() -}; - -#if !defined( __WXMSW__ ) && !defined( __WXMAC__) -#define wxMessageDialog wxGenericMessageDialog - -int wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1); - -#endif - -#endif - // __MSGDLGH_G__ diff --git a/include/wx/gtk/textdlg.h b/include/wx/gtk/textdlg.h deleted file mode 100644 index eb2c899db7..0000000000 --- a/include/wx/gtk/textdlg.h +++ /dev/null @@ -1,52 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: textdlgg.h -// Purpose: wxStatusBar class -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef __TEXTDLGH_G__ -#define __TEXTDLGH_G__ - -#ifdef __GNUG__ -#pragma interface "textdlgg.h" -#endif - -#include "wx/setup.h" -#include "wx/dialog.h" -#include "wx/extdlg.h" - -// Handy dialog functions (will be converted into classes at some point) -WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr; -WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; - -#define wxID_TEXT 3000 - -class WXDLLEXPORT wxTextEntryDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxTextEntryDialog) -protected: - long m_dialogStyle; - wxString m_value; -public: - wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr, - const wxString& value = wxEmptyString, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - inline void SetValue(const wxString& val) { m_value = val; } - inline wxString GetValue(void) const { return m_value; } - - void OnOK(wxCommandEvent& event); - -DECLARE_EVENT_TABLE() -}; - -wxString WXDLLEXPORT wxGetTextFromUser(const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr, - const wxString& default_value = wxEmptyString, wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE); - -#endif - // __TEXTDLGH_G__ diff --git a/include/wx/gtk1/Makefile.am b/include/wx/gtk1/Makefile.am index d38b4dff97..304b0416bd 100644 --- a/include/wx/gtk1/Makefile.am +++ b/include/wx/gtk1/Makefile.am @@ -15,7 +15,6 @@ wx_gtk_include_HEADERS = \ checkbox.h \ checklst.h \ choice.h \ - choicdlg.h \ clipbrd.h \ colour.h \ combobox.h \ @@ -39,7 +38,6 @@ wx_gtk_include_HEADERS = \ mdi.h \ menu.h \ menuitem.h \ - msgdlg.h \ minifram.h \ notebook.h \ palette.h \ @@ -57,7 +55,6 @@ wx_gtk_include_HEADERS = \ stattext.h \ tbargtk.h \ textctrl.h \ - textdlg.h \ timer.h \ tooltip.h \ treectrl.h \ diff --git a/include/wx/gtk1/choicdlg.h b/include/wx/gtk1/choicdlg.h deleted file mode 100644 index c9f6c4ee66..0000000000 --- a/include/wx/gtk1/choicdlg.h +++ /dev/null @@ -1,101 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: choicdgg.h -// Purpose: Generic choice dialogs -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __CHOICEDLGH_G__ -#define __CHOICEDLGH_G__ - -#ifdef __GNUG__ -#pragma interface "choicdgg.h" -#endif - -#include "wx/setup.h" -#include "wx/dialog.h" - -#define wxCHOICE_HEIGHT 150 -#define wxCHOICE_WIDTH 200 - -#define wxID_LISTBOX 3000 - -class WXDLLEXPORT wxSingleChoiceDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxSingleChoiceDialog) -public: - wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - bool Create(wxWindow *parent, const wxString& message, const wxString& caption, - int n, const wxString *choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - bool Create(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData = (char **) NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - void SetSelection(int sel) ; - int GetSelection() const { return m_selection; } - wxString GetStringSelection() const { return m_stringSelection; } - char *GetSelectionClientData() const { return (char *)m_clientData; } - - void OnOK(wxCommandEvent& event); - void OnListBoxDClick(wxCommandEvent& event); - -DECLARE_EVENT_TABLE() - -protected: - long m_dialogStyle; - int m_selection; - wxString m_stringSelection; -}; - -WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message, const wxString& caption, - int n, const wxString *choices, wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -WXDLLEXPORT wxString wxGetSingleChoice(const wxString& message, const wxString& caption, - int n, wxChar *choices[], wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -// Same as above but gets position in list of strings, instead of string, -// or -1 if no selection -WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, - int n, const wxString *choices, wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -WXDLLEXPORT int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, - int n, wxChar *choices[], wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -// Return client data instead -WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption, - int n, const wxString *choices, char **client_data, - wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1, - bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -WXDLLEXPORT wxChar* wxGetSingleChoiceData(const wxString& message, const wxString& caption, - int n, wxChar *choices[], char **client_data, - wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1, - bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); - -/* -WXDLLEXPORT int wxGetMultipleChoice(const wxString& message, const wxString& caption, - int n, const wxString *choices, - int nsel, int * selection, - wxWindow *parent = NULL, int x = -1 , int y = -1, bool centre = TRUE, - int width = wxCHOICE_WIDTH, int height = wxCHOICE_HEIGHT); -*/ - -#endif diff --git a/include/wx/gtk1/msgdlg.h b/include/wx/gtk1/msgdlg.h deleted file mode 100644 index a545631340..0000000000 --- a/include/wx/gtk1/msgdlg.h +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: msgdlgg.h -// Purpose: Generic wxMessageDialog -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __MSGDLGH_G__ -#define __MSGDLGH_G__ - -#ifdef __GNUG__ -#pragma interface "msgdlgg.h" -#endif - -#include "wx/setup.h" -#include "wx/dialog.h" - -// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO -// Returns wxYES/NO/OK/CANCEL - -WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr; - -class WXDLLEXPORT wxGenericMessageDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog) - -public: - wxGenericMessageDialog(wxWindow *parent, const wxString& message, - const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - void OnYes(wxCommandEvent& event); - void OnNo(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); - -private: - wxList m_buttons; - int m_dialogStyle; - -DECLARE_EVENT_TABLE() -}; - -#if !defined( __WXMSW__ ) && !defined( __WXMAC__) -#define wxMessageDialog wxGenericMessageDialog - -int wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1); - -#endif - -#endif - // __MSGDLGH_G__ diff --git a/include/wx/gtk1/textdlg.h b/include/wx/gtk1/textdlg.h deleted file mode 100644 index eb2c899db7..0000000000 --- a/include/wx/gtk1/textdlg.h +++ /dev/null @@ -1,52 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: textdlgg.h -// Purpose: wxStatusBar class -// Author: Julian Smart -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef __TEXTDLGH_G__ -#define __TEXTDLGH_G__ - -#ifdef __GNUG__ -#pragma interface "textdlgg.h" -#endif - -#include "wx/setup.h" -#include "wx/dialog.h" -#include "wx/extdlg.h" - -// Handy dialog functions (will be converted into classes at some point) -WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr; -WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; - -#define wxID_TEXT 3000 - -class WXDLLEXPORT wxTextEntryDialog: public wxDialog -{ -DECLARE_DYNAMIC_CLASS(wxTextEntryDialog) -protected: - long m_dialogStyle; - wxString m_value; -public: - wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr, - const wxString& value = wxEmptyString, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition); - - inline void SetValue(const wxString& val) { m_value = val; } - inline wxString GetValue(void) const { return m_value; } - - void OnOK(wxCommandEvent& event); - -DECLARE_EVENT_TABLE() -}; - -wxString WXDLLEXPORT wxGetTextFromUser(const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr, - const wxString& default_value = wxEmptyString, wxWindow *parent = (wxWindow *) NULL, - int x = -1, int y = -1, bool centre = TRUE); - -#endif - // __TEXTDLGH_G__ diff --git a/include/wx/msgdlg.h b/include/wx/msgdlg.h index 173e699e36..573907b3c6 100644 --- a/include/wx/msgdlg.h +++ b/include/wx/msgdlg.h @@ -6,7 +6,7 @@ #elif defined(__WXMOTIF__) #include "wx/motif/msgdlg.h" #elif defined(__WXGTK__) -#include "wx/gtk/msgdlg.h" +#include "wx/generic/msgdlgg.h" #elif defined(__WXQT__) #include "wx/generic/msgdlgg.h" #elif defined(__WXMAC__) diff --git a/include/wx/sizer.h b/include/wx/sizer.h index a7f2cb0564..5f82f4ce94 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -28,7 +28,7 @@ class wxSizerItem; class wxSizer; -class wxBox; +class wxBoxSizer; //--------------------------------------------------------------------------- // wxSizerItem @@ -115,13 +115,13 @@ protected: }; //--------------------------------------------------------------------------- -// wxBox +// wxBoxSizer //--------------------------------------------------------------------------- -class WXDLLEXPORT wxBox: public wxSizer +class WXDLLEXPORT wxBoxSizer: public wxSizer { public: - wxBox( int orient ); + wxBoxSizer( int orient ); void RecalcSizes(); wxSize CalcMin(); diff --git a/include/wx/textdlg.h b/include/wx/textdlg.h index 564f6e14cf..9fe13dda44 100644 --- a/include/wx/textdlg.h +++ b/include/wx/textdlg.h @@ -1,11 +1,7 @@ #ifndef _WX_TEXTDLG_H_BASE_ #define _WX_TEXTDLG_H_BASE_ -#ifdef __WXGTK__ -#include "wx/gtk/textdlg.h" -#else #include "wx/generic/textdlgg.h" -#endif // ---------------------------------------------------------------------------- // function to get a number from user diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index d32d59beef..fe0d694bbc 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -31,7 +31,6 @@ #include "wx/fontdlg.h" #include "wx/choicdlg.h" #include "wx/tipdlg.h" -#include "wx/extdlg.h" #define wxTEST_GENERIC_DIALOGS_IN_MSW 0 @@ -80,7 +79,6 @@ bool MyApp::OnInit(void) file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry"); file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N"); file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice"); - file_menu->Append(DIALOGS_EXT_DIALOG, "&Extended dialog"); file_menu->AppendSeparator(); file_menu->Append(DIALOGS_TIP, "&Tip of the day"); file_menu->AppendSeparator(); @@ -111,43 +109,6 @@ MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, co wxFrame(parent, -1, title, pos, size) {} -void MyFrame::ExtDialog(wxCommandEvent& WXUNUSED(event) ) -{ - // The standard flags causes this dialog to display a - // wxStaticLine under wxMotif and wxGTK, but none under - // other platforms. Also, it will not be resizable - // anywhere. - - wxExtDialog dialog( this, -1, "Test 1 for wxExtDialog", wxOK|wxFORWARD|wxBACKWARD ); - dialog.AddButton( new wxButton( &dialog, -1, "Custom") ); - - dialog.SetClientWindow( new wxTextCtrl( &dialog, -1, "Test", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ) ); - - // query minimal recommended size from the buttons - dialog.SetSize( dialog.GetButtonAreaSize().x, 170 ); - - dialog.Centre( wxBOTH ); - dialog.ShowModal(); - - // This dialog uses the standard dialog styles but is also - // resizable on all platforms and shows a wxStaticLine on - // all platforms. - - wxExtDialog dialog2( this, -1, "Test 2 for wxExtDialog", - wxOK|wxFORWARD|wxBACKWARD|wxCANCEL, - wxDefaultPosition, wxSize(400,170), - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxED_BUTTONS_RIGHT | wxED_STATIC_LINE | wxED_CLIENT_MARGIN ); - - dialog2.SetClientWindow( new wxTextCtrl( &dialog2, -1, "Test", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ) ); - - // query minimal recommended size from the buttons - wxSize min_size( dialog2.GetButtonAreaSize() ); - dialog2.SetSizeHints( min_size.x + 200, min_size.y ); - - dialog2.Centre( wxBOTH ); - dialog2.ShowModal(); -} - void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) { wxColourData data; @@ -392,7 +353,6 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave) EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose) EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip) - EVT_MENU(DIALOGS_EXT_DIALOG, MyFrame::ExtDialog) #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric) EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric) diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index b0f79f0116..9c0cc248f5 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -39,7 +39,6 @@ public: void FileSave(wxCommandEvent& event); void DirChoose(wxCommandEvent& event); void ShowTip(wxCommandEvent& event); - void ExtDialog(wxCommandEvent &event); #if !defined(__WXMSW__) || wxTEST_GENERIC_DIALOGS_IN_MSW void ChooseColourGeneric(wxCommandEvent& event); @@ -74,7 +73,6 @@ public: #define DIALOGS_FILE_SAVE 9 #define DIALOGS_DIR_CHOOSE 10 #define DIALOGS_TIP 11 -#define DIALOGS_EXT_DIALOG 12 #define DIALOGS_NUM_ENTRY 13 #endif diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index f08d15cace..f9d62a3b2f 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -36,154 +36,119 @@ #include "wx/intl.h" #include "wx/settings.h" #include "wx/stattext.h" + #include "wx/sizer.h" #endif -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -const long wxDialogBase::LAYOUT_X_MARGIN = 5; -const long wxDialogBase::LAYOUT_Y_MARGIN = 5; - -const long wxDialogBase::MARGIN_BETWEEN_BUTTONS = 3*LAYOUT_X_MARGIN; - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// dialog layout functions -// ---------------------------------------------------------------------------- +//-------------------------------------------------------------------------- +// wxDialogBase +//-------------------------------------------------------------------------- -wxSize wxDialogBase::SplitTextMessage(const wxString& message, - wxArrayString *lines) +wxSizer *wxDialogBase::CreateTextSizer( const wxString &message ) { - wxClientDC dc(this); - dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); - - wxString curLine; - long height, width, heightTextMax = 0, widthTextMax = 0; - for ( const wxChar *pc = message; ; pc++ ) + wxBoxSizer *box = new wxBoxSizer( wxVERTICAL ); + + wxString line; + for (size_t pos = 0; pos < message.Len(); pos++) { - if ( *pc == _T('\n') || !*pc ) + if (message[pos] == _T('\n')) { -#if defined(__VISAGECPP__) -// have two versions of this in wxWindowDC tp avoid function hiding -// since there are two of these in wxDCBase, and in turn in wxDC. -// VA cannot resolve this so: - dc.GetTextExtent(curLine, &width, &height, NULL, NULL, NULL, FALSE); -#else - dc.GetTextExtent(curLine, &width, &height); -#endif - if ( width > widthTextMax ) - widthTextMax = width; - if ( height > heightTextMax ) - heightTextMax = height; - - lines->Add(curLine); - - if ( !*pc ) + if (!line.IsEmpty()) { - // the end of string - break; + wxStaticText *s1 = new wxStaticText( this, -1, line ); + box->Add( s1 ); + line = _T(""); } - - curLine.Empty(); } else { - curLine += *pc; + line += message[pos]; } } - - return wxSize(widthTextMax, heightTextMax); -} - -long wxDialogBase::CreateTextMessage(const wxArrayString& lines, - const wxPoint& posText, - const wxSize& sizeText) -{ - wxStaticText *text; - int y = posText.y; - size_t nLineCount = lines.GetCount(); - for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) + + // remaining text behind last '\n' + if (!line.IsEmpty()) { - text = new wxStaticText(this, -1, lines[nLine], - wxPoint(posText.x, y), - sizeText); - y += sizeText.GetHeight(); + wxStaticText *s2 = new wxStaticText( this, -1, line ); + box->Add( s2 ); } - - return y; + + return box; } - -wxSize wxDialogBase::GetStandardButtonSize(bool hasCancel) + +wxSizer *wxDialogBase::CreateButtonSizer( long flags ) { -#if 0 - int wButton = 0; - GetTextExtent(_("OK"), &wButton, NULL); + wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL ); - if ( hasCancel ) - { - int width; - GetTextExtent(_("Cancel"), &width, NULL); - if ( width > wButton ) - wButton = width; - } +#if defined(__WXMSW__) || defined(__WXMAC__) + int margin = 6; +#else + int margin = 10; +#endif - if ( wButton < 75 ) + wxButton *ok = (wxButton *) NULL; + wxButton *cancel = (wxButton *) NULL; + wxButton *yes = (wxButton *) NULL; + wxButton *no = (wxButton *) NULL; + + if (flags & wxYES_NO) { - // the minimal acceptable width - wButton = 75; + yes = new wxButton( this, wxID_YES, _("Yes") ); + box->Add( yes, 0, wxLEFT|wxRIGHT, margin ); + no = new wxButton( this, wxID_NO, _("No") ); + box->Add( no, 0, wxLEFT|wxRIGHT, margin ); + } else + if (flags & wxYES) + { + yes = new wxButton( this, wxID_YES, _("Yes") ); + box->Add( yes, 0, wxLEFT|wxRIGHT, margin ); + } else + if (flags & wxNO) + { + no = new wxButton( this, wxID_NO, _("No") ); + box->Add( no, 0, wxLEFT|wxRIGHT, margin ); } - else + + if (flags & wxOK) { - // the width of the button is not just the width of the label... - wButton += 2*LAYOUT_X_MARGIN; + ok = new wxButton( this, wxID_OK, _("OK") ); + box->Add( ok, 0, wxLEFT|wxRIGHT, margin ); } - // a nice looking proportion - int hButton = (wButton * 23) / 75; + if (flags & wxFORWARD) + box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin ); - return wxSize(wButton, hButton); -#else - return wxButton::GetDefaultSize(); -#endif -} + if (flags & wxBACKWARD) + box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin ); -void wxDialogBase::CreateStandardButtons(long wDialog, - long y, - long wButton, - long hButton, - bool hasCancel) -{ - // NB: create [Ok] first to get the right tab order - wxButton *ok = (wxButton *) NULL; - wxButton *cancel = (wxButton *) NULL; + if (flags & wxSETUP) + box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin ); - long x = wDialog / 2; - if ( hasCancel ) - x -= MARGIN_BETWEEN_BUTTONS / 2 + wButton; - else - x -= wButton / 2; + if (flags & wxMORE) + box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin ); - ok = new wxButton( this, wxID_OK, _("OK"), - wxPoint(x, y), - wxSize(wButton, hButton) ); + if (flags & wxHELP) + box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin ); - if ( hasCancel ) + if (flags & wxCANCEL) { - x += MARGIN_BETWEEN_BUTTONS + wButton; - cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), - wxPoint(x, y), - wxSize(wButton, hButton) ); + cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); + box->Add( cancel, 0, wxLEFT|wxRIGHT, margin ); } - ok->SetDefault(); - ok->SetFocus(); + if ((flags & wxNO_DEFAULT) == 0) + { + if (ok) + { + ok->SetDefault(); + ok->SetFocus(); + } + else if (yes) + { + yes->SetDefault(); + yes->SetFocus(); + } + } + + return box; } -long wxDialogBase::GetStandardTextHeight() -{ - return (3*GetCharHeight()) / 2; -} diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 9a140fd684..f5f6ede49e 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -232,15 +232,15 @@ void wxSizer::SetDimension( int x, int y, int width, int height ) } //--------------------------------------------------------------------------- -// wxBox +// wxBoxSizer //--------------------------------------------------------------------------- -wxBox::wxBox( int orient ) +wxBoxSizer::wxBoxSizer( int orient ) { m_orient = orient; } -void wxBox::RecalcSizes() +void wxBoxSizer::RecalcSizes() { if (m_children.GetCount() == 0) { @@ -328,7 +328,7 @@ void wxBox::RecalcSizes() } } -wxSize wxBox::CalcMin() +wxSize wxBoxSizer::CalcMin() { if (m_children.GetCount() == 0) return wxSize(2,2); diff --git a/src/generic/choicdgg.cpp b/src/generic/choicdgg.cpp index 017151f363..608fec4009 100644 --- a/src/generic/choicdgg.cpp +++ b/src/generic/choicdgg.cpp @@ -28,6 +28,7 @@ #include "wx/listbox.h" #include "wx/stattext.h" #include "wx/intl.h" + #include "wx/sizer.h" #endif #if wxUSE_STATLINE @@ -164,9 +165,17 @@ END_EVENT_TABLE() IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog) #endif +#if defined(__WXMSW__) || defined(__WXMAC__) #define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \ wxDIALOG_MODAL | \ wxTAB_TRAVERSAL) +#else +#define wxCHOICEDLG_DIALOG_STYLE (wxDEFAULT_DIALOG_STYLE | \ + wxDIALOG_MODAL | \ + wxRESIZE_BORDER | \ + wxTAB_TRAVERSAL) +#endif + wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, @@ -225,118 +234,46 @@ bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), { m_selection = 0; m_clientData = NULL; - - // calc the message size - // --------------------- - - wxArrayString lines; - wxSize sizeText = SplitTextMessage(message, &lines); - long heightTextMax = sizeText.GetHeight(), - widthTextMax = sizeText.GetWidth(); - size_t nLineCount = lines.Count(); - long hTotalMsg = heightTextMax*nLineCount; - - // calc the button size - // -------------------- - - // always create the OK button - the code below supposes we do have buttons - // and besides the user should have some way to close this dialog - wxASSERT_MSG( style & wxOK, _T("this dialog should have OK button") ); - - bool hasCancel = (style & wxCANCEL) != 0; - - wxSize sizeButtons = GetStandardButtonSize(hasCancel); - - long wButton = sizeButtons.GetWidth(), - hButton = sizeButtons.GetHeight(); - - long wTotalButtons = wButton; - if ( hasCancel ) - { - wTotalButtons *= 2; // second button - wTotalButtons += MARGIN_BETWEEN_BUTTONS; // margin between the 2 - } - - // listbox and stat line - // --------------------- - - // make the listbox at least as tall as the message - otherwise it looks - // ugly (the lower limit of 300 for the width is arbitrary OTOH) - // - // NB: we write "n + 2" because the horiz. scrollbar also takes some place - long hListbox = wxMax((n + 2) * heightTextMax, hTotalMsg), - wListbox = wxMax(300, wxMax(wTotalButtons, widthTextMax)); - -#if wxUSE_STATLINE - long hStatLine = wxStaticLine::GetDefaultSize(); -#endif - - // now the complete dialog size - // ---------------------------- - - long hDialog = 2*LAYOUT_Y_MARGIN + // top margin - hTotalMsg + // message - 2*LAYOUT_Y_MARGIN + // margin between text and listbox - hListbox + // listbox -#if wxUSE_STATLINE - LAYOUT_Y_MARGIN + // margin - hStatLine + // separator line -#endif - 2*LAYOUT_Y_MARGIN + // margin between listbox and buttons - hButton + // button(s) - LAYOUT_Y_MARGIN; // bottom margin - - long wDialog = wxMax(wListbox, wxMax(wTotalButtons, widthTextMax)) + - 4*LAYOUT_X_MARGIN; // 2 from each side - - // create the controls - // ------------------- - - // message - wxStaticText *text; - int y = 2*LAYOUT_Y_MARGIN; - for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) - { - text = new wxStaticText(this, -1, lines[nLine], - wxPoint(2*LAYOUT_X_MARGIN, y), - wxSize(widthTextMax, heightTextMax)); - y += heightTextMax; - } - - y += 2*LAYOUT_X_MARGIN; - - // listbox - m_listbox = new wxListBox( this, wxID_LISTBOX, - wxPoint(2*LAYOUT_X_MARGIN, y), - wxSize(wListbox, hListbox), - n, choices, - wxLB_HSCROLL); - y += hListbox; - - if ( clientData ) + m_stringSelection = _T(""); + + m_dialogStyle = style; + + wxBeginBusyCursor(); + + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); + + // 1) text message + topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 ); + + // 2) list box + m_listbox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) , + n, choices, wxLB_ALWAYS_SB ); + m_listbox->SetSelection( m_selection ); + if (clientData) { for (int i = 0; i < n; i++) m_listbox->SetClientData(i, clientData[i]); } + topsizer->Add( m_listbox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); - // separator line #if wxUSE_STATLINE - (void) new wxStaticLine( this, -1, - wxPoint(2*LAYOUT_X_MARGIN, y + LAYOUT_Y_MARGIN), - wxSize(wDialog - 4*LAYOUT_X_MARGIN, hStatLine) ); - - y += LAYOUT_Y_MARGIN + hStatLine; + // 3) static line + topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); #endif - // buttons + // 4) buttons + topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 ); - y += 2*LAYOUT_X_MARGIN; + topsizer->SetSizeHints( this ); + topsizer->Fit( this ); + SetSizer( topsizer ); + SetAutoLayout( TRUE ); - CreateStandardButtons(wDialog, y, wButton, hButton, hasCancel); + Centre( wxBOTH ); - SetClientSize( wDialog, hDialog ); + m_listbox->SetFocus(); - Centre( wxBOTH ); + wxEndBusyCursor(); return TRUE; } diff --git a/src/generic/extdlgg.cpp b/src/generic/extdlgg.cpp deleted file mode 100644 index 40b7552741..0000000000 --- a/src/generic/extdlgg.cpp +++ /dev/null @@ -1,386 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: extdlgg.cpp -// Purpose: extended generic dialog -// Author: Robert Roebling -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "extdlgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include -#include "wx/intl.h" -#include "wx/dialog.h" -#include "wx/button.h" -#endif - -#if wxUSE_STATLINE -#include "wx/statline.h" -#endif - -#include "wx/generic/extdlgg.h" - -//----------------------------------------------------------------------------- -// wxExtDialog -//----------------------------------------------------------------------------- - -#define BUTTON_AREA_MARGIN 10 - -#if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxExtDialog, wxDialog) - -BEGIN_EVENT_TABLE(wxExtDialog, wxDialog) - EVT_SIZE(wxExtDialog::OnSize) - EVT_BUTTON(wxID_YES, wxExtDialog::OnYes) - EVT_BUTTON(wxID_NO, wxExtDialog::OnNo) - EVT_BUTTON(wxID_CANCEL, wxExtDialog::OnCancel) -END_EVENT_TABLE() -#endif - -wxExtDialog::wxExtDialog( wxWindow *parent, wxWindowID id, - const wxString& title, long extraStyle, - const wxPoint& pos, const wxSize& size, - long style, const wxString &name ) -{ - Create( parent, id, title, extraStyle, pos, size, style, name ); -} - -bool wxExtDialog::Create( wxWindow *parent, wxWindowID id, - const wxString& title, long extraStyle, - const wxPoint& pos, const wxSize& size, - long style, const wxString &name ) -{ - if (!wxDialog::Create( parent, id, title, pos, size, style, name )) - return FALSE; - - m_extraStyle = extraStyle; - - m_clientWindowMargin = 10; - - if (m_windowStyle & wxED_BUTTONS_RIGHT) - { - m_spacePerButton.x = wxButton::GetDefaultSize().x + 18; - m_spacePerButton.y = wxButton::GetDefaultSize().y + 8; - } - else - { - m_spacePerButton.x = wxButton::GetDefaultSize().x + 8; - m_spacePerButton.y = wxButton::GetDefaultSize().y + 18; - } - -#if defined(__WXGTK__) || defined(__WXMOTIF__) - // Under Motif and GTK, the default button has a big frame around - // it and to avoid overlapping buttons we make the margin bigger. - // We could give other platforms a bigger margin as well, but this - // wouldn't be standard L&F. - m_spacePerButton.x += 10; - m_spacePerButton.y += 10; -#endif - - wxButton *ok = (wxButton *) NULL; - wxButton *cancel = (wxButton *) NULL; - wxButton *yes = (wxButton *) NULL; - wxButton *no = (wxButton *) NULL; - - - if (m_extraStyle & wxYES_NO) - { - yes = new wxButton( this, wxID_YES, _("Yes") ); - m_buttons.Append( yes ); - no = new wxButton( this, wxID_NO, _("No") ); - m_buttons.Append( no ); - } - - if (m_extraStyle & wxYES) - { - yes = new wxButton( this, wxID_YES, _("Yes") ); - m_buttons.Append( yes ); - } - - if (m_extraStyle & wxNO) - { - no = new wxButton( this, wxID_NO, _("No") ); - m_buttons.Append( no ); - } - - if (m_extraStyle & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK") ); - m_buttons.Append( ok ); - } - - if (m_extraStyle & wxFORWARD) - AddButton( new wxButton( this, wxID_FORWARD, _("Forward") ) ); - - if (m_extraStyle & wxBACKWARD) - AddButton( new wxButton( this, wxID_BACKWARD, _("Backward") ) ); - - if (m_extraStyle & wxSETUP) - AddButton( new wxButton( this, wxID_SETUP, _("Setup") ) ); - - if (m_extraStyle & wxMORE) - AddButton( new wxButton( this, wxID_MORE, _("More...") ) ); - - if (m_extraStyle & wxHELP) - AddButton( new wxButton( this, wxID_HELP, _("Help") ) ); - - if (m_extraStyle & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); - m_buttons.Append( cancel ); - } - - if ((m_extraStyle & wxNO_DEFAULT) == 0) - { - if (ok) - { - ok->SetDefault(); - ok->SetFocus(); - } - else if (yes) - { - yes->SetDefault(); - yes->SetFocus(); - } - } - -#if wxUSE_STATLINE - if (style & wxED_STATIC_LINE) - { - int line_style = wxLI_HORIZONTAL; - if (style & wxED_BUTTONS_RIGHT) line_style = wxLI_VERTICAL; - - m_statLine = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, line_style ); - } - else - m_statLine = (wxStaticLine*) NULL; -#endif - - if (m_extraStyle & wxCENTRE) - Centre( wxBOTH ); - - return TRUE; -} - -void wxExtDialog::AddButton( wxButton *button ) -{ - m_buttons.Append( button ); -} - -void wxExtDialog::SetDefaultButton( wxWindowID button ) -{ - wxNode *node = m_buttons.First(); - while (node) - { - wxButton *but = (wxButton*) node->Data(); - if (but->GetId() == button) - { - but->SetDefault(); - but->SetFocus(); - return; - } - } -} - -void wxExtDialog::EnableButton( wxWindowID button, bool enable ) -{ - wxNode *node = m_buttons.First(); - while (node) - { - wxButton *but = (wxButton*) node->Data(); - if (but->GetId() == button) - { - but->Enable(enable); - return; - } - } -} - -bool wxExtDialog::ButtonIsEnabled( wxWindowID button ) -{ - wxNode *node = m_buttons.First(); - while (node) - { - wxButton *but = (wxButton*) node->Data(); - if (but->GetId() == button) - return but->IsEnabled(); - } - return FALSE; -} - -void wxExtDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - wxSize client_size( GetClientSize() ); - wxSize button_area( LayoutButtons() ); - - if (HasFlag(wxED_BUTTONS_RIGHT)) - client_size.x -= button_area.x; - else - client_size.y -= button_area.y; - - if (m_clientWindow) - { - if (m_windowStyle & wxED_CLIENT_MARGIN) - m_clientWindow->SetSize( m_clientWindowMargin, - m_clientWindowMargin, - client_size.x - 2*m_clientWindowMargin, - client_size.y - 2*m_clientWindowMargin ); - else - m_clientWindow->SetSize( 0, 0, client_size.x, client_size.y ); - - if (m_clientWindow->GetAutoLayout()) - m_clientWindow->Layout(); - } -} - -void wxExtDialog::OnYes(wxCommandEvent& event) -{ - EndModal( wxID_YES ); -} - -void wxExtDialog::OnNo(wxCommandEvent& event) -{ - EndModal( wxID_NO ); -} - -void wxExtDialog::OnCancel(wxCommandEvent& event) -{ - /* allow cancellation via ESC/Close button except if - only YES and NO are specified. */ - if ((m_extraStyle & wxYES_NO) != wxYES_NO || (m_extraStyle & wxCANCEL)) - { - EndModal( wxID_CANCEL ); - } -} - -wxSize wxExtDialog::GetButtonAreaSize() -{ - if (m_buttons.GetCount() == 0) return wxSize(0,0); - - wxSize ret(0,0); - - if (m_windowStyle & wxED_BUTTONS_RIGHT) - { - ret.x = m_spacePerButton.x; - ret.y = m_buttons.GetCount()*m_spacePerButton.y + 2*BUTTON_AREA_MARGIN; -#if wxUSE_STATLINE - if (m_statLine) - ret.x += wxStaticLine::GetDefaultSize(); -#endif - } - else - { - ret.x = m_buttons.GetCount()*m_spacePerButton.x + 2*BUTTON_AREA_MARGIN; - ret.y = m_spacePerButton.y; -#if wxUSE_STATLINE - if (m_statLine) - ret.y += wxStaticLine::GetDefaultSize(); -#endif - } - - return ret; -} - -wxSize wxExtDialog::LayoutButtons() -{ - if (m_buttons.GetCount() == 0) return wxSize(0,0); - - wxSize area_used( GetButtonAreaSize() ); - wxSize client_area( GetClientSize() ); - - if (m_windowStyle & wxED_BUTTONS_RIGHT) - { - area_used.y = client_area.y; - wxSize area_used_by_buttons( area_used ); -#if wxUSE_STATLINE - if (m_statLine) - area_used_by_buttons.x -= wxStaticLine::GetDefaultSize(); -#endif - - int space_for_each_button = (client_area.y-2*BUTTON_AREA_MARGIN) / m_buttons.GetCount(); - int n = 0; - wxNode *node = m_buttons.First(); - while (node) - { - wxButton *button = (wxButton*)node->Data(); - - wxSize button_size( button->GetSize() ); - if (button_size.x < wxButton::GetDefaultSize().x) button_size.x = wxButton::GetDefaultSize().x; - - int center_of_button_y = n*space_for_each_button + space_for_each_button/2; - int button_y = BUTTON_AREA_MARGIN + center_of_button_y - button_size.y/2; - - int center_of_button_x = client_area.x - area_used_by_buttons.x/2; - int button_x = center_of_button_x - button_size.x/2; - - button->SetSize( button_x, button_y, button_size.x, button_size.y ); - - node = node->Next(); - n++; - } - -#if wxUSE_STATLINE - if (m_statLine) - m_statLine->SetSize( client_area.x - area_used_by_buttons.x - wxStaticLine::GetDefaultSize(), - 0, - wxStaticLine::GetDefaultSize(), - client_area.y ); -#endif - } - else - { - area_used.x = client_area.x; - wxSize area_used_by_buttons( area_used ); -#if wxUSE_STATLINE - if (m_statLine) - area_used_by_buttons.y -= wxStaticLine::GetDefaultSize(); -#endif - - int space_for_each_button = (client_area.x-2*BUTTON_AREA_MARGIN) / m_buttons.GetCount(); - int n = 0; - wxNode *node = m_buttons.First(); - while (node) - { - wxButton *button = (wxButton*)node->Data(); - - wxSize button_size( button->GetSize() ); - if (button_size.x < wxButton::GetDefaultSize().x) button_size.x = wxButton::GetDefaultSize().x; - - int center_of_button_x = n*space_for_each_button + space_for_each_button/2; - int button_x = BUTTON_AREA_MARGIN + center_of_button_x - button_size.x/2; - - int center_of_button_y = client_area.y - area_used_by_buttons.y/2; - int button_y = center_of_button_y - button_size.y/2; - - button->SetSize( button_x, button_y, button_size.x, button_size.y ); - - node = node->Next(); - n++; - } - -#if wxUSE_STATLINE - if (m_statLine) - m_statLine->SetSize( 0, - client_area.y - area_used_by_buttons.y - wxStaticLine::GetDefaultSize(), - client_area.x, - wxStaticLine::GetDefaultSize() ); -#endif - } - - return area_used; -} - - diff --git a/src/generic/msgdlgg.cpp b/src/generic/msgdlgg.cpp index 18bd2ba2ba..e693f4eade 100644 --- a/src/generic/msgdlgg.cpp +++ b/src/generic/msgdlgg.cpp @@ -29,7 +29,8 @@ #include "wx/layout.h" #include "wx/intl.h" #include "wx/icon.h" -# include "wx/app.h" + #include "wx/sizer.h" + #include "wx/app.h" #endif #include @@ -66,170 +67,37 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, wxBeginBusyCursor(); - wxLayoutConstraints *c; - SetAutoLayout(TRUE); + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBitmap *icon = new wxStaticBitmap(this, -1, - wxTheApp->GetStdIcon(style & wxICON_MASK)); - const int iconSize = icon->GetBitmap().GetWidth(); - - // split the message in lines - // -------------------------- - - wxArrayString lines; - wxSize sizeText = SplitTextMessage(message, &lines); - long widthTextMax = sizeText.GetWidth(), - heightTextMax = sizeText.GetHeight(); - size_t nLineCount = lines.GetCount(); - - // calculate the total dialog size - enum + wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL ); + + // 1) icon + if (style & wxICON_MASK) { - Btn_Ok, - Btn_Yes, - Btn_No, - Btn_Cancel, - Btn_Max - }; - wxButton *buttons[Btn_Max] = { NULL, NULL, NULL, NULL }; - int nDefaultBtn = -1; - - // some checks are in order... - wxASSERT_MSG( !(style & wxOK) || !(style & wxYES_NO), - "don't create dialog with both Yes/No and Ok buttons!" ); - - wxASSERT_MSG( (style & wxOK ) || (style & wxYES_NO), - "don't create dialog with only the Cancel button!" ); - - if ( style & wxYES_NO ) { - buttons[Btn_Yes] = new wxButton(this, wxID_YES, _("Yes")); - buttons[Btn_No] = new wxButton(this, wxID_NO, _("No")); - - - if(style & wxNO_DEFAULT) - nDefaultBtn = Btn_No; - else - nDefaultBtn = Btn_Yes; + wxStaticBitmap *icon = new wxStaticBitmap( + this, -1, wxTheApp->GetStdIcon(style & wxICON_MASK)); + icon_text->Add( icon, 0, wxCENTER ); } + + // 2) text + icon_text->Add( CreateTextSizer( message ), 0, wxCENTER | wxLEFT, 10 ); + + topsizer->Add( icon_text, 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 ); + +#if wxUSE_STATLINE + // 3) static line + topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); +#endif - if (style & wxOK) { - buttons[Btn_Ok] = new wxButton(this, wxID_OK, _("OK")); - - if ( nDefaultBtn == -1 ) - nDefaultBtn = Btn_Ok; - } - - if (style & wxCANCEL) { - buttons[Btn_Cancel] = new wxButton(this, wxID_CANCEL, _("Cancel")); - } - - // get the longest caption and also calc the number of buttons - size_t nBtn, nButtons = 0; - int width, widthBtnMax = 0; - for ( nBtn = 0; nBtn < Btn_Max; nBtn++ ) { - if ( buttons[nBtn] ) { - nButtons++; - GetTextExtent(buttons[nBtn]->GetLabel(), &width, NULL); - if ( width > widthBtnMax ) - widthBtnMax = width; - } - } - - // now we can place the buttons - if ( widthBtnMax < 75 ) - widthBtnMax = 75; - else - widthBtnMax += 10; - long heightButton = widthBtnMax*23/75; - - // *1.2 baselineskip - heightTextMax *= 12; - heightTextMax /= 10; - - long widthButtonsTotal = nButtons * (widthBtnMax + LAYOUT_X_MARGIN) - - LAYOUT_X_MARGIN; - - // the size of the dialog - long widthDlg = wxMax(widthTextMax + iconSize + 4*LAYOUT_X_MARGIN, - wxMax(widthButtonsTotal, width)) + - 2*LAYOUT_X_MARGIN, - heightDlg = 8*LAYOUT_Y_MARGIN + heightButton + - heightTextMax*(nLineCount + 1); - - // create the controls - // ------------------- - - // the icon first - c = new wxLayoutConstraints; - c->width.Absolute(iconSize); - c->height.Absolute(iconSize); - c->top.SameAs(this, wxTop, 3*LAYOUT_Y_MARGIN); - c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN); - icon->SetConstraints(c); - - wxStaticText *text = NULL; - for ( size_t nLine = 0; nLine < nLineCount; nLine++ ) { - c = new wxLayoutConstraints; - if ( text == NULL ) - c->top.SameAs(this, wxTop, 3*LAYOUT_Y_MARGIN); - else - c->top.Below(text); - - c->left.RightOf(icon, 2*LAYOUT_X_MARGIN); - c->width.Absolute(widthTextMax); - c->height.Absolute(heightTextMax); - text = new wxStaticText(this, -1, lines[nLine]); - text->SetConstraints(c); - } - - // create the buttons - wxButton *btnPrevious = (wxButton *)NULL; - for ( nBtn = 0; nBtn < Btn_Max; nBtn++ ) { - if ( buttons[nBtn] ) { - c = new wxLayoutConstraints; - - if ( btnPrevious ) { - c->left.RightOf(btnPrevious, LAYOUT_X_MARGIN); - } - else { - c->left.SameAs(this, wxLeft, - (widthDlg - widthButtonsTotal) / 2); - } - - c->width.Absolute(widthBtnMax); - c->top.Below(text, 4*LAYOUT_Y_MARGIN); - c->height.Absolute(heightButton); - buttons[nBtn]->SetConstraints(c); - - btnPrevious = buttons[nBtn]; - } - } - - // set default button - // ------------------ - - if ( nDefaultBtn != -1 ) { - buttons[nDefaultBtn]->SetDefault(); - buttons[nDefaultBtn]->SetFocus(); - } - else { - wxFAIL_MSG( "can't find default button for this dialog." ); - } - - // position the controls and the dialog itself - // ------------------------------------------- - - SetClientSize(widthDlg, heightDlg); - - // SetSizeHints() wants the size of the whole dialog, not just client size - wxSize sizeTotal = GetSize(), - sizeClient = GetClientSize(); - SetSizeHints(widthDlg + sizeTotal.GetWidth() - sizeClient.GetWidth(), - heightDlg + sizeTotal.GetHeight() - sizeClient.GetHeight()); + // 4) buttons + topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 ); - Layout(); + topsizer->SetSizeHints( this ); + topsizer->Fit( this ); + SetSizer( topsizer ); + SetAutoLayout( TRUE ); - Centre(wxCENTER_FRAME | wxBOTH); + Centre( wxBOTH | wxCENTER_FRAME); wxEndBusyCursor(); } diff --git a/src/generic/numdlgg.cpp b/src/generic/numdlgg.cpp index a11b234489..c6100c88ff 100644 --- a/src/generic/numdlgg.cpp +++ b/src/generic/numdlgg.cpp @@ -48,35 +48,6 @@ // this is where wxGetNumberFromUser() is declared #include "wx/generic/textdlgg.h" -static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer ) -{ - wxString line; - for (size_t pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line ); - sizer->Add( s1 ); - line = _T(""); - } - } - else - { - line += message[pos]; - } - } - - // remaining text behind last '\n' - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line ); - sizer->Add( s2 ); - } -} - - // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -137,15 +108,13 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent, wxBeginBusyCursor(); - wxBox *topsizer = new wxBox( wxVERTICAL ); + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); // 1) text message - wxBox *textsizer = new wxBox( wxVERTICAL ); - wxSplitMessage2( message, this, textsizer ); - topsizer->Add( textsizer, 0, wxALL, 10 ); - + topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 ); + // 2) prompt and text ctrl - wxBox *inputsizer = new wxBox( wxHORIZONTAL ); + wxBoxSizer *inputsizer = new wxBoxSizer( wxHORIZONTAL ); // prompt if any if (!prompt.IsEmpty()) inputsizer->Add( new wxStaticText( this, -1, prompt ), 0, wxCENTER | wxLEFT, 10 ); @@ -162,26 +131,9 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent, topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); #endif - // 4) buttons - wxBox *buttonsizer = new wxBox( wxHORIZONTAL ); - - wxButton *ok = (wxButton *) NULL; -// if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK") ); - buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 ); - } - - wxButton *cancel = (wxButton *) NULL; -// if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); - buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 ); - } + topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 ); - topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 ); - SetSizer( topsizer ); SetAutoLayout( TRUE ); @@ -190,9 +142,6 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent, Centre( wxBOTH ); - if (ok) - ok->SetDefault(); - m_spinctrl->SetFocus(); wxEndBusyCursor(); diff --git a/src/generic/textdlgg.cpp b/src/generic/textdlgg.cpp index b9a35cf729..b828f75294 100644 --- a/src/generic/textdlgg.cpp +++ b/src/generic/textdlgg.cpp @@ -37,6 +37,7 @@ #include "wx/stattext.h" #include "wx/textctrl.h" #include "wx/intl.h" + #include "wx/sizer.h" #endif #if wxUSE_STATLINE @@ -77,55 +78,38 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL), m_value(value) { - // calculate the sizes - // ------------------- - - wxArrayString lines; - wxSize sizeText = SplitTextMessage(message, &lines); - - wxSize sizeBtn = GetStandardButtonSize(); - - long wText = wxMax(4*sizeBtn.GetWidth(), sizeText.GetWidth()); - long hText = GetStandardTextHeight(); - - long wDialog = 4*LAYOUT_X_MARGIN + wText; - long hDialog = 2*LAYOUT_Y_MARGIN + - sizeText.GetHeight() * lines.GetCount() + - 2*LAYOUT_Y_MARGIN + - hText + - 2*LAYOUT_Y_MARGIN + - sizeBtn.GetHeight() + - 2*LAYOUT_Y_MARGIN; - - // create the controls - // ------------------- - - // message - long x = 2*LAYOUT_X_MARGIN; - long y = CreateTextMessage(lines, - wxPoint(x, 2*LAYOUT_Y_MARGIN), - sizeText); - - y += 2*LAYOUT_X_MARGIN; - - // text ctrl - m_textctrl = new wxTextCtrl(this, wxID_TEXT, m_value, - wxPoint(x, y), - wxSize(wText, hText)); - y += hText + 2*LAYOUT_X_MARGIN; - - // and buttons - CreateStandardButtons(wDialog, y, sizeBtn.GetWidth(), sizeBtn.GetHeight()); - - // set the dialog size and position - SetClientSize(wDialog, hDialog); - if ( pos == wxDefaultPosition ) - { - // centre the dialog if no explicit position given - Centre(wxBOTH | wxCENTER_FRAME); - } + m_dialogStyle = style; + m_value = value; + + wxBeginBusyCursor(); + + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); + + // 1) text message + topsizer->Add( CreateTextSizer( message ), 0, wxALL, 10 ); + + // 2) text ctrl + m_textctrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1)); + topsizer->Add( m_textctrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); + +#if wxUSE_STATLINE + // 3) static line + topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); +#endif + + // 4) buttons + topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 ); + + topsizer->SetSizeHints( this ); + topsizer->Fit( this ); + SetSizer( topsizer ); + SetAutoLayout( TRUE ); + + Centre( wxBOTH ); m_textctrl->SetFocus(); + + wxEndBusyCursor(); } void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) diff --git a/src/generic/tipdlg.cpp b/src/generic/tipdlg.cpp index 4aebcf06e3..72f4675b25 100644 --- a/src/generic/tipdlg.cpp +++ b/src/generic/tipdlg.cpp @@ -37,10 +37,10 @@ #include "wx/dialog.h" #include "wx/icon.h" #include "wx/intl.h" - #include "wx/layout.h" #include "wx/settings.h" #include "wx/textctrl.h" #include "wx/statbmp.h" + #include "wx/sizer.h" #endif // WX_PRECOMP #include "wx/statline.h" @@ -164,12 +164,13 @@ wxTipDialog::wxTipDialog(wxWindow *parent, { m_tipProvider = tipProvider; - wxSize sizeBtn = GetStandardButtonSize(); - wxLayoutConstraints *c; - - // create the controls in the right order, then set the constraints + // 1) create all controls in tab order + wxButton *btnClose = new wxButton(this, wxID_CANCEL, _("&Close")); + m_checkbox = new wxCheckBox(this, -1, _("&Show tips at startup")); + m_checkbox->SetValue(showAtStartup); + wxButton *btnNext = new wxButton(this, wxID_NEXT_TIP, _("&Next")); wxTextCtrl *text = new wxTextCtrl(this, -1, _("Did you know..."), @@ -179,7 +180,7 @@ wxTipDialog::wxTipDialog(wxWindow *parent, text->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE)); m_text = new wxTextCtrl(this, -1, _T(""), - wxDefaultPosition, wxDefaultSize, + wxDefaultPosition, wxSize(200, 160), wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER); m_text->SetFont(wxFont(14, wxROMAN, wxNORMAL, wxNORMAL)); @@ -189,63 +190,35 @@ wxTipDialog::wxTipDialog(wxWindow *parent, #include "wx/generic/tip.xpm" wxIcon icon(tipIcon); #endif - wxStaticBitmap *bmp = new wxStaticBitmap(this, -1, icon); - const int iconSize = icon.GetWidth(); - - c = new wxLayoutConstraints; - c->top.SameAs(this, wxTop, 2*LAYOUT_Y_MARGIN); - c->left.RightOf(bmp, 2*LAYOUT_X_MARGIN); - c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN); - c->height.Absolute(2*text->GetSize().GetHeight()); - text->SetConstraints(c); - - c = new wxLayoutConstraints; - c->centreY.SameAs(text, wxCentreY); - c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN); - c->width.Absolute(iconSize); - c->height.Absolute(iconSize); - bmp->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN); - c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN); - c->width.Absolute(sizeBtn.GetWidth()); - c->height.Absolute(sizeBtn.GetHeight()); - btnClose->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN); - c->right.LeftOf(btnClose, 2*LAYOUT_X_MARGIN); - c->width.Absolute(sizeBtn.GetWidth()); - c->height.Absolute(sizeBtn.GetHeight()); - btnNext->SetConstraints(c); - - c = new wxLayoutConstraints; - c->bottom.SameAs(this, wxBottom, 2*LAYOUT_X_MARGIN); - c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN); - c->width.AsIs(); - c->height.AsIs(); - m_checkbox->SetConstraints(c); - m_checkbox->SetValue(showAtStartup); + // 2) put them in boxes - c = new wxLayoutConstraints; - c->top.Below(text); - c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN); - c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN); - c->bottom.Above(btnClose, -2*LAYOUT_Y_MARGIN); - m_text->SetConstraints(c); + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL ); + icon_text->Add( bmp, 0, wxCENTER ); + icon_text->Add( text, 1, wxCENTER | wxLEFT, 10 ); + topsizer->Add( icon_text, 0, wxEXPAND | wxALL, 10 ); + + topsizer->Add( m_text, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 ); + + wxBoxSizer *bottom = new wxBoxSizer( wxHORIZONTAL ); + bottom->Add( m_checkbox, 0, wxCENTER ); + bottom->Add( btnNext, 0, wxCENTER | wxLEFT, 10 ); + bottom->Add( btnClose, 0, wxCENTER | wxLEFT, 10 ); + topsizer->Add( bottom, 0, wxALIGN_RIGHT | wxALL, 10 ); SetTipText(); + + SetAutoLayout(TRUE); + SetSizer( topsizer ); + + topsizer->SetSizeHints( this ); + topsizer->Fit( this ); Centre(wxBOTH | wxCENTER_FRAME); - wxSize size(5*sizeBtn.GetWidth(), 10*sizeBtn.GetHeight()); - SetSize(size); - SetSizeHints(size.x, size.y); - - SetAutoLayout(TRUE); } // ---------------------------------------------------------------------------- diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am index 963bc6076e..bc745946f1 100644 --- a/src/gtk/Makefile.am +++ b/src/gtk/Makefile.am @@ -117,10 +117,10 @@ libwx_gtk_la_SOURCES = \ \ busyinfo.cpp \ caret.cpp \ + choicdgg.cpp \ colrdlgg.cpp \ dcpsg.cpp \ dirdlgg.cpp \ - extdlgg.cpp \ fontdlgg.cpp \ gridg.cpp \ helpext.cpp \ @@ -129,6 +129,7 @@ libwx_gtk_la_SOURCES = \ imaglist.cpp \ laywin.cpp \ listctrl.cpp \ + msgdlgg.cpp \ numdlgg.cpp \ panelg.cpp \ printps.cpp \ @@ -142,6 +143,7 @@ libwx_gtk_la_SOURCES = \ splitter.cpp \ statusbr.cpp \ tabg.cpp \ + textdlgg.cpp \ tipdlg.cpp \ treectrl.cpp \ \ @@ -157,7 +159,6 @@ libwx_gtk_la_SOURCES = \ checkbox.cpp \ checklst.cpp \ choice.cpp \ - choicdlg.cpp \ clipbrd.cpp \ colour.cpp \ combobox.cpp \ @@ -182,7 +183,6 @@ libwx_gtk_la_SOURCES = \ mdi.cpp \ menu.cpp \ minifram.cpp \ - msgdlg.cpp \ notebook.cpp \ palette.cpp \ pen.cpp \ @@ -199,7 +199,6 @@ libwx_gtk_la_SOURCES = \ stattext.cpp \ tbargtk.cpp \ textctrl.cpp \ - textdlg.cpp \ timer.cpp \ tooltip.cpp \ utilsgtk.cpp \ diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index e109966054..2bb626f031 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -97,8 +97,17 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font ); wxSize newSize = size; - if (newSize.x == -1) newSize.x = 12+x; - if (newSize.y == -1) newSize.y = 11+y; + if (newSize.x == -1) + { + newSize.x = 12+x; + if (newSize.x < 80) newSize.x = 80; + } + if (newSize.y == -1) + { + newSize.y = 11+y; + if (newSize.x < 26) newSize.x = 26; + } + SetSize( newSize.x, newSize.y ); gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", diff --git a/src/gtk/choicdlg.cpp b/src/gtk/choicdlg.cpp deleted file mode 100644 index 177457ad54..0000000000 --- a/src/gtk/choicdlg.cpp +++ /dev/null @@ -1,332 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: choicdgg.cpp -// Purpose: Choice dialogs -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ - #pragma implementation "choicdgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include - #include "wx/utils.h" - #include "wx/dialog.h" - #include "wx/button.h" - #include "wx/listbox.h" - #include "wx/stattext.h" - #include "wx/intl.h" - #include "wx/sizer.h" -#endif - -#if wxUSE_STATLINE - #include "wx/statline.h" -#endif - -#include "wx/gtk/choicdlg.h" - -static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer ) -{ - wxString line; - for (size_t pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line ); - sizer->Add( s1 ); - line = _T(""); - } - } - else - { - line += message[pos]; - } - } - - // remaining text behind last '\n' - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line ); - sizer->Add( s2 ); - } -} - - -wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n, - const wxString *choices, wxWindow *parent, - int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxSingleChoiceDialog dialog(parent, message, caption, n, choices); - if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetStringSelection(); - else - return _T(""); -} - -// Overloaded for backward compatibility -wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n, - char *choices[], wxWindow *parent, - int x, int y, bool centre, - int width, int height ) -{ - wxString *strings = new wxString[n]; - int i; - for ( i = 0; i < n; i++) - { - strings[i] = choices[i]; - } - wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent, - x, y, centre, width, height)); - delete[] strings; - return ans; -} - -int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n, - const wxString *choices, wxWindow *parent, - int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxSingleChoiceDialog dialog(parent, message, caption, n, choices); - if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetSelection(); - else - return -1; -} - -// Overloaded for backward compatibility -int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n, - wxChar *choices[], wxWindow *parent, - int x, int y, bool centre, - int width, int height ) -{ - wxString *strings = new wxString[n]; - for ( int i = 0; i < n; i++) - strings[i] = choices[i]; - int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent, - x, y, centre, width, height); - delete[] strings; - return ans; -} - -wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n, - const wxString *choices, char **client_data, wxWindow *parent, - int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data); - if ( dialog.ShowModal() == wxID_OK ) - return (wxChar *)dialog.GetSelectionClientData(); - else - return NULL; -} - -// Overloaded for backward compatibility -wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n, - wxChar *choices[], char **client_data, wxWindow *parent, - int x, int y, bool centre, - int width, int height ) -{ - wxString *strings = new wxString[n]; - int i; - for ( i = 0; i < n; i++) - { - strings[i] = choices[i]; - } - wxChar *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent, - x, y, centre, width, height); - delete[] strings; - return data; -} - - -/* Multiple choice dialog contributed by Robert Cowell - * - -The new data passed are in the "int nsel" and "int * selection" - -The idea is to make a multiple selection from list of strings. -The returned value is the total number selected. initialily there -are nsel selected, with indices stored in -selection[0],...,selection[nsel-1] which appear highlighted to -begin with. On exit with value i -selection[0..i-1] contains the indices of the selected items. -(Some prior selectecions might be deselected.) -Thus selection must be as big as choices, in case all items are -selected. - -*/ -/* -int wxGetMultipleChoice(const wxString& message, const wxString& caption, - int n, const wxString *choices, - int nsel, int * selection, - wxWindow *parent , int x , int y, bool centre, - int width, int height) -{ - return -1; -} -*/ - -// wxSingleChoiceDialog - -#if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog) - EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK) - EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick) -END_EVENT_TABLE() - -IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog) -#endif - -wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - int n, const wxString *choices, char **clientData, long style, const wxPoint& pos): - wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL) -{ - Create(parent, message, caption, n, choices, clientData, style); -} - -wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData, long style, const wxPoint& pos): - wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL) -{ - Create(parent, message, caption, choices, clientData, style); -} - -bool wxSingleChoiceDialog::Create(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData, long style, const wxPoint& pos) -{ - wxString *strings = new wxString[choices.Number()]; - int i; - for ( i = 0; i < choices.Number(); i++) - { - strings[i] = (char *)choices.Nth(i)->Data(); - } - bool ans = Create(parent, message, caption, choices.Number(), strings, clientData, style, pos); - delete[] strings; - return ans; -} - -bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& message, - const wxString& WXUNUSED(caption), int n, - const wxString *choices, char **clientData, long style, - const wxPoint& WXUNUSED(pos) ) -{ - m_dialogStyle = style; - m_selection = 0; - m_stringSelection = _T(""); - m_clientData = NULL; - - wxBeginBusyCursor(); - - wxBox *topsizer = new wxBox( wxVERTICAL ); - - // 1) text message - wxBox *textsizer = new wxBox( wxVERTICAL ); - wxSplitMessage2( message, this, textsizer ); - topsizer->Add( textsizer, 0, wxALL, 10 ); - - // 2) list box - wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) , - n, choices, wxLB_ALWAYS_SB ); - listBox->SetSelection( m_selection ); - if (clientData) - { - for (int i = 0; i < n; i++) - listBox->SetClientData(i, clientData[i]); - } - topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); - - -#if wxUSE_STATLINE - // 3) static line - topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); -#endif - - - // 4) buttons - wxBox *buttonsizer = new wxBox( wxHORIZONTAL ); - - wxButton *ok = (wxButton *) NULL; - if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK") ); - buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 ); - } - - wxButton *cancel = (wxButton *) NULL; - if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); - buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 ); - } - - topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - SetSizer( topsizer ); - SetAutoLayout( TRUE ); - - Centre( wxBOTH ); - - if (ok) - ok->SetDefault(); - - listBox->SetFocus(); - - wxEndBusyCursor(); - - return TRUE; -} - -// Set the selection -void wxSingleChoiceDialog::SetSelection(int sel) -{ - wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); - if (listBox) - { - listBox->SetSelection(sel); - } - m_selection = sel; -} - -void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); - if ( listBox ) - { - m_selection = listBox->GetSelection(); - m_stringSelection = listBox->GetStringSelection(); - m_clientData = listBox->GetClientData(m_selection); - } - - EndModal(wxID_OK); -} - -void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event)) -{ - wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); - if ( listBox ) - { - m_selection = listBox->GetSelection(); - m_stringSelection = listBox->GetStringSelection(); - m_clientData = listBox->GetClientData(m_selection); - } - - EndModal(wxID_OK); -} - diff --git a/src/gtk/makefile.unx.in b/src/gtk/makefile.unx.in index 2089c71ef0..ebbd715dd8 100644 --- a/src/gtk/makefile.unx.in +++ b/src/gtk/makefile.unx.in @@ -11,7 +11,7 @@ # # # -# This file was automatically generated by tmake at 19:48, 1999/08/10 +# This file was automatically generated by tmake at 09:46, 1999/08/11 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs GTK_GENERICOBJS = \ ../generic/busyinfo.o \ ../generic/caret.o \ + ../generic/choicdgg.o \ ../generic/colrdlgg.o \ ../generic/dirdlgg.o \ - ../generic/extdlgg.o \ ../generic/fontdlgg.o \ ../generic/gridg.o \ ../generic/imaglist.o \ @@ -123,6 +123,7 @@ GTK_GENERICOBJS = \ ../generic/scrolwin.o \ ../generic/splitter.o \ ../generic/statusbr.o \ + ../generic/textdlgg.o \ ../generic/tipdlg.o \ ../generic/treectrl.o @@ -216,7 +217,6 @@ GTK_GUIOBJS = \ ../gtk/button.o \ ../gtk/checkbox.o \ ../gtk/checklst.o \ - ../gtk/choicdlg.o \ ../gtk/choice.o \ ../gtk/clipbrd.o \ ../gtk/colour.o \ @@ -260,7 +260,6 @@ GTK_GUIOBJS = \ ../gtk/stattext.o \ ../gtk/tbargtk.o \ ../gtk/textctrl.o \ - ../gtk/textdlg.o \ ../gtk/timer.o \ ../gtk/tooltip.o \ ../gtk/utilsgtk.o \ @@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \ ../generic/choicdgg.o \ ../generic/colrdlgg.o \ ../generic/dirdlgg.o \ - ../generic/extdlgg.o \ ../generic/fontdlgg.o \ ../generic/gridg.o \ ../generic/helpxlp.o \ diff --git a/src/gtk/msgdlg.cpp b/src/gtk/msgdlg.cpp deleted file mode 100644 index 212f62da5a..0000000000 --- a/src/gtk/msgdlg.cpp +++ /dev/null @@ -1,197 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: msgdlgg.cpp -// Purpose: wxGenericMessageDialog -// Author: Julian Smart, Robert Roebling -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "msgdlgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/utils.h" -#include "wx/dialog.h" -#include "wx/listbox.h" -#include "wx/button.h" -#include "wx/statbmp.h" -#include "wx/stattext.h" -#include "wx/layout.h" -#include "wx/intl.h" -#include "wx/bitmap.h" -#include "wx/app.h" -#endif - -#include -#include - -#include "wx/gtk/msgdlg.h" -#include "wx/statline.h" - -/////////////////////////////////////////////////////////////////// -// New dialog box implementations - -// Split message, using constraints to position controls -wxSize wxSplitMessage2( const wxString &message, wxWindow *parent, int text_pos_x ) -{ - int y = 15; - int w = 50; - wxString line( _T("") ); - for (uint pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) ); - wxSize size1( s1->GetSize() ); - if (size1.x > w) w = size1.x; - line = _T(""); - } - y += 18; - } - else - { - line += message[pos]; - } - } - - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) ); - wxSize size2( s2->GetSize() ); - if (size2.x > w) w = size2.x; - } - - y += 18; - - return wxSize(w+15+text_pos_x,y); -} - -#if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog) - EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes) - EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo) - EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel) -END_EVENT_TABLE() - -IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog) -#endif - -wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message, - const wxString& caption, long style, const wxPoint& pos) : - wxDialog( parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ) -{ - m_dialogStyle = style; - - int text_pos_x = 15; - - if (m_dialogStyle & wxICON_MASK) - text_pos_x += 80; - - wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) ); - - if (m_dialogStyle & wxICON_MASK) - { - if (message_size.y < 50) message_size.y = 50; - (void) new wxStaticBitmap( this, -1, - wxTheApp->GetStdIcon(m_dialogStyle - & wxICON_MASK), - wxPoint(15,message_size.y/2-16) ); - } - - wxButton *ok = (wxButton *) NULL; - wxButton *cancel = (wxButton *) NULL; - wxButton *yes = (wxButton *) NULL; - wxButton *no = (wxButton *) NULL; - - int y = message_size.y + 30; - - if (style & wxYES_NO) - { - yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( yes ); - no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( no ); - } - - if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( ok ); - } - - if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( cancel ); - } - - if (ok) - { - ok->SetDefault(); - ok->SetFocus(); - } - else if (yes) - { - yes->SetDefault(); - yes->SetFocus(); - } - - int w = m_buttons.GetCount() * 100; - if (message_size.x > w) w = message_size.x; - int space = w / (m_buttons.GetCount()*2); - - int n = 0; - wxNode *node = m_buttons.First(); - while (node) - { - wxWindow *win = (wxWindow*)node->Data(); - int x = (n*2+1)*space - 40 + 15; - win->Move( x, -1 ); - node = node->Next(); - n++; - } - -#ifdef __WXGTK__ - int edge_margin = 7; - (void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) ); -#endif - - SetSize( w+30, y+40 ); - - Centre( wxBOTH ); -} - -void wxGenericMessageDialog::OnYes(wxCommandEvent& WXUNUSED(event)) -{ - EndModal( wxID_YES ); -} - -void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event)) -{ - EndModal( wxID_NO ); -} - -void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) -{ - /* Allow cancellation via ESC/Close button except if - only YES and NO are specified. */ - if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) ) - { - EndModal( wxID_CANCEL ); - } -} - - diff --git a/src/gtk/textdlg.cpp b/src/gtk/textdlg.cpp deleted file mode 100644 index c4cbd59af0..0000000000 --- a/src/gtk/textdlg.cpp +++ /dev/null @@ -1,146 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: textdlgg.cpp -// Purpose: wxTextEntryDialog -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "textdlgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include - #include "wx/utils.h" - #include "wx/dialog.h" - #include "wx/button.h" - #include "wx/stattext.h" - #include "wx/textctrl.h" - #include "wx/intl.h" - #include "wx/sizer.h" -#endif - -#if wxUSE_STATLINE - #include "wx/statline.h" -#endif - -#include "wx/gtk/textdlg.h" - -static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer ) -{ - wxString line; - for (size_t pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line ); - sizer->Add( s1 ); - line = _T(""); - } - } - else - { - line += message[pos]; - } - } - - // remaining text behind last '\n' - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line ); - sizer->Add( s2 ); - } -} - -// wxTextEntryDialog - -#if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog) - EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK) -END_EVENT_TABLE() - -IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog) -#endif - -wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption, - const wxString& value, long style, const wxPoint& pos): - wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL) -{ - m_dialogStyle = style; - m_value = value; - - wxBeginBusyCursor(); - - wxBox *topsizer = new wxBox( wxVERTICAL ); - - // 1) text message - wxBox *textsizer = new wxBox( wxVERTICAL ); - wxSplitMessage2( message, this, textsizer ); - topsizer->Add( textsizer, 0, wxALL, 10 ); - - // 2) text ctrl - wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1)); - topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); - -#if wxUSE_STATLINE - // 3) static line - topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); -#endif - - - // 4) buttons - wxBox *buttonsizer = new wxBox( wxHORIZONTAL ); - - wxButton *ok = (wxButton *) NULL; - if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK") ); - buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 ); - } - - wxButton *cancel = (wxButton *) NULL; - if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); - buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 ); - } - - topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - SetSizer( topsizer ); - SetAutoLayout( TRUE ); - - Centre( wxBOTH ); - - if (ok) - ok->SetDefault(); - - textCtrl->SetFocus(); - - wxEndBusyCursor(); -} - -void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) -{ - wxTextCtrl *textCtrl = (wxTextCtrl *)FindWindow(wxID_TEXT); - if ( textCtrl ) - m_value = textCtrl->GetValue(); - - EndModal(wxID_OK); -} - diff --git a/src/gtk1/Makefile.am b/src/gtk1/Makefile.am index 963bc6076e..bc745946f1 100644 --- a/src/gtk1/Makefile.am +++ b/src/gtk1/Makefile.am @@ -117,10 +117,10 @@ libwx_gtk_la_SOURCES = \ \ busyinfo.cpp \ caret.cpp \ + choicdgg.cpp \ colrdlgg.cpp \ dcpsg.cpp \ dirdlgg.cpp \ - extdlgg.cpp \ fontdlgg.cpp \ gridg.cpp \ helpext.cpp \ @@ -129,6 +129,7 @@ libwx_gtk_la_SOURCES = \ imaglist.cpp \ laywin.cpp \ listctrl.cpp \ + msgdlgg.cpp \ numdlgg.cpp \ panelg.cpp \ printps.cpp \ @@ -142,6 +143,7 @@ libwx_gtk_la_SOURCES = \ splitter.cpp \ statusbr.cpp \ tabg.cpp \ + textdlgg.cpp \ tipdlg.cpp \ treectrl.cpp \ \ @@ -157,7 +159,6 @@ libwx_gtk_la_SOURCES = \ checkbox.cpp \ checklst.cpp \ choice.cpp \ - choicdlg.cpp \ clipbrd.cpp \ colour.cpp \ combobox.cpp \ @@ -182,7 +183,6 @@ libwx_gtk_la_SOURCES = \ mdi.cpp \ menu.cpp \ minifram.cpp \ - msgdlg.cpp \ notebook.cpp \ palette.cpp \ pen.cpp \ @@ -199,7 +199,6 @@ libwx_gtk_la_SOURCES = \ stattext.cpp \ tbargtk.cpp \ textctrl.cpp \ - textdlg.cpp \ timer.cpp \ tooltip.cpp \ utilsgtk.cpp \ diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index e109966054..2bb626f031 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -97,8 +97,17 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font ); wxSize newSize = size; - if (newSize.x == -1) newSize.x = 12+x; - if (newSize.y == -1) newSize.y = 11+y; + if (newSize.x == -1) + { + newSize.x = 12+x; + if (newSize.x < 80) newSize.x = 80; + } + if (newSize.y == -1) + { + newSize.y = 11+y; + if (newSize.x < 26) newSize.x = 26; + } + SetSize( newSize.x, newSize.y ); gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", diff --git a/src/gtk1/choicdlg.cpp b/src/gtk1/choicdlg.cpp deleted file mode 100644 index 177457ad54..0000000000 --- a/src/gtk1/choicdlg.cpp +++ /dev/null @@ -1,332 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: choicdgg.cpp -// Purpose: Choice dialogs -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ - #pragma implementation "choicdgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include - #include "wx/utils.h" - #include "wx/dialog.h" - #include "wx/button.h" - #include "wx/listbox.h" - #include "wx/stattext.h" - #include "wx/intl.h" - #include "wx/sizer.h" -#endif - -#if wxUSE_STATLINE - #include "wx/statline.h" -#endif - -#include "wx/gtk/choicdlg.h" - -static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer ) -{ - wxString line; - for (size_t pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line ); - sizer->Add( s1 ); - line = _T(""); - } - } - else - { - line += message[pos]; - } - } - - // remaining text behind last '\n' - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line ); - sizer->Add( s2 ); - } -} - - -wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n, - const wxString *choices, wxWindow *parent, - int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxSingleChoiceDialog dialog(parent, message, caption, n, choices); - if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetStringSelection(); - else - return _T(""); -} - -// Overloaded for backward compatibility -wxString wxGetSingleChoice( const wxString& message, const wxString& caption, int n, - char *choices[], wxWindow *parent, - int x, int y, bool centre, - int width, int height ) -{ - wxString *strings = new wxString[n]; - int i; - for ( i = 0; i < n; i++) - { - strings[i] = choices[i]; - } - wxString ans(wxGetSingleChoice(message, caption, n, (const wxString *)strings, parent, - x, y, centre, width, height)); - delete[] strings; - return ans; -} - -int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n, - const wxString *choices, wxWindow *parent, - int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxSingleChoiceDialog dialog(parent, message, caption, n, choices); - if ( dialog.ShowModal() == wxID_OK ) - return dialog.GetSelection(); - else - return -1; -} - -// Overloaded for backward compatibility -int wxGetSingleChoiceIndex( const wxString& message, const wxString& caption, int n, - wxChar *choices[], wxWindow *parent, - int x, int y, bool centre, - int width, int height ) -{ - wxString *strings = new wxString[n]; - for ( int i = 0; i < n; i++) - strings[i] = choices[i]; - int ans = wxGetSingleChoiceIndex(message, caption, n, (const wxString *)strings, parent, - x, y, centre, width, height); - delete[] strings; - return ans; -} - -wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n, - const wxString *choices, char **client_data, wxWindow *parent, - int WXUNUSED(x), int WXUNUSED(y), bool WXUNUSED(centre), - int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data); - if ( dialog.ShowModal() == wxID_OK ) - return (wxChar *)dialog.GetSelectionClientData(); - else - return NULL; -} - -// Overloaded for backward compatibility -wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption, int n, - wxChar *choices[], char **client_data, wxWindow *parent, - int x, int y, bool centre, - int width, int height ) -{ - wxString *strings = new wxString[n]; - int i; - for ( i = 0; i < n; i++) - { - strings[i] = choices[i]; - } - wxChar *data = wxGetSingleChoiceData(message, caption, n, (const wxString *)strings, client_data, parent, - x, y, centre, width, height); - delete[] strings; - return data; -} - - -/* Multiple choice dialog contributed by Robert Cowell - * - -The new data passed are in the "int nsel" and "int * selection" - -The idea is to make a multiple selection from list of strings. -The returned value is the total number selected. initialily there -are nsel selected, with indices stored in -selection[0],...,selection[nsel-1] which appear highlighted to -begin with. On exit with value i -selection[0..i-1] contains the indices of the selected items. -(Some prior selectecions might be deselected.) -Thus selection must be as big as choices, in case all items are -selected. - -*/ -/* -int wxGetMultipleChoice(const wxString& message, const wxString& caption, - int n, const wxString *choices, - int nsel, int * selection, - wxWindow *parent , int x , int y, bool centre, - int width, int height) -{ - return -1; -} -*/ - -// wxSingleChoiceDialog - -#if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxSingleChoiceDialog, wxDialog) - EVT_BUTTON(wxID_OK, wxSingleChoiceDialog::OnOK) - EVT_LISTBOX_DCLICK(wxID_LISTBOX, wxSingleChoiceDialog::OnListBoxDClick) -END_EVENT_TABLE() - -IMPLEMENT_CLASS(wxSingleChoiceDialog, wxDialog) -#endif - -wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - int n, const wxString *choices, char **clientData, long style, const wxPoint& pos): - wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxDIALOG_MODAL|wxTAB_TRAVERSAL) -{ - Create(parent, message, caption, n, choices, clientData, style); -} - -wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData, long style, const wxPoint& pos): - wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL) -{ - Create(parent, message, caption, choices, clientData, style); -} - -bool wxSingleChoiceDialog::Create(wxWindow *parent, const wxString& message, const wxString& caption, - const wxStringList& choices, char **clientData, long style, const wxPoint& pos) -{ - wxString *strings = new wxString[choices.Number()]; - int i; - for ( i = 0; i < choices.Number(); i++) - { - strings[i] = (char *)choices.Nth(i)->Data(); - } - bool ans = Create(parent, message, caption, choices.Number(), strings, clientData, style, pos); - delete[] strings; - return ans; -} - -bool wxSingleChoiceDialog::Create( wxWindow *WXUNUSED(parent), const wxString& message, - const wxString& WXUNUSED(caption), int n, - const wxString *choices, char **clientData, long style, - const wxPoint& WXUNUSED(pos) ) -{ - m_dialogStyle = style; - m_selection = 0; - m_stringSelection = _T(""); - m_clientData = NULL; - - wxBeginBusyCursor(); - - wxBox *topsizer = new wxBox( wxVERTICAL ); - - // 1) text message - wxBox *textsizer = new wxBox( wxVERTICAL ); - wxSplitMessage2( message, this, textsizer ); - topsizer->Add( textsizer, 0, wxALL, 10 ); - - // 2) list box - wxListBox *listBox = new wxListBox( this, wxID_LISTBOX, wxDefaultPosition, wxSize(160,100) , - n, choices, wxLB_ALWAYS_SB ); - listBox->SetSelection( m_selection ); - if (clientData) - { - for (int i = 0; i < n; i++) - listBox->SetClientData(i, clientData[i]); - } - topsizer->Add( listBox, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); - - -#if wxUSE_STATLINE - // 3) static line - topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); -#endif - - - // 4) buttons - wxBox *buttonsizer = new wxBox( wxHORIZONTAL ); - - wxButton *ok = (wxButton *) NULL; - if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK") ); - buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 ); - } - - wxButton *cancel = (wxButton *) NULL; - if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); - buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 ); - } - - topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - SetSizer( topsizer ); - SetAutoLayout( TRUE ); - - Centre( wxBOTH ); - - if (ok) - ok->SetDefault(); - - listBox->SetFocus(); - - wxEndBusyCursor(); - - return TRUE; -} - -// Set the selection -void wxSingleChoiceDialog::SetSelection(int sel) -{ - wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); - if (listBox) - { - listBox->SetSelection(sel); - } - m_selection = sel; -} - -void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event)) -{ - wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); - if ( listBox ) - { - m_selection = listBox->GetSelection(); - m_stringSelection = listBox->GetStringSelection(); - m_clientData = listBox->GetClientData(m_selection); - } - - EndModal(wxID_OK); -} - -void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event)) -{ - wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX); - if ( listBox ) - { - m_selection = listBox->GetSelection(); - m_stringSelection = listBox->GetStringSelection(); - m_clientData = listBox->GetClientData(m_selection); - } - - EndModal(wxID_OK); -} - diff --git a/src/gtk1/makefile.unx.in b/src/gtk1/makefile.unx.in index 2089c71ef0..ebbd715dd8 100644 --- a/src/gtk1/makefile.unx.in +++ b/src/gtk1/makefile.unx.in @@ -11,7 +11,7 @@ # # # -# This file was automatically generated by tmake at 19:48, 1999/08/10 +# This file was automatically generated by tmake at 09:46, 1999/08/11 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs GTK_GENERICOBJS = \ ../generic/busyinfo.o \ ../generic/caret.o \ + ../generic/choicdgg.o \ ../generic/colrdlgg.o \ ../generic/dirdlgg.o \ - ../generic/extdlgg.o \ ../generic/fontdlgg.o \ ../generic/gridg.o \ ../generic/imaglist.o \ @@ -123,6 +123,7 @@ GTK_GENERICOBJS = \ ../generic/scrolwin.o \ ../generic/splitter.o \ ../generic/statusbr.o \ + ../generic/textdlgg.o \ ../generic/tipdlg.o \ ../generic/treectrl.o @@ -216,7 +217,6 @@ GTK_GUIOBJS = \ ../gtk/button.o \ ../gtk/checkbox.o \ ../gtk/checklst.o \ - ../gtk/choicdlg.o \ ../gtk/choice.o \ ../gtk/clipbrd.o \ ../gtk/colour.o \ @@ -260,7 +260,6 @@ GTK_GUIOBJS = \ ../gtk/stattext.o \ ../gtk/tbargtk.o \ ../gtk/textctrl.o \ - ../gtk/textdlg.o \ ../gtk/timer.o \ ../gtk/tooltip.o \ ../gtk/utilsgtk.o \ @@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \ ../generic/choicdgg.o \ ../generic/colrdlgg.o \ ../generic/dirdlgg.o \ - ../generic/extdlgg.o \ ../generic/fontdlgg.o \ ../generic/gridg.o \ ../generic/helpxlp.o \ diff --git a/src/gtk1/msgdlg.cpp b/src/gtk1/msgdlg.cpp deleted file mode 100644 index 212f62da5a..0000000000 --- a/src/gtk1/msgdlg.cpp +++ /dev/null @@ -1,197 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: msgdlgg.cpp -// Purpose: wxGenericMessageDialog -// Author: Julian Smart, Robert Roebling -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "msgdlgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/utils.h" -#include "wx/dialog.h" -#include "wx/listbox.h" -#include "wx/button.h" -#include "wx/statbmp.h" -#include "wx/stattext.h" -#include "wx/layout.h" -#include "wx/intl.h" -#include "wx/bitmap.h" -#include "wx/app.h" -#endif - -#include -#include - -#include "wx/gtk/msgdlg.h" -#include "wx/statline.h" - -/////////////////////////////////////////////////////////////////// -// New dialog box implementations - -// Split message, using constraints to position controls -wxSize wxSplitMessage2( const wxString &message, wxWindow *parent, int text_pos_x ) -{ - int y = 15; - int w = 50; - wxString line( _T("") ); - for (uint pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) ); - wxSize size1( s1->GetSize() ); - if (size1.x > w) w = size1.x; - line = _T(""); - } - y += 18; - } - else - { - line += message[pos]; - } - } - - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line, wxPoint(text_pos_x,y) ); - wxSize size2( s2->GetSize() ); - if (size2.x > w) w = size2.x; - } - - y += 18; - - return wxSize(w+15+text_pos_x,y); -} - -#if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxGenericMessageDialog, wxDialog) - EVT_BUTTON(wxID_YES, wxGenericMessageDialog::OnYes) - EVT_BUTTON(wxID_NO, wxGenericMessageDialog::OnNo) - EVT_BUTTON(wxID_CANCEL, wxGenericMessageDialog::OnCancel) -END_EVENT_TABLE() - -IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog) -#endif - -wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message, - const wxString& caption, long style, const wxPoint& pos) : - wxDialog( parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ) -{ - m_dialogStyle = style; - - int text_pos_x = 15; - - if (m_dialogStyle & wxICON_MASK) - text_pos_x += 80; - - wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) ); - - if (m_dialogStyle & wxICON_MASK) - { - if (message_size.y < 50) message_size.y = 50; - (void) new wxStaticBitmap( this, -1, - wxTheApp->GetStdIcon(m_dialogStyle - & wxICON_MASK), - wxPoint(15,message_size.y/2-16) ); - } - - wxButton *ok = (wxButton *) NULL; - wxButton *cancel = (wxButton *) NULL; - wxButton *yes = (wxButton *) NULL; - wxButton *no = (wxButton *) NULL; - - int y = message_size.y + 30; - - if (style & wxYES_NO) - { - yes = new wxButton( this, wxID_YES, _("Yes"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( yes ); - no = new wxButton( this, wxID_NO, _("No"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( no ); - } - - if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( ok ); - } - - if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxPoint(-1,y), wxSize(80,-1) ); - m_buttons.Append( cancel ); - } - - if (ok) - { - ok->SetDefault(); - ok->SetFocus(); - } - else if (yes) - { - yes->SetDefault(); - yes->SetFocus(); - } - - int w = m_buttons.GetCount() * 100; - if (message_size.x > w) w = message_size.x; - int space = w / (m_buttons.GetCount()*2); - - int n = 0; - wxNode *node = m_buttons.First(); - while (node) - { - wxWindow *win = (wxWindow*)node->Data(); - int x = (n*2+1)*space - 40 + 15; - win->Move( x, -1 ); - node = node->Next(); - n++; - } - -#ifdef __WXGTK__ - int edge_margin = 7; - (void) new wxStaticLine( this, -1, wxPoint(edge_margin,y-20), wxSize(w+30-2*edge_margin, 5) ); -#endif - - SetSize( w+30, y+40 ); - - Centre( wxBOTH ); -} - -void wxGenericMessageDialog::OnYes(wxCommandEvent& WXUNUSED(event)) -{ - EndModal( wxID_YES ); -} - -void wxGenericMessageDialog::OnNo(wxCommandEvent& WXUNUSED(event)) -{ - EndModal( wxID_NO ); -} - -void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) -{ - /* Allow cancellation via ESC/Close button except if - only YES and NO are specified. */ - if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) ) - { - EndModal( wxID_CANCEL ); - } -} - - diff --git a/src/gtk1/textdlg.cpp b/src/gtk1/textdlg.cpp deleted file mode 100644 index c4cbd59af0..0000000000 --- a/src/gtk1/textdlg.cpp +++ /dev/null @@ -1,146 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: textdlgg.cpp -// Purpose: wxTextEntryDialog -// Author: Julian Smart -// Modified by: -// Created: 04/01/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "textdlgg.h" -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include - #include "wx/utils.h" - #include "wx/dialog.h" - #include "wx/button.h" - #include "wx/stattext.h" - #include "wx/textctrl.h" - #include "wx/intl.h" - #include "wx/sizer.h" -#endif - -#if wxUSE_STATLINE - #include "wx/statline.h" -#endif - -#include "wx/gtk/textdlg.h" - -static void wxSplitMessage2( const wxString &message, wxWindow *parent, wxSizer* sizer ) -{ - wxString line; - for (size_t pos = 0; pos < message.Len(); pos++) - { - if (message[pos] == _T('\n')) - { - if (!line.IsEmpty()) - { - wxStaticText *s1 = new wxStaticText( parent, -1, line ); - sizer->Add( s1 ); - line = _T(""); - } - } - else - { - line += message[pos]; - } - } - - // remaining text behind last '\n' - if (!line.IsEmpty()) - { - wxStaticText *s2 = new wxStaticText( parent, -1, line ); - sizer->Add( s2 ); - } -} - -// wxTextEntryDialog - -#if !USE_SHARED_LIBRARY -BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog) - EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK) -END_EVENT_TABLE() - -IMPLEMENT_CLASS(wxTextEntryDialog, wxDialog) -#endif - -wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption, - const wxString& value, long style, const wxPoint& pos): - wxDialog(parent, -1, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL) -{ - m_dialogStyle = style; - m_value = value; - - wxBeginBusyCursor(); - - wxBox *topsizer = new wxBox( wxVERTICAL ); - - // 1) text message - wxBox *textsizer = new wxBox( wxVERTICAL ); - wxSplitMessage2( message, this, textsizer ); - topsizer->Add( textsizer, 0, wxALL, 10 ); - - // 2) text ctrl - wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_TEXT, value, wxDefaultPosition, wxSize(300, -1)); - topsizer->Add( textCtrl, 1, wxEXPAND | wxLEFT|wxRIGHT, 15 ); - -#if wxUSE_STATLINE - // 3) static line - topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); -#endif - - - // 4) buttons - wxBox *buttonsizer = new wxBox( wxHORIZONTAL ); - - wxButton *ok = (wxButton *) NULL; - if (style & wxOK) - { - ok = new wxButton( this, wxID_OK, _("OK") ); - buttonsizer->Add( ok, 0, wxLEFT|wxRIGHT, 10 ); - } - - wxButton *cancel = (wxButton *) NULL; - if (style & wxCANCEL) - { - cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); - buttonsizer->Add( cancel, 0, wxLEFT|wxRIGHT, 10 ); - } - - topsizer->Add( buttonsizer, 0, wxCENTRE | wxALL, 10 ); - - topsizer->SetSizeHints( this ); - topsizer->Fit( this ); - SetSizer( topsizer ); - SetAutoLayout( TRUE ); - - Centre( wxBOTH ); - - if (ok) - ok->SetDefault(); - - textCtrl->SetFocus(); - - wxEndBusyCursor(); -} - -void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) ) -{ - wxTextCtrl *textCtrl = (wxTextCtrl *)FindWindow(wxID_TEXT); - if ( textCtrl ) - m_value = textCtrl->GetValue(); - - EndModal(wxID_OK); -} - diff --git a/src/motif/makefile.unx.in b/src/motif/makefile.unx.in index 2089c71ef0..ebbd715dd8 100644 --- a/src/motif/makefile.unx.in +++ b/src/motif/makefile.unx.in @@ -11,7 +11,7 @@ # # # -# This file was automatically generated by tmake at 19:48, 1999/08/10 +# This file was automatically generated by tmake at 09:46, 1999/08/11 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -103,9 +103,9 @@ DOCDIR = $(WXDIR)/docs GTK_GENERICOBJS = \ ../generic/busyinfo.o \ ../generic/caret.o \ + ../generic/choicdgg.o \ ../generic/colrdlgg.o \ ../generic/dirdlgg.o \ - ../generic/extdlgg.o \ ../generic/fontdlgg.o \ ../generic/gridg.o \ ../generic/imaglist.o \ @@ -123,6 +123,7 @@ GTK_GENERICOBJS = \ ../generic/scrolwin.o \ ../generic/splitter.o \ ../generic/statusbr.o \ + ../generic/textdlgg.o \ ../generic/tipdlg.o \ ../generic/treectrl.o @@ -216,7 +217,6 @@ GTK_GUIOBJS = \ ../gtk/button.o \ ../gtk/checkbox.o \ ../gtk/checklst.o \ - ../gtk/choicdlg.o \ ../gtk/choice.o \ ../gtk/clipbrd.o \ ../gtk/colour.o \ @@ -260,7 +260,6 @@ GTK_GUIOBJS = \ ../gtk/stattext.o \ ../gtk/tbargtk.o \ ../gtk/textctrl.o \ - ../gtk/textdlg.o \ ../gtk/timer.o \ ../gtk/tooltip.o \ ../gtk/utilsgtk.o \ @@ -275,7 +274,6 @@ MOTIF_GENERICOBJS = \ ../generic/choicdgg.o \ ../generic/colrdlgg.o \ ../generic/dirdlgg.o \ - ../generic/extdlgg.o \ ../generic/fontdlgg.o \ ../generic/gridg.o \ ../generic/helpxlp.o \ -- 2.45.2