Merged in v 26.12.
[AROS-Contrib.git] / mui / classes / thebar / demo / demo6.c
blob07aa0027a9b0b8d084ce4452dfff72d2b3c53f4f
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"
12 /***********************************************************************/
14 long __stack = 8192;
15 #if defined(__amigaos4__)
16 struct Library *IntuitionBase;
17 struct Library *MUIMasterBase;
18 struct IntuitionIFace *IIntuition;
19 struct MUIMasterIFace *IMUIMaster;
20 #else
21 struct IntuitionBase *IntuitionBase;
22 struct Library *MUIMasterBase;
23 #endif
25 /***********************************************************************/
27 #ifndef MAKE_ID
28 #define MAKE_ID(a,b,c,d) ((ULONG)(a)<<24|(ULONG)(b)<<16|(ULONG)(c)<<8|(ULONG)(d))
29 #endif
31 /***********************************************************************/
33 #if defined(__amigaos4__)
34 #define CLOSELIB(lib, iface) { if((iface) && (lib)) { DropInterface((APTR)(iface)); iface = NULL; CloseLibrary((struct Library *)lib); lib = NULL; } }
35 #define GETINTERFACE(iname, iface, base) ((iface) = (APTR)GetInterface((struct Library *)(base), (iname), 1L, NULL))
36 #define DROPINTERFACE(iface) { DropInterface((APTR)(iface)); iface = NULL; }
37 #else
38 #define CLOSELIB(lib, iface) { if((lib)) { CloseLibrary((struct Library *)lib); lib = NULL; } }
39 #define GETINTERFACE(iname, iface, base) TRUE
40 #define DROPINTERFACE(iface) ((void)0)
41 #endif
43 /***********************************************************************/
45 #define ROWS 3
46 #define COLS 16
47 #define HSPACE 0
48 #define VSPACE 0
49 #define PIC(x,y) (x+y*COLS)
51 #define BAR {MUIV_TheBar_BarSpacer, -1, NULL, NULL, 0, 0, NULL, NULL}
53 struct MUIS_TheBar_Button buttons[] =
55 {PIC(7,0), 1, "_Face", "Just a face.", 0, 0, NULL, NULL},
56 {PIC(14,0), 2, "_Mouse", "Your mouse.", 0, 0, NULL, NULL},
57 {PIC(1,1), 3, "_Tree", "Mind takes place.", 0, 0, NULL, NULL},
59 BAR,
61 {PIC(10,1), 4, "_Help", "Read this!.", 0, 0, NULL, NULL},
62 {PIC(2,2), 5, "_ARexx", "ARexx for ever!.", 0, 0, NULL, NULL},
63 {PIC(1,0), 6, "_Host", "Your computer.", 0, 0, NULL, NULL},
65 {MUIV_TheBar_End, 0, NULL, NULL, 0, 0, NULL, NULL}
68 /***********************************************************************/
70 const char *appearances[] = {"Images and text","Images","Text",NULL};
71 const char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
73 const char *usedClasses[] = {"TheBar.mcc",NULL};
75 int
76 main(UNUSED int argc,char **argv)
78 int res;
80 if ((IntuitionBase = (APTR)OpenLibrary("intuition.library",39)) != NULL &&
81 GETINTERFACE("main", IIntuition, IntuitionBase))
83 if ((MUIMasterBase = OpenLibrary("muimaster.library",19)) != NULL &&
84 GETINTERFACE("main", IMUIMaster, MUIMasterBase))
86 Object *app, *win, *sb, *appearance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
88 if ((app = ApplicationObject,
89 MUIA_Application_Title, "TheBar Demo6",
90 MUIA_Application_Version, "$VER: TheBarDemo6 1.0 (24.6.2003)",
91 MUIA_Application_Copyright, "Copyright 2003 by Alfonso Ranieri",
92 MUIA_Application_Author, "Alfonso Ranieri <alforan@tin.it>",
93 MUIA_Application_Description, "TheBar example",
94 MUIA_Application_Base, "THEBAREXAMPLE",
95 MUIA_Application_UsedClasses, usedClasses,
97 SubWindow, win = WindowObject,
98 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
99 MUIA_Window_Title, "TheBar Demo6",
100 WindowContents, VGroup,
101 Child, sb = TheBarObject,
102 MUIA_Group_Horiz, TRUE,
103 MUIA_TheBar_IgnoreAppearance, TRUE,
104 MUIA_TheBar_EnableKeys, TRUE,
105 MUIA_TheBar_Buttons, buttons,
106 MUIA_TheBar_PicsDrawer, "PROGDIR:Pics",
107 MUIA_TheBar_Strip, "symbols",
108 MUIA_TheBar_StripCols, COLS,
109 MUIA_TheBar_StripRows, ROWS,
110 MUIA_TheBar_StripHSpace, HSPACE,
111 MUIA_TheBar_StripVSpace, VSPACE,
112 End,
113 Child, VGroup,
114 GroupFrameT("Settings"),
115 Child, HGroup,
116 Child, Label2("Appearance"),
117 Child, appearance = MUI_MakeObject(MUIO_Cycle,NULL,appearances),
118 Child, Label2("Label pos"),
119 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
120 End,
121 Child, HGroup,
122 Child, HSpace(0),
123 Child, Label1("Borderless"),
124 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
125 Child, HSpace(0),
126 Child, Label1("Sunny"),
127 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
128 Child, HSpace(0),
129 Child, Label1("Raised"),
130 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
131 Child, HSpace(0),
132 Child, Label1("Scaled"),
133 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
134 Child, HSpace(0),
135 End,
136 End,
137 Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
138 End,
139 End,
140 End) != NULL)
142 ULONG sigs = 0;
143 LONG id;
145 DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
146 DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
148 set(win,MUIA_Window_Open,TRUE);
150 while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
152 if (id==(LONG)TAG_USER)
154 IPTR appearanceV = 0,
155 labelPosV = 0,
156 borderlessV = 0,
157 sunnyV = 0,
158 raisedV = 0,
159 scaledV = 0;
161 get(appearance,MUIA_Cycle_Active,&appearanceV);
162 get(labelPos,MUIA_Cycle_Active,&labelPosV);
163 get(borderless,MUIA_Selected,&borderlessV);
164 get(sunny,MUIA_Selected,&sunnyV);
165 get(raised,MUIA_Selected,&raisedV);
166 get(scaled,MUIA_Selected,&scaledV);
168 SetAttrs(sb,MUIA_TheBar_ViewMode, appearanceV,
169 MUIA_TheBar_LabelPos, labelPosV,
170 MUIA_TheBar_Borderless, borderlessV,
171 MUIA_TheBar_Sunny, sunnyV,
172 MUIA_TheBar_Raised, raisedV,
173 MUIA_TheBar_Scaled, scaledV,
174 TAG_DONE);
177 if (sigs)
179 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
180 if (sigs & SIGBREAKF_CTRL_C) break;
184 MUI_DisposeObject(app);
186 res = RETURN_OK;
188 else
190 printf("%s: can't create application\n",argv[0]);
191 res = RETURN_FAIL;
194 CLOSELIB(MUIMasterBase, IMUIMaster);
196 else
198 printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
199 res = RETURN_ERROR;
202 CLOSELIB(IntuitionBase, IIntuition);
204 else
206 printf("%s: Can't open intuition.library ver 39 or higher\n",argv[0]);
207 res = RETURN_ERROR;
210 return res;
213 /***********************************************************************/