(new in Rev4.00)
MQWidgetBase is a base class for all widgets such as a button, a check box, a window and so on. The following classes inherit a MQWidgetBase class.
Name | Description |
MQWindowBase | A base class for a window and a dialog |
|- MQWindow | Window |
|- MQDialog | Dialog |
MQFrameBase | A base class for frames |
|- MQFrame | Frame |
|- MQGroupBox | Group box |
MQScrollBox | Scroll area |
MQTab | Switch multiple pages |
MQButton | Button |
MQCheckBox | Check box |
MQRadioButton | Radio button |
MQComboBox | Combo box |
MQListBox | List box |
MQLabel | Display a text |
MQEdit | Input a text |
MQMemo | Input multiple text lines |
MQSpinBox | Input an integer |
MQDoubleSpinBox | Input a real number |
MQSlider | Slider |
MQScrollBar | Scroll bar |
MQColorPanel | Color panel |
You can use as a class library by adding MQWidget.cpp and MQWidget.h to your project.
Class | |
MQWidgetBase | Constructor |
~MQWidgetBase | Destructor |
Member functions | |
GetID | Get a widget ID |
AddChild | Add a child widget |
RemoveChild | Remove a child widget |
GetEnabled | Get an enabling status |
SetEnabled | Set an enabling status |
GetVisible | Get a visibility |
SetVisible | Set a visibility |
GetHorzLayout | Get a horizontal layout status |
SetHorzLayout | Set a horizontal layout status |
GetVertLayout | Get a vertical layout status |
SetVertLayout | Set a vertical layout status |
GetWidth | Get a width |
SetWidth | Set a width |
GetHeight | Get a height |
SetHeight | Set a height |
GetFillRateX | Get a filling rate in the width |
SetFillRateX | Set a filling rate in the width |
GetFillRateY | Get a filling rate in the height |
SetFillRateY | Set a filling rate in the height |
GetFillBeforeRate | Get a filling rate for a forward space |
SetFillBeforeRate | Set a filling rate for a forward space |
GetFillAfterRate | Get a filling rate for a backward space |
SetFillAfterRate | Set a filling rate for a backward space |
GetInSpace | Get spaces between child widgets |
SetInSpace | Set spaces between child widgets |
GetOutSpace | Get a space outside all children |
SetOutSpace | Set a space outside all children |
GetHintSizeRateX | Get a hint size for a width |
SetHintSizeRateX | Set a hint size for a width |
GetHintSizeRateY | Get a hint size for a height |
SetHintSizeRateY | Set a hint size for a height |
GetJustSize | Get a size to contain all child widgets. |
Static functions | |
FindWidgetByID | Find a widget by ID |
GetSystemWidgetID | Get a widget ID for a system widget |
GetDefaultFrameColor | Get a default frame color |
Events | |
AddLeftDownEvent | Add an event for pushing a left button |
AddLeftUpEvent | Add an event for releasing a left button |
AddLeftDoubleClickEvent | Add an event for double-clicking a left button |
AddMiddleDownEvent | Add an event for pushing a middle button |
AddMiddleUpEvent | Add an event for releasing a middle button |
AddMiddleDoubleClickEvent | Add an event for double-clicking a middle button |
AddRightDownEvent | Add an event for pushing a right button |
AddRightUpEvent | Add an event for releasing a right button |
AddRightDoubleClickEvent | Add an event for double-clicking a right button |
AddMouseMoveEvent | Add an event for moving a mouse cursor |
AddMouseWheelEvent | Add an event for rotating a mouse wheel |
AddKeyDownEvent | Add an event for pushing a key |
AddKeyUpEvent | Add an event for releasing a key |
MQWidgetBase::MQWidgetBase();
MQWidgetBase::MQWidgetBase(int id);
It is a constructor.
virtual MQWidgetBase::~MQWidgetBase();
It is a destructor. It is declared as a virtual function.
int MQWidgetBase::GetID();
It returns a widget ID.
int MQWidgetBase::AddChild(MQWidgetBase *child);
It adds the specified widget as a child.
The added child widget will be deleted together when this parent widget is deleted.
child must not be a window or a dialog. Please refer MQWindowBase::AddChildWindow() to add a child window.
void MQWidgetBase::RemoveChild(MQWidgetBase *child);
It separates the child widget from this widget.
The separated widget is not deleted automatically. Please delete it manually after separating.
bool MQWidgetBase::GetEnabled();
It returns whether the widget is enabled or disabled.
It is necessary to check the enabling status of the parent widget if the messages are actually notified to this widget.
void MQWidgetBase::SetEnabled(bool value);
It specifies the widget is enabled or disabled.
Mouse and keyboard messages are not notified to disabled widgets and the child widgets.
bool MQWidgetBase::GetVisible();
It returns the widget is visible or invisible.
void MQWidgetBase::SetVisible(bool value);
It specifies the widget is visible or invisible.
LAYOUT_TYPE MQWidgetBase::GetHorzLayout();
It returns how to determine a width.
void MQWidgetBase::SetHorzLayout(LAYOUT_TYPE value);
It specifies how to determine a width.
LAYOUT_TYPE MQWidgetBase::GetVertLayout();
It returns how to determine a height.
void MQWidgetBase::SetVertLayout(LAYOUT_TYPE value);
It specifies how to determine a height.
int MQWidgetBase::GetWidth();
It returns the width in pixels.
void MQWidgetBase::SetWidth(int value);
It specifies the width in pixels.。
This functions is deprecated unless the fixed pixel size is necessary. Please use SetHintSizeRateX() as possible.
int MQWidgetBase::GetHeight();
It returns the height in pixels.
void MQWidgetBase::SetHeight(int value);
It specifies the height in pixels.。
This functions is deprecated unless the fixed pixel size is necessary. Please use SetHintSizeRateY() as possible.
double MQWidgetBase::GetFillRateX();
It returns a filling rate in the width when widgets in the same parent widget have LAYOUT_FILL flags for SetHorzLayout().
A width of the widget is determined by the rate for sum of each widget's filing rate.
The default value is 1.
void MQWidgetBase::SetFillRateX(double value);
It specifies a filling rate in the width when widgets in the same parent widget have LAYOUT_FILL flags for SetHorzLayout().
A width of the widget is determined by the rate for sum of each widget's filing rate.
The default value is 1.
double MQWidgetBase::GetFillRateY();
It returns a filling rate in the width when widgets in the same parent widget have LAYOUT_FILL flags for SetVertLayout() .
A height of the widget is determined by the rate for sum of each widget's filing rate.
The default value is 1.
void MQWidgetBase::SetFillRateY(double value);
It specifies a filling rate in the width when widgets in the same parent widget have LAYOUT_FILL flags for SetVertLayout() .
A height of the widget is determined by the rate for sum of each widget's filing rate.
The default value is 1.
double MQWidgetBase::GetFillBeforeRate();
It returns a filling rate for a forward space of the widget.
A size of the forward space is determined by the rate for sum of each widget's filing rate.
void MQWidgetBase::SetFillBeforeRate(double value);
It specifies a filling rate for a forward space of the widget.
A size of the forward space is determined by the rate for sum of each widget's filing rate.
double MQWidgetBase::GetFillAfterRate();
It returns a filling rate for a backward space of the widget.
A size of the backward space is determined by the rate for sum of each widget's filing rate.
void MQWidgetBase::SetFillAfterRate(double value);
It specifies a filling rate for a backward space of the widget.
A size of the backward space is determined by the rate for sum of each widget's filing rate.
double MQWidgetBase::GetInSpace();
It returns a space between two child widgets in the ratio to the base size.
void MQWidgetBase::SetInSpace(double value);
It specify a space between two child widgets in the ratio to the base size.
double MQWidgetBase::GetOutSpace();
It returns a space outside all child widgets in the ratio to the base size.
void MQWidgetBase::SetOutSpace(double value);
It specifies a space outside all child widgets in the ratio to the base size.
double MQWidgetBase::GetHintSizeRateX();
It returns a normal width in the ratio to the base size.
void MQWidgetBase::SetHintSizeRateX(double value);
It specifies a normal width in the ratio to the base size.
A width of the widget is determined by a hint size when the LAYOUT_HINTSIZE flag is specified for SetHorzLayout(). The hint size is just a hint, and a determined size will be changed by a type of a widget and specified parameters.
double MQWidgetBase::GetHintSizeRateY();
It returns a normal height in the ratio to the base size.
void MQWidgetBase::SetHintSizeRateY(double value);
It specifies a normal height in the ratio to the base size.
A height of the widget is determined by a hint size when the LAYOUT_HINTSIZE flag is specified for SetVertLayout(). The hint size is just a hint, and a determined size will be changed by a type of a widget and specified parameters.
POINT MQWidgetBase::GetJustSize(int max_width = -1, int max_height = -1);
It returns a size to contain all child widget.
The size will be calculated without an upper limit when -1 is specified for max_width or max_height.
static MQWidgetBase *MQWidgetBase::FindWidgetByID(int id);
It returns a widget which has the specified ID.
NULL is returned when no widget has the ID.
static int MQWidgetBase::GetSystemWidgetID(MQSystemWidget::WidgetType type);
It returns a widget ID created in the main program.
A system widget are usually used as a parent widget to create child windows or a child widgets. An unexpected malfunction may be caused when you operate the system widget.
static void MQWidgetBase::GetDefaultFrameColor(int& r, int& g, int& b, int& a);
It returns a default frame color.
template<typename T> void MQWidgetBase::AddLeftDownEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a left button is pushed.
A member function 'f' must have the following options and return value.
BOOL T::f(MQWidgetBase* sender, MQDocument doc, MQWidgetMouseParam& param);
struct MQWidgetMouseParam { POINT ClientPos; POINT ScreenPos; POINT DownPos; POINT LastPos; int Wheel; bool LButton; bool MButton; bool RButton; bool Shift; bool Ctrl; bool Alt; };
template<typename T> void MQWidgetBase::AddLeftUpEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a left button is released.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddLeftDoubleClickEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a left button is double-clicked.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddMiddleDownEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a middle button is pushed.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddMiddleUpEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a middle button is released.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddMiddleDoubleClickEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a middle button is double-clicked.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddRightDownEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a right button is pushed.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddRightUpEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a right button is released.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddRightDoubleClickEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a right button is double-clicked.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddMouseMoveEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a mouse cursor is moved on this widget.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddMouseWheelEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetMouseParam&), bool prior = false)
It adds events notified when a mouse wheel is rotated.
Please refer the description in AddLeftDownEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddKeyDownEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetKeyParam&), bool prior = false)
It adds events notified when a key is pushed.
A member function 'f' must have the following options and return value.
BOOL T::f(MQWidgetBase* sender, MQDocument doc, MQWidgetKeyParam& param);
struct MQWidgetKeyParam { int Key; bool AutoRepeat; bool LButton; bool MButton; bool RButton; bool Shift; bool Ctrl; bool Alt; };
template<typename T> void MQWidgetBase::AddKeyUpEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQWidgetKeyParam&), bool prior = false)
It adds events notified when a key is released.
Please refer the description in AddKeyDownEvent about the member function 'f'.