TwBar parameters syntaxDescriptionThis 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:
where They can also be set or get using the TwSetParam and TwGetParam functions, eg.:
Bar parameterslabelSyntax
DescriptionChanges 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. ExampleTwDefine(" mybar label='Engine properties' "); helpSyntax
DescriptionDefines 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 ExampleTwDefine(" 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!' "); colorSyntax
DescriptionChanges the color of a bar.
ExampleTwDefine(" 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 alphaSyntax
DescriptionChanges the bar opacity.
Bar opacity a can vary from 0 for fully transparent to 255 for fully opaque. See also the ExampleTwDefine(" mybar alpha=0 "); // transparent bar TwDefine(" mybar alpha=128 "); // half-transparent bar TwDefine(" mybar alpha=255 "); // opaque bar textSyntax
DescriptionChanges 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 ExampleTwDefine(" mybar text=dark "); // use dark text color TwDefine(" mybar text=light "); // use light text color positionSyntax
DescriptionMove a bar to a new position.
ExampleTwDefine(" mybar position='200 40' "); // move bar to position (200, 40) sizeSyntax
DescriptionChange the bar size.
ExampleTwDefine(" mybar size='240 320' "); // resize bar valueswidthSyntax
DescriptionChange the width of the bar right column used to display numerical values.
If ExampleTwDefine(" mybar valueswidth=120 "); // set values column width TwDefine(" mybar valueswidth=fit "); // column width fits content refreshSyntax
DescriptionChange the refresh rate of the bar.
Values displayed by a bar are automatically updated to reflect changes of their associated variables. ExampleTwDefine(" mybar refresh=1.5 "); // refresh the bar every 1.5 seconds visibleSyntax
DescriptionShow or hide a tweak bar. ExampleTwDefine(" mybar visible=false "); // mybar is hidden TwDefine(" mybar visible=true "); // mybar is displayed again NoteThe help bar can be hidden by calling: TwDefine(" TW_HELP visible=false "); // help bar is hidden iconifiedSyntax
DescriptionIconify or deiconify a tweak bar. ExampleTwDefine(" mybar iconified=true "); // mybar is iconified iconposSyntax
DescriptionChanges the place where icons of iconified bars are displayed.
Note that this parameter is applied to all bar icons. You can use the ExampleTwDefine(" GLOBAL iconpos=bottomright "); // icons go to bottom-right corner of the window iconalignSyntax
DescriptionChanges 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 ExampleTwDefine(" GLOBAL iconalign=horizontal "); // icons will be aligned horizontally iconmarginSyntax
Description
Add a margin between borders of the window and icons of iconified bars.
Note that this parameter is applied to all bar icons. You can use the ExampleTwDefine(" GLOBAL iconmargin='8 16' "); // icons will be displayed at 8 and 16 pixels from the horizontal and vertical window borders respectively iconifiableSyntax
DescriptionAllow a bar to be iconified or not by the user. ExampleTwDefine(" mybar iconifiable=false "); // mybar cannot be iconified movableSyntax
DescriptionAllow a bar to be moved or not by the user. ExampleTwDefine(" mybar movable=false "); // mybar cannot be moved resizableSyntax
DescriptionAllow a bar to be resized or not by the user. ExampleTwDefine(" mybar resizable=false "); // mybar cannot be resized fontsizeSyntax
DescriptionChange the size of the font used by the bars.
ExampleTwDefine(" GLOBAL fontsize=3 "); // use large font fontstyleSyntax
DescriptionChange the style of the font used by the bars.
Either specify
ExampleTwDefine(" GLOBAL fontstyle=fixed "); // use fixed-width font fontresizableSyntax
DescriptionAllow bar fonts to be resized or not by the user.
Note that this parameter is applied to all bars. You can use the ExampleTwDefine(" GLOBAL fontresizable=false "); // font cannot be resized fontscalingSyntax
Description
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.
ExampleTwDefine(" GLOBAL fontscaling=2 "); // double the size of all fonts TwInit(....); alwaystopSyntax
DescriptionSet a bar to be always on top of the others. ExampleTwDefine(" mybar alwaystop=true "); // mybar is always on top alwaysbottomSyntax
DescriptionSet a bar to be always behind the others. ExampleTwDefine(" mybar alwaysbottom=true "); // mybar is always on bottom containedSyntax
Description
Prevent a bar from moving outside of the window. To prevent all bars from moving outside of the window, use ExampleTwDefine(" GLOBAL contained=true "); // bars cannot move outside of the window overlapSyntax
DescriptionIf 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 ExampleTwDefine(" GLOBAL overlap=true "); buttonalignSyntax
DescriptionChange display alignment of buttons added by TwAddButton to a bar.
This parameter could be applied to all bars by using the ExampleTwDefine(" GLOBAL buttonalign=left "); // buttons are left-aligned NotesNote on string parameters
If a parameter requires a 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`' " Note on case sensitivity
See also |