Merge branch 'wxslider' of https://github.com/MaartenBent/wxWidgets
wxSlider and widgets samples improvements:
- Document `wxSL_BOTH` style of `wxSlider`.
- Centre labels above and below vertical `wxSlider`. Improve label
position for specific combinations of `wxSlider` styles.
- Improve `wxSlider` in high DPI. Make thumb and tick size DPI
dependent.
- Better fix layout of `wxSlider` labels after changing value range.
Commit 0b821ad
did not (always) trigger a call to `DoMoveWindow`. See
[#17093](https://trac.wxwidgets.org/ticket/17093).
- Fix `wxSlider::SetThumbLength()` on `wxMSW`. It requires
`TBS_FIXEDLENGTH` style. Use `GetThumbLength()` instead of the
arbitrary defined `THUMB` size.
- Improve guards in button pages of widgets sample.
- Use `wxSizerFlags` for slider page in widgets sample.
- Some fixes for `wxSlider` in widgets sample
- Correctly save the slider value before recreating the slider.
- Layout the entire page instead of only the slider sizer.
- Update the text controls after recreating the slider.
- Always enable 'both sides' checkbox. It has additional effects in
`wxMSW`.
- Demonstrate `wxSlider::SetSelection()` in widgets sample.
See https://github.com/wxWidgets/wxWidgets/pull/1208
This commit is contained in:
@@ -57,6 +57,8 @@
|
|||||||
Displays ticks on the top.
|
Displays ticks on the top.
|
||||||
@style{wxSL_BOTTOM}
|
@style{wxSL_BOTTOM}
|
||||||
Displays ticks on the bottom (this is the default).
|
Displays ticks on the bottom (this is the default).
|
||||||
|
@style{wxSL_BOTH}
|
||||||
|
Displays ticks on both sides of the slider. Windows only.
|
||||||
@style{wxSL_SELRANGE}
|
@style{wxSL_SELRANGE}
|
||||||
Displays a highlighted selection range. Windows only.
|
Displays a highlighted selection range. Windows only.
|
||||||
@style{wxSL_INVERSE}
|
@style{wxSL_INVERSE}
|
||||||
|
@@ -456,7 +456,9 @@ void ButtonWidgetsPage::CreateButton()
|
|||||||
bool showsBitmap = false;
|
bool showsBitmap = false;
|
||||||
if ( m_chkBitmapOnly->GetValue() )
|
if ( m_chkBitmapOnly->GetValue() )
|
||||||
{
|
{
|
||||||
|
#if wxUSE_COMMANDLINKBUTTON
|
||||||
m_chkCommandLink->SetValue(false); // wxCommandLinkButton cannot be "Bitmap only"
|
m_chkCommandLink->SetValue(false); // wxCommandLinkButton cannot be "Bitmap only"
|
||||||
|
#endif
|
||||||
|
|
||||||
showsBitmap = true;
|
showsBitmap = true;
|
||||||
|
|
||||||
@@ -537,7 +539,9 @@ void ButtonWidgetsPage::CreateButton()
|
|||||||
|
|
||||||
m_chkTextAndBitmap->Enable(!m_chkBitmapOnly->IsChecked());
|
m_chkTextAndBitmap->Enable(!m_chkBitmapOnly->IsChecked());
|
||||||
m_chkBitmapOnly->Enable(!m_chkTextAndBitmap->IsChecked());
|
m_chkBitmapOnly->Enable(!m_chkTextAndBitmap->IsChecked());
|
||||||
|
#if wxUSE_COMMANDLINKBUTTON
|
||||||
m_chkCommandLink->Enable(!m_chkBitmapOnly->IsChecked());
|
m_chkCommandLink->Enable(!m_chkBitmapOnly->IsChecked());
|
||||||
|
#endif
|
||||||
m_chkUseBitmapClass->Enable(showsBitmap);
|
m_chkUseBitmapClass->Enable(showsBitmap);
|
||||||
|
|
||||||
m_chkUsePressed->Enable(showsBitmap);
|
m_chkUsePressed->Enable(showsBitmap);
|
||||||
|
@@ -59,6 +59,7 @@ enum
|
|||||||
SliderPage_Clear,
|
SliderPage_Clear,
|
||||||
SliderPage_SetValue,
|
SliderPage_SetValue,
|
||||||
SliderPage_SetMinAndMax,
|
SliderPage_SetMinAndMax,
|
||||||
|
SliderPage_SetRange,
|
||||||
SliderPage_SetLineSize,
|
SliderPage_SetLineSize,
|
||||||
SliderPage_SetPageSize,
|
SliderPage_SetPageSize,
|
||||||
SliderPage_SetTickFreq,
|
SliderPage_SetTickFreq,
|
||||||
@@ -67,12 +68,15 @@ enum
|
|||||||
SliderPage_ValueText,
|
SliderPage_ValueText,
|
||||||
SliderPage_MinText,
|
SliderPage_MinText,
|
||||||
SliderPage_MaxText,
|
SliderPage_MaxText,
|
||||||
|
SliderPage_RangeMinText,
|
||||||
|
SliderPage_RangeMaxText,
|
||||||
SliderPage_LineSizeText,
|
SliderPage_LineSizeText,
|
||||||
SliderPage_PageSizeText,
|
SliderPage_PageSizeText,
|
||||||
SliderPage_TickFreqText,
|
SliderPage_TickFreqText,
|
||||||
SliderPage_ThumbLenText,
|
SliderPage_ThumbLenText,
|
||||||
SliderPage_RadioSides,
|
SliderPage_RadioSides,
|
||||||
SliderPage_BothSides,
|
SliderPage_BothSides,
|
||||||
|
SliderPage_SelectRange,
|
||||||
SliderPage_Slider
|
SliderPage_Slider
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,6 +111,7 @@ protected:
|
|||||||
void OnButtonClear(wxCommandEvent& event);
|
void OnButtonClear(wxCommandEvent& event);
|
||||||
void OnButtonSetValue(wxCommandEvent& event);
|
void OnButtonSetValue(wxCommandEvent& event);
|
||||||
void OnButtonSetMinAndMax(wxCommandEvent& event);
|
void OnButtonSetMinAndMax(wxCommandEvent& event);
|
||||||
|
void OnButtonSetRange(wxCommandEvent& event);
|
||||||
void OnButtonSetLineSize(wxCommandEvent& event);
|
void OnButtonSetLineSize(wxCommandEvent& event);
|
||||||
void OnButtonSetPageSize(wxCommandEvent& event);
|
void OnButtonSetPageSize(wxCommandEvent& event);
|
||||||
void OnButtonSetTickFreq(wxCommandEvent& event);
|
void OnButtonSetTickFreq(wxCommandEvent& event);
|
||||||
@@ -118,12 +123,14 @@ protected:
|
|||||||
|
|
||||||
void OnUpdateUIValueButton(wxUpdateUIEvent& event);
|
void OnUpdateUIValueButton(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
|
void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
|
||||||
|
void OnUpdateUIRangeButton(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUILineSize(wxUpdateUIEvent& event);
|
void OnUpdateUILineSize(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUIPageSize(wxUpdateUIEvent& event);
|
void OnUpdateUIPageSize(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUITickFreq(wxUpdateUIEvent& event);
|
void OnUpdateUITickFreq(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUIThumbLen(wxUpdateUIEvent& event);
|
void OnUpdateUIThumbLen(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUIRadioSides(wxUpdateUIEvent& event);
|
void OnUpdateUIRadioSides(wxUpdateUIEvent& event);
|
||||||
void OnUpdateUIBothSides(wxUpdateUIEvent& event);
|
void OnUpdateUIBothSides(wxUpdateUIEvent& event);
|
||||||
|
void OnUpdateUISelectRange(wxUpdateUIEvent& event);
|
||||||
|
|
||||||
void OnUpdateUIResetButton(wxUpdateUIEvent& event);
|
void OnUpdateUIResetButton(wxUpdateUIEvent& event);
|
||||||
|
|
||||||
@@ -147,6 +154,9 @@ protected:
|
|||||||
// set the thumb len from the text field value
|
// set the thumb len from the text field value
|
||||||
void DoSetThumbLen();
|
void DoSetThumbLen();
|
||||||
|
|
||||||
|
// set the selection range from the text field values
|
||||||
|
void DoSetSelectionRange();
|
||||||
|
|
||||||
// is this slider value in range?
|
// is this slider value in range?
|
||||||
bool IsValidValue(int val) const
|
bool IsValidValue(int val) const
|
||||||
{ return (val >= m_min) && (val <= m_max); }
|
{ return (val >= m_min) && (val <= m_max); }
|
||||||
@@ -154,6 +164,9 @@ protected:
|
|||||||
// the slider range
|
// the slider range
|
||||||
int m_min, m_max;
|
int m_min, m_max;
|
||||||
|
|
||||||
|
// the slider selection range
|
||||||
|
int m_rangeMin, m_rangeMax;
|
||||||
|
|
||||||
// the controls
|
// the controls
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
@@ -162,7 +175,8 @@ protected:
|
|||||||
*m_chkValueLabel,
|
*m_chkValueLabel,
|
||||||
*m_chkInverse,
|
*m_chkInverse,
|
||||||
*m_chkTicks,
|
*m_chkTicks,
|
||||||
*m_chkBothSides;
|
*m_chkBothSides,
|
||||||
|
*m_chkSelectRange;
|
||||||
|
|
||||||
wxRadioBox *m_radioSides;
|
wxRadioBox *m_radioSides;
|
||||||
|
|
||||||
@@ -174,6 +188,8 @@ protected:
|
|||||||
wxTextCtrl *m_textValue,
|
wxTextCtrl *m_textValue,
|
||||||
*m_textMin,
|
*m_textMin,
|
||||||
*m_textMax,
|
*m_textMax,
|
||||||
|
*m_textRangeMin,
|
||||||
|
*m_textRangeMax,
|
||||||
*m_textLineSize,
|
*m_textLineSize,
|
||||||
*m_textPageSize,
|
*m_textPageSize,
|
||||||
*m_textTickFreq,
|
*m_textTickFreq,
|
||||||
@@ -192,6 +208,7 @@ wxBEGIN_EVENT_TABLE(SliderWidgetsPage, WidgetsPage)
|
|||||||
EVT_BUTTON(SliderPage_Reset, SliderWidgetsPage::OnButtonReset)
|
EVT_BUTTON(SliderPage_Reset, SliderWidgetsPage::OnButtonReset)
|
||||||
EVT_BUTTON(SliderPage_SetValue, SliderWidgetsPage::OnButtonSetValue)
|
EVT_BUTTON(SliderPage_SetValue, SliderWidgetsPage::OnButtonSetValue)
|
||||||
EVT_BUTTON(SliderPage_SetMinAndMax, SliderWidgetsPage::OnButtonSetMinAndMax)
|
EVT_BUTTON(SliderPage_SetMinAndMax, SliderWidgetsPage::OnButtonSetMinAndMax)
|
||||||
|
EVT_BUTTON(SliderPage_SetRange, SliderWidgetsPage::OnButtonSetRange)
|
||||||
EVT_BUTTON(SliderPage_SetLineSize, SliderWidgetsPage::OnButtonSetLineSize)
|
EVT_BUTTON(SliderPage_SetLineSize, SliderWidgetsPage::OnButtonSetLineSize)
|
||||||
EVT_BUTTON(SliderPage_SetPageSize, SliderWidgetsPage::OnButtonSetPageSize)
|
EVT_BUTTON(SliderPage_SetPageSize, SliderWidgetsPage::OnButtonSetPageSize)
|
||||||
EVT_BUTTON(SliderPage_SetTickFreq, SliderWidgetsPage::OnButtonSetTickFreq)
|
EVT_BUTTON(SliderPage_SetTickFreq, SliderWidgetsPage::OnButtonSetTickFreq)
|
||||||
@@ -199,12 +216,14 @@ wxBEGIN_EVENT_TABLE(SliderWidgetsPage, WidgetsPage)
|
|||||||
|
|
||||||
EVT_UPDATE_UI(SliderPage_SetValue, SliderWidgetsPage::OnUpdateUIValueButton)
|
EVT_UPDATE_UI(SliderPage_SetValue, SliderWidgetsPage::OnUpdateUIValueButton)
|
||||||
EVT_UPDATE_UI(SliderPage_SetMinAndMax, SliderWidgetsPage::OnUpdateUIMinMaxButton)
|
EVT_UPDATE_UI(SliderPage_SetMinAndMax, SliderWidgetsPage::OnUpdateUIMinMaxButton)
|
||||||
|
EVT_UPDATE_UI(SliderPage_SetRange, SliderWidgetsPage::OnUpdateUIRangeButton)
|
||||||
EVT_UPDATE_UI(SliderPage_SetLineSize, SliderWidgetsPage::OnUpdateUILineSize)
|
EVT_UPDATE_UI(SliderPage_SetLineSize, SliderWidgetsPage::OnUpdateUILineSize)
|
||||||
EVT_UPDATE_UI(SliderPage_SetPageSize, SliderWidgetsPage::OnUpdateUIPageSize)
|
EVT_UPDATE_UI(SliderPage_SetPageSize, SliderWidgetsPage::OnUpdateUIPageSize)
|
||||||
EVT_UPDATE_UI(SliderPage_SetTickFreq, SliderWidgetsPage::OnUpdateUITickFreq)
|
EVT_UPDATE_UI(SliderPage_SetTickFreq, SliderWidgetsPage::OnUpdateUITickFreq)
|
||||||
EVT_UPDATE_UI(SliderPage_SetThumbLen, SliderWidgetsPage::OnUpdateUIThumbLen)
|
EVT_UPDATE_UI(SliderPage_SetThumbLen, SliderWidgetsPage::OnUpdateUIThumbLen)
|
||||||
EVT_UPDATE_UI(SliderPage_RadioSides, SliderWidgetsPage::OnUpdateUIRadioSides)
|
EVT_UPDATE_UI(SliderPage_RadioSides, SliderWidgetsPage::OnUpdateUIRadioSides)
|
||||||
EVT_UPDATE_UI(SliderPage_BothSides, SliderWidgetsPage::OnUpdateUIBothSides)
|
EVT_UPDATE_UI(SliderPage_BothSides, SliderWidgetsPage::OnUpdateUIBothSides)
|
||||||
|
EVT_UPDATE_UI(SliderPage_SelectRange, SliderWidgetsPage::OnUpdateUISelectRange)
|
||||||
|
|
||||||
EVT_UPDATE_UI(SliderPage_Reset, SliderWidgetsPage::OnUpdateUIResetButton)
|
EVT_UPDATE_UI(SliderPage_Reset, SliderWidgetsPage::OnUpdateUIResetButton)
|
||||||
|
|
||||||
@@ -235,12 +254,15 @@ SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
// init everything
|
// init everything
|
||||||
m_min = 0;
|
m_min = 0;
|
||||||
m_max = 100;
|
m_max = 100;
|
||||||
|
m_rangeMin = 20;
|
||||||
|
m_rangeMax = 80;
|
||||||
|
|
||||||
m_chkInverse =
|
m_chkInverse =
|
||||||
m_chkTicks =
|
m_chkTicks =
|
||||||
m_chkMinMaxLabels =
|
m_chkMinMaxLabels =
|
||||||
m_chkValueLabel =
|
m_chkValueLabel =
|
||||||
m_chkBothSides = (wxCheckBox *)NULL;
|
m_chkBothSides =
|
||||||
|
m_chkSelectRange =(wxCheckBox *)NULL;
|
||||||
|
|
||||||
m_radioSides = (wxRadioBox *)NULL;
|
m_radioSides = (wxRadioBox *)NULL;
|
||||||
|
|
||||||
@@ -272,17 +294,20 @@ void SliderWidgetsPage::CreateContent()
|
|||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
WXSIZEOF(sides), sides,
|
WXSIZEOF(sides), sides,
|
||||||
1, wxRA_SPECIFY_COLS);
|
1, wxRA_SPECIFY_COLS);
|
||||||
sizerLeft->Add(m_radioSides, 0, wxGROW | wxALL, 5);
|
sizerLeft->Add(m_radioSides, wxSizerFlags().Expand().Border());
|
||||||
m_chkBothSides = CreateCheckBoxAndAddToSizer
|
m_chkBothSides = CreateCheckBoxAndAddToSizer
|
||||||
(sizerLeft, "&Both sides", SliderPage_BothSides);
|
(sizerLeft, "&Both sides", SliderPage_BothSides);
|
||||||
|
m_chkSelectRange = CreateCheckBoxAndAddToSizer
|
||||||
|
(sizerLeft, "&Selection range", SliderPage_SelectRange);
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
m_chkBothSides->SetToolTip("\"Both sides\" is only supported \nin Universal");
|
m_chkBothSides->SetToolTip("\"Both sides\" is only supported \nin Universal");
|
||||||
|
m_chkSelectRange->SetToolTip("\"Select range\" is only supported \nin wxMSW");
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
|
sizerLeft->AddSpacer(5);
|
||||||
|
|
||||||
wxButton *btn = new wxButton(this, SliderPage_Reset, "&Reset");
|
wxButton *btn = new wxButton(this, SliderPage_Reset, "&Reset");
|
||||||
sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
|
sizerLeft->Add(btn, wxSizerFlags().CentreHorizontal().Border(wxALL, 15));
|
||||||
|
|
||||||
// middle pane
|
// middle pane
|
||||||
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Change slider value");
|
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Change slider value");
|
||||||
@@ -294,13 +319,13 @@ void SliderWidgetsPage::CreateContent()
|
|||||||
&text);
|
&text);
|
||||||
text->SetEditable(false);
|
text->SetEditable(false);
|
||||||
|
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetValue,
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetValue,
|
||||||
"Set &value",
|
"Set &value",
|
||||||
SliderPage_ValueText,
|
SliderPage_ValueText,
|
||||||
&m_textValue);
|
&m_textValue);
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetMinAndMax,
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetMinAndMax,
|
||||||
"&Min and max",
|
"&Min and max",
|
||||||
@@ -308,26 +333,39 @@ void SliderWidgetsPage::CreateContent()
|
|||||||
&m_textMin);
|
&m_textMin);
|
||||||
|
|
||||||
m_textMax = new wxTextCtrl(this, SliderPage_MaxText, wxEmptyString);
|
m_textMax = new wxTextCtrl(this, SliderPage_MaxText, wxEmptyString);
|
||||||
sizerRow->Add(m_textMax, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5);
|
sizerRow->Add(m_textMax, wxSizerFlags(1).CentreVertical().Border(wxLEFT));
|
||||||
|
|
||||||
m_textMin->SetValue( wxString::Format("%d", m_min) );
|
m_textMin->SetValue( wxString::Format("%d", m_min) );
|
||||||
m_textMax->SetValue( wxString::Format("%d", m_max) );
|
m_textMax->SetValue( wxString::Format("%d", m_max) );
|
||||||
|
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetRange,
|
||||||
|
"&Selection",
|
||||||
|
SliderPage_RangeMinText,
|
||||||
|
&m_textRangeMin);
|
||||||
|
|
||||||
|
m_textRangeMax = new wxTextCtrl(this, SliderPage_RangeMaxText, wxEmptyString);
|
||||||
|
sizerRow->Add(m_textRangeMax, wxSizerFlags(1).CentreVertical().Border(wxLEFT));
|
||||||
|
|
||||||
|
m_textRangeMin->SetValue( wxString::Format("%d", m_rangeMin) );
|
||||||
|
m_textRangeMax->SetValue( wxString::Format("%d", m_rangeMax) );
|
||||||
|
|
||||||
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetLineSize,
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetLineSize,
|
||||||
"Li&ne size",
|
"Li&ne size",
|
||||||
SliderPage_LineSizeText,
|
SliderPage_LineSizeText,
|
||||||
&m_textLineSize);
|
&m_textLineSize);
|
||||||
|
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetPageSize,
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetPageSize,
|
||||||
"P&age size",
|
"P&age size",
|
||||||
SliderPage_PageSizeText,
|
SliderPage_PageSizeText,
|
||||||
&m_textPageSize);
|
&m_textPageSize);
|
||||||
|
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetTickFreq,
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetTickFreq,
|
||||||
"Tick &frequency",
|
"Tick &frequency",
|
||||||
@@ -336,30 +374,29 @@ void SliderWidgetsPage::CreateContent()
|
|||||||
|
|
||||||
m_textTickFreq->SetValue("10");
|
m_textTickFreq->SetValue("10");
|
||||||
|
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetThumbLen,
|
sizerRow = CreateSizerWithTextAndButton(SliderPage_SetThumbLen,
|
||||||
"Thumb &length",
|
"Thumb &length",
|
||||||
SliderPage_ThumbLenText,
|
SliderPage_ThumbLenText,
|
||||||
&m_textThumbLen);
|
&m_textThumbLen);
|
||||||
|
|
||||||
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
|
sizerMiddle->Add(sizerRow, wxSizerFlags().Expand().Border());
|
||||||
|
|
||||||
// right pane
|
// right pane
|
||||||
wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizerRight->SetMinSize(150, 40);
|
|
||||||
m_sizerSlider = sizerRight; // save it to modify it later
|
m_sizerSlider = sizerRight; // save it to modify it later
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
CreateSlider();
|
CreateSlider();
|
||||||
|
|
||||||
m_textLineSize->SetValue(wxString::Format("%d", m_slider->GetLineSize()));
|
|
||||||
m_textPageSize->SetValue(wxString::Format("%d", m_slider->GetPageSize()));
|
|
||||||
|
|
||||||
// the 3 panes panes compose the window
|
// the 3 panes panes compose the window
|
||||||
sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
|
sizerTop->Add(sizerLeft,
|
||||||
sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
|
wxSizerFlags(0).Expand().Border((wxALL & ~wxLEFT), 10));
|
||||||
sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
|
sizerTop->Add(sizerMiddle,
|
||||||
|
wxSizerFlags(1).Expand().Border(wxALL, 10));
|
||||||
|
sizerTop->Add(sizerRight,
|
||||||
|
wxSizerFlags(1).Expand().Border((wxALL & ~wxRIGHT), 10));
|
||||||
|
|
||||||
// final initializations
|
// final initializations
|
||||||
SetSizer(sizerTop);
|
SetSizer(sizerTop);
|
||||||
@@ -376,6 +413,7 @@ void SliderWidgetsPage::Reset()
|
|||||||
m_chkValueLabel->SetValue(true);
|
m_chkValueLabel->SetValue(true);
|
||||||
m_chkMinMaxLabels->SetValue(true);
|
m_chkMinMaxLabels->SetValue(true);
|
||||||
m_chkBothSides->SetValue(false);
|
m_chkBothSides->SetValue(false);
|
||||||
|
m_chkSelectRange->SetValue(false);
|
||||||
|
|
||||||
m_radioSides->SetSelection(SliderTicks_None);
|
m_radioSides->SetSelection(SliderTicks_None);
|
||||||
}
|
}
|
||||||
@@ -438,11 +476,16 @@ void SliderWidgetsPage::CreateSlider()
|
|||||||
flags |= wxSL_BOTH;
|
flags |= wxSL_BOTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_chkSelectRange->GetValue() )
|
||||||
|
{
|
||||||
|
flags |= wxSL_SELRANGE;
|
||||||
|
}
|
||||||
|
|
||||||
int val = m_min;
|
int val = m_min;
|
||||||
if ( m_slider )
|
if ( m_slider )
|
||||||
{
|
{
|
||||||
int valOld = m_slider->GetValue();
|
int valOld = m_slider->GetValue();
|
||||||
if ( !IsValidValue(valOld) )
|
if ( IsValidValue(valOld) )
|
||||||
{
|
{
|
||||||
val = valOld;
|
val = valOld;
|
||||||
}
|
}
|
||||||
@@ -466,21 +509,30 @@ void SliderWidgetsPage::CreateSlider()
|
|||||||
|
|
||||||
if ( m_slider->HasFlag(wxSL_VERTICAL) )
|
if ( m_slider->HasFlag(wxSL_VERTICAL) )
|
||||||
{
|
{
|
||||||
m_sizerSlider->Add(0, 0, 1);
|
m_sizerSlider->AddStretchSpacer(1);
|
||||||
m_sizerSlider->Add(m_slider, 0, wxGROW | wxALL, 5);
|
m_sizerSlider->Add(m_slider, wxSizerFlags(0).Expand().Border());
|
||||||
m_sizerSlider->Add(0, 0, 1);
|
m_sizerSlider->AddStretchSpacer(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sizerSlider->Add(m_slider, 1, wxCENTRE | wxALL, 5);
|
m_sizerSlider->Add(m_slider, wxSizerFlags(1).Centre().Border());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_textLineSize->SetValue(wxString::Format("%d", m_slider->GetLineSize()));
|
||||||
|
m_textPageSize->SetValue(wxString::Format("%d", m_slider->GetPageSize()));
|
||||||
|
m_textThumbLen->SetValue(wxString::Format("%d", m_slider->GetThumbLength()));
|
||||||
|
|
||||||
if ( m_chkTicks->GetValue() )
|
if ( m_chkTicks->GetValue() )
|
||||||
{
|
{
|
||||||
DoSetTickFreq();
|
DoSetTickFreq();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sizerSlider->Layout();
|
if ( m_chkSelectRange->GetValue() )
|
||||||
|
{
|
||||||
|
DoSetSelectionRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidgetsPage::DoSetLineSize()
|
void SliderWidgetsPage::DoSetLineSize()
|
||||||
@@ -543,6 +595,39 @@ void SliderWidgetsPage::DoSetThumbLen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_slider->SetThumbLength(len);
|
m_slider->SetThumbLength(len);
|
||||||
|
|
||||||
|
if ( m_slider->GetThumbLength() != len )
|
||||||
|
{
|
||||||
|
wxLogWarning(wxString::Format("Invalid thumb length in slider: %d",
|
||||||
|
m_slider->GetThumbLength()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SliderWidgetsPage::DoSetSelectionRange()
|
||||||
|
{
|
||||||
|
long minNew,
|
||||||
|
maxNew = 0; // init to suppress compiler warning
|
||||||
|
if ( !m_textRangeMin->GetValue().ToLong(&minNew) ||
|
||||||
|
!m_textRangeMax->GetValue().ToLong(&maxNew) ||
|
||||||
|
minNew >= maxNew || minNew < m_min || maxNew > m_max )
|
||||||
|
{
|
||||||
|
wxLogWarning("Invalid selection range for the slider.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rangeMin = minNew;
|
||||||
|
m_rangeMax = maxNew;
|
||||||
|
|
||||||
|
m_slider->SetSelection(m_rangeMin, m_rangeMax);
|
||||||
|
|
||||||
|
if ( m_slider->GetSelStart() != m_rangeMin ||
|
||||||
|
m_slider->GetSelEnd() != m_rangeMax )
|
||||||
|
{
|
||||||
|
wxLogWarning("Invalid selection range in slider.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -601,6 +686,11 @@ void SliderWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SliderWidgetsPage::OnButtonSetRange(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
DoSetSelectionRange();
|
||||||
|
}
|
||||||
|
|
||||||
void SliderWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
|
void SliderWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
long val;
|
long val;
|
||||||
@@ -656,6 +746,17 @@ void SliderWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event)
|
|||||||
mn < mx);
|
mn < mx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SliderWidgetsPage::OnUpdateUIRangeButton(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
long mn, mx;
|
||||||
|
event.Enable( m_chkSelectRange->GetValue() &&
|
||||||
|
m_textRangeMin->GetValue().ToLong(&mn) &&
|
||||||
|
m_textRangeMax->GetValue().ToLong(&mx) &&
|
||||||
|
mn < mx &&
|
||||||
|
mn >= m_min && mx <= m_max );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
event.Enable( m_chkInverse->GetValue() ||
|
event.Enable( m_chkInverse->GetValue() ||
|
||||||
@@ -663,6 +764,7 @@ void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
|||||||
!m_chkValueLabel->GetValue() ||
|
!m_chkValueLabel->GetValue() ||
|
||||||
!m_chkMinMaxLabels->GetValue() ||
|
!m_chkMinMaxLabels->GetValue() ||
|
||||||
m_chkBothSides->GetValue() ||
|
m_chkBothSides->GetValue() ||
|
||||||
|
m_chkSelectRange->GetValue() ||
|
||||||
m_radioSides->GetSelection() != SliderTicks_None );
|
m_radioSides->GetSelection() != SliderTicks_None );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,12 +786,21 @@ void SliderWidgetsPage::OnUpdateUIRadioSides(wxUpdateUIEvent& event)
|
|||||||
void SliderWidgetsPage::OnUpdateUIBothSides(wxUpdateUIEvent& event)
|
void SliderWidgetsPage::OnUpdateUIBothSides(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
||||||
event.Enable( m_chkTicks->GetValue() );
|
event.Enable( true );
|
||||||
#else
|
#else
|
||||||
event.Enable( false );
|
event.Enable( false );
|
||||||
#endif // defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
#endif // defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SliderWidgetsPage::OnUpdateUISelectRange(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
#if defined(__WXMSW__)
|
||||||
|
event.Enable( true );
|
||||||
|
#else
|
||||||
|
event.Enable( false );
|
||||||
|
#endif // defined(__WXMSW__)
|
||||||
|
}
|
||||||
|
|
||||||
void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
|
void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( event.GetInt() == m_slider->GetValue(),
|
wxASSERT_MSG( event.GetInt() == m_slider->GetValue(),
|
||||||
|
@@ -117,16 +117,18 @@ protected:
|
|||||||
// the controls
|
// the controls
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
|
wxCheckBox *m_chkFit,
|
||||||
|
*m_chkDisable;
|
||||||
|
|
||||||
#if wxUSE_MARKUP
|
#if wxUSE_MARKUP
|
||||||
wxCheckBox *m_chkUseMarkup;
|
wxCheckBox *m_chkUseMarkup;
|
||||||
#endif // wxUSE_MARKUP
|
#endif // wxUSE_MARKUP
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
// the check/radio boxes for styles
|
// the check/radio boxes for styles
|
||||||
wxCheckBox *m_chkBitmapOnly,
|
wxCheckBox *m_chkBitmapOnly,
|
||||||
*m_chkTextAndBitmap,
|
*m_chkTextAndBitmap,
|
||||||
*m_chkFit,
|
*m_chkUseBitmapClass;
|
||||||
*m_chkUseBitmapClass,
|
|
||||||
*m_chkDisable;
|
|
||||||
|
|
||||||
// more checkboxes for wxBitmapToggleButton only
|
// more checkboxes for wxBitmapToggleButton only
|
||||||
wxCheckBox *m_chkUsePressed,
|
wxCheckBox *m_chkUsePressed,
|
||||||
@@ -142,11 +144,7 @@ protected:
|
|||||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
||||||
|
|
||||||
// the checkbox itself and the sizer it is in
|
// the checkbox itself and the sizer it is in
|
||||||
#ifdef wxHAS_ANY_BUTTON
|
|
||||||
wxToggleButton *m_toggle;
|
wxToggleButton *m_toggle;
|
||||||
#else
|
|
||||||
wxToggleButtonBase *m_toggle;
|
|
||||||
#endif // wxHAS_ANY_BUTTON
|
|
||||||
wxSizer *m_sizerToggle;
|
wxSizer *m_sizerToggle;
|
||||||
|
|
||||||
// the text entries for command parameters
|
// the text entries for command parameters
|
||||||
@@ -187,16 +185,18 @@ ToggleWidgetsPage::ToggleWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
wxImageList *imaglist)
|
wxImageList *imaglist)
|
||||||
:WidgetsPage(book, imaglist, toggle_xpm)
|
:WidgetsPage(book, imaglist, toggle_xpm)
|
||||||
{
|
{
|
||||||
|
m_chkFit =
|
||||||
|
m_chkDisable = (wxCheckBox *)NULL;
|
||||||
|
|
||||||
#if wxUSE_MARKUP
|
#if wxUSE_MARKUP
|
||||||
m_chkUseMarkup = (wxCheckBox *)NULL;
|
m_chkUseMarkup = (wxCheckBox *)NULL;
|
||||||
#endif // wxUSE_MARKUP
|
#endif // wxUSE_MARKUP
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
// init everything
|
// init everything
|
||||||
m_chkBitmapOnly =
|
m_chkBitmapOnly =
|
||||||
m_chkTextAndBitmap =
|
m_chkTextAndBitmap =
|
||||||
m_chkFit =
|
|
||||||
m_chkUseBitmapClass =
|
m_chkUseBitmapClass =
|
||||||
m_chkDisable =
|
|
||||||
m_chkUsePressed =
|
m_chkUsePressed =
|
||||||
m_chkUseFocused =
|
m_chkUseFocused =
|
||||||
m_chkUseCurrent =
|
m_chkUseCurrent =
|
||||||
@@ -225,18 +225,20 @@ void ToggleWidgetsPage::CreateContent()
|
|||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
m_chkBitmapOnly = CreateCheckBoxAndAddToSizer(sizerLeft, "&Bitmap only");
|
m_chkBitmapOnly = CreateCheckBoxAndAddToSizer(sizerLeft, "&Bitmap only");
|
||||||
m_chkTextAndBitmap = CreateCheckBoxAndAddToSizer(sizerLeft, "Text &and bitmap");
|
m_chkTextAndBitmap = CreateCheckBoxAndAddToSizer(sizerLeft, "Text &and bitmap");
|
||||||
m_chkFit = CreateCheckBoxAndAddToSizer(sizerLeft, "&Fit exactly");
|
|
||||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
||||||
|
|
||||||
#if wxUSE_MARKUP
|
#if wxUSE_MARKUP
|
||||||
m_chkUseMarkup = CreateCheckBoxAndAddToSizer(sizerLeft, "Interpret &markup");
|
m_chkUseMarkup = CreateCheckBoxAndAddToSizer(sizerLeft, "Interpret &markup");
|
||||||
#endif // wxUSE_MARKUP
|
#endif // wxUSE_MARKUP
|
||||||
|
|
||||||
|
m_chkFit = CreateCheckBoxAndAddToSizer(sizerLeft, "&Fit exactly");
|
||||||
|
m_chkDisable = CreateCheckBoxAndAddToSizer(sizerLeft, "Disable");
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
m_chkUseBitmapClass = CreateCheckBoxAndAddToSizer(sizerLeft,
|
m_chkUseBitmapClass = CreateCheckBoxAndAddToSizer(sizerLeft,
|
||||||
"Use wxBitmapToggleButton");
|
"Use wxBitmapToggleButton");
|
||||||
m_chkUseBitmapClass->SetValue(true);
|
m_chkUseBitmapClass->SetValue(true);
|
||||||
|
|
||||||
m_chkDisable = CreateCheckBoxAndAddToSizer(sizerLeft, "Disable");
|
|
||||||
|
|
||||||
sizerLeft->AddSpacer(5);
|
sizerLeft->AddSpacer(5);
|
||||||
|
|
||||||
@@ -329,15 +331,18 @@ void ToggleWidgetsPage::CreateContent()
|
|||||||
|
|
||||||
void ToggleWidgetsPage::Reset()
|
void ToggleWidgetsPage::Reset()
|
||||||
{
|
{
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
|
||||||
m_chkBitmapOnly->SetValue(false);
|
|
||||||
m_chkFit->SetValue(true);
|
m_chkFit->SetValue(true);
|
||||||
m_chkTextAndBitmap->SetValue(false);
|
m_chkDisable->SetValue(false);
|
||||||
|
|
||||||
#if wxUSE_MARKUP
|
#if wxUSE_MARKUP
|
||||||
m_chkUseMarkup->SetValue(false);
|
m_chkUseMarkup->SetValue(false);
|
||||||
#endif // wxUSE_MARKUP
|
#endif // wxUSE_MARKUP
|
||||||
|
|
||||||
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
|
m_chkBitmapOnly->SetValue(false);
|
||||||
|
m_chkTextAndBitmap->SetValue(false);
|
||||||
m_chkUseBitmapClass->SetValue(true);
|
m_chkUseBitmapClass->SetValue(true);
|
||||||
m_chkDisable->SetValue(false);
|
|
||||||
|
|
||||||
m_chkUsePressed->SetValue(true);
|
m_chkUsePressed->SetValue(true);
|
||||||
m_chkUseFocused->SetValue(true);
|
m_chkUseFocused->SetValue(true);
|
||||||
@@ -381,6 +386,7 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int flags = GetAttrs().m_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
switch ( m_radioHAlign->GetSelection() )
|
switch ( m_radioHAlign->GetSelection() )
|
||||||
{
|
{
|
||||||
@@ -418,9 +424,7 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
flags |= wxBU_BOTTOM;
|
flags |= wxBU_BOTTOM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
|
||||||
bool showsBitmap = false;
|
bool showsBitmap = false;
|
||||||
if ( m_chkBitmapOnly->GetValue() )
|
if ( m_chkBitmapOnly->GetValue() )
|
||||||
{
|
{
|
||||||
@@ -437,7 +441,6 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
btgl = new wxToggleButton(this, TogglePage_Picker, "");
|
btgl = new wxToggleButton(this, TogglePage_Picker, "");
|
||||||
btgl->SetBitmapLabel(CreateBitmap("normal", wxART_INFORMATION));
|
btgl->SetBitmapLabel(CreateBitmap("normal", wxART_INFORMATION));
|
||||||
}
|
}
|
||||||
#ifdef wxHAS_ANY_BUTTON
|
|
||||||
if ( m_chkUsePressed->GetValue() )
|
if ( m_chkUsePressed->GetValue() )
|
||||||
btgl->SetBitmapPressed(CreateBitmap("pushed", wxART_HELP));
|
btgl->SetBitmapPressed(CreateBitmap("pushed", wxART_HELP));
|
||||||
if ( m_chkUseFocused->GetValue() )
|
if ( m_chkUseFocused->GetValue() )
|
||||||
@@ -446,7 +449,6 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
btgl->SetBitmapCurrent(CreateBitmap("hover", wxART_WARNING));
|
btgl->SetBitmapCurrent(CreateBitmap("hover", wxART_WARNING));
|
||||||
if ( m_chkUseDisabled->GetValue() )
|
if ( m_chkUseDisabled->GetValue() )
|
||||||
btgl->SetBitmapDisabled(CreateBitmap("disabled", wxART_MISSING_IMAGE));
|
btgl->SetBitmapDisabled(CreateBitmap("disabled", wxART_MISSING_IMAGE));
|
||||||
#endif // wxHAS_ANY_BUTTON
|
|
||||||
m_toggle = btgl;
|
m_toggle = btgl;
|
||||||
}
|
}
|
||||||
else // normal button
|
else // normal button
|
||||||
@@ -459,7 +461,6 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
m_toggle->SetValue(value);
|
m_toggle->SetValue(value);
|
||||||
|
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
#ifdef wxHAS_ANY_BUTTON
|
|
||||||
if ( !showsBitmap && m_chkTextAndBitmap->GetValue() )
|
if ( !showsBitmap && m_chkTextAndBitmap->GetValue() )
|
||||||
{
|
{
|
||||||
showsBitmap = true;
|
showsBitmap = true;
|
||||||
@@ -481,7 +482,6 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
if ( m_chkUseDisabled->GetValue() )
|
if ( m_chkUseDisabled->GetValue() )
|
||||||
m_toggle->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON));
|
m_toggle->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON));
|
||||||
}
|
}
|
||||||
#endif // wxHAS_ANY_BUTTON
|
|
||||||
|
|
||||||
m_chkUseBitmapClass->Enable(showsBitmap);
|
m_chkUseBitmapClass->Enable(showsBitmap);
|
||||||
m_chkTextAndBitmap->Enable(!m_chkBitmapOnly->IsChecked());
|
m_chkTextAndBitmap->Enable(!m_chkBitmapOnly->IsChecked());
|
||||||
@@ -490,9 +490,10 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
m_chkUseFocused->Enable(showsBitmap);
|
m_chkUseFocused->Enable(showsBitmap);
|
||||||
m_chkUseCurrent->Enable(showsBitmap);
|
m_chkUseCurrent->Enable(showsBitmap);
|
||||||
m_chkUseDisabled->Enable(showsBitmap);
|
m_chkUseDisabled->Enable(showsBitmap);
|
||||||
m_toggle->Enable(!m_chkDisable->IsChecked());
|
|
||||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
||||||
|
|
||||||
|
m_toggle->Enable(!m_chkDisable->IsChecked());
|
||||||
|
|
||||||
AddButtonToSizer();
|
AddButtonToSizer();
|
||||||
|
|
||||||
m_sizerToggle->Layout();
|
m_sizerToggle->Layout();
|
||||||
@@ -500,7 +501,6 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
|
|
||||||
void ToggleWidgetsPage::AddButtonToSizer()
|
void ToggleWidgetsPage::AddButtonToSizer()
|
||||||
{
|
{
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
|
||||||
if ( m_chkFit->GetValue() )
|
if ( m_chkFit->GetValue() )
|
||||||
{
|
{
|
||||||
m_sizerToggle->AddStretchSpacer(1);
|
m_sizerToggle->AddStretchSpacer(1);
|
||||||
@@ -508,7 +508,6 @@ void ToggleWidgetsPage::AddButtonToSizer()
|
|||||||
m_sizerToggle->AddStretchSpacer(1);
|
m_sizerToggle->AddStretchSpacer(1);
|
||||||
}
|
}
|
||||||
else // take up the entire space
|
else // take up the entire space
|
||||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
|
||||||
{
|
{
|
||||||
m_sizerToggle->Add(m_toggle, wxSizerFlags(1).Expand().Border());
|
m_sizerToggle->Add(m_toggle, wxSizerFlags(1).Expand().Border());
|
||||||
}
|
}
|
||||||
|
@@ -54,8 +54,7 @@ enum
|
|||||||
// the gaps between the slider and the labels, in pixels
|
// the gaps between the slider and the labels, in pixels
|
||||||
const int HGAP = 5;
|
const int HGAP = 5;
|
||||||
const int VGAP = 4;
|
const int VGAP = 4;
|
||||||
// these 2 values are arbitrary:
|
// this value is arbitrary:
|
||||||
const int THUMB = 24;
|
|
||||||
const int TICK = 8;
|
const int TICK = 8;
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -194,6 +193,9 @@ WXDWORD wxSlider::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
// TBS_HORZ, TBS_RIGHT and TBS_BOTTOM are 0 but do include them for clarity
|
// TBS_HORZ, TBS_RIGHT and TBS_BOTTOM are 0 but do include them for clarity
|
||||||
msStyle |= style & wxSL_VERTICAL ? TBS_VERT : TBS_HORZ;
|
msStyle |= style & wxSL_VERTICAL ? TBS_VERT : TBS_HORZ;
|
||||||
|
|
||||||
|
// allow setting thumb size
|
||||||
|
msStyle |= TBS_FIXEDLENGTH;
|
||||||
|
|
||||||
if ( style & wxSL_BOTH )
|
if ( style & wxSL_BOTH )
|
||||||
{
|
{
|
||||||
// this fully specifies the style combined with TBS_VERT/HORZ above
|
// this fully specifies the style combined with TBS_VERT/HORZ above
|
||||||
@@ -390,6 +392,9 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int thumbSize = GetThumbLength();
|
||||||
|
const int tickSize = FromDIP(TICK);
|
||||||
|
|
||||||
int minLabelWidth,
|
int minLabelWidth,
|
||||||
maxLabelWidth;
|
maxLabelWidth;
|
||||||
const int labelHeight = GetLabelsSize(&minLabelWidth, &maxLabelWidth);
|
const int labelHeight = GetLabelsSize(&minLabelWidth, &maxLabelWidth);
|
||||||
@@ -401,10 +406,10 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int tickOffset = 0;
|
int tickOffset = 0;
|
||||||
if ( HasFlag(wxSL_TICKS))
|
if ( HasFlag(wxSL_TICKS) )
|
||||||
tickOffset = TICK;
|
tickOffset = tickSize;
|
||||||
if ( HasFlag(wxSL_BOTH))
|
if ( HasFlag(wxSL_BOTH) )
|
||||||
tickOffset *= 2;
|
tickOffset *= 2;
|
||||||
|
|
||||||
// be careful to position the slider itself after moving the labels as
|
// be careful to position the slider itself after moving the labels as
|
||||||
// otherwise our GetBoundingBox(), which is called from WM_SIZE handler,
|
// otherwise our GetBoundingBox(), which is called from WM_SIZE handler,
|
||||||
@@ -419,7 +424,7 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
sliderOffset += longestLabelWidth + HGAP;
|
sliderOffset += longestLabelWidth + HGAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
int labelHeightUsed = 0 ;
|
int labelHeightUsed = 0;
|
||||||
|
|
||||||
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||||
{
|
{
|
||||||
@@ -429,9 +434,12 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
if ( HasFlag(wxSL_LEFT) )
|
if ( HasFlag(wxSL_LEFT) )
|
||||||
{
|
{
|
||||||
// Label aligned to the left edge of the slider.
|
// Label aligned to the left edge of the slider.
|
||||||
xPos = sliderOffset + tickOffset;
|
xPos = sliderOffset + thumbSize / 2;
|
||||||
holdTopX = xPos;
|
if ( HasFlag(wxSL_TICKS) )
|
||||||
holdBottomX = xPos;
|
xPos += tickSize;
|
||||||
|
|
||||||
|
holdTopX = xPos - minLabelWidth / 2;
|
||||||
|
holdBottomX = xPos - maxLabelWidth / 2;
|
||||||
if ( holdTopX + minLabelWidth > width )
|
if ( holdTopX + minLabelWidth > width )
|
||||||
holdTopX = width - minLabelWidth;
|
holdTopX = width - minLabelWidth;
|
||||||
if ( holdBottomX + maxLabelWidth > width )
|
if ( holdBottomX + maxLabelWidth > width )
|
||||||
@@ -440,24 +448,18 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
else // wxSL_RIGHT
|
else // wxSL_RIGHT
|
||||||
{
|
{
|
||||||
// Label aligned to the right edge of the slider.
|
// Label aligned to the right edge of the slider.
|
||||||
if ( HasFlag(wxSL_BOTH) )
|
xPos = sliderOffset + thumbSize / 2;
|
||||||
xPos = sliderOffset + THUMB + tickOffset/2;
|
if ( HasFlag(wxSL_TICKS) && HasFlag(wxSL_BOTH) )
|
||||||
else
|
xPos += tickSize;
|
||||||
xPos = sliderOffset + THUMB;
|
|
||||||
|
|
||||||
holdTopX = xPos - minLabelWidth;
|
holdTopX = xPos - minLabelWidth / 2;
|
||||||
holdBottomX = xPos - maxLabelWidth;
|
holdBottomX = xPos - maxLabelWidth / 2;
|
||||||
if ( holdTopX < 0 )
|
if ( holdTopX < 0 )
|
||||||
holdTopX = 0;
|
holdTopX = 0;
|
||||||
if ( holdBottomX < 0 )
|
if ( holdBottomX < 0 )
|
||||||
holdBottomX = 0;
|
holdBottomX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( HasFlag(wxSL_INVERSE) )
|
|
||||||
{
|
|
||||||
wxSwap(holdTopX, holdBottomX);
|
|
||||||
}
|
|
||||||
|
|
||||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
|
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
|
||||||
x + holdTopX,
|
x + holdTopX,
|
||||||
y,
|
y,
|
||||||
@@ -467,14 +469,14 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
y + height - labelHeight,
|
y + height - labelHeight,
|
||||||
maxLabelWidth, labelHeight);
|
maxLabelWidth, labelHeight);
|
||||||
|
|
||||||
labelHeightUsed = labelHeight ;
|
labelHeightUsed = labelHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||||
{
|
{
|
||||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
||||||
x + ( HasFlag(wxSL_LEFT) ? THUMB + tickOffset + HGAP : 0 ),
|
x + ( HasFlag(wxSL_LEFT) ? thumbSize + tickOffset + HGAP : 0 ),
|
||||||
y + (height - labelHeight)/2,
|
y + (height - labelHeight) / 2,
|
||||||
longestLabelWidth, labelHeight);
|
longestLabelWidth, labelHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,27 +484,27 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
wxSliderBase::DoMoveWindow(
|
wxSliderBase::DoMoveWindow(
|
||||||
x + sliderOffset,
|
x + sliderOffset,
|
||||||
y + labelHeightUsed,
|
y + labelHeightUsed,
|
||||||
THUMB + tickOffset,
|
thumbSize + tickOffset,
|
||||||
height - (labelHeightUsed * 2));
|
height - (labelHeightUsed * 2));
|
||||||
}
|
}
|
||||||
else // horizontal
|
else // horizontal
|
||||||
{
|
{
|
||||||
int yLabelMinMax =
|
int yLabelMinMax =
|
||||||
(y + ((THUMB + tickOffset) / 2)) - (labelHeight / 2);
|
((thumbSize + tickOffset) / 2) - (labelHeight / 2);
|
||||||
int xLabelValue =
|
int xLabelValue =
|
||||||
x + minLabelWidth +
|
minLabelWidth +
|
||||||
((width - (minLabelWidth + maxLabelWidth)) / 2) -
|
((width - (minLabelWidth + maxLabelWidth)) / 2) -
|
||||||
(longestLabelWidth / 2);
|
(longestLabelWidth / 2);
|
||||||
|
|
||||||
int ySlider = y;
|
int ySlider = 0;
|
||||||
int minLabelWidthUsed = 0 ;
|
int minLabelWidthUsed = 0;
|
||||||
int maxLabelWidthUsed = 0 ;
|
int maxLabelWidthUsed = 0;
|
||||||
|
|
||||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||||
{
|
{
|
||||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Value],
|
||||||
xLabelValue,
|
x + xLabelValue,
|
||||||
y + (HasFlag(wxSL_BOTTOM) ? 0 : THUMB + tickOffset),
|
y + (HasFlag(wxSL_BOTTOM) ? 0 : thumbSize + tickOffset),
|
||||||
longestLabelWidth, labelHeight);
|
longestLabelWidth, labelHeight);
|
||||||
|
|
||||||
if ( HasFlag(wxSL_BOTTOM) )
|
if ( HasFlag(wxSL_BOTTOM) )
|
||||||
@@ -516,36 +518,38 @@ void wxSlider::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
{
|
{
|
||||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
|
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Min],
|
||||||
x,
|
x,
|
||||||
yLabelMinMax,
|
y + yLabelMinMax,
|
||||||
minLabelWidth, labelHeight);
|
minLabelWidth, labelHeight);
|
||||||
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Max],
|
DoMoveSibling((HWND)(*m_labels)[SliderLabel_Max],
|
||||||
x + width - maxLabelWidth,
|
x + width - maxLabelWidth,
|
||||||
yLabelMinMax,
|
y + yLabelMinMax,
|
||||||
maxLabelWidth, labelHeight);
|
maxLabelWidth, labelHeight);
|
||||||
|
|
||||||
minLabelWidthUsed = minLabelWidth + VGAP ;
|
minLabelWidthUsed = minLabelWidth + VGAP;
|
||||||
maxLabelWidthUsed = maxLabelWidth + VGAP ;
|
maxLabelWidthUsed = maxLabelWidth + VGAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// position the slider itself along the top/bottom edge
|
// position the slider itself along the top/bottom edge
|
||||||
wxSliderBase::DoMoveWindow(
|
wxSliderBase::DoMoveWindow(
|
||||||
x + minLabelWidthUsed,
|
x + minLabelWidthUsed,
|
||||||
ySlider,
|
y + ySlider,
|
||||||
width - (minLabelWidthUsed + maxLabelWidthUsed),
|
width - (minLabelWidthUsed + maxLabelWidthUsed),
|
||||||
THUMB + tickOffset);
|
thumbSize + tickOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxSlider::DoGetBestSize() const
|
wxSize wxSlider::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
// this value is arbitrary:
|
// this value is arbitrary:
|
||||||
static const int length = 100;
|
static const int length = FromDIP(100);
|
||||||
|
const int thumbSize = GetThumbLength();
|
||||||
|
const int tickSize = FromDIP(TICK);
|
||||||
|
|
||||||
int *width;
|
int *width;
|
||||||
wxSize size;
|
wxSize size;
|
||||||
if ( HasFlag(wxSL_VERTICAL) )
|
if ( HasFlag(wxSL_VERTICAL) )
|
||||||
{
|
{
|
||||||
size.Set(THUMB, length);
|
size.Set(thumbSize, length);
|
||||||
width = &size.x;
|
width = &size.x;
|
||||||
|
|
||||||
if ( m_labels )
|
if ( m_labels )
|
||||||
@@ -559,7 +563,7 @@ wxSize wxSlider::DoGetBestSize() const
|
|||||||
if ( HasFlag(wxSL_VALUE_LABEL) )
|
if ( HasFlag(wxSL_VALUE_LABEL) )
|
||||||
size.x += longestLabelWidth + HGAP;
|
size.x += longestLabelWidth + HGAP;
|
||||||
|
|
||||||
if (HasFlag(wxSL_MIN_MAX_LABELS))
|
if ( HasFlag(wxSL_MIN_MAX_LABELS) )
|
||||||
{
|
{
|
||||||
size.x = wxMax(size.x, longestLabelWidth);
|
size.x = wxMax(size.x, longestLabelWidth);
|
||||||
size.y += hLabel * 2;
|
size.y += hLabel * 2;
|
||||||
@@ -568,7 +572,7 @@ wxSize wxSlider::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
else // horizontal
|
else // horizontal
|
||||||
{
|
{
|
||||||
size.Set(length, THUMB);
|
size.Set(length, thumbSize);
|
||||||
width = &size.y;
|
width = &size.y;
|
||||||
|
|
||||||
if ( m_labels )
|
if ( m_labels )
|
||||||
@@ -588,10 +592,10 @@ wxSize wxSlider::DoGetBestSize() const
|
|||||||
// need extra space to show ticks
|
// need extra space to show ticks
|
||||||
if ( HasFlag(wxSL_TICKS) )
|
if ( HasFlag(wxSL_TICKS) )
|
||||||
{
|
{
|
||||||
*width += TICK;
|
*width += tickSize;
|
||||||
// and maybe twice as much if we show them on both sides
|
// and maybe twice as much if we show them on both sides
|
||||||
if ( HasFlag(wxSL_BOTH) )
|
if ( HasFlag(wxSL_BOTH) )
|
||||||
*width += TICK;
|
*width += tickSize;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -649,7 +653,7 @@ void wxSlider::SetRange(int minValue, int maxValue)
|
|||||||
|
|
||||||
if ( m_labels )
|
if ( m_labels )
|
||||||
{
|
{
|
||||||
Move(wxDefaultPosition); // Force a re-layout the labels.
|
Move(wxDefaultPosition, wxSIZE_FORCE); // Force a re-layout the labels.
|
||||||
|
|
||||||
// Update the label with the value adjusted by the control as
|
// Update the label with the value adjusted by the control as
|
||||||
// old value can be out of the new range.
|
// old value can be out of the new range.
|
||||||
@@ -730,6 +734,8 @@ void wxSlider::SetSelection(int minPos, int maxPos)
|
|||||||
void wxSlider::SetThumbLength(int len)
|
void wxSlider::SetThumbLength(int len)
|
||||||
{
|
{
|
||||||
::SendMessage(GetHwnd(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0);
|
::SendMessage(GetHwnd(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0);
|
||||||
|
|
||||||
|
InvalidateBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxSlider::GetThumbLength() const
|
int wxSlider::GetThumbLength() const
|
||||||
|
Reference in New Issue
Block a user