DialogControls-CheckBoxes: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Created page with "'''TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here.''' === Checkboxes === The Checkboxes are a set of state change buttons, ordered by columns...")
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here.'''
'''TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here.'''
=== Checkboxes ===
=== Checkboxes ===
The Checkboxes are a set of state change buttons, ordered by columns and rows. Unlike the Toolbox Control more than one button can become active.
The Checkboxes (also known as textual checkboxes) are a set of state change buttons, ordered by columns and rows. Unlike the Toolbox Control more than one button can become active. Maximum number of checkboxes available for a single control is 32. It is possible to create more than 32 checkboxes, however over-the-limit checkboxes will just become duplicates.


{| border="1" align="left" cellpadding="3" cellspacing="0" |
{| border="1" align="left" cellpadding="3" cellspacing="0" |
Line 9: Line 9:
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Type
! bgcolor="#ddddff" | Remark
! bgcolor="#ddddff" | Remark
|-
| '''idc'''
| integer
| the unique ID number of this dialog. Can be -1 if you don't require access to the dialog itself from within a script.
|-
|-
| '''colorText'''
| '''colorText'''
| color array
| color array
| color of the control text.
| color of the unchecked checkbox text
|-
| '''color'''
| color array
| color of border from selected entry, if other control has focus.
|-
|-
| '''colorTextSelect'''
| '''colorTextSelect'''
| color array
| color array
| color of text if selected
| color of the checked checkbox text
|-
| '''colorSelect'''
| color array
| color of border from selected entry.
|-
| '''colorTextDisable'''
| color array
| color of control text, if control is disabled.
|-
| '''colorDisable'''
| color array
| seems nothing to change, but define it to avoid errors.
|-
|-
| '''font'''
| '''font'''
Line 45: Line 25:
| float
| float
| the font size of text (0 to 1)  
| the font size of text (0 to 1)  
|-
| '''colorSelectedBg'''
| color array
| color of the background when checkbox is focus selected (doesn't matter if checked or not)
|-
|-
| '''rows'''
| '''rows'''
| integer
| integer
| amount of rows to display
| amount of rows to arrange checkboxes into
|-
|-
| '''columns'''
| '''columns'''
| integer
| integer
| amount of columns to display
| amount of columns to arrange checkboxes into
|-
|-
| '''color'''
| '''strings'''
| color array
| string array
| color of the control surrounding lines.
| checkboxes texts to display
|-
|-
| '''strings'''
| '''checked_strings'''
| string array
| string array
| text for each toolbox entry
| checkboxes texts to display when checkboxes are checked
|-
|-
|}<br clear="all">
|}<br clear="all">


Checkboxes corresponding '''type''' property is ''CT_CHECKBOXES''.
[[Image:checkboxes.jpg|thumb|400px|A Checkboxes Control from example code with a hint dialog from UI event handler]]
 
<br>'''Example:'''<br>
<syntaxhighlight lang=cpp>
class MyCheckBoxes
{
idc = -1;
type = 7; // CT_CHECKBOXES
style = 2; // ST_CENTER


[[Image:CheckboxesControl.jpg|thumb|200px|A Checkboxes Control from example code with a hint dialog from UI event handler]]
x = 0.25;
* '''Example:'''
y = 0.25;
<code><nowiki>class MyRscCheckBoxes {
w = 0.5;
  idc = 200;
h = 0.5;
  type = CT_CHECKBOXES; // defined contant (7)
 
  style = ST_CENTER; // defined constat (0)
colorSelectedBg[] = {0, 0, 0, 0.2}; // selected item bg color
 
 
  x = 0.1;
colorText[] = {0, 1, 0, 1}; // checkbox unchecked color
  y = 0.18;
colorTextSelect[] = {1, 0, 0, 1}; // checkbox checked color
  w = 0.15;
 
  h = 0.15;
colorBackground[] = {0, 0, 1, 0.3}; // control generic BG color
 
  colorText[] = {1, 0, 0, 1};
font = "RobotoCondensed";
  color[] = {0, 1, 0, 1}; //seems nothing to change, but define to avaoid errors
sizeEx = 0.04;
  colorTextSelect[] = {0, 0.8, 0, 1};
  colorSelect[] = {0, 0, 0, 1};
onCheckBoxesSelChanged = "hint str _this";
  colorTextDisable[] = {0.4, 0.4, 0.4, 1};
  colorDisable[] = {0.4, 0.4, 0.4, 1};
columns = 8;
 
rows = 4;
  font = "Zeppelin32";
strings[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
  sizeEx = 0.0208333;
checked_strings[] = {"[0]","[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","[10]","[11]","[12]","[13]","[14]","[15]","[16]","[17]","[18]","[19]","[20]","[21]","[22]","[23]","[24]","[25]","[26]","[27]","[28]","[29]","[30]","[31]"};
 
  rows = 3;
  columns = 2;
  strings[] = {"Entry 1","Entry 2","Entry 3","Entry 4","Entry 5","Entry 6"};
 
  //Simple UI event handler to show response on clicks
  onCheckBoxesSelChanged = "hint format[""Checkbox change:\n%1\nEntry#: %2\nNewState: %3"",(_this select 0),(_this select 1),(_this select 2)];"
};
};
</nowiki></code>
</syntaxhighlight>
 
<code>[[with]] [[uiNamespace]] [[do]]
{
ctrl = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["MyCheckBoxes", -1];
};</code>


'''Notice:'''
'''Script commands for use with CheckBoxes:'''  
As you see in the example image, the returned entry number from the ''onCheckBoxesSelChanged'' event handler starts at zero (0)! So if you have 6 toolbox entrys, the first is 0 and the last is 5!
* [[ctrlChecked]]
'''Notice:'''
* [[ctrlSetChecked]]
You must add this line : '''coloSelectedBg[] = {0, 0, 0, 0};''' (for setting the selected box color)
[[Category: Dialogs]]
[[Category: Dialogs]]

Revision as of 18:41, 4 May 2017

TokenNames common to most controls, such as x,y,w,h,text,idc... are not listed here.

Checkboxes

The Checkboxes (also known as textual checkboxes) are a set of state change buttons, ordered by columns and rows. Unlike the Toolbox Control more than one button can become active. Maximum number of checkboxes available for a single control is 32. It is possible to create more than 32 checkboxes, however over-the-limit checkboxes will just become duplicates.

Properties
Name Type Remark
colorText color array color of the unchecked checkbox text
colorTextSelect color array color of the checked checkbox text
font float the font to use. See the list of available fonts for possible values
sizeEx float the font size of text (0 to 1)
colorSelectedBg color array color of the background when checkbox is focus selected (doesn't matter if checked or not)
rows integer amount of rows to arrange checkboxes into
columns integer amount of columns to arrange checkboxes into
strings string array checkboxes texts to display
checked_strings string array checkboxes texts to display when checkboxes are checked


A Checkboxes Control from example code with a hint dialog from UI event handler


Example:

class MyCheckBoxes
{
	idc = -1;
	type = 7; // CT_CHECKBOXES
	style = 2; // ST_CENTER

	x = 0.25;
	y = 0.25;
	w = 0.5;
	h = 0.5;

	colorSelectedBg[] = {0, 0, 0, 0.2}; // selected item bg color

	colorText[] = {0, 1, 0, 1}; // checkbox unchecked color
	colorTextSelect[] = {1, 0, 0, 1}; // checkbox checked color

	colorBackground[] = {0, 0, 1, 0.3}; // control generic BG color
	
	font = "RobotoCondensed";
	sizeEx = 0.04;
	
	onCheckBoxesSelChanged = "hint str _this";
	
	columns = 8;
	rows = 4;
	strings[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
	checked_strings[] = {"[0]","[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","[10]","[11]","[12]","[13]","[14]","[15]","[16]","[17]","[18]","[19]","[20]","[21]","[22]","[23]","[24]","[25]","[26]","[27]","[28]","[29]","[30]","[31]"};
};

with uiNamespace do { ctrl = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["MyCheckBoxes", -1]; };

Script commands for use with CheckBoxes: