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
This commit is contained in:
Robert Roebling
1998-07-31 20:04:04 +00:00
parent 110f32055e
commit 47908e25f9
62 changed files with 1352 additions and 194 deletions

View File

@@ -76,6 +76,7 @@ class wxComboBox: public wxControl
wxString GetStringSelection(void) const; wxString GetStringSelection(void) const;
int Number(void) const; int Number(void) const;
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string );
// Text field functions // Text field functions
wxString GetValue(void) const ; wxString GetValue(void) const ;
@@ -96,8 +97,11 @@ class wxComboBox: public wxControl
private: private:
wxList m_clientData; wxList m_clientData;
public:
bool m_alreadySent;
}; };
#endif // __GTKCOMBOBOXH__ #endif // __GTKCOMBOBOXH__

View File

@@ -79,6 +79,9 @@ class wxRadioBox: public wxControl
GtkRadioButton *m_radio; GtkRadioButton *m_radio;
public:
bool m_alreadySent;
}; };
#endif // __GTKRADIOBOXH__ #endif // __GTKRADIOBOXH__

View File

@@ -76,6 +76,7 @@ class wxComboBox: public wxControl
wxString GetStringSelection(void) const; wxString GetStringSelection(void) const;
int Number(void) const; int Number(void) const;
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string );
// Text field functions // Text field functions
wxString GetValue(void) const ; wxString GetValue(void) const ;
@@ -96,8 +97,11 @@ class wxComboBox: public wxControl
private: private:
wxList m_clientData; wxList m_clientData;
public:
bool m_alreadySent;
}; };
#endif // __GTKCOMBOBOXH__ #endif // __GTKCOMBOBOXH__

View File

@@ -79,6 +79,9 @@ class wxRadioBox: public wxControl
GtkRadioButton *m_radio; GtkRadioButton *m_radio;
public:
bool m_alreadySent;
}; };
#endif // __GTKRADIOBOXH__ #endif // __GTKRADIOBOXH__

View File

