virtual bool Enable(bool enable = TRUE) ;
virtual bool Show(bool show = TRUE) ;
-
+ virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
+
virtual void MacRedrawControl () ;
virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
virtual void MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
// temporarily switches event handlers).
// ----------------------------------------------------------------------------
+// different window variants, on platforms like eg mac uses different rendering sizes
+
+enum wxWindowVariant
+{
+ wxWINDOW_VARIANT_DEFAULT, // Default size (usually == normal, may be set by a wxSystemOptions entry)
+ wxWINDOW_VARIANT_NORMAL, // Normal size
+ wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal )
+ wxWINDOW_VARIANT_MINI, // Mini size (about 33 % smaller than normal )
+ wxWINDOW_VARIANT_LARGE, // Large size (about 25 % larger than normal )
+};
+
class WXDLLEXPORT wxWindowBase : public wxEvtHandler
{
public:
virtual void SetName( const wxString &name ) { m_windowName = name; }
virtual wxString GetName() const { return m_windowName; }
+ // sets the window variant, calls internally DoSetVariant if variant has changed
+ void SetWindowVariant( wxWindowVariant variant ) ;
+ wxWindowVariant GetWindowVariant() const { return m_windowVariant ; }
+
+
// window id uniquely identifies the window among its siblings unless
// it is -1 which means "don't care"
void SetId( wxWindowID winid ) { m_windowId = winid; }
int m_minVirtualHeight;
int m_maxVirtualWidth;
int m_maxVirtualHeight;
+
+ wxWindowVariant m_windowVariant ;
// override this to change the default (i.e. used when no style is
// specified) border for the window class
virtual void AdjustForParentClientOrigin(int& x, int& y,
int sizeFlags = 0) const;
+ // implements the window variants
+ virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
private:
#endif
m_virtualSize = wxDefaultSize;
-
+
m_minVirtualWidth =
m_minVirtualHeight =
m_maxVirtualWidth =
m_maxVirtualHeight = -1;
+ m_windowVariant = wxWINDOW_VARIANT_DEFAULT ;
+
// Whether we're using the current theme for this window (wxGTK only for now)
m_themeEnabled = false;
}
m_maxHeight = maxH;
}
+void wxWindowBase::SetWindowVariant( wxWindowVariant variant )
+{
+ if ( m_windowVariant == variant )
+ return ;
+
+ m_windowVariant = variant ;
+
+ DoSetWindowVariant( variant ) ;
+ return ;
+}
+
+void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant )
+{
+ wxFont font = wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT ) ;
+ int size = font.GetPointSize() ;
+ switch ( variant )
+ {
+ case wxWINDOW_VARIANT_NORMAL :
+ break ;
+ case wxWINDOW_VARIANT_SMALL :
+ font.SetPointSize( size * 3 / 4 ) ;
+ break ;
+ case wxWINDOW_VARIANT_MINI :
+ font.SetPointSize( size * 2 / 3 ) ;
+ break ;
+ case wxWINDOW_VARIANT_LARGE :
+ font.SetPointSize( size * 5 / 4 ) ;
+ break ;
+ case wxWINDOW_VARIANT_DEFAULT :
+ break ;
+ default:
+ wxFAIL_MSG(_T("unexpected window variant"));
+ break ;
+ }
+ SetFont( font ) ;
+}
+
void wxWindowBase::SetVirtualSizeHints( int minW, int minH,
int maxW, int maxH )
{
void wxControl::MacPostControlCreate()
{
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
+ DoSetWindowVariant( m_windowVariant ) ;
+ /*
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{
// no font
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
}
+ */
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
::EmbedControl( (ControlHandle) m_macControl , container ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
}
+void wxControl::DoSetWindowVariant( wxWindowVariant variant )
+{
+ if ( m_macControl == NULL )
+ {
+ wxWindow::SetWindowVariant( variant ) ;
+ return ;
+
+ }
+ m_windowVariant = variant ;
+
+ ControlSize size ;
+ ControlFontStyleRec fontStyle;
+ fontStyle.flags = kControlUseFontMask ;
+
+ // we will get that from the settings later
+ // and make this NORMAL later, but first
+ // we have a few calculations that we must fix
+
+ if ( variant == wxWINDOW_VARIANT_DEFAULT )
+ variant = wxWINDOW_VARIANT_SMALL ;
+
+ switch ( variant )
+ {
+ case wxWINDOW_VARIANT_NORMAL :
+ size = kControlSizeNormal;
+ fontStyle.font = kControlFontBigSystemFont;
+ break ;
+ case wxWINDOW_VARIANT_SMALL :
+ size = kControlSizeSmall;
+ fontStyle.font = kControlFontSmallSystemFont;
+ break ;
+ case wxWINDOW_VARIANT_MINI :
+ if (UMAGetSystemVersion() >= 0x1030 )
+ {
+ size = 3 ; // not always defined in the header
+ fontStyle.font = -5 ; // not always defined in the header
+ }
+ else
+ {
+ size = kControlSizeSmall;
+ fontStyle.font = kControlFontSmallSystemFont;
+ }
+ break;
+ break ;
+ case wxWINDOW_VARIANT_LARGE :
+ size = kControlSizeLarge;
+ fontStyle.font = kControlFontBigSystemFont;
+ break ;
+ default:
+ wxFAIL_MSG(_T("unexpected window variant"));
+ break ;
+ }
+ ::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
+ ::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle );
+}
void wxControl::MacPostControlCreate()
{
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
+ DoSetWindowVariant( m_windowVariant ) ;
+ /*
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{
// no font
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
}
+ */
ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
::EmbedControl( (ControlHandle) m_macControl , container ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
}
+void wxControl::DoSetWindowVariant( wxWindowVariant variant )
+{
+ if ( m_macControl == NULL )
+ {
+ wxWindow::SetWindowVariant( variant ) ;
+ return ;
+
+ }
+ m_windowVariant = variant ;
+
+ ControlSize size ;
+ ControlFontStyleRec fontStyle;
+ fontStyle.flags = kControlUseFontMask ;
+
+ // we will get that from the settings later
+ // and make this NORMAL later, but first
+ // we have a few calculations that we must fix
+
+ if ( variant == wxWINDOW_VARIANT_DEFAULT )
+ variant = wxWINDOW_VARIANT_SMALL ;
+
+ switch ( variant )
+ {
+ case wxWINDOW_VARIANT_NORMAL :
+ size = kControlSizeNormal;
+ fontStyle.font = kControlFontBigSystemFont;
+ break ;
+ case wxWINDOW_VARIANT_SMALL :
+ size = kControlSizeSmall;
+ fontStyle.font = kControlFontSmallSystemFont;
+ break ;
+ case wxWINDOW_VARIANT_MINI :
+ if (UMAGetSystemVersion() >= 0x1030 )
+ {
+ size = 3 ; // not always defined in the header
+ fontStyle.font = -5 ; // not always defined in the header
+ }
+ else
+ {
+ size = kControlSizeSmall;
+ fontStyle.font = kControlFontSmallSystemFont;
+ }
+ break;
+ break ;
+ case wxWINDOW_VARIANT_LARGE :
+ size = kControlSizeLarge;
+ fontStyle.font = kControlFontBigSystemFont;
+ break ;
+ default:
+ wxFAIL_MSG(_T("unexpected window variant"));
+ break ;
+ }
+ ::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
+ ::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle );
+}