|
QtCanpool 3.3.0
|
#include <qxribbon/ribbonbutton_p.h>

Public 成员函数 | |
| RibbonButtonPrivate () | |
| virtual | ~RibbonButtonPrivate () |
| QStyle * | style () const |
| void | recalcSizeHint (QStyleOptionToolButton &opt, QSize s) |
| 重新计算sizehint,sizehint函数在第一次计算完成后会记录结果,如果文字字体或者内容不变是不需要进行重复计算 | |
| void | calcIconAndTextRect (const QStyleOptionToolButton &opt) |
| 根据设定计算图标和文本的绘制区域 | |
| QRect | adjustedTextRect (const QStyleOptionToolButton &opt, const QWidget *w) |
| 根据设定计算文本显示区域 | |
| QRect | calcIndicatorArrowDownRect (const QStyleOptionToolButton &opt) |
| sub control 的下拉箭头的位置 | |
| virtual QPixmap | createIconPixmap (const QStyleOptionToolButton &opt, const QSize &iconsize) |
| void | updateButtonState (const QPoint &pos) |
| void | drawButton (QStyleOptionToolButton &opt, QPainter &p, const QWidget *w) |
| void | drawIconAndLabel (QStyleOptionToolButton &opt, QPainter &p, const QWidget *w) |
| RibbonButton::drawIconAndLabel | |
| void | drawArrow (const QStyle *style, const QStyleOptionToolButton *toolbutton, const QRect &rect, QPainter *painter, const QWidget *widget=Q_NULLPTR) |
Public 属性 | |
| RibbonButton::RibbonButtonType | m_buttonType |
| RibbonButton::LargeButtonType | m_largeButtonType |
| bool | m_mouseOnSubControl |
| 这个用于标记MenuButtonPopup模式下,鼠标在文本区域 | |
| bool | m_menuButtonPressed |
| bool | m_isWordWrap |
| 标记是否文字换行,默认 false | |
| int | m_spacing |
| 按钮和边框的距离 | |
| QSize | m_sizeHint |
| 保存计算好的sizehint | |
| QRect | m_iconRect |
| 记录icon的绘制位置 | |
| QRect | m_textRect |
| 记录text的绘制位置 | |
| QRect | m_indicatorArrowRect |
| 记录IndicatorArrow的绘制位置 | |
静态 Public 属性 | |
| static bool | s_isToolButtonTextShift = false |
| 配置RibbonButton文字在点击时是否会轻微改变位置而达到一种类似跳动的效果 | |
在文件 ribbonbutton_p.h 第 15 行定义.
| QxRibbon::RibbonButtonPrivate::RibbonButtonPrivate | ( | ) |
在文件 ribbonbutton.cpp 第 65 行定义.
|
virtual |
在文件 ribbonbutton.cpp 第 75 行定义.
| QRect QxRibbon::RibbonButtonPrivate::adjustedTextRect | ( | const QStyleOptionToolButton & | opt, |
| const QWidget * | w | ||
| ) |
| void QxRibbon::RibbonButtonPrivate::calcIconAndTextRect | ( | const QStyleOptionToolButton & | opt | ) |
| QRect QxRibbon::RibbonButtonPrivate::calcIndicatorArrowDownRect | ( | const QStyleOptionToolButton & | opt | ) |
sub control 的下拉箭头的位置
对于大模式,如果文字换行,箭头会在最右侧,如果文字不换行,箭头就在原来文字第二行的位置
| opt |
在文件 ribbonbutton.cpp 第 469 行定义.
|
virtual |
被 QxRibbon::RibbonColorButtonPrivate 重载.
在文件 ribbonbutton.cpp 第 503 行定义.
| void QxRibbon::RibbonButtonPrivate::drawArrow | ( | const QStyle * | style, |
| const QStyleOptionToolButton * | toolbutton, | ||
| const QRect & | rect, | ||
| QPainter * | painter, | ||
| const QWidget * | widget = Q_NULLPTR |
||
| ) |
在文件 ribbonbutton.cpp 第 335 行定义.
| void QxRibbon::RibbonButtonPrivate::drawButton | ( | QStyleOptionToolButton & | opt, |
| QPainter & | p, | ||
| const QWidget * | w | ||
| ) |
在文件 ribbonbutton.cpp 第 543 行定义.
| void QxRibbon::RibbonButtonPrivate::drawIconAndLabel | ( | QStyleOptionToolButton & | opt, |
| QPainter & | p, | ||
| const QWidget * | w | ||
| ) |
RibbonButton::drawIconAndLabel
在LargeButtonType == Normal模式下,icon占大按钮的一半区域,在wps模式下,icon占大按钮的60,文字占40,且文字不换行
| opt | |
| p | |
| w |
在文件 ribbonbutton.cpp 第 205 行定义.
| void QxRibbon::RibbonButtonPrivate::recalcSizeHint | ( | QStyleOptionToolButton & | opt, |
| QSize | s | ||
| ) |
重新计算sizehint,sizehint函数在第一次计算完成后会记录结果,如果文字字体或者内容不变是不需要进行重复计算
正常来讲,高度是不需要管,因为高度是有RibbonGroupLayout来控制,这个函数主要是为了提供宽度信息,宽度信息给到RibbonGroupLayout, 然后对button进行布局,最终会触发resize函数,resize函数会再进行一次计算确定具体的尺寸
因此,resize函数确定的尺寸方式必须和recalcSizeHint保持一致,尤其是涉及字体设置
一般布局前调用sizehint,布局后会调用resizeevent,尤其字体信息会计算两遍,这里后续可以有更好的优化空间
1 先获取最优的文字textRange
2 再判断箭头来调整textRange
在文件 ribbonbutton.cpp 第 95 行定义.
| QStyle * QxRibbon::RibbonButtonPrivate::style | ( | ) | const |
在文件 ribbonbutton.cpp 第 79 行定义.
| void QxRibbon::RibbonButtonPrivate::updateButtonState | ( | const QPoint & | pos | ) |
在文件 ribbonbutton.cpp 第 526 行定义.
| RibbonButton::RibbonButtonType QxRibbon::RibbonButtonPrivate::m_buttonType |
在文件 ribbonbutton_p.h 第 41 行定义.
| QRect QxRibbon::RibbonButtonPrivate::m_iconRect |
记录icon的绘制位置
在文件 ribbonbutton_p.h 第 48 行定义.
| QRect QxRibbon::RibbonButtonPrivate::m_indicatorArrowRect |
记录IndicatorArrow的绘制位置
在文件 ribbonbutton_p.h 第 50 行定义.
| bool QxRibbon::RibbonButtonPrivate::m_isWordWrap |
标记是否文字换行,默认 false
在文件 ribbonbutton_p.h 第 45 行定义.
| RibbonButton::LargeButtonType QxRibbon::RibbonButtonPrivate::m_largeButtonType |
在文件 ribbonbutton_p.h 第 42 行定义.
| bool QxRibbon::RibbonButtonPrivate::m_menuButtonPressed |
在文件 ribbonbutton_p.h 第 44 行定义.
| bool QxRibbon::RibbonButtonPrivate::m_mouseOnSubControl |
这个用于标记MenuButtonPopup模式下,鼠标在文本区域
在文件 ribbonbutton_p.h 第 43 行定义.
| QSize QxRibbon::RibbonButtonPrivate::m_sizeHint |
保存计算好的sizehint
在文件 ribbonbutton_p.h 第 47 行定义.
| int QxRibbon::RibbonButtonPrivate::m_spacing |
按钮和边框的距离
在文件 ribbonbutton_p.h 第 46 行定义.
| QRect QxRibbon::RibbonButtonPrivate::m_textRect |
记录text的绘制位置
在文件 ribbonbutton_p.h 第 49 行定义.
|
static |
配置RibbonButton文字在点击时是否会轻微改变位置而达到一种类似跳动的效果
在文件 ribbonbutton_p.h 第 52 行定义.