index

Varkon MBS Programmers manual

# cre_button - Function

## Description

##

Creates a button in a dialogue window. Buttons without frames ( frame = 0 ) are regarded as simple text labels. A button without frame and with str1 = str2 = "" (null string) appear as simple rectangles and may be used for decoration.

Buttons with frame may toggle between two states if str1 is different from str2 or may not toggle if str1 = str2.

Clicking a button with frame generates an event that will be catched if waited for by the wait_win() routine.

## Syntax

      cre_button(window, pos, width, height, frame, str1, str2, font, bcolor, tcolor);

      int    window;
      vector pos;
      float  width;
      float  height;
      float  frame;
      string str1*132;
      string str2*132;
      string font*132;
      int    bcolor;
      int    tcolor;

## Principal parameters

window | - Identity of parent dialog window
pos | - Upper left coordinates relative to the parent window
width | - Horisontal size in pixels
height | - Vertical size in pixels
frame | - Frame width in pixels
str1 | - Default button text
str2 | - Toggle text

## Optional parameters

font | - Textfont (UNIX, with Microsoft Windows font = Size, see below)
bcolor | - Background color (UNIX only, not supported on Microsoft Windows)
tcolor | - Text color (UNIX only, not supported on Microsoft Windows)

## Return value

An INT holding the id of the button created.

## Example

      button_id:=cre_button(dia_win, vec(10,20), 5, 5, 0, "","","",2);

Creates a rectangle 5 by 5 pixels in poisition X=10, Y=20 filled with color number 2, usually red. No text is displayed.

      button_id:=cre_button(dia_win, vec(10,20), 5, 5, 0, "Text","");

Creates a text label.

      button_id:=cre_button(dia_win, vec(10,20), 5, 5, 1, "OKEY", "OKEY");

Creates a non toggling button.

      button_id:=cre_button(dia_win, vec(10,20), 5, 5, 1, "ON", "OFF");

Creates a toggle button.

## Comments

The Microsoft Windows implementation of VARKON is different from the UNIX implementation when it comes to fonts for text. In UNIX where X-Windows (X11) is used fonts of different sizes have different names but in Microsoft Windows a font with a certain name may be displayed in many different sizes.

The font parameter in cre_button() is treated as the name of a X11 font if UNIX is used but treated as the size of the currently active font set by VARKON.INI if Windows is used.

Frame width can be zero or one but the UNIX version of VARKON also honours values greater than one to create thicker frames if needed.

The Microsoft Windows implementation of VARKON currently does not support parameters bcolor and tcolor.

See also:

cre_fbutton(), cre_win(), cre_edit(), cre_icon(), cre_ficon(),

Varkon version 1.19C svn# 120