Merged in v 26.12.
[AROS-Contrib.git] / mui / classes / thebar / demo / demo8.c
blob40a842eba6ffde0598bd51e8ca2d1cfb1ebe3613
2 #include <proto/exec.h>
3 #include <proto/dos.h>
4 #include <proto/muimaster.h>
5 #include <proto/intuition.h>
6 #include <clib/alib_protos.h>
7 #include <mui/TheBar_mcc.h>
8 #include <string.h>
9 #include <stdio.h>
10 #include "SDI_compiler.h"
11 #include "Symbols.h"
13 /***********************************************************************/
15 long __stack = 8192;
16 #if defined(__amigaos4__)
17 struct Library *IntuitionBase;
18 struct Library *MUIMasterBase;
19 struct IntuitionIFace *IIntuition;
20 struct MUIMasterIFace *IMUIMaster;
21 #else
22 struct IntuitionBase *IntuitionBase;
23 struct Library *MUIMasterBase;
24 #endif
26 /***********************************************************************/
28 #ifndef MAKE_ID
29 #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
30 #endif
32 /***********************************************************************/
34 #if defined(__amigaos4__)
35 #define CLOSELIB(lib, iface) { if((iface) && (lib)) { DropInterface((APTR)(iface)); iface = NULL; CloseLibrary((struct Library *)lib); lib = NULL; } }
36 #define GETINTERFACE(iname, iface, base) ((iface) = (APTR)GetInterface((struct Library *)(base), (iname), 1L, NULL))
37 #define DROPINTERFACE(iface) { DropInterface((APTR)(iface)); iface = NULL; }
38 #else
39 #define CLOSELIB(lib, iface) { if((lib)) { CloseLibrary((struct Library *)lib); lib = NULL; } }
40 #define GETINTERFACE(iname, iface, base) TRUE
41 #define DROPINTERFACE(iface) ((void)0)
42 #endif
44 /***********************************************************************/
46 #define PIC_WIDTH 16
47 #define PIC_HEIGHT 16
48 #define PIC(x,y) (x)*PIC_WIDTH, (y)*PIC_HEIGHT, PIC_WIDTH, PIC_HEIGHT
50 struct MUIS_TheBar_Brush brush0 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 7,0), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS, {0, 0, 0, 0}};
51 struct MUIS_TheBar_Brush brush1 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC(14,0), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS, {0, 0, 0, 0}};
52 struct MUIS_TheBar_Brush brush2 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 1,1), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS, {0, 0, 0, 0}};
53 struct MUIS_TheBar_Brush brush3 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC(10,1), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS, {0, 0, 0, 0}};
54 struct MUIS_TheBar_Brush brush4 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 2,2), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS, {0, 0, 0, 0}};
55 struct MUIS_TheBar_Brush brush5 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 1,0), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS, {0, 0, 0, 0}};
57 struct MUIS_TheBar_Brush *brushes[] = {&brush0,&brush1,&brush2,&brush3,&brush4,&brush5,(APTR)-1};
59 struct MUIS_TheBar_Button buttons[] =
61 {0, 0, "_Face", "Just a face." , 0, 0, NULL, NULL},
62 {1, 1, "_Mouse", "Your mouse." , 0, 0, NULL, NULL},
63 {2, 2, "_Tree", "Mind takes place.", 0, 0, NULL, NULL},
64 {MUIV_TheBar_BarSpacer, -1, NULL, NULL, 0, 0, NULL, NULL},
65 {3, 3, "_Help", "Read this!." , 0, 0, NULL, NULL},
66 {4, 4, "_ARexx", "ARexx for ever!." , 0, 0, NULL, NULL},
67 {5, 5, "_Host", "Your computer." , 0, 0, NULL, NULL},
68 {MUIV_TheBar_End, 0, NULL, NULL, 0, 0, NULL, NULL},
71 /***********************************************************************/
73 const char *appearances[] = {"Images and text","Images","Text",NULL};
74 const char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
76 const char *usedClasses[] = {"TheBar.mcc",NULL};
78 int
79 main(UNUSED int argc,char **argv)
81 int res;
83 if ((IntuitionBase = (APTR)OpenLibrary("intuition.library",39)) != NULL &&
84 GETINTERFACE("main", IIntuition, IntuitionBase))
86 if ((MUIMasterBase = OpenLibrary("muimaster.library",19)) != NULL &&
87 GETINTERFACE("main", IMUIMaster, MUIMasterBase))
89 Object *app, *win, *sb, *appearance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
91 if ((app = ApplicationObject,
92 MUIA_Application_Title, "TheBar Demo8",
93 MUIA_Application_Version, "$VER: TheBarDemo8 1.0 (24.6.2003)",
94 MUIA_Application_Copyright, "Copyright 2003 by Alfonso Ranieri",
95 MUIA_Application_Author, "Alfonso Ranieri <alforan@tin.it>",
96 MUIA_Application_Description, "TheBar example",
97 MUIA_Application_Base, "THEBAREXAMPLE",
98 MUIA_Application_UsedClasses, usedClasses,
100 SubWindow, win = WindowObject,
101 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
102 MUIA_Window_Title, "TheBar Demo8",
103 WindowContents, VGroup,
104 Child, sb = TheBarObject,
105 MUIA_Group_Horiz, TRUE,
106 MUIA_TheBar_IgnoreAppearance, TRUE,
107 MUIA_TheBar_EnableKeys, TRUE,
108 MUIA_TheBar_Buttons, buttons,
109 MUIA_TheBar_Images, brushes,
110 End,
111 Child, VGroup,
112 GroupFrameT("Settings"),
113 Child, HGroup,
114 Child, Label2("Appearance"),
115 Child, appearance = MUI_MakeObject(MUIO_Cycle,NULL,appearances),
116 Child, Label2("Label pos"),
117 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
118 End,
119 Child, HGroup,
120 Child, HSpace(0),
121 Child, Label1("Borderless"),
122 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
123 Child, HSpace(0),
124 Child, Label1("Sunny"),
125 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
126 Child, HSpace(0),
127 Child, Label1("Raised"),
128 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
129 Child, HSpace(0),
130 Child, Label1("Scaled"),
131 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
132 Child, HSpace(0),
133 End,
134 End,
135 Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
136 End,
137 End,
138 End) != NULL)
140 ULONG sigs = 0;
141 LONG id;
143 DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
144 DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
146 set(win,MUIA_Window_Open,TRUE);
148 while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
150 if (id==(LONG)TAG_USER)
152 IPTR appearanceV = 0,
153 labelPosV = 0,
154 borderlessV = 0,
155 sunnyV = 0,
156 raisedV = 0,
157 scaledV = 0;
159 get(appearance,MUIA_Cycle_Active,&appearanceV);
160 get(labelPos,MUIA_Cycle_Active,&labelPosV);
161 get(borderless,MUIA_Selected,&borderlessV);
162 get(sunny,MUIA_Selected,&sunnyV);
163 get(raised,MUIA_Selected,&raisedV);
164 get(scaled,MUIA_Selected,&scaledV);
166 SetAttrs(sb,MUIA_TheBar_ViewMode, appearanceV,
167 MUIA_TheBar_LabelPos, labelPosV,
168 MUIA_TheBar_Borderless, borderlessV,
169 MUIA_TheBar_Sunny, sunnyV,
170 MUIA_TheBar_Raised, raisedV,
171 MUIA_TheBar_Scaled, scaledV,
172 TAG_DONE);
175 if (sigs)
177 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
178 if (sigs & SIGBREAKF_CTRL_C) break;
182 MUI_DisposeObject(app);
184 res = RETURN_OK;
186 else
188 printf("%s: can't create application\n",argv[0]);
189 res = RETURN_FAIL;
192 CLOSELIB(MUIMasterBase, IMUIMaster);
194 else
196 printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
197 res = RETURN_ERROR;
200 CLOSELIB(IntuitionBase, IIntuition);
202 else
204 printf("%s: Can't open intuition.library ver 37 or higher\n",argv[0]);
205 res = RETURN_ERROR;
208 return res;
211 /***********************************************************************/