wxButton::GetDefaultSize() fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -84,6 +84,8 @@ public:
|
|||||||
void OnPageChanging( wxNotebookEvent &event );
|
void OnPageChanging( wxNotebookEvent &event );
|
||||||
void OnSliderUpdate( wxCommandEvent &event );
|
void OnSliderUpdate( wxCommandEvent &event );
|
||||||
#ifndef wxUSE_SPINBUTTON
|
#ifndef wxUSE_SPINBUTTON
|
||||||
|
void OnSpinUp( wxSpinEvent &event );
|
||||||
|
void OnSpinDown( wxSpinEvent &event );
|
||||||
void OnSpinUpdate( wxSpinEvent &event );
|
void OnSpinUpdate( wxSpinEvent &event );
|
||||||
void OnUpdateShowProgress( wxUpdateUIEvent& event );
|
void OnUpdateShowProgress( wxUpdateUIEvent& event );
|
||||||
void OnShowProgress( wxCommandEvent &event );
|
void OnShowProgress( wxCommandEvent &event );
|
||||||
@@ -279,6 +281,8 @@ EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
|
|||||||
EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
|
EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
|
||||||
#ifndef wxUSE_SPINBUTTON
|
#ifndef wxUSE_SPINBUTTON
|
||||||
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
|
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
|
||||||
|
EVT_SPIN_UP (ID_SPIN, MyPanel::OnSpinUp)
|
||||||
|
EVT_SPIN_DOWN (ID_SPIN, MyPanel::OnSpinDown)
|
||||||
EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
|
EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
|
||||||
EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
|
EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
|
||||||
#endif
|
#endif
|
||||||
@@ -456,11 +460,14 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
|||||||
wxSize(240, 110)
|
wxSize(240, 110)
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
m_spintext = new wxTextCtrl( panel, -1, "-5", wxPoint(20,160), wxSize(80,-1) );
|
int initialSpinValue = -5;
|
||||||
|
wxString s;
|
||||||
|
s << initialSpinValue;
|
||||||
|
m_spintext = new wxTextCtrl( panel, -1, s, wxPoint(20,160), wxSize(80,-1) );
|
||||||
#ifndef wxUSE_SPINBUTTON
|
#ifndef wxUSE_SPINBUTTON
|
||||||
m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
|
m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
|
||||||
m_spinbutton->SetRange(-10,30);
|
m_spinbutton->SetRange(-10,30);
|
||||||
m_spinbutton->SetValue(-5);
|
m_spinbutton->SetValue(initialSpinValue);
|
||||||
|
|
||||||
m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog",
|
m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog",
|
||||||
wxPoint(208, 159) );
|
wxPoint(208, 159) );
|
||||||
@@ -511,15 +518,17 @@ void MyPanel::OnPageChanging( wxNotebookEvent &event )
|
|||||||
int selOld = event.GetOldSelection();
|
int selOld = event.GetOldSelection();
|
||||||
if ( selOld == 2 )
|
if ( selOld == 2 )
|
||||||
{
|
{
|
||||||
wxMessageBox("This demonstrates how a program may prevent the "
|
if ( wxMessageBox("This demonstrates how a program may prevent the "
|
||||||
"page change from taking place - \n the current page will "
|
"page change from taking place - if you select "
|
||||||
"stay the third one", "Control sample",
|
"[No] the current page will stay the third one",
|
||||||
wxICON_INFORMATION | wxOK);
|
"Control sample",
|
||||||
|
wxICON_QUESTION | wxYES_NO) != wxYES )
|
||||||
|
{
|
||||||
event.Veto();
|
event.Veto();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*m_text << "Notebook selection is being changed from " << selOld << "\n";
|
*m_text << "Notebook selection is being changed from " << selOld << "\n";
|
||||||
}
|
}
|
||||||
@@ -752,6 +761,38 @@ void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef wxUSE_SPINBUTTON
|
#ifndef wxUSE_SPINBUTTON
|
||||||
|
void MyPanel::OnSpinUp( wxSpinEvent &event )
|
||||||
|
{
|
||||||
|
wxString value;
|
||||||
|
value.Printf( _T("Spin control up: current = %d\n"),
|
||||||
|
m_spinbutton->GetValue());
|
||||||
|
|
||||||
|
if ( m_spinbutton->GetValue() > 17 )
|
||||||
|
{
|
||||||
|
value += _T("Preventing the spin button from going above 17.\n");
|
||||||
|
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_text->AppendText(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyPanel::OnSpinDown( wxSpinEvent &event )
|
||||||
|
{
|
||||||
|
wxString value;
|
||||||
|
value.Printf( _T("Spin control down: current = %d\n"),
|
||||||
|
m_spinbutton->GetValue());
|
||||||
|
|
||||||
|
if ( m_spinbutton->GetValue() < -17 )
|
||||||
|
{
|
||||||
|
value += _T("Preventing the spin button from going below -17.\n");
|
||||||
|
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_text->AppendText(value);
|
||||||
|
}
|
||||||
|
|
||||||
void MyPanel::OnSpinUpdate( wxSpinEvent &event )
|
void MyPanel::OnSpinUpdate( wxSpinEvent &event )
|
||||||
{
|
{
|
||||||
wxString value;
|
wxString value;
|
||||||
@@ -777,7 +818,11 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
|
|||||||
"An informative message",
|
"An informative message",
|
||||||
max, // range
|
max, // range
|
||||||
this, // parent
|
this, // parent
|
||||||
wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
|
wxPD_CAN_ABORT |
|
||||||
|
wxPD_APP_MODAL |
|
||||||
|
wxPD_ELAPSED_TIME |
|
||||||
|
wxPD_ESTIMATED_TIME |
|
||||||
|
wxPD_REMAINING_TIME);
|
||||||
|
|
||||||
|
|
||||||
bool cont = TRUE;
|
bool cont = TRUE;
|
||||||
|
@@ -119,6 +119,7 @@ long wxDialogBase::CreateTextMessage(const wxArrayString& lines,
|
|||||||
|
|
||||||
wxSize wxDialogBase::GetStandardButtonSize(bool hasCancel)
|
wxSize wxDialogBase::GetStandardButtonSize(bool hasCancel)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
int wButton = 0;
|
int wButton = 0;
|
||||||
GetTextExtent(_("OK"), &wButton, NULL);
|
GetTextExtent(_("OK"), &wButton, NULL);
|
||||||
|
|
||||||
@@ -145,6 +146,9 @@ wxSize wxDialogBase::GetStandardButtonSize(bool hasCancel)
|
|||||||
int hButton = (wButton * 23) / 75;
|
int hButton = (wButton * 23) / 75;
|
||||||
|
|
||||||
return wxSize(wButton, hButton);
|
return wxSize(wButton, hButton);
|
||||||
|
#else
|
||||||
|
return wxButton::GetDefaultSize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialogBase::CreateStandardButtons(long wDialog,
|
void wxDialogBase::CreateStandardButtons(long wDialog,
|
||||||
|
@@ -136,15 +136,26 @@ wxSize wxButton::DoGetBestSize()
|
|||||||
/* static */
|
/* static */
|
||||||
wxSize wxButton::GetDefaultSize()
|
wxSize wxButton::GetDefaultSize()
|
||||||
{
|
{
|
||||||
// the base unit is the height of the system GUI font
|
static wxSize s_sizeBtn;
|
||||||
int wChar, hChar;
|
|
||||||
wxGetCharSize(0, &wChar, &hChar, NULL);
|
|
||||||
|
|
||||||
// the button height is proportional to the height of the font used
|
if ( s_sizeBtn.x == 0 )
|
||||||
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
|
{
|
||||||
|
wxScreenDC dc;
|
||||||
|
dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
|
||||||
|
|
||||||
// and the width/height ration is 75/23
|
// the size of a standard button in the dialog units is 50x14,
|
||||||
return wxSize((75 * hBtn) / 23, hBtn);
|
// translate this to pixels
|
||||||
|
// NB1: the multipliers come from the Windows convention
|
||||||
|
// NB2: the extra +1/+2 were needed to get the size be the same as the
|
||||||
|
// size of the buttons in the standard dialog - I don't know how
|
||||||
|
// this happens, but on my system this size is 75x23 in pixels and
|
||||||
|
// 23*8 isn't even divisible by 14... Would be nice to understand
|
||||||
|
// why these constants are needed though!
|
||||||
|
s_sizeBtn.x = (50 * (dc.GetCharWidth() + 1))/4;
|
||||||
|
s_sizeBtn.y = ((14 * dc.GetCharHeight()) + 2)/8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_sizeBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user