@@ -26,6 +26,10 @@
#include "wx/notebook.h" #include "wx/notebook.h"
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class definitions // class definitions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -45,10 +49,17 @@ class MyPanel: public wxPanel
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
void OnListBox( wxCommandEvent &event ); void OnListBox( wxCommandEvent &event );
void OnListBoxButtons( 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; wxListBox *m_listbox;
wxChoice *m_choice; wxChoice *m_choice;
wxComboBox *m_combo; wxComboBox *m_combo;
wxRadioBox *m_radio;
wxTextCtrl *m_text; wxTextCtrl *m_text;
wxNotebook *m_notebook; wxNotebook *m_notebook;
@@ -93,9 +104,8 @@ bool MyApp::OnInit(void)
// Give it an icon // Give it an icon
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));
#endif #else
#ifdef __X__ frame->SetIcon(wxIcon( mondrian_xpm ));
frame->SetIcon(wxIcon("aiai.xbm"));
#endif #endif
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
@@ -132,9 +142,17 @@ const ID_CHOICE_CLEAR = 123;
const ID_CHOICE_APPEND = 124; const ID_CHOICE_APPEND = 124;
const ID_COMBO = 140; 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_TEXT = 150;
const ID_RADIOBOX = 160;
const ID_RADIOBOX_SEL_NUM = 161;
const ID_RADIOBOX_SEL_STR = 162;
BEGIN_EVENT_TABLE(MyPanel, wxPanel) BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize) EVT_SIZE ( MyPanel::OnSize)
EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) 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_SEL_STR, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_APPEND, 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() END_EVENT_TABLE()
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : 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[] = wxString choices[] =
{ {
"This", "This",
"is", "is a",
"a", "wonderfull",
"wonderfull example.", "example.",
"Or",
"what",
"do",
"you",
"think?"
}; };
wxPanel *panel = new wxPanel(m_notebook); 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_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_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), 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"); m_notebook->AddPage(panel, "wxList");
panel = new wxPanel(m_notebook); 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"); m_notebook->AddPage(panel, "wxChoice");
panel = new wxPanel(m_notebook); 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"); m_notebook->AddPage(panel, "wxComboBox");
wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE ); wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE );
m_notebook->AddPage( text, "wxTextCtrl" ); 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) ) void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
@@ -196,16 +236,128 @@ void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
void MyPanel::OnListBox( wxCommandEvent &event ) void MyPanel::OnListBox( wxCommandEvent &event )
{ {
m_text->WriteText( "ListBox Event:\n");
m_text->WriteText( "ListBox selection string is: " ); m_text->WriteText( "ListBox selection string is: " );
m_text->WriteText( event.GetString() ); m_text->WriteText( event.GetString() );
m_text->WriteText( "\n" ); m_text->WriteText( "\n" );
} }
void MyPanel::OnListBoxButtons( wxCommandEvent &WXUNUSED(event) ) void MyPanel::OnListBoxButtons( wxCommandEvent &event )
{ {
if (m_notebook->GetPageCount() > 1) switch (event.GetId())
m_notebook->DeletePage( 1 ); {
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 )
{
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;
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -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 ++++ ",
" "
};

View File

@@ -50,7 +50,7 @@ IMPLEMENT_WXWIN_MAIN
bool MyApp::OnInit(void) bool MyApp::OnInit(void)
{ {
m_canvasTextColour = wxColour("BLACK"); m_canvasTextColour = wxColour("BLACK");
m_canvasFont = *wxNORMAL_FONT; m_canvasFont = *wxSWISS_FONT;
// Create the main frame window // Create the main frame window
MyFrame *frame = new MyFrame(NULL, "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300)); MyFrame *frame = new MyFrame(NULL, "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300));

View File

@@ -24,6 +24,10 @@
#include "wx/dnd.h" #include "wx/dnd.h"
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Derive 2 simple classes which just put in the listbox the strings (text or // Derive 2 simple classes which just put in the listbox the strings (text or
// file names) we drop on them // 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__ #ifdef __WXMSW__
// frame icon and status bar // frame icon and status bar
SetIcon(wxIcon("mondrian")); SetIcon(wxIcon("mondrian"));
#else
SetIcon(wxIcon(mondrian_xpm));
#endif #endif
const int widths[] = { -1 }; const int widths[] = { -1 };

44
samples/dnd/mondrian.xpm Normal file
View File

@@ -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 ++++ ",
" "
};

View File

@@ -25,6 +25,10 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
// Define a new application type // Define a new application type
class MyApp: public wxApp class MyApp: public wxApp
{ public: { public:
@@ -62,9 +66,8 @@ bool MyApp::OnInit(void)
// Give it an icon // Give it an icon
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));
#endif #else
#ifdef __X__ frame->SetIcon(wxIcon(mondrian_xpm));
frame->SetIcon(wxIcon("aiai.xbm"));
#endif #endif
// Make a menubar // Make a menubar

View File

@@ -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 ++++ ",
" "
};

View File

@@ -29,6 +29,10 @@
#include "wx/file.h" #include "wx/file.h"
#include "wx/log.h" #include "wx/log.h"
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
// Define a new application type // Define a new application type
class MyApp: public wxApp class MyApp: public wxApp
{ {
@@ -100,9 +104,8 @@ bool MyApp::OnInit(void)
// Give it an icon // Give it an icon
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));
#endif #else
#ifdef __X__ frame->SetIcon(wxIcon(mondrian_xpm));
frame->SetIcon(wxIcon("aiai.xbm"));
#endif #endif
// Make a menubar // Make a menubar

View File

@@ -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 ++++ ",
" "
};

View File

@@ -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",
" "
};

View File

@@ -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 "
};

View File

@@ -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.. ",
" ... "
};

View File

@@ -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. ",
" ........... ",
" "
};

View File

@@ -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. ",
" ........... ",
" "
};

View File

@@ -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 ... ",
"............. . ",
" . . . ",
" ........... "
};

View File

@@ -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. ",
" ............. "
};

View File

