OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
WScaleToolButton Class Reference

Special Button that can shrink and expand in a layout. More...

#include <WScaleToolButton.h>

+ Inheritance diagram for WScaleToolButton:
+ Collaboration diagram for WScaleToolButton:

Public Member Functions

 WScaleToolButton (size_t length=WPREFERRED_LABEL_LENGTH, QWidget *parent=NULL)
 Constructor. More...
 
 WScaleToolButton (const QString &text, size_t length=WPREFERRED_LABEL_LENGTH, QWidget *parent=NULL)
 Constructor. More...
 
virtual QSize sizeHint () const
 overwritten from QToolButton, returning the widgets prefered size More...
 
virtual QSize minimumSizeHint () const
 overwritten from QToolButton, returning the widgets prefered size More...
 
virtual void setText (const QString &text)
 reimplemented function to setText More...
 
virtual void addAdditionalWidth (int margin)
 Set this to reserve extra space for a margin. More...
 
virtual void setMinimalLength (size_t chars)
 How many characters should be visible all the time? More...
 
virtual size_t getMinimalLength () const
 Get the current minimal number of characters. More...
 

Protected Member Functions

virtual void resizeEvent (QResizeEvent *event)
 custom implementation of the resize event to fit the QString into the butons current size More...
 

Private Member Functions

void fitTextToSize ()
 set the actual text which is shown on the QToolButton More...
 

Private Attributes

QString m_orgText
 QString to remember the original unshortend text of the widget. More...
 
int m_additionalWidth
 The additional width we need to reserver (like for margins). More...
 
size_t m_minLength
 Minimal character number. More...
 

Detailed Description

Special Button that can shrink and expand in a layout.

Definition at line 36 of file WScaleToolButton.h.

Constructor & Destructor Documentation

◆ WScaleToolButton() [1/2]

WScaleToolButton::WScaleToolButton ( size_t  length = WPREFERRED_LABEL_LENGTH,
QWidget *  parent = NULL 
)

Constructor.

Parameters
parentthe widgets parent
lengththe minimal number of characters visible

Definition at line 27 of file WScaleToolButton.cpp.

References m_additionalWidth, m_minLength, and m_orgText.

◆ WScaleToolButton() [2/2]

WScaleToolButton::WScaleToolButton ( const QString &  text,
size_t  length = WPREFERRED_LABEL_LENGTH,
QWidget *  parent = NULL 
)

Constructor.

Creates the button with its original text

Parameters
texttext of the button
parentthe widgets parent
lengththe minimal number of characters

Definition at line 36 of file WScaleToolButton.cpp.

References m_additionalWidth, m_minLength, m_orgText, and setText().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAdditionalWidth()

void WScaleToolButton::addAdditionalWidth ( int  margin)
virtual

Set this to reserve extra space for a margin.

This function does not set the margin. This is still your task, using stylesheets. You will not need this when using QToolButton::setMargin().

Parameters
marginthe margin to keep in mind for size calculations

Definition at line 90 of file WScaleToolButton.cpp.

References m_additionalWidth.

◆ fitTextToSize()

void WScaleToolButton::fitTextToSize ( )
private

set the actual text which is shown on the QToolButton

Definition at line 71 of file WScaleToolButton.cpp.

References m_orgText.

Referenced by resizeEvent(), and setText().

+ Here is the caller graph for this function:

◆ getMinimalLength()

size_t WScaleToolButton::getMinimalLength ( ) const
virtual

Get the current minimal number of characters.

Returns
the number of chars visible all the time

Definition at line 101 of file WScaleToolButton.cpp.

References m_minLength.

◆ minimumSizeHint()

QSize WScaleToolButton::minimumSizeHint ( ) const
virtual

overwritten from QToolButton, returning the widgets prefered size

Returns
minimum size of the button

Definition at line 58 of file WScaleToolButton.cpp.

References m_additionalWidth, m_minLength, and m_orgText.

◆ resizeEvent()

void WScaleToolButton::resizeEvent ( QResizeEvent *  event)
protectedvirtual

custom implementation of the resize event to fit the QString into the butons current size

Parameters
eventresize event passed from the parent widgets event handling

Definition at line 47 of file WScaleToolButton.cpp.

References fitTextToSize().

+ Here is the call graph for this function:

◆ setMinimalLength()

void WScaleToolButton::setMinimalLength ( size_t  chars)
virtual

How many characters should be visible all the time?

Parameters
charsthe number of chars

Definition at line 95 of file WScaleToolButton.cpp.

References m_minLength, m_orgText, and setText().

+ Here is the call graph for this function:

◆ setText()

void WScaleToolButton::setText ( const QString &  text)
virtual

reimplemented function to setText

Parameters
texttext of the button

Definition at line 64 of file WScaleToolButton.cpp.

References fitTextToSize(), m_additionalWidth, m_minLength, and m_orgText.

Referenced by WQtPropertyGroupWidget::createPropertyGroupBox(), setMinimalLength(), WPropertyTriggerWidget::WPropertyTriggerWidget(), and WScaleToolButton().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeHint()

QSize WScaleToolButton::sizeHint ( ) const
virtual

overwritten from QToolButton, returning the widgets prefered size

Returns
prefered size of the button

Definition at line 52 of file WScaleToolButton.cpp.

References m_additionalWidth, and m_orgText.

Member Data Documentation

◆ m_additionalWidth

int WScaleToolButton::m_additionalWidth
private

The additional width we need to reserver (like for margins).

Definition at line 121 of file WScaleToolButton.h.

Referenced by addAdditionalWidth(), minimumSizeHint(), setText(), sizeHint(), and WScaleToolButton().

◆ m_minLength

size_t WScaleToolButton::m_minLength
private

Minimal character number.

Definition at line 126 of file WScaleToolButton.h.

Referenced by getMinimalLength(), minimumSizeHint(), setMinimalLength(), setText(), and WScaleToolButton().

◆ m_orgText

QString WScaleToolButton::m_orgText
private

QString to remember the original unshortend text of the widget.

Definition at line 116 of file WScaleToolButton.h.

Referenced by fitTextToSize(), minimumSizeHint(), setMinimalLength(), setText(), sizeHint(), and WScaleToolButton().


The documentation for this class was generated from the following files: