From 47908e25f992135fbc8c9573870784c62654e9e9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 31 Jul 1998 20:04:04 +0000 Subject: [PATCH] Added bitmaps and icons to samples Fixed event handling in all controls Add some missing functions to wxRadioBox Fixed clientData stuff to Choice (Combo?) No more gtk warning in Combo Fixed toolbar sample and mdi sample Fixed bug in AddChild resulting from mdi changes Fixed wxFrame::GetPosition() Changed order of notification calls in wxListCtrl to prevent what I think is a reentry bug The usual compile fixes here and there git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/combobox.h | 8 +- include/wx/gtk/radiobox.h | 3 + include/wx/gtk1/combobox.h | 8 +- include/wx/gtk1/radiobox.h | 3 + samples/controls/controls.cpp | 188 +++++++++++++++++++++++++--- samples/controls/mondrian.xpm | 44 +++++++ samples/dialogs/dialogs.cpp | 2 +- samples/dnd/dnd.cpp | 6 + samples/dnd/mondrian.xpm | 44 +++++++ samples/dynamic/minimal.cpp | 9 +- samples/dynamic/mondrian.xpm | 44 +++++++ samples/internat/internat.cpp | 9 +- samples/internat/mondrian.xpm | 44 +++++++ samples/mdi/bitmaps/copy.xpm | 25 ++++ samples/mdi/bitmaps/cut.xpm | 24 ++++ samples/mdi/bitmaps/help.xpm | 25 ++++ samples/mdi/bitmaps/new.xpm | 24 ++++ samples/mdi/bitmaps/open.xpm | 26 ++++ samples/mdi/bitmaps/print.xpm | 26 ++++ samples/mdi/bitmaps/save.xpm | 25 ++++ samples/mdi/mdi.cpp | 37 +++--- samples/mdi/mondrian.xpm | 44 +++++++ samples/memcheck/memcheck.cpp | 8 +- samples/memcheck/mondrian.xpm | 44 +++++++ samples/toolbar/bitmaps/copy.xpm | 25 ++++ samples/toolbar/bitmaps/cut.xpm | 24 ++++ samples/toolbar/bitmaps/help.xpm | 25 ++++ samples/toolbar/bitmaps/new.xpm | 24 ++++ samples/toolbar/bitmaps/open.xpm | 26 ++++ samples/toolbar/bitmaps/preview.xpm | 26 ++++ samples/toolbar/bitmaps/print.xpm | 26 ++++ samples/toolbar/bitmaps/save.xpm | 25 ++++ samples/toolbar/mondrian.xpm | 44 +++++++ samples/toolbar/test.cpp | 49 ++++---- samples/treectrl/mondrian.xpm | 44 +++++++ samples/treectrl/treetest.cpp | 9 +- src/generic/listctrl.cpp | 20 +-- src/gtk/bmpbuttn.cpp | 5 +- src/gtk/button.cpp | 5 +- src/gtk/checkbox.cpp | 5 +- src/gtk/choice.cpp | 19 +-- src/gtk/combobox.cpp | 76 +++++++++-- src/gtk/frame.cpp | 27 +++- src/gtk/listbox.cpp | 7 +- src/gtk/radiobox.cpp | 59 +++++++-- src/gtk/scrolbar.cpp | 2 +- src/gtk/textctrl.cpp | 3 +- src/gtk/window.cpp | 15 +-- src/gtk1/bmpbuttn.cpp | 5 +- src/gtk1/button.cpp | 5 +- src/gtk1/checkbox.cpp | 5 +- src/gtk1/choice.cpp | 19 +-- src/gtk1/combobox.cpp | 76 +++++++++-- src/gtk1/frame.cpp | 27 +++- src/gtk1/listbox.cpp | 7 +- src/gtk1/radiobox.cpp | 59 +++++++-- src/gtk1/scrolbar.cpp | 2 +- src/gtk1/textctrl.cpp | 3 +- src/gtk1/window.cpp | 15 +-- user/wxFile/wxFile.cpp | 2 + user/wxLayout/wxllist.h | 9 +- user/wxLayout/wxlwindow.h | 2 + 62 files changed, 1352 insertions(+), 194 deletions(-) create mode 100644 samples/controls/mondrian.xpm create mode 100644 samples/dnd/mondrian.xpm create mode 100644 samples/dynamic/mondrian.xpm create mode 100644 samples/internat/mondrian.xpm create mode 100644 samples/mdi/bitmaps/copy.xpm create mode 100644 samples/mdi/bitmaps/cut.xpm create mode 100644 samples/mdi/bitmaps/help.xpm create mode 100644 samples/mdi/bitmaps/new.xpm create mode 100644 samples/mdi/bitmaps/open.xpm create mode 100644 samples/mdi/bitmaps/print.xpm create mode 100644 samples/mdi/bitmaps/save.xpm create mode 100644 samples/mdi/mondrian.xpm create mode 100644 samples/memcheck/mondrian.xpm create mode 100644 samples/toolbar/bitmaps/copy.xpm create mode 100644 samples/toolbar/bitmaps/cut.xpm create mode 100644 samples/toolbar/bitmaps/help.xpm create mode 100644 samples/toolbar/bitmaps/new.xpm create mode 100644 samples/toolbar/bitmaps/open.xpm create mode 100644 samples/toolbar/bitmaps/preview.xpm create mode 100644 samples/toolbar/bitmaps/print.xpm create mode 100644 samples/toolbar/bitmaps/save.xpm create mode 100644 samples/toolbar/mondrian.xpm create mode 100644 samples/treectrl/mondrian.xpm diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index 28a906f941..1215f6a85d 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -76,6 +76,7 @@ class wxComboBox: public wxControl wxString GetStringSelection(void) const; int Number(void) const; void SetSelection( int n ); + void SetStringSelection( const wxString &string ); // Text field functions wxString GetValue(void) const ; @@ -96,8 +97,11 @@ class wxComboBox: public wxControl private: - wxList m_clientData; - + wxList m_clientData; + + public: + + bool m_alreadySent; }; #endif // __GTKCOMBOBOXH__ diff --git a/include/wx/gtk/radiobox.h b/include/wx/gtk/radiobox.h index f648659e65..c1218fc449 100644 --- a/include/wx/gtk/radiobox.h +++ b/include/wx/gtk/radiobox.h @@ -79,6 +79,9 @@ class wxRadioBox: public wxControl GtkRadioButton *m_radio; + public: + + bool m_alreadySent; }; #endif // __GTKRADIOBOXH__ diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h index 28a906f941..1215f6a85d 100644 --- a/include/wx/gtk1/combobox.h +++ b/include/wx/gtk1/combobox.h @@ -76,6 +76,7 @@ class wxComboBox: public wxControl wxString GetStringSelection(void) const; int Number(void) const; void SetSelection( int n ); + void SetStringSelection( const wxString &string ); // Text field functions wxString GetValue(void) const ; @@ -96,8 +97,11 @@ class wxComboBox: public wxControl private: - wxList m_clientData; - + wxList m_clientData; + + public: + + bool m_alreadySent; }; #endif // __GTKCOMBOBOXH__ diff --git a/include/wx/gtk1/radiobox.h b/include/wx/gtk1/radiobox.h index f648659e65..c1218fc449 100644 --- a/include/wx/gtk1/radiobox.h +++ b/include/wx/gtk1/radiobox.h @@ -79,6 +79,9 @@ class wxRadioBox: public wxControl GtkRadioButton *m_radio; + public: + + bool m_alreadySent; }; #endif // __GTKRADIOBOXH__ diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 7ecbdf18d9..3f805cc9fe 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -26,6 +26,10 @@ #include "wx/notebook.h" +#ifdef __WXGTK__ +#include "mondrian.xpm" +#endif + //---------------------------------------------------------------------- // class definitions //---------------------------------------------------------------------- @@ -45,10 +49,17 @@ class MyPanel: public wxPanel void OnSize( wxSizeEvent& event ); void OnListBox( wxCommandEvent &event ); void OnListBoxButtons( wxCommandEvent &event ); + void OnChoice( wxCommandEvent &event ); + void OnChoiceButtons( wxCommandEvent &event ); + void OnCombo( wxCommandEvent &event ); + void OnComboButtons( wxCommandEvent &event ); + void OnRadio( wxCommandEvent &event ); + void OnRadioButtons( wxCommandEvent &event ); wxListBox *m_listbox; wxChoice *m_choice; wxComboBox *m_combo; + wxRadioBox *m_radio; wxTextCtrl *m_text; wxNotebook *m_notebook; @@ -93,9 +104,8 @@ bool MyApp::OnInit(void) // Give it an icon #ifdef __WXMSW__ frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef __X__ - frame->SetIcon(wxIcon("aiai.xbm")); +#else + frame->SetIcon(wxIcon( mondrian_xpm )); #endif wxMenu *file_menu = new wxMenu; @@ -132,9 +142,17 @@ const ID_CHOICE_CLEAR = 123; const ID_CHOICE_APPEND = 124; const ID_COMBO = 140; +const ID_COMBO_SEL_NUM = 141; +const ID_COMBO_SEL_STR = 142; +const ID_COMBO_CLEAR = 143; +const ID_COMBO_APPEND = 144; const ID_TEXT = 150; +const ID_RADIOBOX = 160; +const ID_RADIOBOX_SEL_NUM = 161; +const ID_RADIOBOX_SEL_STR = 162; + BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_SIZE ( MyPanel::OnSize) EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) @@ -142,6 +160,19 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons) + EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice) + EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons) + EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons) + EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons) + EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons) + EVT_CHOICE (ID_COMBO, MyPanel::OnCombo) + EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons) + EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons) + EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons) + EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons) + EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio) + EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons) + EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons) END_EVENT_TABLE() MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : @@ -154,18 +185,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : wxString choices[] = { "This", - "is", - "a", - "wonderfull example.", - "Or", - "what", - "do", - "you", - "think?" + "is a", + "wonderfull", + "example.", }; wxPanel *panel = new wxPanel(m_notebook); - m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 9, choices ); + m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 4, choices ); (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) ); (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) ); (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) ); @@ -173,15 +199,29 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : m_notebook->AddPage(panel, "wxList"); panel = new wxPanel(m_notebook); - m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 9, choices ); + m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 4, choices ); + (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) ); + (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) ); + (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) ); + (void)new wxButton( panel, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) ); m_notebook->AddPage(panel, "wxChoice"); panel = new wxPanel(m_notebook); - m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 9, choices ); + m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(170,-1), 4, choices ); + (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) ); + (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) ); + (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) ); + (void)new wxButton( panel, ID_COMBO_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) ); m_notebook->AddPage(panel, "wxComboBox"); wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE ); m_notebook->AddPage( text, "wxTextCtrl" ); + + panel = new wxPanel(m_notebook); + m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 4, choices ); + (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(200,30), wxSize(100,30) ); + (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(200,80), wxSize(100,30) ); + m_notebook->AddPage(panel, "wxRadioBox"); } void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) @@ -196,16 +236,128 @@ void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) void MyPanel::OnListBox( wxCommandEvent &event ) { - m_text->WriteText( "ListBox Event:\n"); m_text->WriteText( "ListBox selection string is: " ); m_text->WriteText( event.GetString() ); m_text->WriteText( "\n" ); } -void MyPanel::OnListBoxButtons( wxCommandEvent &WXUNUSED(event) ) +void MyPanel::OnListBoxButtons( wxCommandEvent &event ) +{ + switch (event.GetId()) + { + case ID_LISTBOX_SEL_NUM: + { + m_listbox->SetSelection( 2 ); + break; + } + case ID_LISTBOX_SEL_STR: + { + m_listbox->SetStringSelection( "This" ); + break; + } + case ID_LISTBOX_CLEAR: + { + m_listbox->Clear(); + break; + } + case ID_LISTBOX_APPEND: + { + m_listbox->Append( "Hi!" ); + break; + } + } +} + +void MyPanel::OnChoice( wxCommandEvent &event ) +{ + m_text->WriteText( "Choice selection string is: " ); + m_text->WriteText( event.GetString() ); + m_text->WriteText( "\n" ); +} + +void MyPanel::OnChoiceButtons( wxCommandEvent &event ) +{ + switch (event.GetId()) + { + case ID_CHOICE_SEL_NUM: + { + m_choice->SetSelection( 2 ); + break; + } + case ID_CHOICE_SEL_STR: + { + m_choice->SetStringSelection( "This" ); + break; + } + case ID_CHOICE_CLEAR: + { + m_choice->Clear(); + break; + } + case ID_CHOICE_APPEND: + { + m_choice->Append( "Hi!" ); + break; + } + } +} + +void MyPanel::OnCombo( wxCommandEvent &event ) +{ + m_text->WriteText( "ComboBox selection string is: " ); + m_text->WriteText( event.GetString() ); + m_text->WriteText( "\n" ); +} + +void MyPanel::OnComboButtons( wxCommandEvent &event ) { - if (m_notebook->GetPageCount() > 1) - m_notebook->DeletePage( 1 ); + switch (event.GetId()) + { + case ID_COMBO_SEL_NUM: + { + m_combo->SetSelection( 2 ); + break; + } + case ID_COMBO_SEL_STR: + { + m_combo->SetStringSelection( "This" ); + break; + } + case ID_COMBO_CLEAR: + { + m_combo->Clear(); + break; + } + case ID_COMBO_APPEND: + { + m_combo->Append( "Hi!" ); + break; + } + } +} + +void MyPanel::OnRadio( wxCommandEvent &event ) +{ + m_text->WriteText( "RadioBox selection string is: " ); + m_text->WriteText( event.GetString() ); + m_text->WriteText( "\n" ); +} + +void MyPanel::OnRadioButtons( wxCommandEvent &event ) +{ + switch (event.GetId()) + { + case ID_RADIOBOX_SEL_NUM: + { + m_radio->SetSelection( 2 ); + break; + } + case ID_RADIOBOX_SEL_STR: + { + m_radio->SetStringSelection( "This" ); + break; + } + } } //---------------------------------------------------------------------- diff --git a/samples/controls/mondrian.xpm b/samples/controls/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/controls/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 7a501ba5ef..0d8fd9a363 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -50,7 +50,7 @@ IMPLEMENT_WXWIN_MAIN bool MyApp::OnInit(void) { m_canvasTextColour = wxColour("BLACK"); - m_canvasFont = *wxNORMAL_FONT; + m_canvasFont = *wxSWISS_FONT; // Create the main frame window MyFrame *frame = new MyFrame(NULL, "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300)); diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 9c61559838..53f2c43f12 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -24,6 +24,10 @@ #include "wx/dnd.h" +#ifdef __WXGTK__ +#include "mondrian.xpm" +#endif + // ---------------------------------------------------------------------------- // Derive 2 simple classes which just put in the listbox the strings (text or // file names) we drop on them @@ -142,6 +146,8 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) #ifdef __WXMSW__ // frame icon and status bar SetIcon(wxIcon("mondrian")); +#else + SetIcon(wxIcon(mondrian_xpm)); #endif const int widths[] = { -1 }; diff --git a/samples/dnd/mondrian.xpm b/samples/dnd/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/dnd/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/dynamic/minimal.cpp b/samples/dynamic/minimal.cpp index 50b45ca0bd..393cc37957 100644 --- a/samples/dynamic/minimal.cpp +++ b/samples/dynamic/minimal.cpp @@ -25,6 +25,10 @@ #include "wx/wx.h" #endif +#ifdef __WXGTK__ +#include "mondrian.xpm" +#endif + // Define a new application type class MyApp: public wxApp { public: @@ -62,9 +66,8 @@ bool MyApp::OnInit(void) // Give it an icon #ifdef __WXMSW__ frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef __X__ - frame->SetIcon(wxIcon("aiai.xbm")); +#else + frame->SetIcon(wxIcon(mondrian_xpm)); #endif // Make a menubar diff --git a/samples/dynamic/mondrian.xpm b/samples/dynamic/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/dynamic/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/internat/internat.cpp b/samples/internat/internat.cpp index 265dd57e67..6e669da1a8 100644 --- a/samples/internat/internat.cpp +++ b/samples/internat/internat.cpp @@ -29,6 +29,10 @@ #include "wx/file.h" #include "wx/log.h" +#ifdef __WXGTK__ +#include "mondrian.xpm" +#endif + // Define a new application type class MyApp: public wxApp { @@ -100,9 +104,8 @@ bool MyApp::OnInit(void) // Give it an icon #ifdef __WXMSW__ frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef __X__ - frame->SetIcon(wxIcon("aiai.xbm")); +#else + frame->SetIcon(wxIcon(mondrian_xpm)); #endif // Make a menubar diff --git a/samples/internat/mondrian.xpm b/samples/internat/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/internat/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/mdi/bitmaps/copy.xpm b/samples/mdi/bitmaps/copy.xpm new file mode 100644 index 0000000000..47565c1cae --- /dev/null +++ b/samples/mdi/bitmaps/copy.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *copy_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Gray100", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXX.. ", +" .XXXX.X. ", +" .X..X.oooooo ", +" .XXXXXoXXXXoo ", +" .X....oXXXXoXo ", +" .XXXXXoX..Xoooo", +" .X....oXXXXXXXo", +" .XXXXXoX.....Xo", +" ......oXXXXXXXo", +" oX.....Xo", +" oXXXXXXXo", +" ooooooooo", +" " +}; diff --git a/samples/mdi/bitmaps/cut.xpm b/samples/mdi/bitmaps/cut.xpm new file mode 100644 index 0000000000..bfe7e95cea --- /dev/null +++ b/samples/mdi/bitmaps/cut.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *cut_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +" c None", +". c Black", +"X c #000080", +/* pixels */ +" ", +" . . ", +" . . ", +" . . ", +" .. .. ", +" . . ", +" ... ", +" . ", +" X.X ", +" X XXX ", +" XXX X X ", +" X X X X ", +" X X X X ", +" X X XX ", +" XX " +}; diff --git a/samples/mdi/bitmaps/help.xpm b/samples/mdi/bitmaps/help.xpm new file mode 100644 index 0000000000..50fdb4157e --- /dev/null +++ b/samples/mdi/bitmaps/help.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *help_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Blue", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXXX.. ", +" .XX...oX.. ", +" .X.. .X.. ", +" .X.. .XX.. ", +" .. .XX.. ", +" .XX.. ", +" .X.. ", +" .X.. ", +" .o.. ", +" .. ", +" .XX.. ", +" .XX.. ", +" ... " +}; diff --git a/samples/mdi/bitmaps/new.xpm b/samples/mdi/bitmaps/new.xpm new file mode 100644 index 0000000000..754d2d20a2 --- /dev/null +++ b/samples/mdi/bitmaps/new.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *new_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +/* pixels */ +" ", +" ........ ", +" .XXXXXX.. ", +" .XXXXXX.X. ", +" .XXXXXX.... ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" ........... ", +" " +}; diff --git a/samples/mdi/bitmaps/open.xpm b/samples/mdi/bitmaps/open.xpm new file mode 100644 index 0000000000..54748e910d --- /dev/null +++ b/samples/mdi/bitmaps/open.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *open_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"X c Yellow", +"o c Gray100", +"O c #bfbf00", +/* pixels */ +" ", +" ... ", +" . . .", +" ..", +" ... ...", +" .XoX....... ", +" .oXoXoXoXo. ", +" .XoXoXoXoX. ", +" .oXoX..........", +" .XoX.OOOOOOOOO.", +" .oo.OOOOOOOOO. ", +" .X.OOOOOOOOO. ", +" ..OOOOOOOOO. ", +" ........... ", +" " +}; diff --git a/samples/mdi/bitmaps/print.xpm b/samples/mdi/bitmaps/print.xpm new file mode 100644 index 0000000000..3c2e2be781 --- /dev/null +++ b/samples/mdi/bitmaps/print.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *print_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"X c Gray100", +"o c #808000", +"O c Yellow", +/* pixels */ +" ", +" ......... ", +" .XXXXXXXX. ", +" .X.....X. ", +" .XXXXXXXX. ", +" .X.....X.... ", +" .XXXXXXXX. . .", +" .......... . ..", +". . . .", +"............. .", +". ooo . . ", +". OOO ... ", +"............. . ", +" . . . ", +" ........... " +}; diff --git a/samples/mdi/bitmaps/save.xpm b/samples/mdi/bitmaps/save.xpm new file mode 100644 index 0000000000..01b18f9340 --- /dev/null +++ b/samples/mdi/bitmaps/save.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *save_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c #808000", +"o c #808080", +/* pixels */ +" ", +" .............. ", +" .X. . . ", +" .X. ... ", +" .X. .X. ", +" .X. .X. ", +" .X. .X. ", +" .X. .X. ", +" .XX........oX. ", +" .XXXXXXXXXXXX. ", +" .XX.........X. ", +" .XX...... .X. ", +" .XX...... .X. ", +" .XX...... .X. ", +" ............. " +}; diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index dfcfa0bb4b..342f52299d 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -24,9 +24,19 @@ #include #ifdef __WXGTK__ -#include "folder.xpm" +#include "mondrian.xpm" +#include "bitmaps/new.xpm" +#include "bitmaps/open.xpm" +#include "bitmaps/save.xpm" +#include "bitmaps/copy.xpm" +#include "bitmaps/cut.xpm" +// #include "bitmaps/paste.xpm" +#include "bitmaps/print.xpm" +#include "bitmaps/preview.xpm" +#include "bitmaps/help.xpm" #endif + #include "mdi.h" MyFrame *frame = NULL; @@ -52,9 +62,6 @@ bool MyApp::OnInit(void) #ifdef __WXMSW__ frame->SetIcon(wxIcon("mdi_icn")); #endif -#ifdef __X__ - frame->SetIcon(wxIcon("aiai.xbm")); -#endif // Make a menubar wxMenu *file_menu = new wxMenu; @@ -136,9 +143,8 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) // Give it an icon (this is ignored in MDI mode: uses resources) #ifdef __WXMSW__ subframe->SetIcon(wxIcon("chrt_icn")); -#endif -#ifdef __X__ - subframe->SetIcon(wxIcon("aiai.xbm")); +#else + subframe->SetIcon(wxIcon(mondrian_xpm)); #endif // Give it a status line @@ -311,14 +317,15 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) bitmaps[6] = new wxBitmap("icon7", wxBITMAP_TYPE_RESOURCE); bitmaps[7] = new wxBitmap("icon8", wxBITMAP_TYPE_RESOURCE); #else - bitmaps[0] = new wxBitmap( folder_xpm ); - bitmaps[1] = new wxBitmap( folder_xpm ); - bitmaps[2] = new wxBitmap( folder_xpm ); - bitmaps[3] = new wxBitmap( folder_xpm ); - bitmaps[4] = new wxBitmap( folder_xpm ); - bitmaps[5] = new wxBitmap( folder_xpm ); - bitmaps[6] = new wxBitmap( folder_xpm ); - bitmaps[7] = new wxBitmap( folder_xpm ); + bitmaps[0] = new wxBitmap( new_xpm ); + bitmaps[1] = new wxBitmap( open_xpm ); + bitmaps[2] = new wxBitmap( save_xpm ); + bitmaps[3] = new wxBitmap( copy_xpm ); + bitmaps[4] = new wxBitmap( cut_xpm ); +// bitmaps[5] = new wxBitmap( paste_xpm ); + bitmaps[5] = new wxBitmap( preview_xpm ); + bitmaps[6] = new wxBitmap( print_xpm ); + bitmaps[7] = new wxBitmap( help_xpm ); #endif #ifdef __WXMSW__ diff --git a/samples/mdi/mondrian.xpm b/samples/mdi/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/mdi/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/memcheck/memcheck.cpp b/samples/memcheck/memcheck.cpp index 805b315945..026f8d0532 100644 --- a/samples/memcheck/memcheck.cpp +++ b/samples/memcheck/memcheck.cpp @@ -27,6 +27,10 @@ #include "wx/date.h" +#ifdef __WXGTK__ +#include "mondrian.xpm" +#endif + #if !WXDEBUG #error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK) #endif @@ -59,9 +63,7 @@ bool MyApp::OnInit(void) // Give it an icon #ifdef wx_msw frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef wx_x - frame->SetIcon(wxIcon("mondrian.xbm")); + frame->SetIcon(wxIcon(mondrian_xpm)); #endif // Make a menubar diff --git a/samples/memcheck/mondrian.xpm b/samples/memcheck/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/memcheck/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/toolbar/bitmaps/copy.xpm b/samples/toolbar/bitmaps/copy.xpm new file mode 100644 index 0000000000..47565c1cae --- /dev/null +++ b/samples/toolbar/bitmaps/copy.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *copy_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Gray100", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXX.. ", +" .XXXX.X. ", +" .X..X.oooooo ", +" .XXXXXoXXXXoo ", +" .X....oXXXXoXo ", +" .XXXXXoX..Xoooo", +" .X....oXXXXXXXo", +" .XXXXXoX.....Xo", +" ......oXXXXXXXo", +" oX.....Xo", +" oXXXXXXXo", +" ooooooooo", +" " +}; diff --git a/samples/toolbar/bitmaps/cut.xpm b/samples/toolbar/bitmaps/cut.xpm new file mode 100644 index 0000000000..bfe7e95cea --- /dev/null +++ b/samples/toolbar/bitmaps/cut.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *cut_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +" c None", +". c Black", +"X c #000080", +/* pixels */ +" ", +" . . ", +" . . ", +" . . ", +" .. .. ", +" . . ", +" ... ", +" . ", +" X.X ", +" X XXX ", +" XXX X X ", +" X X X X ", +" X X X X ", +" X X XX ", +" XX " +}; diff --git a/samples/toolbar/bitmaps/help.xpm b/samples/toolbar/bitmaps/help.xpm new file mode 100644 index 0000000000..50fdb4157e --- /dev/null +++ b/samples/toolbar/bitmaps/help.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *help_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Blue", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXXX.. ", +" .XX...oX.. ", +" .X.. .X.. ", +" .X.. .XX.. ", +" .. .XX.. ", +" .XX.. ", +" .X.. ", +" .X.. ", +" .o.. ", +" .. ", +" .XX.. ", +" .XX.. ", +" ... " +}; diff --git a/samples/toolbar/bitmaps/new.xpm b/samples/toolbar/bitmaps/new.xpm new file mode 100644 index 0000000000..754d2d20a2 --- /dev/null +++ b/samples/toolbar/bitmaps/new.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *new_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +/* pixels */ +" ", +" ........ ", +" .XXXXXX.. ", +" .XXXXXX.X. ", +" .XXXXXX.... ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" ........... ", +" " +}; diff --git a/samples/toolbar/bitmaps/open.xpm b/samples/toolbar/bitmaps/open.xpm new file mode 100644 index 0000000000..54748e910d --- /dev/null +++ b/samples/toolbar/bitmaps/open.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *open_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"X c Yellow", +"o c Gray100", +"O c #bfbf00", +/* pixels */ +" ", +" ... ", +" . . .", +" ..", +" ... ...", +" .XoX....... ", +" .oXoXoXoXo. ", +" .XoXoXoXoX. ", +" .oXoX..........", +" .XoX.OOOOOOOOO.", +" .oo.OOOOOOOOO. ", +" .X.OOOOOOOOO. ", +" ..OOOOOOOOO. ", +" ........... ", +" " +}; diff --git a/samples/toolbar/bitmaps/preview.xpm b/samples/toolbar/bitmaps/preview.xpm new file mode 100644 index 0000000000..0dfdca46e1 --- /dev/null +++ b/samples/toolbar/bitmaps/preview.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *preview_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c Black", +". c None", +"X c Gray100", +"o c #808080", +"O c Cyan", +/* pixels */ +" .......", +" XXXXXXX ......", +" XXXXXXX . .....", +" XXXXXXX ....", +" XXXXXXXXXX ....", +" XXXXXXX ....", +" XXXXXX o..o ...", +" XXXXX oOO.oo ..", +" XXXXX .O..o. ..", +" XXXXX ....o. ..", +" XXXXX o..Ooo ..", +" XXXXXX o..o o..", +" XXXXXXX o .", +" XXXXXXXXXX . ", +" .. " +}; diff --git a/samples/toolbar/bitmaps/print.xpm b/samples/toolbar/bitmaps/print.xpm new file mode 100644 index 0000000000..3c2e2be781 --- /dev/null +++ b/samples/toolbar/bitmaps/print.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *print_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"X c Gray100", +"o c #808000", +"O c Yellow", +/* pixels */ +" ", +" ......... ", +" .XXXXXXXX. ", +" .X.....X. ", +" .XXXXXXXX. ", +" .X.....X.... ", +" .XXXXXXXX. . .", +" .......... . ..", +". . . .", +"............. .", +". ooo . . ", +". OOO ... ", +"............. . ", +" . . . ", +" ........... " +}; diff --git a/samples/toolbar/bitmaps/save.xpm b/samples/toolbar/bitmaps/save.xpm new file mode 100644 index 0000000000..01b18f9340 --- /dev/null +++ b/samples/toolbar/bitmaps/save.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *save_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c #808000", +"o c #808080", +/* pixels */ +" ", +" .............. ", +" .X. . . ", +" .X. ... ", +" .X. .X. ", +" .X. .X. ", +" .X. .X. ", +" .X. .X. ", +" .XX........oX. ", +" .XXXXXXXXXXXX. ", +" .XX.........X. ", +" .XX...... .X. ", +" .XX...... .X. ", +" .XX...... .X. ", +" ............. " +}; diff --git a/samples/toolbar/mondrian.xpm b/samples/toolbar/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/toolbar/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index c4b1ea21e2..842dbea3da 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -23,11 +23,21 @@ #include "wx/toolbar.h" #include "test.h" +#ifdef __WXGTK__ +#include "mondrian.xpm" +#include "bitmaps/new.xpm" +#include "bitmaps/open.xpm" +#include "bitmaps/save.xpm" +#include "bitmaps/copy.xpm" +#include "bitmaps/cut.xpm" +// #include "bitmaps/paste.xpm" +#include "bitmaps/print.xpm" +#include "bitmaps/preview.xpm" +#include "bitmaps/help.xpm" +#endif + IMPLEMENT_APP(MyApp) -#ifdef __X__ -// TODO: include XBM or XPM icons for X apps -#endif // The `main program' equivalent, creating the windows and returning the // main frame @@ -43,9 +53,8 @@ bool MyApp::OnInit(void) // Give it an icon #ifdef __WXMSW__ frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef __X__ - frame->SetIcon(wxIcon("mondrian.xbm")); +#else + frame->SetIcon( wxIcon(mondrian_xpm) ); #endif // Make a menubar @@ -96,17 +105,16 @@ bool MyApp::InitToolbar(wxToolBar* toolBar) toolBarBitmaps[5] = new wxBitmap("icon6"); toolBarBitmaps[6] = new wxBitmap("icon7"); toolBarBitmaps[7] = new wxBitmap("icon8"); -#endif -#ifdef __X__ - // TODO - toolBarBitmaps[0] = new wxBitmap(...); - toolBarBitmaps[1] = new wxBitmap(...); - toolBarBitmaps[2] = new wxBitmap(...); - toolBarBitmaps[3] = new wxBitmap(...); - toolBarBitmaps[4] = new wxBitmap(...); - toolBarBitmaps[5] = new wxBitmap(...); - toolBarBitmaps[6] = new wxBitmap(...); - toolBarBitmaps[7] = new wxBitmap(...); +#else + toolBarBitmaps[0] = new wxBitmap( new_xpm ); + toolBarBitmaps[1] = new wxBitmap( open_xpm ); + toolBarBitmaps[2] = new wxBitmap( save_xpm ); + toolBarBitmaps[3] = new wxBitmap( copy_xpm ); + toolBarBitmaps[4] = new wxBitmap( cut_xpm ); +// toolBarBitmaps[5] = new wxBitmap( paste_xpm ); + toolBarBitmaps[5] = new wxBitmap( preview_xpm ); + toolBarBitmaps[6] = new wxBitmap( print_xpm ); + toolBarBitmaps[7] = new wxBitmap( help_xpm ); #endif #ifdef __WXMSW__ @@ -114,7 +122,6 @@ bool MyApp::InitToolbar(wxToolBar* toolBar) #else int width = 16; #endif - int offX = 5; int currentX = 5; toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "New file"); @@ -164,19 +171,19 @@ MyFrame::MyFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wx m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE); } -void MyFrame::OnQuit(wxCommandEvent& event) +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); } -void MyFrame::OnAbout(wxCommandEvent& event) +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar"); } // Define the behaviour for the frame closing // - must delete all frames except for the main one. -void MyFrame::OnCloseWindow(wxCloseEvent& event) +void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { Destroy(); } diff --git a/samples/treectrl/mondrian.xpm b/samples/treectrl/mondrian.xpm new file mode 100644 index 0000000000..409f27a843 --- /dev/null +++ b/samples/treectrl/mondrian.xpm @@ -0,0 +1,44 @@ +/* XPM */ +static char *mondrian_xpm[] = { +/* columns rows colors chars-per-pixel */ +"32 32 6 1", +" c Black", +". c Blue", +"X c #00bf00", +"o c Red", +"O c Yellow", +"+ c Gray100", +/* pixels */ +" ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" oooooo +++++++++++++++++++++++ ", +" ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ .... ", +" ++++++ ++++++++++++++++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++++++++++++++++ ++++ ", +" ++++++ ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" ++++++ OOOOOOOOOOOO XXXXX ++++ ", +" " +}; diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index eb946008a7..0eb7d88946 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -25,6 +25,10 @@ #include "wx/wx.h" #endif +#ifdef __WXGTK__ +#include "mondrian.xpm" +#endif + #include "wx/treectrl.h" #include "treetest.h" @@ -65,9 +69,8 @@ bool MyApp::OnInit(void) // Give it an icon #ifdef __WXMSW__ frame->SetIcon(wxIcon("mondrian")); -#endif -#ifdef __X__ - frame->SetIcon(wxIcon("aiai.xbm")); +#else + frame->SetIcon(wxIcon(mondrian_xpm)); #endif // Make an image list containing small icons diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 6c6eba0be6..67d086dc72 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1103,6 +1103,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) m_current = line; HilightAll( FALSE ); m_current->ReverseHilight(); + RefreshLine( m_current ); } else { @@ -1110,6 +1111,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) { m_current = line; m_current->ReverseHilight(); + RefreshLine( m_current ); } else if (event.ControlDown()) { @@ -1143,21 +1145,20 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) RefreshLine( test_line ); node = node->Next(); } - return; } else { m_current = line; HilightAll( FALSE ); m_current->ReverseHilight(); + RefreshLine( m_current ); } } - RefreshLine( m_current ); if (m_current != oldCurrent) { + RefreshLine( oldCurrent ); UnfocusLine( oldCurrent ); FocusLine( m_current ); - RefreshLine( oldCurrent ); }; m_lastOnSame = (m_current == oldCurrent); return; @@ -1198,15 +1199,15 @@ void wxListMainWindow::MoveToFocus( void ) void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown ) { - UnfocusLine( m_current ); if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE ); wxListLineData *oldCurrent = m_current; m_current = newCurrent; MoveToFocus(); if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE ); - FocusLine( m_current ); RefreshLine( m_current ); RefreshLine( oldCurrent ); + FocusLine( m_current ); + UnfocusLine( oldCurrent ); }; void wxListMainWindow::OnChar( wxKeyEvent &event ) @@ -1310,14 +1311,14 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) if (!(m_mode & wxLC_SINGLE_SEL)) { wxListLineData *oldCurrent = m_current; - UnfocusLine( m_current ); m_current->ReverseHilight(); wxNode *node = m_lines.Member( m_current )->Next(); if (node) m_current = (wxListLineData*)node->Data(); MoveToFocus(); - FocusLine( m_current ); - RefreshLine( m_current ); RefreshLine( oldCurrent ); + RefreshLine( m_current ); + UnfocusLine( oldCurrent ); + FocusLine( m_current ); }; }; break; @@ -1828,6 +1829,7 @@ void wxListMainWindow::DeleteColumn( int col ) void wxListMainWindow::DeleteAllItems( void ) { m_dirty = TRUE; + m_current = NULL; wxNode *node = m_lines.First(); while (node) { @@ -1836,12 +1838,12 @@ void wxListMainWindow::DeleteAllItems( void ) node = node->Next(); }; m_lines.Clear(); - m_current = NULL; }; void wxListMainWindow::DeleteEverything( void ) { m_dirty = TRUE; + m_current = NULL; wxNode *node = m_lines.First(); while (node) { diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index fe0b6ebe1e..f1a0aa1a46 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -26,12 +26,11 @@ class wxBitmapButton; IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) -void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - wxBitmapButton *button = (wxBitmapButton*)data; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); - button->ProcessEvent(event); + button->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 2201232c15..52c4e2d4b9 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -26,12 +26,11 @@ class wxButton; IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) -void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) { - wxButton *button = (wxButton*)data; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); - button->ProcessEvent(event); + button->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index ee3830f361..b4c8a447ff 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -19,13 +19,12 @@ // wxCheckBox //----------------------------------------------------------------------------- -void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) { - wxCheckBox *cb = (wxCheckBox*)data; wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); event.SetInt( cb->GetValue() ); event.SetEventObject(cb); - cb->ProcessEvent(event); + cb->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 57922091b9..180bbb17d3 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -19,15 +19,14 @@ // wxChoice //----------------------------------------------------------------------------- -void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { - wxChoice *choice = (wxChoice*)data; - wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId()); + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); event.SetInt( choice->GetSelection() ); wxString tmp( choice->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject(choice); - choice->ProcessEvent(event); + choice->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- @@ -103,8 +102,8 @@ void wxChoice::Clear(void) int wxChoice::FindString( const wxString &string ) const { - // If you read this code once and you think you undestand - // it, then you are very wrong. RR + // If you read this code once and you think you understand + // it, then you are very wrong. Robert Roebling. GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); int count = 0; @@ -112,7 +111,8 @@ int wxChoice::FindString( const wxString &string ) const while (child) { GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL(bin->child); + GtkLabel *label = NULL; + if (bin->child) label = GTK_LABEL(bin->child); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); if (string == label->label) return count; child = child->next; @@ -151,7 +151,8 @@ wxString wxChoice::GetString( int n ) const GtkBin *bin = GTK_BIN( child->data ); if (count == n) { - GtkLabel *label = GTK_LABEL(bin->child); + GtkLabel *label = NULL; + if (bin->child) label = GTK_LABEL(bin->child); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); return label->label; }; @@ -188,6 +189,8 @@ void wxChoice::SetSelection( int n ) { int tmp = n; gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); + + gtk_choice_clicked_callback( NULL, this ); }; void wxChoice::SetStringSelection( const wxString &string ) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 5d080a400a..2e892f7e3a 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -14,20 +14,54 @@ #include "wx/combobox.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxComboBox //----------------------------------------------------------------------------- -void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) +//----------------------------------------------------------------------------- +// clicked + +static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { + if (combo->m_alreadySent) + { + combo->m_alreadySent = FALSE; + return; + } + + combo->m_alreadySent = TRUE; + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId()); event.SetInt( combo->GetSelection() ); wxString tmp( combo->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject(combo); - combo->ProcessEvent(event); + combo->GetEventHandler()->ProcessEvent(event); }; +//----------------------------------------------------------------------------- +// size + +/* +static gint gtk_combo_size_callback( GtkCombo *widget, GtkAllocation* alloc, wxComboBox *win ) +{ + if (!win->HasVMT()) return FALSE; + if (g_blockEventsOnDrag) return FALSE; + if (!widget->button) return FALSE; + + widget->button->allocation.x = + alloc->width - widget->button->allocation.width; + + return FALSE; +}; +*/ + //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) @@ -37,6 +71,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, int n, const wxString choices[], long style, const wxString& name ) { + m_alreadySent = FALSE; m_needParent = TRUE; PreCreation( parent, id, pos, size, style, name ); @@ -60,11 +95,18 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, gtk_container_add( GTK_CONTAINER(list), list_item ); + m_clientData.Append( (wxObject*)NULL ); + gtk_widget_show( list_item ); }; PostCreation(); +/* + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this ); +*/ + if (!value.IsNull()) SetValue( value ); Show( TRUE ); @@ -76,31 +118,44 @@ void wxComboBox::Clear(void) { GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, Number() ); + + m_clientData.Clear(); }; void wxComboBox::Append( const wxString &item ) +{ + Append( item, (char*)NULL ); +}; + +void wxComboBox::Append( const wxString &item, char *clientData ) { GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list_item; list_item = gtk_list_item_new_with_label( item ); - gtk_signal_connect( GTK_OBJECT(list_item), "select", + gtk_signal_connect( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_widget_show( list_item ); -}; - -void wxComboBox::Append( const wxString &WXUNUSED(item), char* WXUNUSED(clientData) ) -{ + + m_clientData.Append( (wxObject*)clientData ); }; void wxComboBox::Delete( int n ) { GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), n, n ); + + wxNode *node = m_clientData.Nth( n ); + if (!node) + { + wxFAIL_MSG("wxComboBox::Delete wrong index"); + } + else + m_clientData.DeleteNode( node ); }; int wxComboBox::FindString( const wxString &item ) @@ -196,6 +251,13 @@ void wxComboBox::SetSelection( int n ) gtk_list_select_item( GTK_LIST(list), n ); }; +void wxComboBox::SetStringSelection( const wxString &string ) +{ + int res = FindString( string ); + if (res == -1) return; + SetSelection( res ); +}; + wxString wxComboBox::GetValue(void) const { GtkWidget *entry = GTK_COMBO(m_widget)->entry; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 0abf2c82df..99d98fcdb8 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -33,7 +33,7 @@ extern wxList wxPendingDelete; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -// size +// set size void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { @@ -66,6 +66,19 @@ bool gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED( return TRUE; }; +//----------------------------------------------------------------------------- +// configure + +gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) +{ + if (!win->HasVMT()) return FALSE; + + win->m_x = event->x; + win->m_y = event->y; + + return FALSE; +}; + //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(wxFrame, wxWindow) @@ -143,6 +156,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", + GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); + PostCreation(); gtk_widget_realize( m_mainWindow ); @@ -210,10 +226,11 @@ void wxFrame::GetClientSize( int *width, int *height ) const }; }; -void wxFrame::GtkOnSize( int x, int y, int width, int height ) +void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { - m_x = x; - m_y = y; + // due to a bug in gtk, x,y are always 0 + // m_x = x; + // m_y = y; if ((m_height == height) && (m_width == width) && (m_sizeSet)) return; @@ -240,7 +257,7 @@ void wxFrame::GtkOnSize( int x, int y, int width, int height ) // m_wxwindow just like any other window. // not really needed - gtk_widget_set_usize( m_mainWindow, width, height ); +// gtk_widget_set_usize( m_mainWindow, width, height ); if (m_frameMenuBar) { diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index f880a3291e..359adda8d0 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -20,10 +20,8 @@ // wxListBox //----------------------------------------------------------------------------- -void gtk_listitem_select_callback( GtkWidget *widget, gpointer data ) +void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) { - wxListBox *listbox = (wxListBox*)data; - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); event.SetInt( listbox->GetIndex( widget ) ); @@ -32,10 +30,9 @@ void gtk_listitem_select_callback( GtkWidget *widget, gpointer data ) GtkLabel *label = GTK_LABEL( bin->child ); wxString tmp( label->label ); event.SetString( WXSTRINGCAST(tmp) ); - event.SetEventObject( listbox ); - listbox->ProcessEvent( event ); + listbox->GetEventHandler()->ProcessEvent( event ); }; //----------------------------------------------------------------------------- diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index c449676506..f4efa3d603 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -22,15 +22,22 @@ // wxRadioBox //----------------------------------------------------------------------------- -void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) { - wxRadioBox *rb = (wxRadioBox*)data; + if (rb->m_alreadySent) + { + rb->m_alreadySent = FALSE; + return; + } + + rb->m_alreadySent = TRUE; + wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() ); event.SetInt( rb->GetSelection() ); wxString tmp( rb->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject( rb ); - rb->ProcessEvent(event); + rb->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- @@ -56,6 +63,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, int WXUNUSED(majorDim), long style, const wxString &name ) { + m_alreadySent = FALSE; m_needParent = TRUE; PreCreation( parent, id, pos, size, style, name ); @@ -74,6 +82,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, for (int i = 0; i < n; i++) { if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); + m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); @@ -123,13 +132,33 @@ bool wxRadioBox::Show( bool show ) return TRUE; }; -int wxRadioBox::FindString( const wxString& WXUNUSED(s) ) const +int wxRadioBox::FindString( const wxString &s ) const { - return 0; + GSList *item = gtk_radio_button_group( m_radio ); + + int count = g_slist_length(item)-1; + + while (item) + { + GtkButton *b = GTK_BUTTON( item->data ); + GtkLabel *l = GTK_LABEL( b->child ); + if (s == l->label) return count; + count--; + item = item->next; + }; + + return -1; }; -void wxRadioBox::SetSelection( int WXUNUSED(n) ) +void wxRadioBox::SetSelection( int n ) { + GSList *item = gtk_radio_button_group( m_radio ); + item = g_slist_nth( item, g_slist_length(item)-n-1 ); + if (!item) return; + + GtkToggleButton *button = GTK_TOGGLE_BUTTON( item->data ); + + gtk_toggle_button_set_state( button, 1 ); }; int wxRadioBox::GetSelection(void) const @@ -146,9 +175,18 @@ int wxRadioBox::GetSelection(void) const return -1; }; -wxString wxRadioBox::GetString( int WXUNUSED(n) ) const +wxString wxRadioBox::GetString( int n ) const { - return ""; + GSList *item = gtk_radio_button_group( m_radio ); + + item = g_slist_nth( item, g_slist_length(item)-n-1 ); + if (!item) return ""; + + GtkToggleButton *button = GTK_TOGGLE_BUTTON( item->data ); + + GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child ); + + return wxString( label->label ); }; wxString wxRadioBox::GetLabel(void) const @@ -201,8 +239,11 @@ wxString wxRadioBox::GetStringSelection(void) const return ""; }; -bool wxRadioBox::SetStringSelection( const wxString& WXUNUSED(s) ) +bool wxRadioBox::SetStringSelection( const wxString&s ) { + int res = FindString( s ); + if (res == -1) return FALSE; + SetSelection( res ); return TRUE; }; diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index bcfece5c27..ac11b17d44 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -52,7 +52,7 @@ void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) wxScrollEvent event( command, win->GetId(), value, orient ); event.SetEventObject( win ); - win->ProcessEvent( event ); + win->GetEventHandler()->ProcessEvent( event ); /* wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index afd11f78a7..deb1db70fb 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -59,7 +59,8 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, PreCreation( parent, id, pos, size, style, name ); bool bMultiLine = (style & wxTE_MULTILINE) != 0; - if ( bMultiLine ) { + if ( bMultiLine ) + { // a multi-line edit control: create a vertical scrollbar by default and // horizontal if requested bool bHasHScrollbar = (style & wxHSCROLL) != 0; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 8f8ccf9446..c064c71faa 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -27,7 +27,7 @@ #include "wx/mdi.h" #include "wx/notebook.h" #include "wx/statusbr.h" -#include "wx/treectrl.h" +//#include "wx/treectrl.h" #include "gdk/gdkkeysyms.h" #include #include "wx/gtk/win_gtk.h" @@ -1064,7 +1064,8 @@ void wxWindow::ImplementSetPosition(void) if (IsKindOf(CLASSINFO(wxFrame)) || IsKindOf(CLASSINFO(wxDialog))) { - gtk_widget_set_uposition( m_widget, m_x, m_y ); + if ((m_x != -1) || (m_y != -1)) + gtk_widget_set_uposition( m_widget, m_x, m_y ); } else { @@ -1362,7 +1363,7 @@ void wxWindow::Fit(void) node = node->Next(); } - SetClientSize(maxX + 5, maxY + 5); + SetClientSize(maxX + 5, maxY + 10); }; void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) @@ -1473,7 +1474,7 @@ void wxWindow::AddChild( wxWindow *child ) // wxFrame has a private AddChild - if (IS_KIND_OF(this,wxFrame)) + if (IS_KIND_OF(this,wxFrame) && !IS_KIND_OF(this,wxMDIChildFrame)) { wxFrame *frame = (wxFrame*)this; frame->AddChild( child ); @@ -1604,12 +1605,6 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) gdk_rect.width = rect->width; gdk_rect.height = rect->height; - if (IS_KIND_OF(this,wxTreeCtrl)) - { - printf( "x: %d y: %d w: %d h: %d .\n", - gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height ); - } - if (m_wxwindow) gtk_widget_draw( m_wxwindow, &gdk_rect ); else diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index fe0b6ebe1e..f1a0aa1a46 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -26,12 +26,11 @@ class wxBitmapButton; IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) -void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - wxBitmapButton *button = (wxBitmapButton*)data; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); - button->ProcessEvent(event); + button->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 2201232c15..52c4e2d4b9 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -26,12 +26,11 @@ class wxButton; IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) -void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) { - wxButton *button = (wxButton*)data; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); - button->ProcessEvent(event); + button->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index ee3830f361..b4c8a447ff 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -19,13 +19,12 @@ // wxCheckBox //----------------------------------------------------------------------------- -void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) { - wxCheckBox *cb = (wxCheckBox*)data; wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); event.SetInt( cb->GetValue() ); event.SetEventObject(cb); - cb->ProcessEvent(event); + cb->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 57922091b9..180bbb17d3 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -19,15 +19,14 @@ // wxChoice //----------------------------------------------------------------------------- -void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { - wxChoice *choice = (wxChoice*)data; - wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId()); + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); event.SetInt( choice->GetSelection() ); wxString tmp( choice->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject(choice); - choice->ProcessEvent(event); + choice->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- @@ -103,8 +102,8 @@ void wxChoice::Clear(void) int wxChoice::FindString( const wxString &string ) const { - // If you read this code once and you think you undestand - // it, then you are very wrong. RR + // If you read this code once and you think you understand + // it, then you are very wrong. Robert Roebling. GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); int count = 0; @@ -112,7 +111,8 @@ int wxChoice::FindString( const wxString &string ) const while (child) { GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL(bin->child); + GtkLabel *label = NULL; + if (bin->child) label = GTK_LABEL(bin->child); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); if (string == label->label) return count; child = child->next; @@ -151,7 +151,8 @@ wxString wxChoice::GetString( int n ) const GtkBin *bin = GTK_BIN( child->data ); if (count == n) { - GtkLabel *label = GTK_LABEL(bin->child); + GtkLabel *label = NULL; + if (bin->child) label = GTK_LABEL(bin->child); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); return label->label; }; @@ -188,6 +189,8 @@ void wxChoice::SetSelection( int n ) { int tmp = n; gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); + + gtk_choice_clicked_callback( NULL, this ); }; void wxChoice::SetStringSelection( const wxString &string ) diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 5d080a400a..2e892f7e3a 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -14,20 +14,54 @@ #include "wx/combobox.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxComboBox //----------------------------------------------------------------------------- -void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) +//----------------------------------------------------------------------------- +// clicked + +static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { + if (combo->m_alreadySent) + { + combo->m_alreadySent = FALSE; + return; + } + + combo->m_alreadySent = TRUE; + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId()); event.SetInt( combo->GetSelection() ); wxString tmp( combo->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject(combo); - combo->ProcessEvent(event); + combo->GetEventHandler()->ProcessEvent(event); }; +//----------------------------------------------------------------------------- +// size + +/* +static gint gtk_combo_size_callback( GtkCombo *widget, GtkAllocation* alloc, wxComboBox *win ) +{ + if (!win->HasVMT()) return FALSE; + if (g_blockEventsOnDrag) return FALSE; + if (!widget->button) return FALSE; + + widget->button->allocation.x = + alloc->width - widget->button->allocation.width; + + return FALSE; +}; +*/ + //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) @@ -37,6 +71,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, int n, const wxString choices[], long style, const wxString& name ) { + m_alreadySent = FALSE; m_needParent = TRUE; PreCreation( parent, id, pos, size, style, name ); @@ -60,11 +95,18 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, gtk_container_add( GTK_CONTAINER(list), list_item ); + m_clientData.Append( (wxObject*)NULL ); + gtk_widget_show( list_item ); }; PostCreation(); +/* + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this ); +*/ + if (!value.IsNull()) SetValue( value ); Show( TRUE ); @@ -76,31 +118,44 @@ void wxComboBox::Clear(void) { GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, Number() ); + + m_clientData.Clear(); }; void wxComboBox::Append( const wxString &item ) +{ + Append( item, (char*)NULL ); +}; + +void wxComboBox::Append( const wxString &item, char *clientData ) { GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list_item; list_item = gtk_list_item_new_with_label( item ); - gtk_signal_connect( GTK_OBJECT(list_item), "select", + gtk_signal_connect( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_widget_show( list_item ); -}; - -void wxComboBox::Append( const wxString &WXUNUSED(item), char* WXUNUSED(clientData) ) -{ + + m_clientData.Append( (wxObject*)clientData ); }; void wxComboBox::Delete( int n ) { GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), n, n ); + + wxNode *node = m_clientData.Nth( n ); + if (!node) + { + wxFAIL_MSG("wxComboBox::Delete wrong index"); + } + else + m_clientData.DeleteNode( node ); }; int wxComboBox::FindString( const wxString &item ) @@ -196,6 +251,13 @@ void wxComboBox::SetSelection( int n ) gtk_list_select_item( GTK_LIST(list), n ); }; +void wxComboBox::SetStringSelection( const wxString &string ) +{ + int res = FindString( string ); + if (res == -1) return; + SetSelection( res ); +}; + wxString wxComboBox::GetValue(void) const { GtkWidget *entry = GTK_COMBO(m_widget)->entry; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 0abf2c82df..99d98fcdb8 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -33,7 +33,7 @@ extern wxList wxPendingDelete; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -// size +// set size void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { @@ -66,6 +66,19 @@ bool gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED( return TRUE; }; +//----------------------------------------------------------------------------- +// configure + +gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) +{ + if (!win->HasVMT()) return FALSE; + + win->m_x = event->x; + win->m_y = event->y; + + return FALSE; +}; + //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(wxFrame, wxWindow) @@ -143,6 +156,9 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", + GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); + PostCreation(); gtk_widget_realize( m_mainWindow ); @@ -210,10 +226,11 @@ void wxFrame::GetClientSize( int *width, int *height ) const }; }; -void wxFrame::GtkOnSize( int x, int y, int width, int height ) +void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) { - m_x = x; - m_y = y; + // due to a bug in gtk, x,y are always 0 + // m_x = x; + // m_y = y; if ((m_height == height) && (m_width == width) && (m_sizeSet)) return; @@ -240,7 +257,7 @@ void wxFrame::GtkOnSize( int x, int y, int width, int height ) // m_wxwindow just like any other window. // not really needed - gtk_widget_set_usize( m_mainWindow, width, height ); +// gtk_widget_set_usize( m_mainWindow, width, height ); if (m_frameMenuBar) { diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index f880a3291e..359adda8d0 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -20,10 +20,8 @@ // wxListBox //----------------------------------------------------------------------------- -void gtk_listitem_select_callback( GtkWidget *widget, gpointer data ) +void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) { - wxListBox *listbox = (wxListBox*)data; - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); event.SetInt( listbox->GetIndex( widget ) ); @@ -32,10 +30,9 @@ void gtk_listitem_select_callback( GtkWidget *widget, gpointer data ) GtkLabel *label = GTK_LABEL( bin->child ); wxString tmp( label->label ); event.SetString( WXSTRINGCAST(tmp) ); - event.SetEventObject( listbox ); - listbox->ProcessEvent( event ); + listbox->GetEventHandler()->ProcessEvent( event ); }; //----------------------------------------------------------------------------- diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index c449676506..f4efa3d603 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -22,15 +22,22 @@ // wxRadioBox //----------------------------------------------------------------------------- -void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) { - wxRadioBox *rb = (wxRadioBox*)data; + if (rb->m_alreadySent) + { + rb->m_alreadySent = FALSE; + return; + } + + rb->m_alreadySent = TRUE; + wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() ); event.SetInt( rb->GetSelection() ); wxString tmp( rb->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject( rb ); - rb->ProcessEvent(event); + rb->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- @@ -56,6 +63,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, int WXUNUSED(majorDim), long style, const wxString &name ) { + m_alreadySent = FALSE; m_needParent = TRUE; PreCreation( parent, id, pos, size, style, name ); @@ -74,6 +82,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, for (int i = 0; i < n; i++) { if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); + m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, choices[i] ) ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); @@ -123,13 +132,33 @@ bool wxRadioBox::Show( bool show ) return TRUE; }; -int wxRadioBox::FindString( const wxString& WXUNUSED(s) ) const +int wxRadioBox::FindString( const wxString &s ) const { - return 0; + GSList *item = gtk_radio_button_group( m_radio ); + + int count = g_slist_length(item)-1; + + while (item) + { + GtkButton *b = GTK_BUTTON( item->data ); + GtkLabel *l = GTK_LABEL( b->child ); + if (s == l->label) return count; + count--; + item = item->next; + }; + + return -1; }; -void wxRadioBox::SetSelection( int WXUNUSED(n) ) +void wxRadioBox::SetSelection( int n ) { + GSList *item = gtk_radio_button_group( m_radio ); + item = g_slist_nth( item, g_slist_length(item)-n-1 ); + if (!item) return; + + GtkToggleButton *button = GTK_TOGGLE_BUTTON( item->data ); + + gtk_toggle_button_set_state( button, 1 ); }; int wxRadioBox::GetSelection(void) const @@ -146,9 +175,18 @@ int wxRadioBox::GetSelection(void) const return -1; }; -wxString wxRadioBox::GetString( int WXUNUSED(n) ) const +wxString wxRadioBox::GetString( int n ) const { - return ""; + GSList *item = gtk_radio_button_group( m_radio ); + + item = g_slist_nth( item, g_slist_length(item)-n-1 ); + if (!item) return ""; + + GtkToggleButton *button = GTK_TOGGLE_BUTTON( item->data ); + + GtkLabel *label = GTK_LABEL( GTK_BUTTON(button)->child ); + + return wxString( label->label ); }; wxString wxRadioBox::GetLabel(void) const @@ -201,8 +239,11 @@ wxString wxRadioBox::GetStringSelection(void) const return ""; }; -bool wxRadioBox::SetStringSelection( const wxString& WXUNUSED(s) ) +bool wxRadioBox::SetStringSelection( const wxString&s ) { + int res = FindString( s ); + if (res == -1) return FALSE; + SetSelection( res ); return TRUE; }; diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp index bcfece5c27..ac11b17d44 100644 --- a/src/gtk1/scrolbar.cpp +++ b/src/gtk1/scrolbar.cpp @@ -52,7 +52,7 @@ void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) wxScrollEvent event( command, win->GetId(), value, orient ); event.SetEventObject( win ); - win->ProcessEvent( event ); + win->GetEventHandler()->ProcessEvent( event ); /* wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index afd11f78a7..deb1db70fb 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -59,7 +59,8 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, PreCreation( parent, id, pos, size, style, name ); bool bMultiLine = (style & wxTE_MULTILINE) != 0; - if ( bMultiLine ) { + if ( bMultiLine ) + { // a multi-line edit control: create a vertical scrollbar by default and // horizontal if requested bool bHasHScrollbar = (style & wxHSCROLL) != 0; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 8f8ccf9446..c064c71faa 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -27,7 +27,7 @@ #include "wx/mdi.h" #include "wx/notebook.h" #include "wx/statusbr.h" -#include "wx/treectrl.h" +//#include "wx/treectrl.h" #include "gdk/gdkkeysyms.h" #include #include "wx/gtk/win_gtk.h" @@ -1064,7 +1064,8 @@ void wxWindow::ImplementSetPosition(void) if (IsKindOf(CLASSINFO(wxFrame)) || IsKindOf(CLASSINFO(wxDialog))) { - gtk_widget_set_uposition( m_widget, m_x, m_y ); + if ((m_x != -1) || (m_y != -1)) + gtk_widget_set_uposition( m_widget, m_x, m_y ); } else { @@ -1362,7 +1363,7 @@ void wxWindow::Fit(void) node = node->Next(); } - SetClientSize(maxX + 5, maxY + 5); + SetClientSize(maxX + 5, maxY + 10); }; void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) @@ -1473,7 +1474,7 @@ void wxWindow::AddChild( wxWindow *child ) // wxFrame has a private AddChild - if (IS_KIND_OF(this,wxFrame)) + if (IS_KIND_OF(this,wxFrame) && !IS_KIND_OF(this,wxMDIChildFrame)) { wxFrame *frame = (wxFrame*)this; frame->AddChild( child ); @@ -1604,12 +1605,6 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) gdk_rect.width = rect->width; gdk_rect.height = rect->height; - if (IS_KIND_OF(this,wxTreeCtrl)) - { - printf( "x: %d y: %d w: %d h: %d .\n", - gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height ); - } - if (m_wxwindow) gtk_widget_draw( m_wxwindow, &gdk_rect ); else diff --git a/user/wxFile/wxFile.cpp b/user/wxFile/wxFile.cpp index 5057a46d8e..aab90635b4 100644 --- a/user/wxFile/wxFile.cpp +++ b/user/wxFile/wxFile.cpp @@ -292,6 +292,8 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) (void) new wxButton( &dialog, wxID_OK, "Return", wxPoint(w/2-40,h-50), wxSize(80,30) ); + dialog.Fit(); + dialog.ShowModal(); }; diff --git a/user/wxLayout/wxllist.h b/user/wxLayout/wxllist.h index d4744a77ba..fc5f5a619c 100644 --- a/user/wxLayout/wxllist.h +++ b/user/wxLayout/wxllist.h @@ -60,8 +60,8 @@ public: @param baseLine the baseline for alignment, from top of box @draw if set to false, do not draw but just calculate sizes */ - virtual void Draw(wxDC &dc, wxPoint position, CoordType baseLine, - bool draw = true) {}; + virtual void Draw( wxDC &WXUNUSED(dc), wxPoint WXUNUSED(position), + CoordType WXUNUSED(baseLine), bool draw = true) {}; /** Calculates and returns the size of the object. May need to be called twice to work. @@ -70,8 +70,9 @@ public: baseline) @return the size of the object's box in pixels */ - virtual wxPoint GetSize(CoordType *baseLine) const { return - wxPoint(0,0); }; + virtual wxPoint GetSize( CoordType *WXUNUSED(baseLine) ) const + { return wxPoint(0,0); }; + /// returns the number of cursor positions occupied by this object virtual CoordType CountPositions(void) const { return 1; } diff --git a/user/wxLayout/wxlwindow.h b/user/wxLayout/wxlwindow.h index cf656ce45c..61304396e3 100644 --- a/user/wxLayout/wxlwindow.h +++ b/user/wxLayout/wxlwindow.h @@ -16,6 +16,8 @@ #include "wxllist.h" +#define BROKEN_COMPILER + #ifdef BROKEN_COMPILER # define virtual #endif -- 2.45.2