(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 |
|- MQPopup | Popup |
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 |
MQCheckListBox | Check list box |
MQTreeListBox | Tree 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 |
MQProgressBar | Progress bar |
MQScrollBar | Scroll bar |
MQColorPanel | Color panel |
MQPaintBox | Paint box |
MQMenuItem | Menu item |
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 |
GetName | Get a name |
SetName | Set a name |
GetTag | Get an arbitrary value |
SetTag | Set an arbitrary value |
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 |
GetCellColumn | Get a number of columns of a cell |
SetCellColumn | Set a number of columns of a cell |
GetHintText | Get a hint text |
SetHintText | Set a hint text |
GetJustSize | Get a size to contain all child widgets. |
ClientToScreen | Convert client coordinate to screen |
ScreenToClient | Convert screen coordinate to client |
ClientToClient | Convert client coordinate to other client |
Repaint | Repaint |
RefreshPaint | Apply a repainting reservation |
CaptureMouse | Capture a mouse operation |
Static functions | |
FindWidgetByID | Find a widget by ID |
GetSystemWidgetID | Get a widget ID for a system widget |
GetBaseRateSize | Get a widget size by a rate of a base size |
GetDefaultFrameColor | Get a default frame color |
GetDefaultTextColor | Get a default text color |
GetDefaultTitleBackColor | Get a default title background color |
GetDefaultTitleTextColor | Get a default title text color |
GetDefaultListBackColor | Get a default list background color |
GetDefaultListTextColor | Get a default list text color |
GetDefaultListActiveColor | Get a default list active color |
GetDefaultListActiveTextColor | Get a default list active text color |
GetDefaultEditBackColor | Get a default edit background color |
GetDefaultEditTextColor | Get a default edit text color |
GetDefaultEditSelectionColor | Get a default edit selection color |
GetDefaultEditSelectionTextColor | Get a default edit selection text color |
RegisterSubCommandButton | Register a button for a sub command |
EnterEventLoop | Enter an event loop |
ExitEventLoop | Exit an event loop |
Events | |
AddShowEvent | Add an event for showing a widget |
AddHideEvent | Add an event for hiding a widget |
AddMoveEvent | Add an event for moving a widget |
AddResizeEvent | Add an event for resizing a widget |
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 |
AddTimerEvent | Add an event for a timer |
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.
std::wstring MQWidgetBase::GetName();
(new in Rev4.50)
It returns a widget's name.
void MQWidgetBase::SetName(const std::wstring& value);
(new in Rev4.50)
It specifies a widget's name.
It cannot rename for the named widget.
__int64 MQWidgetBase::GetTag();
(new in Rev4.50)
It returns an arbitrary value specified to the widget.
void MQWidgetBase::SetTag(__int64 value);
(new in Rev4.50)
It specifies an arbitrary value to the widget.
You can use an arbitrary value for an index, ID and so on to distinguish widgets.
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.
int MQWidgetBase::GetCellColumn();
(new in Rev4.23)
It returns a number of columns of a cell in a matrix frame by MQFrameBase::SetMatrixColumn().
void MQWidgetBase::SetCellColumn(int value);
(new in Rev4.23)
It specifies a number of columns of a cell in a matrix frame by MQFrameBase::SetMatrixColumn().
std::wstring MQWidgetBase::GetHintText();
(new in Rev4.30)
It returns a text displayed at the time that a mouse cursor is on a widget.
void MQWidgetBase::SetHintText(const std::wstring& value);
(new in Rev4.30)
It specifies a text displayed at the time that a mouse cursor is on a widget.
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.
bool MQWidgetBase::ClientToScreen(int client_x, int client_y, int *screen_x, int *screen_y);
It converts a client coordinate to a screen coordinate.
bool MQWidgetBase::ScreenToClient(int screen_x, int screen_y, int *client_x, int *client_y);
It converts a screen coordinate to a client coordinate.
bool MQWidgetBase::ClientToClient(int client_x, int client_y, MQWidgetBase *target, int *target_x, int *target_y);
It converts a client coordinate to the target client coordinate.
void MQWidgetBase::Repaint(bool immediate = false);
It repaints a widget.
When immediate is true, the widget will be repainted immediately. When immediate is false, a repainting is reserved and it will be repainted after returning to an event loop.
void MQWidgetBase::RefreshPaint();
(new in Rev4.30)
It performs to paint immediately to the area where a repainting is reserved by Repaint(false), a window operation and so on.
void MQWidgetBase::CaptureMouse(bool value);
(new in Rev4.30)
It captures a mouse operation, and mouse events are notified to this widget even if a mouse is moved out of this widget.
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 int MQWidgetBase::GetBaseRateSize(double rate);
It returns a widget size by a rate of a base size.
static void MQWidgetBase::GetDefaultFrameColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultFrameColor();
It returns a default frame color.
static void MQWidgetBase::GetDefaultTextColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultTextColor();
It returns a default text color.
static void MQWidgetBase::GetDefaultTitleBackColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultTitleBackColor();
(new in Rev4.11)
It returns a default title background color.
static void MQWidgetBase::GetDefaultTitleTextColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultTitleTextColor();
(new in Rev4.11)
It returns a default title text color.
static void MQWidgetBase::GetDefaultListBackColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultListBackColor();
It returns a default list background color.
static void MQWidgetBase::GetDefaultListTextColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultListTextColor();
It returns a default list text color.
static void MQWidgetBase::GetDefaultListActiveColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultListActiveColor();
It returns a default list active color.
static void MQWidgetBase::GetDefaultListActiveTextColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultListActiveTextColor();
It returns a default list active text color.
static void MQWidgetBase::GetDefaultEditBackColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultEditBackColor();
It returns a default edit background color.
static void MQWidgetBase::GetDefaultEditTextColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultEditTextColor();
It returns a default edit text color.
static void MQWidgetBase::GetDefaultEditSelectionColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultEditSelectionColor();
It returns a default edit selection color.
static void MQWidgetBase::GetDefaultEditSelectionTextColor(int& r, int& g, int& b, int& a);
static MQCanvasColor MQWidgetBase::GetDefaultEditSelectionTextColor();
It returns a default edit selection text color.
static void MQWidgetBase::RegisterSubCommandButton(MQStationPlugin *plugin, MQButton *button, const char *command_str);
(new in Rev4.30)
It registers a button for a sub command corresponding with MQStationPlugin::EnumSubCommand().
A shortcut key will be shown on the button when the key is assigned to the specified sub command.
static void MQWidgetBase::EnterEventLoop(unsigned int timeout_ms = (unsigned int)-1, bool empty_return = false);
It enters a new event loop to process events such as a mouse, a keyboard or a drawing.
When timeout_ms is 0 or larger, a procedure will exit an event loop and return when a specified time is exceeded. But if a processing which requires time within an event loop is performed, a procedure will not return until the processing finished, even if a time is exceeded.
When timeout_ms is not specified, a procedure continues in an event loop and does not return until calling ExitEventLoop().
When empty_return is true, a procedure will return immediately at the time that no event exists even if a time is not exceeded.
static void MQWidgetBase::ExitEventLoop();
It is called to exit an event loop entered by EnterEventLoop().
Please be careful that a procedure will become invalid when EnterEventLoop() is not called yet or the procedure already exited an event loop.
template<typename T> void MQWidgetBase::AddShowEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), bool prior = false);
It adds events notified when a widget is shown.
A member function 'f' must have the following options and return value.
BOOL T::f(MQWidgetBase* sender, MQDocument doc);
template<typename T> void MQWidgetBase::AddHideEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), bool prior = false);
It adds events notified when a widget is hidden.
Please refer the description in AddShowEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddMoveEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), bool prior = false);
It adds events notified when a widget is moved.
Please refer the description in AddShowEvent about the member function 'f'.
template<typename T> void MQWidgetBase::AddResizeEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), bool prior = false);
It adds events notified when a widget is resized.
Please refer the description in AddShowEvent about the member function 'f'.
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; float Pressure; bool Finished; };
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; bool Finished; };
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'.
template<typename T> void MQWidgetBase::AddTimerEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), unsigned int timeout_ms, bool overwrite = false);
It invokes a timer event after a specified time is exceeded.
If a processing which requires time within the same thread is performed, a timer event will not invoked until the processing finished, even if a time is exceeded.
When overwrite is true, the old event is overwritten if the target widget and the member function are same.
A timer event is invoked once for calling this function. Specify that overwrite is false and call this function several times if you want to invoke events several times.
Please refer the description in AddShowEvent about the member function 'f'.