Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

Switch

 

class Switch : public Ctrl

Switch provides selection of mutually exclusive options (cases).

 

Options can be visually aligned horizontally or vertically - U++ choses alignment based on size of options and Ctrl rectangle. Each option represents a case with associated text and value. Switch can be assigned any Value (not only Values associated with current cases); if there is no case with Value equal to the Value of Switch, no case is highlighted.

 

Derived from Ctrl

 

 

Constructor Detail

 

Switch()

Initializes the switch.

 


 

~Switch()

Default destructor.

 

 

Public Method List

 

Switch& SetLabel(int i, const char *text, int gap = 0)

Sets text of case with specified index i. Text can contain '\b' for access-key assignment. Value of case is set to i. If i is greater than current number of cases, empty cases are added to Switch with values equivalent to their indexes. gap is optional additional space added before this case, its unit is the height of text / 4. gap can be combined with GAP_SEPARATOR, which adds a gray line in the middle of the space.

 


 

Switch& SetLabel(const char *text)

Sets content of Switch. Each line of text represents one case with value equivalent to the index of line. When there is a number at the start line followed by ^ character, it represents the gap used in SetLabel. Same with | character represents gap with GAP_SEPARATOR. Example

 

    SetLabel("First\n1^Second\n4|Third")

 

    will create switch First, Second a Third labels; there will be 1/4 line gap between First and Second and 1 line gap with separator line in the middle between Second and Third.

 


 

String GetLabel(int iconst

Returns the text of case with specified index i.

 

 


 

String GetLabel() const

Returns the context of the Switch.

 


 

Switch& Set(int i, const Value& val, const char *text, int gap = 0)

Sets text of case with specified index i. Text can contain '\b' for access-key assignment. Value of case is set to val. If i is greater than current number of cases, empty cases are added to Switch with values equivalent to their indexes. See SetLabel for gap parameter explanation.

 


 

Switch& Set(int i, const Value& val)

Sets the Value of of case with specified index i. The text of case is unaltered.

 


 

Switch& Add(const Value& val, const char *text, int gap = 0)

Adds a new case to the Switch. See SetLabel for gap parameter explanation.

 


 

Switch& Add(const char *text, int gap = 0)

Adds a new case to the Switch. Value of the case is set to its index. See SetLabel for gap parameter explanation.

 


 

void EnableCase(int i, bool enable = true)

Enables or disables case with the specified index i.

i

Index of the case to be enabled or disabled.

enable

Enable flag (true if case is to be enabled).

 


 

void DisableCase(int i)

Same as EnableCase(i, false).

 


 

void EnableValue(const Value& val, bool enable = true)

Enables or disables case based on its value.

val

Value of the case to be enabled / disabled.

enable

Enable flag (true if case is to be enabled).

 


 

void DisableValue(const Value& val)

Same as EnableValue(val, false).

 


 

void Reset()

Removes content of the Switch.

 


 

const Array<Case>& GetCases() const

Retrieves information of all cases in the Switch.

Return value

Array of Switch::Case structures.

 


 

operator int() const

Simplified access to Switch Value. Equivalent to (int)GetData().

Switch must be assigned an integer value.

Return value

Integer Value of Switch.

 


 

void operator=(const Value& v)

Equivalent to SetData(v).

 


 

Switch& SetFont(Font f)

Alters the font to be used in the Switch.

f

Font to be used.

Return value

*this for chaining.

 


 

Font GetFont() const

Retrieves the font used in the Switch.

Return value

*this for chaining.

 


 

Switch& MinCaseHeight(int cy)

Sets the minimal height of a case in the switch.

f

Font to be used.

Return value

*this for chaining.

 


 

Switch& SetAutoDirection()

Sets Switch layout to automatic mode, where items are layed out depending on the available area for switch (vertically is the are is high enough, horizontally otherwise).

 


 

Switch& SetHorizontal()

Forces horizontal layout.

 


 

Switch& SetVertical()

Forces vertical layout.

 

 

 

Switch::Case

 

struct Case : public Moveable<Case> 

This structure is returned by the Switch::GetCases method.

 

 

Public Field List

 

String label

Text of the case.

 


 

Value value

Value of the case.

 


 

int accesskey

Access key.

 


 

bool enabled

Enable flag.

 

 

Do you want to contribute?