File: demo4.c

package info (click to toggle)
libsx 2.08-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,668 kB
  • sloc: ansic: 8,739; sh: 8,603; makefile: 62
file content (88 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download | duplicates (3)
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
/*
 * This demo program shows how to use bitmaps in your button widgets.
 * All that's been done is that I created several bitmaps using that
 * horrible X bitmap editor program, bitmap.  I saved those bitmaps
 * in files called thing1.h, thing2.h, etc.  They get #include'ed
 * here, and then we use them as the imagery for the button.
 *
 * Notice how when the button gets created we use NULL instead of a
 * text string.
 *
 * The program doesn't really do much with the buttons once they're
 * up, it just lets you click on them.  BTW, the bitmaps aren't
 * supposed to be anything in particular, it's just that I'm not much
 * of an artist.
 *
 *  Dominic Giampaolo
 *  dbg@sgi.com
 */
#include <stdio.h>
#include <stdlib.h>
#include "libsx.h"

#include "thing1.h"
#include "thing2.h"
#include "thing3.h"
#include "thing4.h"




void quit(Widget w, void *junk)
{
  exit(0);
}


void thing1(Widget w, void *junk)
{
  printf("Thing 1\n");
}


void thing2(Widget w, void *junk)
{
  printf("Thing 2\n");
}



void thing3(Widget w, void *junk)
{
  printf("Thing 3\n");
}


void thing4(Widget w, void *junk)
{
  printf("Thing 4\n");
}



int main(int argc, char **argv)
{
  Widget w[6];

  OpenDisplay(argc, argv);

  w[0] = MakeButton(NULL, thing1, NULL);
  w[1] = MakeButton(NULL, thing2, NULL);
  w[2] = MakeButton(NULL, thing3, NULL);
  w[3] = MakeButton(NULL, thing4, NULL);
  w[4] = MakeButton("Quit", quit, NULL);

  SetWidgetBitmap(w[0], thing1_bits, thing1_width, thing1_height);
  SetWidgetBitmap(w[1], thing2_bits, thing2_width, thing2_height);
  SetWidgetBitmap(w[2], thing3_bits, thing3_width, thing3_height);
  SetWidgetBitmap(w[3], thing4_bits, thing4_width, thing4_height);
  
  SetWidgetPos(w[1], PLACE_RIGHT, w[0], NO_CARE, NULL);
  SetWidgetPos(w[2], PLACE_RIGHT, w[1], NO_CARE, NULL);
  SetWidgetPos(w[3], PLACE_RIGHT, w[2], NO_CARE, NULL);
  SetWidgetPos(w[4], PLACE_RIGHT, w[3], NO_CARE, NULL);

  MainLoop();

  return 0;
}