This page describes the bar parameters aimed at modifying the behavior of a bar. They can be set through the def string of function TwDefine using the syntax:
TwDefine(” barName barParam1=xx barParam2=xx ... “);
where barParam
n is one of the parameter enumerated below.
They can also be set or get using the TwSetParam and TwGetParam functions, eg.:
TwSetParam(bar, NULL, “barParam”, TW_PARAM_xx, nb, &inParamValues);
TwGetParam(bar, NULL, “barParam”, TW_PARAM_xx, nb, &outParamValues);
label=string |
---|
Changes the label of a bar, that is the title displayed on top of a bar. By default, the label is the name used when the bar was created.
TwDefine(" mybar label='Engine properties' ");
help=string |
---|
Defines the help message associated to a bar. This message will be displayed inside the Help bar automatically created to help the user.
You can also define a global help message. It will be displayed at the beginning of the Help bar. To define it, use the GLOBAL
keyword instead of the bar name.
TwDefine(" mybar help='These properties defines the engine behavior' "); TwDefine(" GLOBAL help='I can write here a general description of my program.\n Welcome happy users!' ");
color=‘red green blue‘ |
---|
Changes the color of a bar.
red
, green
and blue
are integer values between 0 and 255 that define the red, green and blue color channels. See also the alpha
and text
parameters to change bar visual aspect.
TwDefine(" mybar color='255 255 0' "); // yellow bar (transparent by default) TwDefine(" mybar color='0 128 255' alpha=128 "); // semi-transparent blue bar TwDefine(" mybar color='192 255 192' text=dark "); // light-green bar with dark text color
alpha=a |
---|
Changes the bar opacity.
Bar opacity a can vary from 0 for fully transparent to 255 for fully opaque. See also the color
and text
parameters to change bar visual aspect.
TwDefine(" mybar alpha=0 "); // transparent bar TwDefine(" mybar alpha=128 "); // half-transparent bar TwDefine(" mybar alpha=255 "); // opaque bar
text=dark |
---|
text=light |
---|
Changes text color.
Depending on your application background color and on bar color and alpha, bar text might be more readable if it is dark or light. This parameter allows to switch between the two modes. See also the color
and alpha
parameters to change bar visual aspect.
TwDefine(" mybar text=dark "); // use dark text color TwDefine(" mybar text=light "); // use light text color
position=‘x y‘ |
---|
Move a bar to a new position.
x
and y
are positive integer values that represent the new position of the bar in pixels. (x
=0, y
=0) is upper-left corner of the application window.
TwDefine(" mybar position='200 40' "); // move bar to position (200, 40)
size=‘sx sy‘ |
---|
Change the bar size.
sx
and sy
are positive integer values that represent the new size of the bar in pixels.
TwDefine(" mybar size='240 320' "); // resize bar
valueswidth=w |
---|
valueswidth=fit |
---|
Change the width of the bar right column used to display numerical values.
w
is a positive integer that represents width in pixels.
If valueswidth
is set to fit
, column width is adjusted to fit column content.
TwDefine(" mybar valueswidth=120 "); // set values column width TwDefine(" mybar valueswidth=fit "); // column width fits content
refresh=r |
---|
Change the refresh rate of the bar.
Values displayed by a bar are automatically updated to reflect changes of their associated variables. r
is a real value corresponding to the number of seconds between two updates.
TwDefine(" mybar refresh=1.5 "); // refresh the bar every 1.5 seconds
visible=true |
---|
visible=false |
---|
Show or hide a tweak bar.
TwDefine(" mybar visible=false "); // mybar is hidden TwDefine(" mybar visible=true "); // mybar is displayed again
The help bar can be hidden by calling:
TwDefine(" TW_HELP visible=false "); // help bar is hidden
iconified=true |
---|
iconified=false |
---|
Iconify or deiconify a tweak bar.
TwDefine(" mybar iconified=true "); // mybar is iconified
iconpos=p |
---|
Changes the place where icons of iconified bars are displayed.
p
is one of the following values:
bottomleft
or bl
for bottom-left corner of the window (default).bottomright
or br
for bottom-right corner of the window.topleft
or tl
for top-left corner of the window.topright
or tr
for top-right corner of the window.
Note that this parameter is applied to all bar icons. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL iconpos=bottomright "); // icons go to bottom-right corner of the window
iconalign=vertical |
---|
iconalign=horizontal |
---|
Changes the alignment of icons of iconified bars. It can be vertical (the default), or horizontal.
Note that this parameter is applied to all bar icons. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL iconalign=horizontal "); // icons will be aligned horizontally
iconmargin=’x y’ |
---|
Add a margin between borders of the window and icons of iconified bars. x
and y
are the number of pixels between window borders and icons in the x and y directions respectively.
Note that this parameter is applied to all bar icons. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL iconmargin='8 16' "); // icons will be displayed at 8 and 16 pixels from the horizontal and vertical window borders respectively
iconifiable=true |
---|
iconifiable=false |
---|
Allow a bar to be iconified or not by the user.
TwDefine(" mybar iconifiable=false "); // mybar cannot be iconified
movable=true |
---|
movable=false |
---|
Allow a bar to be moved or not by the user.
TwDefine(" mybar movable=false "); // mybar cannot be moved
resizable=true |
---|
resizable=false |
---|
Allow a bar to be resized or not by the user.
TwDefine(" mybar resizable=false "); // mybar cannot be resized
fontsize=s |
---|
Change the size of the font used by the bars.
s
is 1 for small font, 2 for medium font, or 3 for large font. Note that all bars share the same font, so this change is applied to all bars.
fontsize
is a global parameter. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL fontsize=3 "); // use large font
fontstyle=default |
---|
fontstyle=fixed |
---|
Change the style of the font used by the bars.
Either specify default
for the default proportional font or fixed
for the non-proportional (fixed-width) font. Note that all bars share the same font and the fixed font has only one size (non-resizable).
fontstyle
is a global parameter. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL fontstyle=fixed "); // use fixed-width font
fontresizable=true |
---|
fontresizable=false |
---|
Allow bar fonts to be resized or not by the user.
Note that this parameter is applied to all bars. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL fontresizable=false "); // font cannot be resized
fontscaling=s |
---|
Apply a global scaling factor to all fonts. This may be useful to double the size of characters on high-density display for instance. The result may be pixelized. s
is any positive real value.
fontscaling
is a global parameter (use the GLOBAL
keyword instead of a bar name to set it) and must be set before calling TwInit
. This is an exception.
TwDefine(" GLOBAL fontscaling=2 "); // double the size of all fonts TwInit(....);
alwaystop=true |
---|
alwaystop=false |
---|
Set a bar to be always on top of the others.
TwDefine(" mybar alwaystop=true "); // mybar is always on top
alwaysbottom=true |
---|
alwaysbottom=false |
---|
Set a bar to be always behind the others.
TwDefine(" mybar alwaysbottom=true "); // mybar is always on bottom
contained=true |
---|
contained=false |
---|
Prevent a bar from moving outside of the window. To prevent all bars from moving outside of the window, use GLOBAL
in place of bar name.
TwDefine(" GLOBAL contained=true "); // bars cannot move outside of the window
overlap=true |
---|
overlap=false |
---|
If true, the content of overlapped bars is always completely drawn. If false, the content of overlapped regions is clipped and not drawn which improves readability of overlapped transparent bars (this is the default).
Note that this parameter is applied to all bars. You can use the GLOBAL
keyword instead of a bar name to set it.
TwDefine(" GLOBAL overlap=true ");
buttonalign=left |
---|
buttonalign=center |
---|
buttonalign=right |
---|
Change display alignment of buttons added by TwAddButton to a bar.
This parameter could be applied to all bars by using the GLOBAL
keyword instead of a bar name.
TwDefine(" GLOBAL buttonalign=left "); // buttons are left-aligned
If a parameter requires a string
, the string can be a simple name without any special characters; but if it contains special characters like spaces, punctuations or quotation marks, you should surround it with simple quotes (‘), back-quotes (`), or double-quotes (“). In between these two quotes, the other kind of quotes would be considered as normal characters; so use a kind of quotes that does not appear in your string. If you need the three kinds of quotes in your string, you can split it and surround each part by a different quotation mark; the successive string parts would then be concatenated and you’d get the expected result (see the following examples).
Examples:
param=Simple // -> Simple param='Two words' // -> Two words param=`That's All Folks` // -> That's All Folks param='He says "Hello!"' // -> He says "Hello!" // note that in a c-string " are replaced by \" ie.: " param='He says \"Hello!\"' " param="'aa'-"`"bb"-`'`cc`' // -> 'aa'-"bb"-`cc` // note that in a c-string " are replaced by \" ie.: " param=\"'aa'-\"`\"bb\"-`'`cc`' "
color=’...’
is the same as Color=’...’
and is the same as COLOR=’...’
.mybar
is different from MyBar
and is different from myBar
.