+ wxSize size = GetBestSize();
+
+ if(GetWindowStyle() & wxSL_VERTICAL) {
+ wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH);
+ }
+ else {
+ wxWindow::SetSizeHints(minW, size.y, maxW, size.y, incW, incH);
+ }
+}
+
+wxSize wxSlider::DoGetBestSize() const
+{
+ wxSize size;
+ int textwidth, textheight;
+
+ if(GetWindowStyle() & wxSL_LABELS)
+ {
+ wxString text;
+ int ht, wd;
+
+ // Get maximum text label width and height
+ text.Printf(wxT("%d"), m_rangeMin);
+ GetTextExtent(text, &textwidth, &textheight);
+ text.Printf(wxT("%d"), m_rangeMax);
+ GetTextExtent(text, &wd, &ht);
+ if(ht > textheight) {
+ textheight = ht;
+ }
+ if (wd > textwidth) {
+ textwidth = wd;
+ }
+ }
+
+ if(GetWindowStyle() & wxSL_VERTICAL)
+ {
+ if(GetWindowStyle() & wxSL_AUTOTICKS) {
+ size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
+ }
+ else {
+ size.x = wxSLIDER_DIMENSIONACROSS_ARROW;
+ }
+ if(GetWindowStyle() & wxSL_LABELS) {
+ size.x += textwidth + wxSLIDER_BORDERTEXT;
+ }
+ size.y = 150;
+ }
+ else
+ {
+ if(GetWindowStyle() & wxSL_AUTOTICKS) {
+ size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
+ }
+ else {
+ size.y = wxSLIDER_DIMENSIONACROSS_ARROW;
+ }
+ if(GetWindowStyle() & wxSL_LABELS) {
+ size.y += textheight + wxSLIDER_BORDERTEXT;
+ }
+ size.x = 150;
+ }
+ return size;
+}
+
+void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags)
+{
+ int xborder, yborder;
+ int minValWidth, maxValWidth, textwidth, textheight;
+ int sliderBreadth;
+
+ xborder = yborder = 0;
+
+ if (GetWindowStyle() & wxSL_LABELS)
+ {
+ wxString text;
+ int ht;
+
+ // Get maximum text label width and height
+ text.Printf(wxT("%d"), m_rangeMin);
+ GetTextExtent(text, &minValWidth, &textheight);
+ text.Printf(wxT("%d"), m_rangeMax);
+ GetTextExtent(text, &maxValWidth, &ht);
+ if(ht > textheight) {
+ textheight = ht;
+ }
+ textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth);
+
+ xborder = textwidth + wxSLIDER_BORDERTEXT;
+ yborder = textheight + wxSLIDER_BORDERTEXT;
+
+ // Get slider breadth
+ if(GetWindowStyle() & wxSL_AUTOTICKS) {
+ sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
+ }
+ else {
+ sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW;
+ }
+
+ if(GetWindowStyle() & wxSL_VERTICAL)
+ {
+
+ if ( m_macMinimumStatic )
+ m_macMinimumStatic->Move(x + sliderBreadth + wxSLIDER_BORDERTEXT,
+ y + h - yborder - textheight);
+ if ( m_macMaximumStatic )
+ m_macMaximumStatic->Move(x + sliderBreadth + wxSLIDER_BORDERTEXT, y + 0);
+ if ( m_macValueStatic )
+ m_macValueStatic->Move(0, y + h - textheight);
+ h = h - yborder ;
+ }
+ else
+ {
+ if ( m_macMinimumStatic )
+ m_macMinimumStatic->Move(x + 0, y + sliderBreadth + wxSLIDER_BORDERTEXT);
+ if ( m_macMaximumStatic )
+ m_macMaximumStatic->Move(x + w - xborder - maxValWidth / 2,
+ y + sliderBreadth + wxSLIDER_BORDERTEXT);
+ if ( m_macValueStatic )
+ m_macValueStatic->Move(x + w - textwidth, y + 0);
+ w = w - xborder ;
+ }
+ }
+
+ wxControl::DoSetSize( x, y , w , h ,sizeFlags ) ;