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"
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
))
31 set(*winp
, MUIA_Window_Open
, FALSE
);
32 DoMethod(app
, OM_REMMEMBER
, *winp
);
33 MUI_DisposeObject(*winp
);
38 struct Hook CloseWinHook
= {{NULL
, NULL
}, UFHN(CloseWinFunc
) };
40 IPTR
fwNew(Class
*cl
, Object
*o
, struct opSet
*msg
)
43 struct TagItem tags
[4];
44 STRPTR filename
= (STRPTR
)GetTagData(MUIA_FontWindow_Filename
, (IPTR
) NULL
, msg
->ops_AttrList
);
47 Object
*install
, *close
, *info
, *app
;
51 DEBUG_FONTWINDOW(dprintf("FontWindow: no filename.\n"));
55 error
= FT_New_Face(ftlibrary
, filename
, 0, &face
);
58 DEBUG_FONTWINDOW(dprintf("FontWindow: New_Face error %d.\n", error
));
62 app
= (Object
*)GetTagData(MUIA_UserData
, 0,
66 DEBUG_FONTWINDOW(dprintf("FontWindow: no app ptr.\n"));
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
,
81 Child
, install
= SimpleButton(_(MSG_BUTTON_INSTALL
)),
82 Child
, RectangleObject
,
84 Child
, close
= SimpleButton(_(MSG_BUTTON_CLOSE
)),
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
);
97 FontWindowData
*dat
= INST_DATA(cl
, o
);
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
);
112 DEBUG_FONTWINDOW(dprintf("FontWindow: created object 0x%lx.\n", 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
))
137 switch (msg
->MethodID
)
140 ret
= fwNew(cl
, o
, (struct opSet
*)msg
);
144 ret
= fwDispose(cl
, o
);
148 ret
= DoSuperMethodA(cl
, o
, msg
);
158 void CleanupFontWindowClass(void)
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
;