@@ -24,9 +24,19 @@
#include <wx/toolbar.h> #include <wx/toolbar.h>
#ifdef __WXGTK__ #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 #endif
#include "mdi.h" #include "mdi.h"
MyFrame *frame = NULL; MyFrame *frame = NULL;
@@ -52,9 +62,6 @@ bool MyApp::OnInit(void)
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mdi_icn")); frame->SetIcon(wxIcon("mdi_icn"));
#endif #endif
#ifdef __X__
frame->SetIcon(wxIcon("aiai.xbm"));
#endif
// Make a menubar // Make a menubar
wxMenu *file_menu = new wxMenu; 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) // Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__ #ifdef __WXMSW__
subframe->SetIcon(wxIcon("chrt_icn")); subframe->SetIcon(wxIcon("chrt_icn"));
#endif #else
#ifdef __X__ subframe->SetIcon(wxIcon(mondrian_xpm));
subframe->SetIcon(wxIcon("aiai.xbm"));
#endif #endif
// Give it a status line // Give it a status line
@@ -311,14 +317,15 @@ void MyFrame::InitToolBar(wxToolBar* toolBar)
bitmaps[6] = new wxBitmap("icon7", wxBITMAP_TYPE_RESOURCE); bitmaps[6] = new wxBitmap("icon7", wxBITMAP_TYPE_RESOURCE);
bitmaps[7] = new wxBitmap("icon8", wxBITMAP_TYPE_RESOURCE); bitmaps[7] = new wxBitmap("icon8", wxBITMAP_TYPE_RESOURCE);
#else #else
bitmaps[0] = new wxBitmap( folder_xpm ); bitmaps[0] = new wxBitmap( new_xpm );
bitmaps[1] = new wxBitmap( folder_xpm ); bitmaps[1] = new wxBitmap( open_xpm );
bitmaps[2] = new wxBitmap( folder_xpm ); bitmaps[2] = new wxBitmap( save_xpm );
bitmaps[3] = new wxBitmap( folder_xpm ); bitmaps[3] = new wxBitmap( copy_xpm );
bitmaps[4] = new wxBitmap( folder_xpm ); bitmaps[4] = new wxBitmap( cut_xpm );
bitmaps[5] = new wxBitmap( folder_xpm ); // bitmaps[5] = new wxBitmap( paste_xpm );
bitmaps[6] = new wxBitmap( folder_xpm ); bitmaps[5] = new wxBitmap( preview_xpm );
bitmaps[7] = new wxBitmap( folder_xpm ); bitmaps[6] = new wxBitmap( print_xpm );
bitmaps[7] = new wxBitmap( help_xpm );
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW__

44
samples/mdi/mondrian.xpm Normal file
View File

@@ -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 ++++ ",
" "
};

View File

@@ -27,6 +27,10 @@
#include "wx/date.h" #include "wx/date.h"
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
#if !WXDEBUG #if !WXDEBUG
#error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK) #error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK)
#endif #endif
@@ -59,9 +63,7 @@ bool MyApp::OnInit(void)
// Give it an icon // Give it an icon
#ifdef wx_msw #ifdef wx_msw
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));
#endif frame->SetIcon(wxIcon(mondrian_xpm));
#ifdef wx_x
frame->SetIcon(wxIcon("mondrian.xbm"));
#endif #endif
// Make a menubar // Make a menubar

View File

@@ -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 ++++ ",
" "
};

View File

@@ -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",
" "
};

View File

@@ -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 "
};

View File

@@ -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.. ",
" ... "
};

View File

@@ -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. ",
" ........... ",
" "
};

View File

@@ -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. ",
" ........... ",
" "
};

View File

@@ -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 . ",
" .. "
};

View File

@@ -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 ... ",
"............. . ",
" . . . ",
" ........... "
};

View File

@@ -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. ",
" ............. "
};

View File

@@ -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 ++++ ",
" "
};

View File

@@ -23,11 +23,21 @@
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "test.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) 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 // The `main program' equivalent, creating the windows and returning the
// main frame // main frame
@@ -43,9 +53,8 @@ bool MyApp::OnInit(void)
// Give it an icon // Give it an icon
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));
#endif #else
#ifdef __X__ frame->SetIcon( wxIcon(mondrian_xpm) );
frame->SetIcon(wxIcon("mondrian.xbm"));
#endif #endif
// Make a menubar // Make a menubar
@@ -96,17 +105,16 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
toolBarBitmaps[5] = new wxBitmap("icon6"); toolBarBitmaps[5] = new wxBitmap("icon6");
toolBarBitmaps[6] = new wxBitmap("icon7"); toolBarBitmaps[6] = new wxBitmap("icon7");
toolBarBitmaps[7] = new wxBitmap("icon8"); toolBarBitmaps[7] = new wxBitmap("icon8");
#endif #else
#ifdef __X__ toolBarBitmaps[0] = new wxBitmap( new_xpm );
// TODO toolBarBitmaps[1] = new wxBitmap( open_xpm );
toolBarBitmaps[0] = new wxBitmap(...); toolBarBitmaps[2] = new wxBitmap( save_xpm );
toolBarBitmaps[1] = new wxBitmap(...); toolBarBitmaps[3] = new wxBitmap( copy_xpm );
toolBarBitmaps[2] = new wxBitmap(...); toolBarBitmaps[4] = new wxBitmap( cut_xpm );
toolBarBitmaps[3] = new wxBitmap(...); // toolBarBitmaps[5] = new wxBitmap( paste_xpm );
toolBarBitmaps[4] = new wxBitmap(...); toolBarBitmaps[5] = new wxBitmap( preview_xpm );
toolBarBitmaps[5] = new wxBitmap(...); toolBarBitmaps[6] = new wxBitmap( print_xpm );
toolBarBitmaps[6] = new wxBitmap(...); toolBarBitmaps[7] = new wxBitmap( help_xpm );
toolBarBitmaps[7] = new wxBitmap(...);
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -114,7 +122,6 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
#else #else
int width = 16; int width = 16;
#endif #endif
int offX = 5;
int currentX = 5; int currentX = 5;
toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "New file"); 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); 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); Close(TRUE);
} }
void MyFrame::OnAbout(wxCommandEvent& event) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{ {
(void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar"); (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar");
} }
// Define the behaviour for the frame closing // Define the behaviour for the frame closing
// - must delete all frames except for the main one. // - must delete all frames except for the main one.
void MyFrame::OnCloseWindow(wxCloseEvent& event) void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{ {
Destroy(); Destroy();
} }

