summaryrefslogtreecommitdiff
path: root/iup/test/zbox.c
blob: 0451277114bede94fdf623e0155c44c403a6eee5 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <stdlib.h>
#include <stdio.h>
#include "iup.h"

static int list_cb (Ihandle *h, char *t, int o, int selected)
{
  if (selected == 1)
  {
    Ihandle* zbox = IupGetHandle ("zbox");
    IupSetAttribute (zbox, "VALUE", t);
  }
  
  return IUP_DEFAULT;
}

void ZboxTest(void)
{
  Ihandle *dlg;
  Ihandle *frm;
  Ihandle *zbox;
  Ihandle *text;
  Ihandle *list;
  Ihandle *lbl;
  Ihandle *btn;
  Ihandle *frame;

  frame = IupFrame(IupSetAttributes(IupList(NULL), "DROPDOWN=YES, 1=Test, 2=XXX, VALUE=1"));
  IupSetAttribute (frame, "TITLE", "List");

  text = IupText("");

  IupSetAttributes (text, "EXPAND = YES, VALUE = \"Enter your text here\"");
  
  /* Creates a label */
  lbl = IupLabel("This element is a label");

  /* Creatas a button */
  btn = IupButton ("This button does nothing", "");

  /* Creates handles for manipulating the zbox VALUE */
  IupSetHandle ("frame", frame);
  IupSetHandle ("text", text);
  IupSetHandle ("lbl", lbl);
  IupSetHandle ("btn", btn);
	
  /* Creates zbox with four elements */
  zbox = IupZbox (frame, text, lbl, btn, NULL);

  /* Associates handle "zbox" with zbox */
  IupSetHandle ("zbox", zbox);

  /* Sets zbox alignment */
  IupSetAttribute (zbox, "ALIGNMENT", "ACENTER");
  IupSetAttribute (zbox, "VALUE", "text");

  /* Creates frame */
  frm = IupFrame
  (
    IupHbox
    (
      list = IupList(NULL),
      NULL
    )
  ),

  /* Creates dialog */
  dlg = IupDialog
  (
    IupVbox
    (
      frm,
      zbox,
      NULL
    )
  );

  IupSetAttributes (list, "1 = frame, 2 = text, 3 = lbl, 4 = btn, VALUE=2");
  IupSetAttribute (frm, "TITLE", "Select an element");
  IupSetAttributes (dlg, "MARGIN=10x10, GAP=10, TITLE = \"IupZbox Example\"");
  IupSetCallback (list, "ACTION", (Icallback) list_cb);

  IupShowXY (dlg, IUP_CENTER, IUP_CENTER );
}

#ifndef BIG_TEST
int main(int argc, char* argv[])
{
  IupOpen(&argc, &argv);

  ZboxTest();

  IupMainLoop();

  IupClose();

  return EXIT_SUCCESS;
}
#endif