Page tree
Skip to end of metadata
Go to start of metadata

Introduction

Multiple controls can be collected into one group, which allows easy position or visibility manipulation of multiple controls at once.
It also allows the creation of controls that are larger than the displayed area, and which can be panned around inside the view via scrollbars.

Usage

Within the 'Controls' or 'ControlsBackground' class a new sub-class has to be created, of type 15 (CT_CONTROLS_GROUP).
This added class then contains another instance of 'Controls', in which the individual control elements are defined.

If the group class has a positive IDC assigned, then it can be manipulated from a script, and any position or visibility changes applied to the group will also be applied to the contained controls.

The x and y coordinates of the child control are relative to the parent class, e.g. if the group is positioned at x=.4; y=.4; and the enclosed control's position is x=.1; y=.1; then the absolute position of this control will be at x=.5; y=.5
The width and height of the enclosed controls are absolute, and if their dimensions exceed the size of the parent group, scrollbars will be displayed.

Properties

Properties
Name Type Remark Script
type Integer must be 15 (or CT_CONTROLS_GROUP, if using constants) -
style Integer 0 (not interpreted, but must be present) -
HScrollbar & VScrollbar Class Horizontal and vertical scrollbars must be defined. See the Dialogs Scrollbars article for details.
The scrollbars will be displayed within the defined width and height of the control group, so that the absolute space that is occupied by a group will always be the same - whether scrollbars are displayed or not.
-
x Float Left edge of control group, relative to the screen (0...1, see SafeZones for details).
Controls within this group will be positioned relative to the group's position.
ctrlSetPosition
y Float Top edge of control, relative to the screen (0...1, see SafeZones for details).
Controls within this group will be positioned relative to the group's position.
ctrlSetPosition
w Float Width of control. If a containing control exceeds this width (considering their x-position and width), then a horizontal scrollbar will be displayed. ctrlSetPosition
h Float Height of control. If a containing control exceeds this height (considering their y-position and height), then a vertical scrollbar will be displayed. ctrlSetPosition
includeVisibleOnly (V3.9+) Boolean When set to true, only ctrlVisible controls are taken into account when dimensions of the scrollable pane are computed. Default = 0. -


Example

Creates a dialog with multiple text controls, which are larger than the defined group (as in the image at the top of this article):

description.ext
Defines the dialog.
dialog.sqf
Opens the dialog, and moves it around.
class Dlg {
  idd = 20000;
  movingEnable = 1;

  class Controls {
    class CONTROLS_GROUP {
      type = 15; // CT_CONTROLS_GROUP
      style = 0; // always 0
      idc = 20000;
      // size and position of group
      x = .4; y = .4;
      w = .2; h = .2;
      // scrollbars
      class VScrollbar {
        color[] = {1, 1, 1, 1};
        width = 0.021;
      };
      class HScrollbar {
        color[] = {1, 1, 1, 1};
        height = 0.028;
      };
      // child controls (3 text fields)
      class Controls {
        class TXT1 {
          type = 0; 
          style = 0;
          idc = -1;
          x = .0; y = 0;
          w = .4; h = .11;
          colorText[] = {0,1,0,1};
          colorSelect[] = {0,1,1,1};
          colorBackground[] = {0,0,0,0.3};
          lineSpacing = 1;
          font = "TahomaB";
          sizeEx = 0.1;
          text = "ONE HUNDRED";
        }; 
        class TXT2 : TXT1 {
          y = .12;
          colorBackground[] = {0,0,0,0};
          text = "TWO HUNDRED";
        }
        class TXT3 : TXT1 {
          y = .24;
          text = "THREE HUNDRED";
        }
      };
    };
  };
};
// open dialog
createDialog "Dlg";
waitUntil {dialog};

// find the dialog and the group
_display = finddisplay 20000;
_group = _display displayctrl 20000;

waitUntil {
  // every 3 seconds, move the group to a new location, 
  // and change its size
  sleep 3;
  _newpos = [random .8,random .8,.1+random .5,.1+random .5];
  _group ctrlSetPosition _newpos;
  _group ctrlCommit 2;
  
  !dialog
};