View File

@@ -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 ++++ ",
" "
};

View File

@@ -25,6 +25,10 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
#include "wx/treectrl.h" #include "wx/treectrl.h"
#include "treetest.h" #include "treetest.h"
@@ -65,9 +69,8 @@ bool MyApp::OnInit(void)
// Give it an icon // Give it an icon
#ifdef __WXMSW__ #ifdef __WXMSW__
frame->SetIcon(wxIcon("mondrian")); frame->SetIcon(wxIcon("mondrian"));
#endif #else
#ifdef __X__ frame->SetIcon(wxIcon(mondrian_xpm));
frame->SetIcon(wxIcon("aiai.xbm"));
#endif #endif
// Make an image list containing small icons // Make an image list containing small icons

View File

@@ -1103,6 +1103,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
m_current = line; m_current = line;
HilightAll( FALSE ); HilightAll( FALSE );
m_current->ReverseHilight(); m_current->ReverseHilight();
RefreshLine( m_current );
} }
else else
{ {
@@ -1110,6 +1111,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
{ {
m_current = line; m_current = line;
m_current->ReverseHilight(); m_current->ReverseHilight();
RefreshLine( m_current );
} }
else if (event.ControlDown()) else if (event.ControlDown())
{ {
@@ -1143,21 +1145,20 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
RefreshLine( test_line ); RefreshLine( test_line );
node = node->Next(); node = node->Next();
} }
return;
} }
else else
{ {
m_current = line; m_current = line;
HilightAll( FALSE ); HilightAll( FALSE );
m_current->ReverseHilight(); m_current->ReverseHilight();
RefreshLine( m_current );
} }
} }
RefreshLine( m_current );
if (m_current != oldCurrent) if (m_current != oldCurrent)
{ {
RefreshLine( oldCurrent );
UnfocusLine( oldCurrent ); UnfocusLine( oldCurrent );
FocusLine( m_current ); FocusLine( m_current );
RefreshLine( oldCurrent );
}; };
m_lastOnSame = (m_current == oldCurrent); m_lastOnSame = (m_current == oldCurrent);
return; return;
@@ -1198,15 +1199,15 @@ void wxListMainWindow::MoveToFocus( void )
void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown ) void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
{ {
UnfocusLine( m_current );
if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE ); if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE );
wxListLineData *oldCurrent = m_current; wxListLineData *oldCurrent = m_current;
m_current = newCurrent; m_current = newCurrent;
MoveToFocus(); MoveToFocus();
if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE ); if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE );
FocusLine( m_current );
RefreshLine( m_current ); RefreshLine( m_current );
RefreshLine( oldCurrent ); RefreshLine( oldCurrent );
FocusLine( m_current );
UnfocusLine( oldCurrent );
}; };
void wxListMainWindow::OnChar( wxKeyEvent &event ) void wxListMainWindow::OnChar( wxKeyEvent &event )
@@ -1310,14 +1311,14 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
if (!(m_mode & wxLC_SINGLE_SEL)) if (!(m_mode & wxLC_SINGLE_SEL))
{ {
wxListLineData *oldCurrent = m_current; wxListLineData *oldCurrent = m_current;
UnfocusLine( m_current );
m_current->ReverseHilight(); m_current->ReverseHilight();
wxNode *node = m_lines.Member( m_current )->Next(); wxNode *node = m_lines.Member( m_current )->Next();
if (node) m_current = (wxListLineData*)node->Data(); if (node) m_current = (wxListLineData*)node->Data();
MoveToFocus(); MoveToFocus();
FocusLine( m_current );
RefreshLine( m_current );
RefreshLine( oldCurrent ); RefreshLine( oldCurrent );
RefreshLine( m_current );
UnfocusLine( oldCurrent );
FocusLine( m_current );
}; };
}; };
break; break;
@@ -1828,6 +1829,7 @@ void wxListMainWindow::DeleteColumn( int col )
void wxListMainWindow::DeleteAllItems( void ) void wxListMainWindow::DeleteAllItems( void )
{ {
m_dirty = TRUE; m_dirty = TRUE;
m_current = NULL;
wxNode *node = m_lines.First(); wxNode *node = m_lines.First();
while (node) while (node)
{ {
@@ -1836,12 +1838,12 @@ void wxListMainWindow::DeleteAllItems( void )
node = node->Next(); node = node->Next();
}; };
m_lines.Clear(); m_lines.Clear();
m_current = NULL;
}; };
void wxListMainWindow::DeleteEverything( void ) void wxListMainWindow::DeleteEverything( void )
{ {
m_dirty = TRUE; m_dirty = TRUE;
m_current = NULL;
wxNode *node = m_lines.First(); wxNode *node = m_lines.First();
while (node) while (node)
{ {

View File

@@ -26,12 +26,11 @@ class wxBitmapButton;
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) 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()); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
event.SetEventObject(button); event.SetEventObject(button);
button->ProcessEvent(event); button->GetEventHandler()->ProcessEvent(event);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -26,12 +26,11 @@ class wxButton;
IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) 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()); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
event.SetEventObject(button); event.SetEventObject(button);
button->ProcessEvent(event); button->GetEventHandler()->ProcessEvent(event);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -19,13 +19,12 @@
// wxCheckBox // 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()); wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
event.SetInt( cb->GetValue() ); event.SetInt( cb->GetValue() );
event.SetEventObject(cb); event.SetEventObject(cb);
cb->ProcessEvent(event); cb->GetEventHandler()->ProcessEvent(event);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -19,15 +19,14 @@
// wxChoice // 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() ); event.SetInt( choice->GetSelection() );
wxString tmp( choice->GetStringSelection() ); wxString tmp( choice->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject(choice); 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 int wxChoice::FindString( const wxString &string ) const
{ {
// If you read this code once and you think you undestand // If you read this code once and you think you understand
// it, then you are very wrong. RR // it, then you are very wrong. Robert Roebling.
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0; int count = 0;
@@ -112,7 +111,8 @@ int wxChoice::FindString( const wxString &string ) const
while (child) while (child)
{ {
GtkBin *bin = GTK_BIN( child->data ); 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 (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (string == label->label) return count; if (string == label->label) return count;
child = child->next; child = child->next;
@@ -151,7 +151,8 @@ wxString wxChoice::GetString( int n ) const
GtkBin *bin = GTK_BIN( child->data ); GtkBin *bin = GTK_BIN( child->data );
if (count == n) 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 ); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
return label->label; return label->label;
}; };
@@ -188,6 +189,8 @@ void wxChoice::SetSelection( int n )
{ {
int tmp = n; int tmp = n;
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
gtk_choice_clicked_callback( NULL, this );
}; };
void wxChoice::SetStringSelection( const wxString &string ) void wxChoice::SetStringSelection( const wxString &string )

View File

@@ -14,20 +14,54 @@
#include "wx/combobox.h" #include "wx/combobox.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxComboBox // 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()); wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId());
event.SetInt( combo->GetSelection() ); event.SetInt( combo->GetSelection() );
wxString tmp( combo->GetStringSelection() ); wxString tmp( combo->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject(combo); 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) IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
@@ -37,6 +71,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
int n, const wxString choices[], int n, const wxString choices[],
long style, const wxString& name ) long style, const wxString& name )
{ {
m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); 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 ); gtk_container_add( GTK_CONTAINER(list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
}; };
PostCreation(); PostCreation();
/*
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this );
*/
if (!value.IsNull()) SetValue( value ); if (!value.IsNull()) SetValue( value );
Show( TRUE ); Show( TRUE );
@@ -76,31 +118,44 @@ void wxComboBox::Clear(void)
{ {
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() ); gtk_list_clear_items( GTK_LIST(list), 0, Number() );
m_clientData.Clear();
}; };
void wxComboBox::Append( const wxString &item ) 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 = GTK_COMBO(m_widget)->list;
GtkWidget *list_item; GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( 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_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
gtk_widget_show( 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 ) void wxComboBox::Delete( int n )
{ {
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), n, n ); 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 ) int wxComboBox::FindString( const wxString &item )
@@ -196,6 +251,13 @@ void wxComboBox::SetSelection( int n )
gtk_list_select_item( GTK_LIST(list), 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 wxString wxComboBox::GetValue(void) const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;

View File

@@ -33,7 +33,7 @@ extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// size // set size
void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) 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; 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) 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_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); 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(); PostCreation();
gtk_widget_realize( m_mainWindow ); 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; // due to a bug in gtk, x,y are always 0
m_y = y; // m_x = x;
// m_y = y;
if ((m_height == height) && (m_width == width) && if ((m_height == height) && (m_width == width) &&
(m_sizeSet)) return; (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. // m_wxwindow just like any other window.
// not really needed // not really needed
gtk_widget_set_usize( m_mainWindow, width, height ); // gtk_widget_set_usize( m_mainWindow, width, height );
if (m_frameMenuBar) if (m_frameMenuBar)
{ {

View File

@@ -20,10 +20,8 @@
// wxListBox // 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() ); wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
event.SetInt( listbox->GetIndex( widget ) ); event.SetInt( listbox->GetIndex( widget ) );
@@ -32,10 +30,9 @@ void gtk_listitem_select_callback( GtkWidget *widget, gpointer data )
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
wxString tmp( label->label ); wxString tmp( label->label );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject( listbox ); event.SetEventObject( listbox );
listbox->ProcessEvent( event ); listbox->GetEventHandler()->ProcessEvent( event );
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -22,15 +22,22 @@
// wxRadioBox // 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() ); wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
event.SetInt( rb->GetSelection() ); event.SetInt( rb->GetSelection() );
wxString tmp( rb->GetStringSelection() ); wxString tmp( rb->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject( rb ); 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, int WXUNUSED(majorDim), long style,
const wxString &name ) const wxString &name )
{ {
m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); 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++) for (int i = 0; i < n; i++)
{ {
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); 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] ) ); 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 ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
@@ -123,13 +132,33 @@ bool wxRadioBox::Show( bool show )
return TRUE; 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 int wxRadioBox::GetSelection(void) const
@@ -146,9 +175,18 @@ int wxRadioBox::GetSelection(void) const
return -1; 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 wxString wxRadioBox::GetLabel(void) const
@@ -201,8 +239,11 @@ wxString wxRadioBox::GetStringSelection(void) const
return ""; 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; return TRUE;
}; };

