2 Copyright © 2002-2008, The AROS Development Team.
8 #include <exec/types.h>
9 #include <exec/libraries.h>
10 #include <aros/libcall.h>
11 #include <aros/symbolsets.h>
13 #include <proto/intuition.h>
14 #include <proto/cybergraphics.h>
15 #include <proto/muimaster.h>
16 #include <proto/graphics.h>
17 #include <proto/dos.h>
19 #include LC_LIBDEFS_FILE
21 #include "muimiamipanel_intern.h"
22 #include "muimiamipanel_locale.h"
23 #include "Classes/muimiamipanel_classes.h"
25 #define MiamiPanelBaseIntern LIBBASE
27 /****************************************************************************************/
29 static int InitMiamiPanel(LIBBASETYPEPTR LIBBASE
)
31 D(bug("[MiamiPanel] Init(%x)\n", LIBBASE
));
33 InitSemaphore(&LIBBASE
->mpb_libSem
);
34 InitSemaphore(&LIBBASE
->mpb_memSem
);
35 InitSemaphore(&LIBBASE
->mpb_procSem
);
37 D(bug("[MiamiPanel] Init: Initialised Semaphores ..\n"));
38 D(bug("[MiamiPanel] Init: - lib sem @ %x\n", &LIBBASE
->mpb_libSem
));
39 D(bug("[MiamiPanel] Init: - mem sem @ %x\n", &LIBBASE
->mpb_memSem
));
40 D(bug("[MiamiPanel] Init: - proc sem @ %x\n", &LIBBASE
->mpb_procSem
));
44 /****************************************************************************************/
45 /***********************************************************************/
48 freeMiamiPanelBase(LIBBASETYPEPTR LIBBASE
)
50 D(bug("[MiamiPanel] freeMiamiPanelBase(%x)\n", LIBBASE
));
52 if (LIBBASE
->mpb_timeTextClass
)
54 MUI_DeleteCustomClass(LIBBASE
->mpb_timeTextClass
);
55 LIBBASE
->mpb_timeTextClass
= NULL
;
58 if (LIBBASE
->mpb_rateClass
)
60 MUI_DeleteCustomClass(LIBBASE
->mpb_rateClass
);
61 LIBBASE
->mpb_rateClass
= NULL
;
64 if (LIBBASE
->mpb_trafficClass
)
66 MUI_DeleteCustomClass(LIBBASE
->mpb_trafficClass
);
67 LIBBASE
->mpb_trafficClass
= NULL
;
70 if (LIBBASE
->mpb_lbuttonClass
)
72 MUI_DeleteCustomClass(LIBBASE
->mpb_lbuttonClass
);
73 LIBBASE
->mpb_lbuttonClass
= NULL
;
76 if (LIBBASE
->mpb_ifClass
)
78 MUI_DeleteCustomClass(LIBBASE
->mpb_ifClass
);
79 LIBBASE
->mpb_ifClass
= NULL
;
82 if (LIBBASE
->mpb_ifGroupClass
)
84 MUI_DeleteCustomClass(LIBBASE
->mpb_ifGroupClass
);
85 LIBBASE
->mpb_ifGroupClass
= NULL
;
88 if (LIBBASE
->mpb_mgroupClass
)
90 MUI_DeleteCustomClass(LIBBASE
->mpb_mgroupClass
);
91 LIBBASE
->mpb_mgroupClass
= NULL
;
94 if (LIBBASE
->mpb_aboutClass
)
96 MUI_DeleteCustomClass(LIBBASE
->mpb_aboutClass
);
97 LIBBASE
->mpb_aboutClass
= NULL
;
100 if (LIBBASE
->mpb_prefsClass
)
102 MUI_DeleteCustomClass(LIBBASE
->mpb_prefsClass
);
103 LIBBASE
->mpb_prefsClass
= NULL
;
106 if (LIBBASE
->mpb_appClass
)
108 MUI_DeleteCustomClass(LIBBASE
->mpb_appClass
);
109 LIBBASE
->mpb_appClass
= NULL
;
112 if (LIBBASE
->mpb_pool
)
114 DeletePool(LIBBASE
->mpb_pool
);
115 LIBBASE
->mpb_pool
= NULL
;
118 LIBBASE
->mpb_flags
&= ~BASEFLG_Init
;
122 initMiamiPanelBase(LIBBASETYPEPTR LIBBASE
)
124 D(bug("[MiamiPanel] initMiamiPanelBase(%x)\n", LIBBASE
));
126 if ((LIBBASE
->mpb_pool
= CreatePool(MEMF_ANY
|MEMF_CLEAR
, 256, 64)))
128 D(bug("[MiamiPanel] initMiamiPanelBase: mem pool allocated @ %x\n", LIBBASE
->mpb_pool
));
129 NEWLIST(&LIBBASE
->mpb_msgList
);
130 Locale_Initialize(LIBBASE
);
132 if (MUIPC_App_ClassInit(LIBBASE
)
133 && MUIPC_MGroup_ClassInit(LIBBASE
)
134 && MUIPC_IfGroup_ClassInit(LIBBASE
)
135 && MUIPC_If_ClassInit(LIBBASE
)
136 && MUIPC_LButton_ClassInit(LIBBASE
)
137 && MUIPC_Traffic_ClassInit(LIBBASE
)
138 && MUIPC_Rate_ClassInit(LIBBASE
)
139 && MUIPC_TimeText_ClassInit(LIBBASE
)
142 D(bug("[MiamiPanel] initMiamiPanelBase: Classes Initialised ..\n"));
143 LIBBASE
->mpb_flags
|= BASEFLG_Init
;
149 D(bug("[MiamiPanel] initMiamiPanelBase: Initialisation Failed!\n"));
151 freeMiamiPanelBase(LIBBASE
);
156 static int OpenMiamiPanel(LIBBASETYPEPTR LIBBASE
)
158 D(bug("[MiamiPanel] Open(%x)\n", LIBBASE
));
160 ObtainSemaphore(&LIBBASE
->mpb_libSem
);
162 if (!(LIBBASE
->mpb_flags
& BASEFLG_Init
) && !initMiamiPanelBase(LIBBASE
))
164 ReleaseSemaphore(&LIBBASE
->mpb_libSem
);
168 ReleaseSemaphore(&LIBBASE
->mpb_libSem
);
173 /****************************************************************************************/
175 static int ExpungeMiamiPanel(LIBBASETYPEPTR LIBBASE
)
177 D(bug("[MiamiPanel] Expunge(%x)\n", LIBBASE
));
179 ObtainSemaphore(&LIBBASE
->mpb_libSem
);
181 freeMiamiPanelBase(LIBBASE
);
183 ReleaseSemaphore(&LIBBASE
->mpb_libSem
);
188 ADD2INITLIB(InitMiamiPanel
, 0);
189 ADD2OPENLIB(OpenMiamiPanel
, 0);
190 ADD2EXPUNGELIB(ExpungeMiamiPanel
, 0);