This commit was manufactured by cvs2svn to create tag 'WX_2_2_7'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_2_7@10617 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2001-06-19 19:19:00 +00:00
parent dc3d889d0b
commit 2c847f1982
2264 changed files with 367714 additions and 112020 deletions

View File

@@ -88,6 +88,8 @@ public:
void OnChoice( wxCommandEvent &event );
void OnChoiceButtons( wxCommandEvent &event );
void OnCombo( wxCommandEvent &event );
void OnComboTextChanged( wxCommandEvent &event );
void OnComboTextEnter( wxCommandEvent &event );
void OnComboButtons( wxCommandEvent &event );
void OnRadio( wxCommandEvent &event );
void OnRadioButtons( wxCommandEvent &event );
@@ -106,6 +108,7 @@ public:
#if wxUSE_SPINCTRL
void OnSpinCtrl(wxSpinEvent& event);
void OnSpinCtrlSetValue(wxCommandEvent& event);
#endif // wxUSE_SPINCTRL
void OnEnableAll(wxCommandEvent& event);
@@ -183,6 +186,103 @@ private:
DECLARE_EVENT_TABLE()
};
// a button which intercepts double clicks (for testing...)
class MyButton : public wxButton
{
public:
MyButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize)
: wxButton(parent, id, label, pos, size)
{
}
void OnDClick(wxMouseEvent& event)
{
wxLogMessage(_T("MyButton::OnDClick"));
event.Skip();
}
void OnButton(wxCommandEvent& event)
{
wxLogMessage(_T("MyButton::OnButton"));
event.Skip();
}
private:
DECLARE_EVENT_TABLE()
};
// a combo which intercepts chars (to test Windows behaviour)
class MyComboBox : public wxComboBox
{
public:
MyComboBox(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
: wxComboBox(parent, id, value, pos, size, n, choices, style,
validator, name) { }
protected:
void OnChar(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnFocusGot(wxFocusEvent& event)
{
wxLogMessage(_T("MyComboBox::OnFocusGot"));
event.Skip();
}
private:
DECLARE_EVENT_TABLE()
};
// a radiobox which handles focus set/kill (for testing)
class MyRadioBox : public wxRadioBox
{
public:
MyRadioBox(wxWindow *parent,
wxWindowID id,
const wxString& title = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 1,
long style = wxRA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
: wxRadioBox(parent, id, title, pos, size, n, choices, majorDim,
style, validator, name) { }
protected:
void OnFocusGot(wxFocusEvent& event)
{
wxLogMessage(_T("MyRadioBox::OnFocusGot"));
event.Skip();
}
void OnFocusLost(wxFocusEvent& event)
{
wxLogMessage(_T("MyRadioBox::OnFocusLost"));
event.Skip();
}
private:
DECLARE_EVENT_TABLE()
};
//----------------------------------------------------------------------
// other
//----------------------------------------------------------------------
@@ -216,7 +316,7 @@ bool MyApp::OnInit()
// parse the cmd line
int x = 50,
y = 50;
if ( argc == 2 )
if ( argc == 3 )
{
wxSscanf(argv[1], "%d", &x);
wxSscanf(argv[2], "%d", &y);
@@ -287,6 +387,8 @@ const int ID_LISTBOX_DELETE = 135;
const int ID_LISTBOX_FONT = 136;
const int ID_LISTBOX_ENABLE = 137;
const int ID_LISTBOX_SORTED = 138;
const int ID_LISTBOX_TOGGLE = 139;
const int ID_LISTBOX_SETFIRST = 140;
const int ID_CHOICE = 120;
const int ID_CHOICE_SEL_NUM = 121;
@@ -325,6 +427,7 @@ const int ID_SPIN = 182;
const int ID_BTNPROGRESS = 183;
const int ID_BUTTON_LABEL = 184;
const int ID_SPINCTRL = 185;
const int ID_SPINCTRL_VALUE = 186;
const int ID_BUTTON_TEST1 = 190;
const int ID_BUTTON_TEST2 = 191;
@@ -345,6 +448,8 @@ EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_FONT, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_TOGGLE, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_SETFIRST, MyPanel::OnListBoxButtons)
EVT_CHECKBOX (ID_LISTBOX_ENABLE, MyPanel::OnListBoxButtons)
EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice)
EVT_CHOICE (ID_CHOICE_SORTED, MyPanel::OnChoice)
@@ -356,6 +461,8 @@ EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons)
EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons)
EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons)
EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo)
EVT_TEXT (ID_COMBO, MyPanel::OnComboTextChanged)
EVT_TEXT_ENTER(ID_COMBO, MyPanel::OnComboTextEnter)
EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
@@ -379,6 +486,7 @@ EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl)
EVT_BUTTON (ID_SPINCTRL_VALUE, MyPanel::OnSpinCtrlSetValue)
#endif // wxUSE_SPINCTRL
EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel)
EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour)
@@ -387,6 +495,28 @@ EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton)
EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyButton, wxButton)
EVT_LEFT_DCLICK(MyButton::OnDClick)
EVT_BUTTON(-1, MyButton::OnButton)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyComboBox, wxComboBox)
EVT_CHAR(MyComboBox::OnChar)
EVT_KEY_DOWN(MyComboBox::OnKeyDown)
EVT_KEY_UP(MyComboBox::OnKeyUp)
EVT_SET_FOCUS(MyComboBox::OnFocusGot)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyRadioBox, wxRadioBox)
EVT_SET_FOCUS(MyRadioBox::OnFocusGot)
EVT_KILL_FOCUS(MyRadioBox::OnFocusLost)
END_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
: wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ),
m_text(NULL), m_notebook(NULL)
@@ -468,11 +598,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
wxPanel *panel = new wxPanel(m_notebook);
m_listbox = new wxListBox( panel, ID_LISTBOX,
wxPoint(10,10), wxSize(120,70),
5, choices, wxLB_ALWAYS_SB );
wxPoint(10,10), wxSize(120,50),
5, choices, wxLB_MULTIPLE);
m_listbox->SetFirstItem( 1 );
m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
wxPoint(10,90), wxSize(120,70),
5, choices, wxLB_SORT );
wxPoint(10,90), wxSize(120,50),
5, choices, wxLB_SORT);
SetControlClientData("listbox", m_listbox);
SetControlClientData("listbox", m_listboxSorted);
@@ -485,9 +616,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #&2", wxPoint(180,30), wxSize(140,30) );
m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, "&Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "&Clear", wxPoint(180,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "&Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new MyButton( panel, ID_LISTBOX_APPEND, "&Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "D&elete selected item", wxPoint(180,130), wxSize(140,30) );
wxButton *button = new wxButton( panel, ID_LISTBOX_FONT, "Set &Italic font", wxPoint(340,130), wxSize(140,30) );
wxButton *button = new MyButton( panel, ID_LISTBOX_FONT, "Set &Italic font", wxPoint(340,130), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_SETFIRST, "#2 SetFirstItem", wxPoint(180,180), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_TOGGLE, "Toggle checkbox", wxPoint(340,180), wxSize(140,30) );
button->SetDefault();
@@ -512,10 +645,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1),
5, choices, wxCB_SORT );
#ifndef __WXMOTIF__
SetControlClientData("choice", m_choice);
SetControlClientData("choice", m_choiceSorted);
#endif
m_choice->SetSelection(2);
m_choice->SetBackgroundColour( "red" );
@@ -532,7 +663,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
panel = new wxPanel(m_notebook);
(void)new wxStaticBox( panel, -1, "&Box around combobox",
wxPoint(5, 5), wxSize(150, 100));
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(20,25), wxSize(120,-1), 5, choices, wxCB_READONLY );
m_combo = new MyComboBox( panel, ID_COMBO, "This",
wxPoint(20,25), wxSize(120, -1),
5, choices,
/* wxCB_READONLY | */ wxPROCESS_ENTER);
(void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #&2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_SEL_STR, "&Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_CLEAR, "&Clear", wxPoint(180,80), wxSize(140,30) );
@@ -542,19 +677,28 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
(void)new wxCheckBox( panel, ID_COMBO_ENABLE, "&Disable", wxPoint(20,130), wxSize(140,30) );
m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo);
wxString choices2[] =
static const wxString choices2[] =
{
"First", "Second",
/* "Third",
"Fourth", "Fifth", "Sixth",
"Seventh", "Eighth", "Nineth", "Tenth" */
};
static const wxString choices10[] =
{
"First", "Second", "Third", "Fourth", "Fifth",
"Sixth", "Seventh", "Eighth", "Nineth", "Tenth"
};
panel = new wxPanel(m_notebook);
(void)new wxRadioBox( panel, ID_RADIOBOX, "&That", wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS );
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "T&his", wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS );
(void)new MyRadioBox( panel, ID_RADIOBOX, "&That", wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS );
wxRadioBox *radio2 = new wxRadioBox(panel, -1, "And another one with very very long title",
wxPoint(165, 115), wxDefaultSize,
WXSIZEOF(choices10), choices10,
3, wxRA_SPECIFY_COLS);
#if wxUSE_TOOLTIPS
radio2->SetToolTip("Test tooltip");
m_combo->SetToolTip("This is a natural\ncombobox - can you believe me?");
m_radio->SetToolTip("Ever seen a radiobox?");
#endif // wxUSE_TOOLTIPS
@@ -563,15 +707,18 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
(void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "&Select 'This'", wxPoint(180,80), wxSize(140,30) );
m_fontButton = new wxButton( panel, ID_SET_FONT, "Set &more Italic font", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_RADIOBOX_FONT, "Set &Italic font", wxPoint(340,80), wxSize(140,30) );
(void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "&Disable", wxPoint(340,130), wxDefaultSize );
wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, "Radiobutton1", wxPoint(210,170), wxDefaultSize, wxRB_GROUP );
rb->SetValue( FALSE );
(void)new wxRadioButton( panel, ID_RADIOBUTTON_2, "&Radiobutton2", wxPoint(340,170), wxDefaultSize );
(void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, "&Disable", wxPoint(400,130), wxDefaultSize );
wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, "Radio&1",
wxPoint(400,170), wxDefaultSize, wxRB_GROUP );
rb->SetValue( TRUE );
(void)new wxRadioButton( panel, ID_RADIOBUTTON_2, "Radio&2", wxPoint(460,170), wxDefaultSize );
m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio);
panel = new wxPanel(m_notebook);
(void)new wxStaticBox( panel, -1, "&wxGauge and wxSlider", wxPoint(10,10), wxSize(200,130) );
m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155, 30) );
m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER );
m_gauge->SetBackgroundColour(*wxGREEN);
m_gauge->SetForegroundColour(*wxRED);
m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1), wxSL_LABELS );
(void)new wxStaticBox( panel, -1, "&Explanation", wxPoint(220,10), wxSize(270,130) );
#ifdef __WXMOTIF__
@@ -603,11 +750,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
m_spinbutton->SetValue(initialSpinValue);
m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "&Show progress dialog",
wxPoint(300, 160) );
wxPoint(330, 160) );
#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, "", wxPoint(200, 160), wxSize(80, -1) );
(void)new wxButton ( panel, ID_SPINCTRL_VALUE, "SetValue", wxPoint(140,160) );
m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, "", wxPoint(240, 160), wxSize(80, -1) );
m_spinctrl->SetRange(10,30);
m_spinctrl->SetValue(15);
#endif // wxUSE_SPINCTRL
@@ -662,7 +811,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
(void)new wxButton(panel, ID_BUTTON_LABEL, "&Toggle label", wxPoint(250, 20));
m_label = new wxStaticText(panel, -1, "Label with some long text",
wxPoint(250, 60), wxDefaultSize,
wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);
m_label->SetForegroundColour( *wxBLUE );
m_notebook->AddPage(panel, "wxBitmapXXX");
@@ -727,7 +876,7 @@ void MyPanel::OnPageChanging( wxNotebookEvent &event )
"page change from taking place - if you select\n"
"[No] the current page will stay the third one\n",
"Control sample",
wxICON_QUESTION | wxYES_NO) != wxYES )
wxICON_QUESTION | wxYES_NO, this) != wxYES )
{
event.Veto();
@@ -875,9 +1024,11 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
{
int idx;
idx = m_listbox->GetSelection();
m_listbox->Delete( idx );
if ( idx != wxNOT_FOUND )
m_listbox->Delete( idx );
idx = m_listboxSorted->GetSelection();
m_listboxSorted->Delete( idx );
if ( idx != wxNOT_FOUND )
m_listboxSorted->Delete( idx );
break;
}
case ID_LISTBOX_FONT:
@@ -887,6 +1038,16 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
m_checkbox->SetFont( *wxITALIC_FONT );
break;
}
case ID_LISTBOX_TOGGLE:
{
m_checkbox->SetValue( !m_checkbox->GetValue() );
break;
}
case ID_LISTBOX_SETFIRST:
{
m_listbox->SetFirstItem( 2 );
break;
}
}
}
@@ -958,9 +1119,11 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
case ID_CHOICE_DELETE:
{
int idx = m_choice->GetSelection();
m_choice->Delete( idx );
if ( idx != wxNOT_FOUND )
m_choice->Delete( idx );
idx = m_choiceSorted->GetSelection();
m_choiceSorted->Delete( idx );
if ( idx != wxNOT_FOUND )
m_choiceSorted->Delete( idx );
break;
}
case ID_CHOICE_FONT:
@@ -982,6 +1145,18 @@ void MyPanel::OnCombo( wxCommandEvent &event )
m_text->AppendText( "\n" );
}
void MyPanel::OnComboTextChanged(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(_T("Text in the combobox changed: now is '%s'."),
m_combo->GetValue().c_str());
}
void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(_T("Enter pressed in the combobox: value is '%s'."),
m_combo->GetValue().c_str());
}
void MyPanel::OnComboButtons( wxCommandEvent &event )
{
switch (event.GetId())
@@ -1070,7 +1245,7 @@ void MyPanel::OnUpdateLabel( wxCommandEvent &WXUNUSED(event) )
static bool s_long = TRUE;
s_long = !s_long;
m_label->SetLabel(s_long ? "very very very long text" : "shorter text");
m_label->SetLabel(s_long ? "Very very very very very long text." : "Shorter text.");
}
void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )
@@ -1088,6 +1263,11 @@ void MyPanel::OnSpinCtrl(wxSpinEvent& event)
m_text->AppendText(s);
}
void MyPanel::OnSpinCtrlSetValue(wxCommandEvent& event)
{
m_spinctrl->SetValue( 12 );
}
#endif // wxUSE_SPINCTRL
#if wxUSE_SPINBTN
@@ -1323,6 +1503,33 @@ void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
}
}
void MyComboBox::OnChar(wxKeyEvent& event)
{
wxLogMessage(_T("MyComboBox::OnChar"));
if ( event.KeyCode() == 'w' )
wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
else
event.Skip();
}
void MyComboBox::OnKeyDown(wxKeyEvent& event)
{
wxLogMessage(_T("MyComboBox::OnKeyDown"));
if ( event.KeyCode() == 'w' )
wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
else
event.Skip();
}
void MyComboBox::OnKeyUp(wxKeyEvent& event)
{
wxLogMessage(_T("MyComboBox::OnKeyUp"));
event.Skip();
}
static void SetControlClientData(const char *name,
wxControlWithItems *control)
{