View File

@@ -52,7 +52,7 @@ void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
wxScrollEvent event( command, win->GetId(), value, orient ); wxScrollEvent event( command, win->GetId(), value, orient );
event.SetEventObject( win ); event.SetEventObject( win );
win->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
/* /*
wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() );

View File

@@ -59,7 +59,8 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
bool bMultiLine = (style & wxTE_MULTILINE) != 0; bool bMultiLine = (style & wxTE_MULTILINE) != 0;
if ( bMultiLine ) { if ( bMultiLine )
{
// a multi-line edit control: create a vertical scrollbar by default and // a multi-line edit control: create a vertical scrollbar by default and
// horizontal if requested // horizontal if requested
bool bHasHScrollbar = (style & wxHSCROLL) != 0; bool bHasHScrollbar = (style & wxHSCROLL) != 0;

View File

@@ -27,7 +27,7 @@
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/treectrl.h" //#include "wx/treectrl.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include <math.h> #include <math.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -1064,7 +1064,8 @@ void wxWindow::ImplementSetPosition(void)
if (IsKindOf(CLASSINFO(wxFrame)) || if (IsKindOf(CLASSINFO(wxFrame)) ||
IsKindOf(CLASSINFO(wxDialog))) 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 else
{ {
@@ -1362,7 +1363,7 @@ void wxWindow::Fit(void)
node = node->Next(); node = node->Next();
} }
SetClientSize(maxX + 5, maxY + 5); SetClientSize(maxX + 5, maxY + 10);
}; };
void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
@@ -1473,7 +1474,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame has a private AddChild // 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; wxFrame *frame = (wxFrame*)this;
frame->AddChild( child ); frame->AddChild( child );
@@ -1604,12 +1605,6 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
gdk_rect.width = rect->width; gdk_rect.width = rect->width;
gdk_rect.height = rect->height; 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) if (m_wxwindow)
gtk_widget_draw( m_wxwindow, &gdk_rect ); gtk_widget_draw( m_wxwindow, &gdk_rect );
else else

View File

@@ -26,12 +26,11 @@ class wxBitmapButton;
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) 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()); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
event.SetEventObject(button); event.SetEventObject(button);
button->ProcessEvent(event); button->GetEventHandler()->ProcessEvent(event);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -26,12 +26,11 @@ class wxButton;
IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) 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()); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
event.SetEventObject(button); event.SetEventObject(button);
button->ProcessEvent(event); button->GetEventHandler()->ProcessEvent(event);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -19,13 +19,12 @@
// wxCheckBox // 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()); wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
event.SetInt( cb->GetValue() ); event.SetInt( cb->GetValue() );
event.SetEventObject(cb); event.SetEventObject(cb);
cb->ProcessEvent(event); cb->GetEventHandler()->ProcessEvent(event);
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -19,15 +19,14 @@
// wxChoice // 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() ); event.SetInt( choice->GetSelection() );
wxString tmp( choice->GetStringSelection() ); wxString tmp( choice->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject(choice); 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 int wxChoice::FindString( const wxString &string ) const
{ {
// If you read this code once and you think you undestand // If you read this code once and you think you understand
// it, then you are very wrong. RR // it, then you are very wrong. Robert Roebling.
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
int count = 0; int count = 0;
@@ -112,7 +111,8 @@ int wxChoice::FindString( const wxString &string ) const
while (child) while (child)
{ {
GtkBin *bin = GTK_BIN( child->data ); 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 (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
if (string == label->label) return count; if (string == label->label) return count;
child = child->next; child = child->next;
@@ -151,7 +151,8 @@ wxString wxChoice::GetString( int n ) const
GtkBin *bin = GTK_BIN( child->data ); GtkBin *bin = GTK_BIN( child->data );
if (count == n) 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 ); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
return label->label; return label->label;
}; };
@@ -188,6 +189,8 @@ void wxChoice::SetSelection( int n )
{ {
int tmp = n; int tmp = n;
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
gtk_choice_clicked_callback( NULL, this );
}; };
void wxChoice::SetStringSelection( const wxString &string ) void wxChoice::SetStringSelection( const wxString &string )

View File

@@ -14,20 +14,54 @@
#include "wx/combobox.h" #include "wx/combobox.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxComboBox // 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()); wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId());
event.SetInt( combo->GetSelection() ); event.SetInt( combo->GetSelection() );
wxString tmp( combo->GetStringSelection() ); wxString tmp( combo->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject(combo); 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) IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
@@ -37,6 +71,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
int n, const wxString choices[], int n, const wxString choices[],
long style, const wxString& name ) long style, const wxString& name )
{ {
m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); 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 ); gtk_container_add( GTK_CONTAINER(list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
}; };
PostCreation(); PostCreation();
/*
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this );
*/
if (!value.IsNull()) SetValue( value ); if (!value.IsNull()) SetValue( value );
Show( TRUE ); Show( TRUE );
@@ -76,31 +118,44 @@ void wxComboBox::Clear(void)
{ {
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() ); gtk_list_clear_items( GTK_LIST(list), 0, Number() );
m_clientData.Clear();
}; };
void wxComboBox::Append( const wxString &item ) 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 = GTK_COMBO(m_widget)->list;
GtkWidget *list_item; GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( 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_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
gtk_widget_show( 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 ) void wxComboBox::Delete( int n )
{ {
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), n, n ); 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 ) int wxComboBox::FindString( const wxString &item )
@@ -196,6 +251,13 @@ void wxComboBox::SetSelection( int n )
gtk_list_select_item( GTK_LIST(list), 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 wxString wxComboBox::GetValue(void) const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;

View File

@@ -33,7 +33,7 @@ extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// size // set size
void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) 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; 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) 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_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); 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(); PostCreation();
gtk_widget_realize( m_mainWindow ); 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; // due to a bug in gtk, x,y are always 0
m_y = y; // m_x = x;
// m_y = y;
if ((m_height == height) && (m_width == width) && if ((m_height == height) && (m_width == width) &&
(m_sizeSet)) return; (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. // m_wxwindow just like any other window.
// not really needed // not really needed
gtk_widget_set_usize( m_mainWindow, width, height ); // gtk_widget_set_usize( m_mainWindow, width, height );
if (m_frameMenuBar) if (m_frameMenuBar)
{ {

View File

@@ -20,10 +20,8 @@
// wxListBox // 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() ); wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
event.SetInt( listbox->GetIndex( widget ) ); event.SetInt( listbox->GetIndex( widget ) );
@@ -32,10 +30,9 @@ void gtk_listitem_select_callback( GtkWidget *widget, gpointer data )
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
wxString tmp( label->label ); wxString tmp( label->label );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject( listbox ); event.SetEventObject( listbox );
listbox->ProcessEvent( event ); listbox->GetEventHandler()->ProcessEvent( event );
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -22,15 +22,22 @@
// wxRadioBox // 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() ); wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() );
event.SetInt( rb->GetSelection() ); event.SetInt( rb->GetSelection() );
wxString tmp( rb->GetStringSelection() ); wxString tmp( rb->GetStringSelection() );
event.SetString( WXSTRINGCAST(tmp) ); event.SetString( WXSTRINGCAST(tmp) );
event.SetEventObject( rb ); 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, int WXUNUSED(majorDim), long style,
const wxString &name ) const wxString &name )
{ {
m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); 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++) for (int i = 0; i < n; i++)
{ {
if (i) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); 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] ) ); 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 ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE );
@@ -123,13 +132,33 @@ bool wxRadioBox::Show( bool show )
return TRUE; 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 int wxRadioBox::GetSelection(void) const
@@ -146,9 +175,18 @@ int wxRadioBox::GetSelection(void) const
return -1; 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 wxString wxRadioBox::GetLabel(void) const
@@ -201,8 +239,11 @@ wxString wxRadioBox::GetStringSelection(void) const
return ""; 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; return TRUE;
}; };

