MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / drawComplexControl

Method drawComplexControl

src/WizNoteStyle.cpp:817–923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

815}
816
817void WizNotePlusStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
818 QPainter *p, const QWidget *widget) const
819{
820 switch (cc) {
821
822 case CC_ToolButton:
823 {
824
825 if (const QStyleOptionToolButton *toolbutton
826 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
827
828 // 分别计算子控件按钮和菜单指示器的边界
829 QRect button, menuarea;
830 button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
831 menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
832
833 //-------------------------------------------------------------------
834 // 按钮状态判断
835 //-------------------------------------------------------------------
836
837 State bflags = toolbutton->state & ~State_Sunken; // 当前状态与非按下状态
838
839 if (bflags & State_AutoRaise) { // 如果非按下状态且设置了自动回弹
840 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
841 bflags &= ~State_Raised;
842 }
843 }
844 State mflags = bflags; // 下拉指示箭头状态
845 if (toolbutton->state & State_Sunken) {
846 if (toolbutton->activeSubControls & SC_ToolButton)
847 bflags |= State_Sunken;
848 mflags |= State_Sunken;
849 }
850
851 //-------------------------------------------------------------------
852 // 绘制样式元素
853 //-------------------------------------------------------------------
854 // 绘制按钮悬浮
855 QStyleOption pannel = *toolbutton;
856 if ( ( bflags | mflags ) & (State_Sunken | State_On | State_Raised)) {
857 pannel.state = bflags | mflags;
858 proxy()->drawPrimitive(PE_PanelButtonCommand, &pannel, p, widget);
859 }
860
861 // 绘制按钮子控件
862 QStyleOption tool = *toolbutton;
863 if (toolbutton->subControls & SC_ToolButton) { // 如果存在按钮子控件
864 if (bflags & (State_Sunken | State_On | State_Raised)) {
865 tool.state = bflags;
866 tool.rect = button;
867 //proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
868 }
869 }
870
871 // 绘制聚焦框
872 if (toolbutton->state & State_HasFocus) {
873 QStyleOptionFocusRect fr;
874 fr.QStyleOption::operator=(*toolbutton);

Callers 1

paintEventMethod · 0.80

Calls 5

drawPrimitiveMethod · 0.80
pixelMetricMethod · 0.80
heightMethod · 0.80
QRectClass · 0.50
drawControlMethod · 0.45

Tested by

no test coverage detected