static void DisclosureElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { SInt32 s; GetThemeMetric(kThemeMetricDisclosureTriangleWidth, &s); *widthPtr = s; GetThemeMetric(kThemeMetricDisclosureTriangleHeight, &s); *heightPtr = s; }
static void TabElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *heightPtr = GetThemeMetric(kThemeMetricLargeTabHeight, heightPtr); *paddingPtr = Ttk_MakePadding(0, 0, 0, 2); }
wxSize wxChoice::DoGetBestSize() const { int lbWidth = GetCount() > 0 ? 20 : 100; // some defaults int lbHeight = 20; int wLine; #if TARGET_CARBON long metric ; GetThemeMetric(kThemeMetricPopupButtonHeight , &metric ); lbHeight = metric ; #endif { wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetTopLevelWindowRef() ) ) ; if ( m_font.Ok() ) { ::TextFont( m_font.MacGetFontNum() ) ; ::TextSize( m_font.MacGetFontSize() ) ; ::TextFace( m_font.MacGetFontStyle() ) ; } else { ::TextFont( kFontIDMonaco ) ; ::TextSize( 9 ); ::TextFace( 0 ) ; } // Find the widest line for(int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); #if wxUSE_UNICODE Point bounds={0,0} ; SInt16 baseline ; ::GetThemeTextDimensions( wxMacCFStringHolder( str , m_font.GetEncoding() ) , kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); wLine = bounds.h ; #else wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; #endif lbWidth = wxMax(lbWidth, wLine); } // Add room for the popup arrow lbWidth += 2 * lbHeight ; // And just a bit more int cx = ::TextWidth( "X" , 0 , 1 ) ; lbWidth += cx ; } return wxSize(lbWidth, lbHeight); }
void QStyleItem::paint(QPainter *painter) { if (width() < 1 || height() <1) return; initStyleOption(); switch (m_itemType) { case Button: qApp->style()->drawControl(QStyle::CE_PushButton, m_styleoption, painter); break; case ItemRow :{ QPixmap pixmap; // Only draw through style once const QString pmKey = QLatin1Literal("itemrow") % QString::number(m_styleoption->state,16) % activeControl(); if (!QPixmapCache::find(pmKey, pixmap) || pixmap.width() < width() || height() != pixmap.height()) { int newSize = width(); pixmap = QPixmap(newSize, height()); pixmap.fill(Qt::transparent); QPainter pixpainter(&pixmap); qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter); if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected()) pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight()); QPixmapCache::insert(pmKey, pixmap); } painter->drawPixmap(0, 0, pixmap); } break; case Item: qApp->style()->drawControl(QStyle::CE_ItemViewItem, m_styleoption, painter); break; case Header: qApp->style()->drawControl(QStyle::CE_Header, m_styleoption, painter); break; case ToolButton: #ifdef Q_OS_MAC if (style() == "mac" && hint().indexOf("segmented") != -1) { const QPaintDevice *target = painter->device(); HIThemeSegmentDrawInfo sgi; sgi.version = 0; sgi.state = isEnabled() ? kThemeStateActive : kThemeStateDisabled; if (sunken()) sgi.state |= kThemeStatePressed; sgi.size = kHIThemeSegmentSizeNormal; sgi.kind = kHIThemeSegmentKindTextured; sgi.value = on() && !sunken() ? kThemeButtonOn : kThemeButtonOff; sgi.adornment |= kHIThemeSegmentAdornmentLeadingSeparator; if (sunken()) { sgi.adornment |= kHIThemeSegmentAdornmentTrailingSeparator; } SInt32 button_height; GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height); sgi.position = info() == "leftmost" ? kHIThemeSegmentPositionFirst: info() == "rightmost" ? kHIThemeSegmentPositionLast : info() == "h_middle" ? kHIThemeSegmentPositionMiddle : kHIThemeSegmentPositionOnly; QRect centered = m_styleoption->rect; centered.setHeight(button_height); centered.moveCenter(m_styleoption->rect.center()); HIRect hirect = qt_hirectForQRect(centered.translated(0, -1), QRect(0, 0, 0, 0)); HIThemeDrawSegment(&hirect, &sgi, qt_mac_cg_context(target), kHIThemeOrientationNormal); } else #endif qApp->style()->drawComplexControl(QStyle::CC_ToolButton, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case Tab: qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter); break; case Frame: qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter); break; case FocusFrame: if (style() == "mac" && hint().indexOf("rounded") != -1) break; // embedded in the line itself else qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter); break; case TabFrame: qApp->style()->drawPrimitive(QStyle::PE_FrameTabWidget, m_styleoption, painter); break; case MenuBar: qApp->style()->drawControl(QStyle::CE_MenuBarEmptyArea, m_styleoption, painter); break; case MenuBarItem: qApp->style()->drawControl(QStyle::CE_MenuBarItem, m_styleoption, painter); break; case MenuItem: case ComboBoxItem: // fall through qApp->style()->drawControl(QStyle::CE_MenuItem, m_styleoption, painter); break; case CheckBox: qApp->style()->drawControl(QStyle::CE_CheckBox, m_styleoption, painter); break; case RadioButton: qApp->style()->drawControl(QStyle::CE_RadioButton, m_styleoption, painter); break; case Edit: { #ifdef Q_OS_MAC if (style() == "mac" && hint().indexOf("rounded") != -1) { const QPaintDevice *target = painter->device(); HIThemeFrameDrawInfo fdi; fdi.version = 0; fdi.state = kThemeStateActive; SInt32 frame_size; GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); fdi.kind = kHIThemeFrameTextFieldRound; if ((m_styleoption->state & QStyle::State_ReadOnly) || !(m_styleoption->state & QStyle::State_Enabled)) fdi.state = kThemeStateInactive; fdi.isFocused = hasFocus(); HIRect hirect = qt_hirectForQRect(m_styleoption->rect, QRect(frame_size, frame_size, frame_size * 2, frame_size * 2)); HIThemeDrawFrame(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal); } else #endif qApp->style()->drawPrimitive(QStyle::PE_PanelLineEdit, m_styleoption, painter); } break; case MacHelpButton: #ifdef Q_OS_MAC { const QPaintDevice *target = painter->device(); HIThemeButtonDrawInfo fdi; fdi.kind = kThemeRoundButtonHelp; fdi.version = 0; fdi.adornment = 0; fdi.state = sunken() ? kThemeStatePressed : kThemeStateActive; HIRect hirect = qt_hirectForQRect(m_styleoption->rect,QRect(0, 0, 0, 0)); HIThemeDrawButton(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal, NULL); } #endif break; case Widget: qApp->style()->drawPrimitive(QStyle::PE_Widget, m_styleoption, painter); break; case ScrollAreaCorner: qApp->style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, m_styleoption, painter); break; case Splitter: if (m_styleoption->rect.width() == 1) painter->fillRect(0, 0, width(), height(), m_styleoption->palette.dark().color()); else qApp->style()->drawControl(QStyle::CE_Splitter, m_styleoption, painter); break; case ComboBox: { qApp->style()->drawComplexControl(QStyle::CC_ComboBox, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); // This is needed on mac as it will use the painter color and ignore the palette QPen pen = painter->pen(); painter->setPen(m_styleoption->palette.text().color()); qApp->style()->drawControl(QStyle::CE_ComboBoxLabel, m_styleoption, painter); painter->setPen(pen); } break; case SpinBox: qApp->style()->drawComplexControl(QStyle::CC_SpinBox, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case Slider: qApp->style()->drawComplexControl(QStyle::CC_Slider, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case Dial: qApp->style()->drawComplexControl(QStyle::CC_Dial, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case ProgressBar: qApp->style()->drawControl(QStyle::CE_ProgressBar, m_styleoption, painter); break; case ToolBar: qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter); break; case StatusBar: if (style() == "mac") { m_styleoption->rect.adjust(0, 1, 0, 0); qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter); m_styleoption->rect.adjust(0, -1, 0, 0); painter->setPen(m_styleoption->palette.dark().color().darker(120)); painter->drawLine(m_styleoption->rect.topLeft(), m_styleoption->rect.topRight()); } else { qApp->style()->drawPrimitive(QStyle::PE_PanelToolBar, m_styleoption, painter); } break; case GroupBox: qApp->style()->drawComplexControl(QStyle::CC_GroupBox, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case ScrollBar: qApp->style()->drawComplexControl(QStyle::CC_ScrollBar, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter); break; case Menu: { QStyleHintReturnMask val; qApp->style()->styleHint(QStyle::SH_Menu_Mask, m_styleoption, 0, &val); painter->save(); painter->setClipRegion(val.region); painter->fillRect(m_styleoption->rect, m_styleoption->palette.window()); painter->restore(); qApp->style()->drawPrimitive(QStyle::PE_PanelMenu, m_styleoption, painter); QStyleOptionFrame frame; frame.lineWidth = qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth); frame.midLineWidth = 0; frame.rect = m_styleoption->rect; qApp->style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, painter); } break; default: break; } }
wxAuiDefaultDockArt::wxAuiDefaultDockArt() { #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON wxColor baseColour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground)); #else wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); #endif // the baseColour is too pale to use as our base colour, // so darken it a bit -- if ((255-baseColour.Red()) + (255-baseColour.Green()) + (255-baseColour.Blue()) < 60) { baseColour = baseColour.ChangeLightness(92); } m_baseColour = baseColour; wxColor darker1Colour = baseColour.ChangeLightness(85); wxColor darker2Colour = baseColour.ChangeLightness(75); wxColor darker3Colour = baseColour.ChangeLightness(60); //wxColor darker4Colour = baseColour.ChangeLightness(50); wxColor darker5Colour = baseColour.ChangeLightness(40); m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); m_inactiveCaptionColour = darker1Colour; m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97); m_inactiveCaptionTextColour = *wxBLACK; m_sashBrush = wxBrush(baseColour); m_backgroundBrush = wxBrush(baseColour); m_gripperBrush = wxBrush(baseColour); m_borderPen = wxPen(darker2Colour); m_gripperPen1 = wxPen(darker5Colour); m_gripperPen2 = wxPen(darker3Colour); m_gripperPen3 = *wxWHITE_PEN; #ifdef __WXMAC__ m_captionFont = *wxSMALL_FONT; #else m_captionFont = wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); #endif // default metric values #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON SInt32 height; GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height ); m_sashSize = height; #elif defined(__WXGTK__) m_sashSize = wxRendererNative::Get().GetSplitterParams(NULL).widthSash; #else m_sashSize = 4; #endif m_captionSize = 17; m_borderSize = 1; m_buttonSize = 14; m_gripperSize = 9; m_gradientType = wxAUI_GRADIENT_VERTICAL; InitBitmaps(); }
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString &name) { if ( !wxCheckListBoxBase::Create(parent, id, pos, size, n, choices, style, validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; m_checkBoxWidth = 12; m_checkBoxHeight= 10; long h = m_checkBoxHeight ; #if TARGET_CARBON GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif const wxFont& font = GetFont(); FontInfo finfo; FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo); m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; if (m_checkBoxHeight<h) { m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2; m_checkBoxHeight= h; } Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macCheckListDefUPP == NULL ) { macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition ); } listDef.u.userProc = macCheckListDefUPP ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true, m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lNoExtend ; } else if ( style & wxLB_EXTENDED ) { options += lExtendDrag ; } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); MacPostControlCreate() ; for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } LSetDrawingMode( true , (ListHandle) m_macList ) ; return TRUE; }
wxAuiDefaultDockArt::wxAuiDefaultDockArt() { #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON wxColor base_colour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground)); #else wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); #endif // the base_colour is too pale to use as our base colour, // so darken it a bit -- if ((255-base_colour.Red()) + (255-base_colour.Green()) + (255-base_colour.Blue()) < 60) { base_colour = wxAuiStepColour(base_colour, 92); } m_base_colour = base_colour; wxColor darker1_colour = wxAuiStepColour(base_colour, 85); wxColor darker2_colour = wxAuiStepColour(base_colour, 75); wxColor darker3_colour = wxAuiStepColour(base_colour, 60); //wxColor darker4_colour = wxAuiStepColour(base_colour, 50); wxColor darker5_colour = wxAuiStepColour(base_colour, 40); m_active_caption_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); m_active_caption_gradient_colour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); m_active_caption_text_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); m_inactive_caption_colour = darker1_colour; m_inactive_caption_gradient_colour = wxAuiStepColour(base_colour, 97); m_inactive_caption_text_colour = *wxBLACK; m_sash_brush = wxBrush(base_colour); m_background_brush = wxBrush(base_colour); m_gripper_brush = wxBrush(base_colour); m_border_pen = wxPen(darker2_colour); m_gripper_pen1 = wxPen(darker5_colour); m_gripper_pen2 = wxPen(darker3_colour); m_gripper_pen3 = *wxWHITE_PEN; #ifdef __WXMAC__ m_caption_font = *wxSMALL_FONT; #else m_caption_font = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE); #endif // some built in bitmaps #if defined( __WXMAC__ ) static const unsigned char close_bits[]={ 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3, 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3, 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF }; #elif defined(__WXGTK__) static const unsigned char close_bits[]={ 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8, 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef, 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #else static const unsigned char close_bits[]={ // reduced height, symmetric 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf3, 0x9f, 0xf9, 0x3f, 0xfc, 0x7f, 0xfe, 0x3f, 0xfc, 0x9f, 0xf9, 0xcf, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* // same height as maximize/restore 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe7, 0xcf, 0xf3, 0x9f, 0xf9, 0x3f, 0xfc, 0x7f, 0xfe, 0x3f, 0xfc, 0x9f, 0xf9, 0xcf, 0xf3, 0xe7, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; */ #endif static const unsigned char maximize_bits[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xf7, 0xf7, 0x07, 0xf0, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static const unsigned char restore_bits[]={ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0x1f, 0xf0, 0xdf, 0xf7, 0x07, 0xf4, 0x07, 0xf4, 0xf7, 0xf5, 0xf7, 0xf1, 0xf7, 0xfd, 0xf7, 0xfd, 0x07, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static const unsigned char pin_bits[]={ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0xdf,0xfc,0xdf,0xfc, 0xdf,0xfc,0xdf,0xfc,0xdf,0xfc,0x0f,0xf8,0x7f,0xff,0x7f,0xff, 0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; #ifdef __WXMAC__ m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE); m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, *wxWHITE ); #else m_inactive_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_inactive_caption_text_colour); m_active_close_bitmap = wxAuiBitmapFromBits(close_bits, 16, 16, m_active_caption_text_colour); #endif #ifdef __WXMAC__ m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE); m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, *wxWHITE ); #else m_inactive_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_inactive_caption_text_colour); m_active_maximize_bitmap = wxAuiBitmapFromBits(maximize_bits, 16, 16, m_active_caption_text_colour); #endif #ifdef __WXMAC__ m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE); m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, *wxWHITE ); #else m_inactive_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_inactive_caption_text_colour); m_active_restore_bitmap = wxAuiBitmapFromBits(restore_bits, 16, 16, m_active_caption_text_colour); #endif m_inactive_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_inactive_caption_text_colour); m_active_pin_bitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_active_caption_text_colour); // default metric values #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON SInt32 height; GetThemeMetric( kThemeMetricSmallPaneSplitterHeight , &height ); m_sash_size = height; #elif defined(__WXGTK__) m_sash_size = wxRendererNative::Get().GetSplitterParams(NULL).widthSash; #else m_sash_size = 4; #endif m_caption_size = 17; m_border_size = 1; m_button_size = 14; m_gripper_size = 9; m_gradient_type = wxAUI_GRADIENT_VERTICAL; }
void TkpComputeButtonGeometry( TkButton *butPtr) /* Button whose geometry may have changed. */ { int width = 0, height = 0, charWidth = 1, haveImage = 0, haveText = 0; int txtWidth = 0, txtHeight = 0; MacButton *mbPtr = (MacButton*)butPtr; Tk_FontMetrics fm; DrawParams drawParams; /* * First figure out the size of the contents of the button. */ TkMacOSXComputeButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo); /* * If the indicator is on, get its size. */ if ( butPtr->indicatorOn ) { switch (butPtr->type) { case TYPE_RADIO_BUTTON: GetThemeMetric(kThemeMetricRadioButtonWidth, &butPtr->indicatorDiameter); break; case TYPE_CHECK_BUTTON: GetThemeMetric(kThemeMetricCheckBoxWidth, &butPtr->indicatorDiameter); break; default: break; } /* Allow 2px extra space next to the indicator. */ butPtr->indicatorSpace = butPtr->indicatorDiameter + 2; } else { butPtr->indicatorSpace = 0; butPtr->indicatorDiameter = 0; } if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); txtWidth = butPtr->textWidth; txtHeight = butPtr->textHeight; charWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); Tk_GetFontMetrics(butPtr->tkfont, &fm); haveText = (txtWidth != 0 && txtHeight != 0); } if (haveImage && haveText) { /* Image and Text */ switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: /* * Image is above or below text. */ height += txtHeight + butPtr->padY; width = (width > txtWidth ? width : txtWidth); break; case COMPOUND_LEFT: case COMPOUND_RIGHT: /* * Image is left or right of text. */ width += txtWidth + butPtr->padX; height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_CENTER: /* * Image and text are superimposed. */ width = (width > txtWidth ? width : txtWidth); height = (height > txtHeight ? height : txtHeight); break; default: break; } width += butPtr->indicatorSpace; } else if (haveImage) { /* Image only */ width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace; height = butPtr->height > 0 ? butPtr->height : height; } else { /* Text only */ width = txtWidth + butPtr->indicatorSpace; height = txtHeight; if (butPtr->width > 0) { width = butPtr->width * charWidth; } if (butPtr->height > 0) { height = butPtr->height * fm.linespace; } } /* Add padding */ width += 2 * butPtr->padX; height += 2 * butPtr->padY; /* * Now figure out the size of the border decorations for the button. */ if (butPtr->highlightWidth < 0) { butPtr->highlightWidth = 0; } butPtr->inset = 0; butPtr->inset += butPtr->highlightWidth; if (TkMacOSXComputeButtonDrawParams(butPtr,&drawParams)) { HIRect tmpRect; HIRect contBounds; int paddingx = 0; int paddingy = 0; tmpRect = CGRectMake(0, 0, width, height); HIThemeGetButtonContentBounds(&tmpRect, &mbPtr->drawinfo, &contBounds); /* If the content region has a minimum height, match it. */ if (height < contBounds.size.height) { height = contBounds.size.height; } /* If the content region has a minimum width, match it. */ if (width < contBounds.size.width) { width = contBounds.size.width; } /* Pad to fill difference between content bounds and button bounds. */ paddingx = contBounds.origin.x; paddingy = contBounds.origin.y; if (height < paddingx - 4) { /* can't have buttons much shorter than button side diameter. */ height = paddingx - 4; } } else { height += butPtr->borderWidth*2; width += butPtr->borderWidth*2; } width += butPtr->inset*2; height += butPtr->inset*2; Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); }
BOOL MacWidgetPainter::DrawSlider(const OpRect& rect, BOOL horizontal, double min, double max, double pos, BOOL highlighted, BOOL pressed_knob, OpRect& out_knob_position, OpPoint& out_start_track, OpPoint& out_end_track) { // Opera 11.50: We are going to use special skinned (non-toolkit) sliders for zoom sliders // so we are not drawing with our painter in that case if (!widget || widget->GetType() == OpTypedObject::WIDGET_TYPE_ZOOM_SLIDER) return FALSE; OpSkinElement *border_skin = widget->GetBorderSkin()->GetSkinElement(); if(!g_skin_manager->GetCurrentSkin() || (border_skin && !border_skin->IsNative())) { return IndpWidgetPainter::DrawSlider(rect, horizontal, min, max, pos, highlighted, pressed_knob, out_knob_position, out_start_track, out_end_track); } CGRect r = {{0, 0}, {rect.width, rect.height}}; CGContextRef context; OpBitmap* bitmap = NULL; int bmpwidth = rect.width; int bmpheight = rect.height; #ifdef PIXEL_SCALE_RENDERING_SUPPORT const PixelScaler& scaler = vd->GetVPScale(); bmpwidth = TO_DEVICE_PIXEL(scaler, bmpwidth); bmpheight = TO_DEVICE_PIXEL(scaler, bmpheight); #endif // PIXEL_SCALE_RENDERING_SUPPORT if(OpStatus::IsSuccess(OpBitmap::Create(&bitmap, bmpwidth, bmpheight, FALSE, TRUE, 0, 0, TRUE))) { int w = bitmap->Width(); int h = bitmap->Height(); int bpl = bitmap->GetBytesPerLine(); void *image_data = bitmap->GetPointer(OpBitmap::ACCESS_WRITEONLY); if (!image_data) { delete bitmap; return FALSE; } memset(image_data, 0, bpl*h); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo alpha = kCGBitmapByteOrderVegaInternal; context = CGBitmapContextCreate(image_data, w, h, 8, bpl, colorSpace, alpha); CGColorSpaceRelease(colorSpace); int win_height = rect.height; float scale = 1.0f; #ifdef PIXEL_SCALE_RENDERING_SUPPORT scale = TO_DEVICE_PIXEL(scaler, scale); #endif // PIXEL_SCALE_RENDERING_SUPPORT CGContextScaleCTM(context, scale, -scale); CGContextTranslateCTM(context, 0.0, -win_height); HIThemeTrackDrawInfo drawInfo; SInt32 thickness = 0; SInt32 shadow = 0; if (noErr == GetThemeMetric(kThemeMetricLargeProgressBarThickness, &thickness) && (noErr == GetThemeMetric(kThemeMetricProgressBarShadowOutset, &shadow))) { SInt32 progressHeight = thickness + shadow; if (horizontal) { if((r.size.height) > progressHeight) { float f = (r.size.height - progressHeight); r.origin.y += f / 2; r.size.height -= f; } } else { if((r.size.width) > progressHeight) { float f = (r.size.width - progressHeight); r.origin.x += f / 2; r.size.width -= f; } } } else { if (horizontal) { float f = (r.size.height / 4) - 1; r.origin.y += f / 2; r.size.height -= f; } else { float f = (r.size.width / 4) - 1; r.origin.x += f / 2; r.size.width -= f; } } drawInfo.version = 0; drawInfo.kind = kThemeSliderSmall; drawInfo.bounds = r; drawInfo.min = 0; drawInfo.max = NUMBER_OF_STEPS; if (widget->GetRTL()) drawInfo.value = (max - pos) / (max - min) * NUMBER_OF_STEPS; else drawInfo.value = (pos - min) / (max - min) * NUMBER_OF_STEPS; drawInfo.attributes = kThemeTrackShowThumb; if (horizontal) { drawInfo.attributes |= kThemeTrackHorizontal; } else { drawInfo.attributes |= kThemeTrackRightToLeft; } drawInfo.enableState = widget->IsEnabled() ? kThemeTrackActive : kThemeTrackInactive; drawInfo.trackInfo.slider.thumbDir = kThemeThumbPlain; drawInfo.trackInfo.slider.pressState = 0; if (highlighted) drawInfo.attributes |= kThemeTrackHasFocus; HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal); HIShapeRef thumb_shape; HIRect thumb_bounds, track_bounds; HIThemeGetTrackThumbShape(&drawInfo, &thumb_shape); HIShapeGetBounds(thumb_shape, &thumb_bounds); HIThemeGetTrackBounds(&drawInfo, &track_bounds); CFRelease(thumb_shape); out_knob_position.Set(thumb_bounds.origin.x, thumb_bounds.origin.y, thumb_bounds.size.width, thumb_bounds.size.height); out_start_track.Set(track_bounds.origin.x, track_bounds.origin.y); out_end_track.Set(track_bounds.origin.x+track_bounds.size.width, track_bounds.origin.y+track_bounds.size.height); CGContextRelease(context); bitmap->ReleasePointer(); vd->BitmapOut(bitmap, OpRect(0, 0, bitmap->Width(), bitmap->Height()), rect); delete bitmap; } return TRUE; }
BOOL MacWidgetPainter::DrawProgressbar(const OpRect &drawrect, double percent, INT32 progress_when_total_unknown, OpWidgetString* string, const char *skin_empty, const char *skin_full) { const char *full_skin = skin_full && *skin_full ? skin_full : "Progress Full Skin"; OpSkinElement *border_skin = g_skin_manager->GetSkinElement(full_skin); if(!g_skin_manager->GetCurrentSkin() || !border_skin || !border_skin->IsNative()) { return IndpWidgetPainter::DrawProgressbar(drawrect, percent, progress_when_total_unknown, string, skin_empty, skin_full); } UINT32 full_color = g_op_ui_info->GetUICSSColor(CSS_VALUE_HighlightText); g_skin_manager->GetTextColor(full_skin, &full_color); CGRect r = {{0, 0}, {drawrect.width, drawrect.height}}; CGContextRef context; OpBitmap* bitmap = NULL; int bmpwidth = drawrect.width; int bmpheight = drawrect.height; #ifdef PIXEL_SCALE_RENDERING_SUPPORT const PixelScaler& scaler = vd->GetVPScale(); bmpwidth = TO_DEVICE_PIXEL(scaler, bmpwidth); bmpheight = TO_DEVICE_PIXEL(scaler, bmpheight); #endif // PIXEL_SCALE_RENDERING_SUPPORT if(OpStatus::IsSuccess(OpBitmap::Create(&bitmap, bmpwidth, bmpheight, FALSE, TRUE, 0, 0, TRUE))) { int w = bitmap->Width(); int h = bitmap->Height(); int bpl = bitmap->GetBytesPerLine(); void *image_data = bitmap->GetPointer(OpBitmap::ACCESS_WRITEONLY); if (!image_data) { delete bitmap; return FALSE; } memset(image_data, 0, bpl*h); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo alpha = kCGBitmapByteOrderVegaInternal; context = CGBitmapContextCreate(image_data, w, h, 8, bpl, colorSpace, alpha); CGColorSpaceRelease(colorSpace); int win_height = drawrect.height; float scale = 1.0f; #ifdef PIXEL_SCALE_RENDERING_SUPPORT scale = TO_DEVICE_PIXEL(scaler, scale); #endif // PIXEL_SCALE_RENDERING_SUPPORT CGContextScaleCTM(context, scale, -scale); CGContextTranslateCTM(context, 0.0, -win_height); if (percent == 0 && progress_when_total_unknown) { HIThemeTrackDrawInfo drawInfo; SInt32 thickness = 0; SInt32 shadow = 0; if (noErr == GetThemeMetric(kThemeMetricLargeProgressBarThickness, &thickness) && (noErr == GetThemeMetric(kThemeMetricProgressBarShadowOutset, &shadow))) { SInt32 progressHeight = thickness + shadow; if((r.size.height) > progressHeight) { float f = (r.size.height - progressHeight); // / 2; r.origin.y += f; r.size.height -= f; } } else { float f = (r.size.height / 4) - 1; r.origin.y += f; r.size.height -= f; } drawInfo.version = 0; drawInfo.kind = kThemeIndeterminateBarLarge; drawInfo.bounds = r; drawInfo.min = 0; drawInfo.max = 100; drawInfo.value = 0; drawInfo.attributes = kThemeTrackHorizontal; drawInfo.enableState = widget->IsEnabled() ? kThemeTrackActive : kThemeTrackInactive; drawInfo.trackInfo.progress.phase = progress_when_total_unknown; HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal); } else { HIThemeTrackDrawInfo drawInfo; SInt32 thickness = 0; SInt32 shadow = 0; if (noErr == GetThemeMetric(kThemeMetricLargeProgressBarThickness, &thickness) && (noErr == GetThemeMetric(kThemeMetricProgressBarShadowOutset, &shadow))) { SInt32 progressHeight = thickness + shadow; if((r.size.height) > progressHeight) { float f = (r.size.height - progressHeight); // / 2; r.origin.y += f; r.size.height -= f; } } else { float f = (r.size.height / 4) - 1; r.origin.y += f; r.size.height -= f; } drawInfo.version = 0; drawInfo.kind = kThemeProgressBarLarge; drawInfo.bounds = r; drawInfo.min = 0; drawInfo.max = 100; drawInfo.value = (SInt32)(percent); drawInfo.attributes = kThemeTrackHorizontal; drawInfo.enableState = widget->IsEnabled() ? kThemeTrackActive : kThemeTrackInactive; drawInfo.trackInfo.progress.phase = floorf(GetCurrentEventTime()*16); HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal); } CGContextRelease(context); bitmap->ReleasePointer(); vd->BitmapOut(bitmap, OpRect(0, 0, bitmap->Width(), bitmap->Height()), drawrect); delete bitmap; } if (string) { widget->SetClipRect(drawrect); OpRect textRect = drawrect; textRect.y -= 1; string->Draw(textRect, vd, full_color); widget->RemoveClipRect(); } return TRUE; }
int CXpTheme::GetThemeMetric(HDC hDC, int iPartId, int iStateId, int iPropId, int iDefault) {_STT(); int i = iDefault; if ( GetThemeMetric( hDC, iPartId, iStateId, iPropId, &i ) ) return i; return i; }