View File

@@ -52,7 +52,7 @@ void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
wxScrollEvent event( command, win->GetId(), value, orient ); wxScrollEvent event( command, win->GetId(), value, orient );
event.SetEventObject( win ); event.SetEventObject( win );
win->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
/* /*
wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() );

View File

@@ -59,7 +59,8 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
bool bMultiLine = (style & wxTE_MULTILINE) != 0; bool bMultiLine = (style & wxTE_MULTILINE) != 0;
if ( bMultiLine ) { if ( bMultiLine )
{
// a multi-line edit control: create a vertical scrollbar by default and // a multi-line edit control: create a vertical scrollbar by default and
// horizontal if requested // horizontal if requested
bool bHasHScrollbar = (style & wxHSCROLL) != 0; bool bHasHScrollbar = (style & wxHSCROLL) != 0;

View File

@@ -27,7 +27,7 @@
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/treectrl.h" //#include "wx/treectrl.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include <math.h> #include <math.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -1064,7 +1064,8 @@ void wxWindow::ImplementSetPosition(void)
if (IsKindOf(CLASSINFO(wxFrame)) || if (IsKindOf(CLASSINFO(wxFrame)) ||
IsKindOf(CLASSINFO(wxDialog))) 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 else
{ {
@@ -1362,7 +1363,7 @@ void wxWindow::Fit(void)
node = node->Next(); node = node->Next();
} }
SetClientSize(maxX + 5, maxY + 5); SetClientSize(maxX + 5, maxY + 10);
}; };
void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
@@ -1473,7 +1474,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame has a private AddChild // 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; wxFrame *frame = (wxFrame*)this;
frame->AddChild( child ); frame->AddChild( child );
@@ -1604,12 +1605,6 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
gdk_rect.width = rect->width; gdk_rect.width = rect->width;
gdk_rect.height = rect->height; 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) if (m_wxwindow)
gtk_widget_draw( m_wxwindow, &gdk_rect ); gtk_widget_draw( m_wxwindow, &gdk_rect );
else else

View File

@@ -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) ); (void) new wxButton( &dialog, wxID_OK, "Return", wxPoint(w/2-40,h-50), wxSize(80,30) );
dialog.Fit();
dialog.ShowModal(); dialog.ShowModal();
}; };

View File

@@ -60,8 +60,8 @@ public:
@param baseLine the baseline for alignment, from top of box @param baseLine the baseline for alignment, from top of box
@draw if set to false, do not draw but just calculate sizes @draw if set to false, do not draw but just calculate sizes
*/ */
virtual void Draw(wxDC &dc, wxPoint position, CoordType baseLine, virtual void Draw( wxDC &WXUNUSED(dc), wxPoint WXUNUSED(position),
bool draw = true) {}; CoordType WXUNUSED(baseLine), bool draw = true) {};
/** Calculates and returns the size of the object. May need to be /** Calculates and returns the size of the object. May need to be
called twice to work. called twice to work.
@@ -70,8 +70,9 @@ public:
baseline) baseline)
@return the size of the object's box in pixels @return the size of the object's box in pixels
*/ */
virtual wxPoint GetSize(CoordType *baseLine) const { return virtual wxPoint GetSize( CoordType *WXUNUSED(baseLine) ) const
wxPoint(0,0); }; { return wxPoint(0,0); };
/// returns the number of cursor positions occupied by this object /// returns the number of cursor positions occupied by this object
virtual CoordType CountPositions(void) const { return 1; } virtual CoordType CountPositions(void) const { return 1; }

View File

@@ -16,6 +16,8 @@
#include "wxllist.h" #include "wxllist.h"
#define BROKEN_COMPILER
#ifdef BROKEN_COMPILER #ifdef BROKEN_COMPILER
# define virtual # define virtual
#endif #endif