make sure retval is not used uninitialized
[AROS-Contrib.git] / vpdf / mcc / annotation_class.c
bloba824eaf9192498bf8540c6fcdb01349bcec8d09d
2 #include <devices/rawkeycodes.h>
3 #include <proto/alib.h>
4 #include <proto/intuition.h>
5 #include <proto/keymap.h>
6 #include <proto/muimaster.h>
7 #include <private/vapor/vapor.h>
8 #include <proto/utility.h>
10 #if defined(__AROS__)
11 #include <clib/arossupport_protos.h>
12 #endif
14 #include "annotation_class.h"
15 #include "pageview_class.h"
16 #include "util.h"
17 #include "window.h"
19 struct Data
21 struct MUI_EventHandlerNode ehnode;
22 int x, y;
23 char *contents;
24 Object *refobj;
25 int visible;
28 DEFNEW
30 char *contents = GetTagData(MUIA_Annotation_Contents, "", INITTAGS);
32 obj = DoSuperNew(cl, obj,
33 MUIA_Group_Horiz, FALSE,
34 MUIA_Alpha, 50,
35 #if defined(MUIA_Floating)
36 // FIXME: AROS
37 MUIA_Floating, TRUE,
38 #endif
39 MUIA_ShowMe, FALSE,
40 Child, StringObject,
41 MUIA_Frame, MUIV_Frame_String,
42 #if defined(MUIA_Textinput_Multiline)
43 // FIXME: AROS
44 MUIA_Textinput_Multiline, 5,
45 #endif
46 MUIA_String_Contents, contents,
47 End,
48 TAG_MORE, INITTAGS);
50 if (obj != NULL)
52 GETDATA;
54 data->x = GetTagData(MUIA_Annotation_PosX, 0, INITTAGS);
55 data->y = GetTagData(MUIA_Annotation_PosY, 0, INITTAGS);
56 data->refobj = GetTagData(MUIA_Annotation_RefObject, NULL, INITTAGS);
57 data->visible = 0;
58 data->contents = contents;
61 return obj;
64 DEFDISP
66 return DOSUPER;
70 DEFMMETHOD(Layout)
72 GETDATA;
73 int width = xget(_parent(obj), MUIA_Width);
74 int height = xget(_parent(obj), MUIA_Height);
76 int x0, y0;
77 int prvwidth, prvheight;
78 int imgwidth, imgheight;
80 x0 = _mleft(data->refobj);
81 y0 = _mtop(data->refobj);
82 prvwidth = xget(data->refobj, MUIA_PageView_RenderWidth);
83 prvheight = xget(data->refobj, MUIA_PageView_RenderHeight);
85 imgwidth = xget(data->refobj, MUIA_PageView_Width);
86 imgheight = xget(data->refobj, MUIA_PageView_Height);
88 /* calculate placement */
90 if (imgheight < prvheight)
91 y0 += (prvheight - imgheight) / 2;
93 if (imgwidth < prvwidth)
94 x0 += (prvwidth - imgwidth) / 2;
96 #if defined(__AROS__)
97 kprintf("[Annotation::Layout] not implemented\n");
98 // FIXME: AROS
99 #else
100 msg->left = data->x + x0;
101 msg->top = data->y + y0;
103 if (msg->height > 50)
104 msg->height = 50;
106 if (msg->width > 200)
107 msg->width = 200;
108 #endif
110 return DOSUPER;
113 DEFSET
115 GETDATA;
117 FORTAG(INITTAGS)
119 case MUIA_Annotation_PosX:
120 data->x = tag->ti_Data;
121 break;
123 case MUIA_Annotation_PosY:
124 data->y = tag->ti_Data;
125 break;
127 NEXTTAG
129 return DOSUPER;
132 DEFMMETHOD(Annotation_Toggle)
134 GETDATA;
136 data->visible = 1 - data->visible;
137 set(obj, MUIA_ShowMe, data->visible);
139 return TRUE;
142 BEGINMTABLE
143 DECNEW
144 DECDISP
145 DECSET
146 DECMMETHOD(Layout)
147 DECMMETHOD(Annotation_Toggle)
148 ENDMTABLE
150 DECSUBCLASS_NC(MUIC_Group, AnnotationClass)