nouveau.hidd: disable warnings about not initialized variables
[AROS.git] / workbench / system / ftmanager / fontwindow_class.c
blob7cd081b124205114c61ae00e89ca7395aef6b27a
1 #include <proto/alib.h>
3 #define NO_INLINE_STDARG
5 #include <aros/debug.h>
6 #include <aros/asmcall.h>
7 #include <libraries/mui.h>
9 #include <proto/muimaster.h>
10 #include <proto/intuition.h>
11 #include <proto/utility.h>
13 #include "fontwindow_class.h"
14 #include "fontinfo_class.h"
15 #include "globals.h"
16 #include "locale.h"
18 struct FontWindowData
20 FT_Face Face;
22 typedef struct FontWindowData FontWindowData;
24 AROS_UFH3(void, CloseWinFunc,
25 AROS_UFHA(struct Hook *, hook, A0),
26 AROS_UFHA(Object *, app, A2),
27 AROS_UFHA(Object **, winp, A1))
29 AROS_USERFUNC_INIT
31 set(*winp, MUIA_Window_Open, FALSE);
32 DoMethod(app, OM_REMMEMBER, *winp);
33 MUI_DisposeObject(*winp);
35 AROS_USERFUNC_EXIT
38 struct Hook CloseWinHook = {{NULL, NULL}, UFHN(CloseWinFunc) };
40 IPTR fwNew(Class *cl, Object *o, struct opSet *msg)
42 struct opSet method;
43 struct TagItem tags[4];
44 STRPTR filename = (STRPTR)GetTagData(MUIA_FontWindow_Filename, (IPTR) NULL, msg->ops_AttrList);
45 FT_Face face;
46 FT_Error error;
47 Object *install, *close, *info, *app;
49 if (filename == NULL)
51 DEBUG_FONTWINDOW(dprintf("FontWindow: no filename.\n"));
52 return 0;
55 error = FT_New_Face(ftlibrary, filename, 0, &face);
56 if (error)
58 DEBUG_FONTWINDOW(dprintf("FontWindow: New_Face error %d.\n", error));
59 return 0;
62 app = (Object *)GetTagData(MUIA_UserData, 0,
63 msg->ops_AttrList);
64 if (NULL == app)
66 DEBUG_FONTWINDOW(dprintf("FontWindow: no app ptr.\n"));
67 return 0;
70 tags[0].ti_Tag = MUIA_Window_ID;
71 tags[0].ti_Data = MAKE_ID('F','O','N','T');
72 tags[1].ti_Tag = MUIA_Window_Title;
73 tags[1].ti_Data = (IPTR)filename;
74 tags[2].ti_Tag = MUIA_Window_RootObject;
75 tags[2].ti_Data = (IPTR)VGroup,
76 Child, info = FontInfoObject,
77 MUIA_FontInfo_Filename, filename,
78 MUIA_FontInfo_Face, face,
79 End,
80 Child, HGroup,
81 Child, install = SimpleButton(_(MSG_BUTTON_INSTALL)),
82 Child, RectangleObject,
83 End,
84 Child, close = SimpleButton(_(MSG_BUTTON_CLOSE)),
85 End,
86 End;
87 tags[3].ti_Tag = TAG_MORE;
88 tags[3].ti_Data = (IPTR)msg->ops_AttrList;
90 method.MethodID = OM_NEW;
91 method.ops_AttrList = tags;
92 method.ops_GInfo = NULL;
94 o = (Object *)DoSuperMethodA(cl, o, (Msg)&method);
95 if (o)
97 FontWindowData *dat = INST_DATA(cl, o);
98 dat->Face = face;
100 DoMethod(install, MUIM_Notify, MUIA_Pressed, FALSE,
101 info, 1, MUIM_FontInfo_WriteFiles);
102 DoMethod(close, MUIM_Notify, MUIA_Pressed, FALSE,
103 app, 6, MUIM_Application_PushMethod, app, 3,
104 MUIM_CallHook, &CloseWinHook, o);
107 else
109 FT_Done_Face(face);
112 DEBUG_FONTWINDOW(dprintf("FontWindow: created object 0x%lx.\n", o));
114 return (IPTR)o;
117 IPTR fwDispose(Class *cl, Object *o)
119 FontWindowData *dat = INST_DATA(cl, o);
121 DEBUG_FONTWINDOW(dprintf("FontWindow: destroy object 0x%lx\n", o));
123 FT_Done_Face(dat->Face);
125 return DoSuperMethod(cl, o, OM_DISPOSE);
128 AROS_UFH3(ULONG, FontWindowDispatch,
129 AROS_UFHA(Class *, cl, A0),
130 AROS_UFHA(Object *, o, A2),
131 AROS_UFHA(Msg, msg, A1))
133 AROS_USERFUNC_INIT
135 ULONG ret;
137 switch (msg->MethodID)
139 case OM_NEW:
140 ret = fwNew(cl, o, (struct opSet *)msg);
141 break;
143 case OM_DISPOSE:
144 ret = fwDispose(cl, o);
145 break;
147 default:
148 ret = DoSuperMethodA(cl, o, msg);
149 break;
152 return ret;
154 AROS_USERFUNC_EXIT
158 void CleanupFontWindowClass(void)
160 if (FontWindowClass)
162 MUI_DeleteCustomClass(FontWindowClass);
163 FontWindowClass = NULL;
167 int InitFontWindowClass(void)
169 FontWindowClass = MUI_CreateCustomClass(NULL, MUIC_Window, NULL,
170 sizeof(FontWindowData), UFHN(FontWindowDispatch));
171 return FontWindowClass != NULL;