Merged in v 26.12.
[AROS-Contrib.git] / mui / classes / thebar / demo / demo1.c
blobd49fcaeb7118787b44c7b8177f62ba8871fc4990
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 struct MUIS_TheBar_Button buttons[] =
47 {0, 0, "_Pred", "Pread mail.", 0, 0, NULL, NULL},
48 {1, 1, "_Next", "Next mail.", 0, 0, NULL, NULL},
49 {2, 2, "_Move", "Move somewhere.", 0, 0, NULL, NULL},
50 {MUIV_TheBar_BarSpacer, 3, NULL, NULL, 0, 0, NULL, NULL},
51 {3, 4, "_Forw", "Forward somewhere.", 0, 0, NULL, NULL},
52 {4, 5, "F_ind", "Find something.", 0, 0, NULL, NULL},
53 {5, 6, "_Save", "Save mail.", 0, 0, NULL, NULL},
54 {MUIV_TheBar_End, 0, NULL, NULL, 0, 0, NULL, NULL},
57 /***********************************************************************/
59 const char *usedClasses[] = {"TheBar.mcc",NULL};
61 const char *appearances[] = {"Images and text","Images","Text",NULL};
62 const char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
64 int
65 main(UNUSED int argc,char **argv)
67 int res;
69 if ((IntuitionBase = (APTR)OpenLibrary("intuition.library",39)) != NULL &&
70 GETINTERFACE("main", IIntuition, IntuitionBase))
72 if ((MUIMasterBase = OpenLibrary("muimaster.library",19)) != NULL &&
73 GETINTERFACE("main", IMUIMaster, MUIMasterBase))
75 Object *app, *win, *sb, *appearance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
77 if ((app = ApplicationObject,
78 MUIA_Application_Title, "TheBar Demo1",
79 MUIA_Application_Version, "$VER: TheBarDemo1 1.0 (24.6.2003)",
80 MUIA_Application_Copyright, "Copyright 2003 by Alfonso Ranieri",
81 MUIA_Application_Author, "Alfonso Ranieri <alforan@tin.it>",
82 MUIA_Application_Description, "TheBar example",
83 MUIA_Application_Base, "THEBAREXAMPLE",
84 MUIA_Application_UsedClasses, usedClasses,
86 SubWindow, win = WindowObject,
87 MUIA_Window_ID, MAKE_ID('M','A','I','N'),
88 MUIA_Window_Title, "TheBar Demo1",
89 WindowContents, VGroup,
90 Child, sb = TheBarObject,
91 MUIA_Group_Horiz, TRUE,
92 MUIA_TheBar_IgnoreAppearance, TRUE,
93 MUIA_TheBar_EnableKeys, TRUE,
94 MUIA_TheBar_Buttons, buttons,
95 MUIA_TheBar_PicsDrawer, "PROGDIR:Pics",
96 MUIA_TheBar_Strip, "Read.toolbar",
97 MUIA_TheBar_SelStrip, "Read_S.toolbar",
98 MUIA_TheBar_DisStrip, "Read_G.toolbar",
99 MUIA_TheBar_StripCols, 11,
100 End,
101 Child, VGroup,
102 GroupFrameT("Settings"),
103 Child, HGroup,
104 Child, Label2("Appearance"),
105 Child, appearance = MUI_MakeObject(MUIO_Cycle,NULL,appearances),
106 Child, Label2("Label pos"),
107 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
108 End,
109 Child, HGroup,
110 Child, HSpace(0),
111 Child, Label1("Borderless"),
112 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
113 Child, HSpace(0),
114 Child, Label1("Sunny"),
115 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
116 Child, HSpace(0),
117 Child, Label1("Raised"),
118 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
119 Child, HSpace(0),
120 Child, Label1("Scaled"),
121 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
122 Child, HSpace(0),
123 End,
124 End,
125 Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
126 End,
127 End,
128 End) != NULL)
130 ULONG sigs = 0;
131 LONG id;
133 DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
134 DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
136 set(win,MUIA_Window_Open,TRUE);
138 while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
140 if (id==(LONG)TAG_USER)
142 IPTR appearanceV = 0,
143 labelPosV = 0,
144 borderlessV = 0,
145 sunnyV = 0,
146 raisedV = 0,
147 scaledV = 0;
149 get(appearance,MUIA_Cycle_Active,&appearanceV);
150 get(labelPos,MUIA_Cycle_Active,&labelPosV);
151 get(borderless,MUIA_Selected,&borderlessV);
152 get(sunny,MUIA_Selected,&sunnyV);
153 get(raised,MUIA_Selected,&raisedV);
154 get(scaled,MUIA_Selected,&scaledV);
156 SetAttrs(sb,MUIA_TheBar_ViewMode, appearanceV,
157 MUIA_TheBar_LabelPos, labelPosV,
158 MUIA_TheBar_Borderless, borderlessV,
159 MUIA_TheBar_Sunny, sunnyV,
160 MUIA_TheBar_Raised, raisedV,
161 MUIA_TheBar_Scaled, scaledV,
162 TAG_DONE);
165 if (sigs)
167 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
168 if (sigs & SIGBREAKF_CTRL_C) break;
172 MUI_DisposeObject(app);
174 res = RETURN_OK;
176 else
178 printf("%s: can't create application\n",argv[0]);
179 res = RETURN_FAIL;
182 CLOSELIB(MUIMasterBase, IMUIMaster);
184 else
186 printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
187 res = RETURN_ERROR;
190 CLOSELIB(IntuitionBase, IIntuition);
192 else
194 printf("%s: Can't open intuition.library ver 39 or higher\n",argv[0]);
195 res = RETURN_ERROR;
198 return res;
201 /***********************************************************************/