File Index Symbol Index

/*********************************************************************** Vczh Library++ 3.0 Developer: Zihan Chen(vczh) GacUI::Control System Interfaces: ***********************************************************************/
#ifndef VCZH_PRESENTATION_CONTROLS_GUIBUTTONCONTROLS
#define VCZH_PRESENTATION_CONTROLS_GUIBUTTONCONTROLS
#include "GuiBasicControls.h"
namespace
vl
{
namespace
presentation
{
namespace
controls
{
/*********************************************************************** Buttons ***********************************************************************/
/// <summary>A control with 3 phases state transffering when mouse click happens.</summary>
class
GuiButton
:
public
GuiControl
,
public
Description
<
GuiButton
> {
protected
:
bool
clickOnMouseUp
=
true
;
bool
ignoreChildControlMouseEvents
=
true
;
bool
autoFocus
=
true
;
bool
keyPressing
=
false
;
bool
mousePressing
=
false
;
bool
mouseHoving
=
false
;
ButtonState
controlState
=
ButtonState
::
Normal
;
void
OnParentLineChanged
()
override
;
void
OnActiveAlt
()
override
;
bool
IsTabAvailable
()
override
;
void
UpdateControlState
();
void
CheckAndClick
(
compositions
::
GuiEventArgs
&
arguments
);
void
OnLeftButtonDown
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiMouseEventArgs
&
arguments
);
void
OnLeftButtonUp
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiMouseEventArgs
&
arguments
);
void
OnMouseEnter
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiEventArgs
&
arguments
);
void
OnMouseLeave
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiEventArgs
&
arguments
);
void
OnKeyDown
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiKeyEventArgs
&
arguments
);
void
OnKeyUp
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiKeyEventArgs
&
arguments
);
void
OnLostFocus
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiEventArgs
&
arguments
);
public
:
/// <summary>Create a control with a specified default theme.</summary>
/// <param name="themeName">The theme name for retriving a default control template.</param>
GuiButton
(
theme
::
ThemeName
themeName
);
~
GuiButton
();
/// <summary>Mouse click event.</summary>
compositions
::
GuiNotifyEvent
Clicked
;
/// <summary>Test is the <see cref="Clicked"/> event raised when left mouse button up.</summary>
/// <returns>Returns true if this event is raised when left mouse button up</returns>
bool
GetClickOnMouseUp
();
/// <summary>Set is the <see cref="Clicked"/> event raised when left mouse button up or not.</summary>
/// <param name="value">Set to true to make this event raised when left mouse button up</param>
void
SetClickOnMouseUp
(
bool
value
);
/// <summary>Test if the button gets focus when it is clicked.</summary>
/// <returns>Returns true if the button gets focus when it is clicked.</returns>
bool
GetAutoFocus
();
/// <summary>Set if the button gets focus when it is clicked.</summary>
/// <param name="value">Set to true to make this button get focus when it is clicked.</param>
void
SetAutoFocus
(
bool
value
);
/// <summary>
/// Test if the button ignores mouse events raised in child controls.
/// When this property is false,
/// the button reacts to mouse operations even when it happens on contained child controls.
/// </summary>
/// <returns>Returns true if the button ignores mouse events raised in child controls.</returns>
bool
GetIgnoreChildControlMouseEvents
();
/// <summary>Set if the button ignores mouse events raised in child controls.</summary>
/// <param name="value">Set to true to make this button ignore mouse events raised in child controls.</param>
void
SetIgnoreChildControlMouseEvents
(
bool
value
); };
/// <summary>A <see cref="GuiButton"/> with a selection state.</summary>
class
GuiSelectableButton
:
public
GuiButton
,
public
Description
<
GuiSelectableButton
> {
public
:
/// <summary>Selection group controller. Control the selection state of all attached button.</summary>
class
GroupController
:
public
GuiComponent
,
public
Description
<
GroupController
> {
protected
:
collections
::
List
<
GuiSelectableButton
*>
buttons
;
public
:
GroupController
();
~
GroupController
();
/// <summary>Called when the group controller is attached to a <see cref="GuiSelectableButton"/>. use [M:vl.presentation.controls.GuiSelectableButton.SetGroupController] to attach or detach a group controller to or from a selectable button.</summary>
/// <param name="button">The button to attach.</param>
virtual
void
Attach
(
GuiSelectableButton
*
button
);
/// <summary>Called when the group controller is deteched to a <see cref="GuiSelectableButton"/>. use [M:vl.presentation.controls.GuiSelectableButton.SetGroupController] to attach or detach a group controller to or from a selectable button.</summary>
/// <param name="button">The button to detach.</param>
virtual
void
Detach
(
GuiSelectableButton
*
button
);
/// <summary>Called when the selection state of any <see cref="GuiSelectableButton"/> changed.</summary>
/// <param name="button">The button that changed the selection state.</param>
virtual
void
OnSelectedChanged
(
GuiSelectableButton
*
button
) =
0
; };
/// <summary>A mutex group controller, usually for radio buttons.</summary>
class
MutexGroupController
:
public
GroupController
,
public
Description
<
MutexGroupController
> {
protected
:
bool
suppress
;
public
:
MutexGroupController
();
~
MutexGroupController
();
void
OnSelectedChanged
(
GuiSelectableButton
*
button
)
override
; };
protected
:
GroupController
*
groupController
=
nullptr
;
bool
autoSelection
=
true
;
bool
isSelected
=
false
;
void
OnClicked
(
compositions
::
GuiGraphicsComposition
*
sender
,
compositions
::
GuiEventArgs
&
arguments
);
public
:
/// <summary>Create a control with a specified default theme.</summary>
/// <param name="themeName">The theme name for retriving a default control template.</param>
GuiSelectableButton
(
theme
::
ThemeName
themeName
);
~
GuiSelectableButton
();
/// <summary>Group controller changed event.</summary>
compositions
::
GuiNotifyEvent
GroupControllerChanged
;
/// <summary>Auto selection changed event.</summary>
compositions
::
GuiNotifyEvent
AutoSelectionChanged
;
/// <summary>Selected changed event.</summary>
compositions
::
GuiNotifyEvent
SelectedChanged
;
/// <summary>Get the attached group controller.</summary>
/// <returns>The attached group controller.</returns>
virtual
GroupController
*
GetGroupController
();
/// <summary>Set the attached group controller.</summary>
/// <param name="value">The attached group controller.</param>
virtual
void
SetGroupController
(
GroupController
*
value
);
/// <summary>Get the auto selection state. True if the button is automatically selected or unselected when the button is clicked.</summary>
/// <returns>The auto selection state.</returns>
virtual
bool
GetAutoSelection
();
/// <summary>Set the auto selection state. True if the button is automatically selected or unselected when the button is clicked.</summary>
/// <param name="value">The auto selection state.</param>
virtual
void
SetAutoSelection
(
bool
value
);
/// <summary>Get the selected state.</summary>
/// <returns>The selected state.</returns>
virtual
bool
GetSelected
();
/// <summary>Set the selected state.</summary>
/// <param name="value">The selected state.</param>
virtual
void
SetSelected
(
bool
value
); }; } } }
#endif