2 Copyright © 2014, Thore Böckelmann. All rights reserved.
3 Copyright © 2014, The AROS Development Team. All rights reserved.
7 #include <proto/alib.h>
8 #include <proto/intuition.h>
9 #include <proto/utility.h>
11 #include <libraries/mui.h>
13 #include "Calltips_mcc.h"
14 #include "Calltips_private.h"
19 static void setRectangle(struct IClass
*cl
, Object
*obj
)
21 struct Data
*data
= INST_DATA(cl
, obj
);
22 struct Window
*parentWin
= _window(data
->source
);
23 LONG left
= parentWin
->LeftEdge
+ data
->rectangle
.MinX
- ((data
->marginLeft
== TRUE
) ? _mleft(data
->rootGroup
) : 0);
24 LONG top
= parentWin
->TopEdge
+ data
->rectangle
.MinY
- ((data
->marginLeft
== TRUE
) ? _mtop(data
->rootGroup
) : 0);
25 LONG width
= data
->rectangle
.MaxX
- data
->rectangle
.MinX
+ 1;
26 LONG height
= data
->rectangle
.MaxY
- data
->rectangle
.MinY
+ 1;
28 // setting the position/dimension depends on the window's open state
29 if(XGET(obj
, MUIA_Window_Open
) == TRUE
)
31 struct Window
*thisWin
= _window(data
->rootGroup
);
33 if(left
!= thisWin
->LeftEdge
|| top
!= thisWin
->TopEdge
|| width
!= thisWin
->Width
|| height
!= thisWin
->Height
)
35 ChangeWindowBox(thisWin
, left
, top
, width
, height
);
36 MoveWindowInFrontOf(thisWin
, parentWin
);
41 SetSuperAttrs(cl
, obj
,
42 MUIA_Window_LeftEdge
, left
,
43 MUIA_Window_TopEdge
, top
,
44 MUIA_Window_Width
, width
,
45 MUIA_Window_Height
, height
,
50 /* ------------------------------------------------------------------------- */
52 IPTR
Calltips__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
54 Object
*source
= NULL
;
55 struct Rect32
*rectangle
= NULL
;
56 ULONG layout
= MUIV_Calltips_Layout_Exact
;
57 BOOL marginLeft
= TRUE
;
58 BOOL marginTop
= TRUE
;
59 struct TagItem
*tstate
= msg
->ops_AttrList
;
62 while ((tag
= NextTagItem(&tstate
)) != NULL
)
66 case MUIA_Calltips_Source
:
68 source
= (Object
*)tag
->ti_Data
;
72 case MUIA_Calltips_Rectangle
:
74 rectangle
= (struct Rect32
*)tag
->ti_Data
;
78 case MUIA_Calltips_Layout
:
80 layout
= tag
->ti_Data
;
84 case MUIA_Calltips_MarginLeft
:
86 marginLeft
= tag
->ti_Data
? TRUE
: FALSE
;
90 case MUIA_Calltips_MarginTop
:
92 marginTop
= tag
->ti_Data
? TRUE
: FALSE
;
100 if((obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
101 MUIA_Window_Screen
, _screen(source
),
102 MUIA_Window_Borderless
, TRUE
,
103 MUIA_Window_SizeGadget
, FALSE
,
104 MUIA_Window_DragBar
, FALSE
,
105 MUIA_Window_DepthGadget
, FALSE
,
106 MUIA_Window_CloseGadget
, FALSE
,
107 MUIA_Window_NoMenus
, TRUE
,
108 // MUIA_Window_IsPopup, TRUE,
109 MUIA_Window_Activate
, FALSE
,
110 // MUIA_Window_StayTop, TRUE,
111 TAG_MORE
, msg
->ops_AttrList
)) != NULL
)
113 struct Data
*data
= INST_DATA(cl
, obj
);
115 data
->source
= source
;
116 data
->rootGroup
= (Object
*)XGET(obj
, MUIA_Window_RootObject
);
117 data
->layout
= layout
;
118 data
->marginLeft
= marginLeft
;
119 data
->marginTop
= marginTop
;
120 if(rectangle
!= NULL
)
122 data
->rectangle
= *rectangle
;
126 data
->rectangle
.MinX
= _mleft(source
);
127 data
->rectangle
.MinY
= _mbottom(source
)+1;
128 data
->rectangle
.MaxX
= _mright(source
);
129 data
->rectangle
.MaxY
= _mbottom(source
)+1+100;
132 setRectangle(cl
, obj
);
144 IPTR
Calltips__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
146 IPTR
*store
= msg
->opg_Storage
;
148 switch(msg
->opg_AttrID
)
150 case MUIA_Version
: *store
= VERSION
; return TRUE
;
151 case MUIA_Revision
: *store
= REVISION
; return TRUE
;
154 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
158 IPTR
Calltips__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
160 struct Data
*data
= INST_DATA(cl
, obj
);
161 struct TagItem
*tstate
= msg
->ops_AttrList
;
164 while ((tag
= NextTagItem(&tstate
)) != NULL
)
168 case MUIA_Calltips_Rectangle
:
170 struct Rect32
*rectangle
= (struct Rect32
*)tag
->ti_Data
;
172 if(rectangle
!= NULL
)
174 data
->rectangle
= *rectangle
;
175 setRectangle(cl
, obj
);
180 case MUIA_Calltips_Layout
:
182 data
->layout
= tag
->ti_Data
;
188 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
192 IPTR
Calltips__MUIM_Calltips_SetRectangle(struct IClass
*cl
, Object
*obj
, struct MUIP_Calltips_SetRectangle
*msg
)
194 struct Data
*data
= INST_DATA(cl
, obj
);
196 data
->rectangle
.MinX
= msg
->MinX
;
197 data
->rectangle
.MinY
= msg
->MinY
;
198 data
->rectangle
.MaxX
= msg
->MaxX
;
199 data
->rectangle
.MaxY
= msg
->MaxY
;
200 setRectangle(cl
, obj
);
206 IPTR
Calltips__MUIM_Calltips_ParentSetup( struct IClass
*cl
, Object
*obj
, Msg msg
)
212 IPTR
Calltips__MUIM_Calltips_ParentCleanup(struct IClass
*cl
, Object
*obj
, Msg msg
)
218 IPTR
Calltips__MUIM_Calltips_ParentShow(struct IClass
*cl
, Object
*obj
, Msg msg
)
220 struct Data
*data
= INST_DATA(cl
, obj
);
222 setRectangle(cl
, obj
);
224 // open our window if it was not opened before
225 if(XGET(obj
, MUIA_Window_Open
) == FALSE
)
227 set(obj
, MUIA_Window_Open
, TRUE
);
228 // check again if we opened successfully
229 if(XGET(obj
, MUIA_Window_Open
) == TRUE
)
231 // make sure we are in front of our parent window
232 MoveWindowInFrontOf(_window(data
->rootGroup
), _window(data
->source
));
240 IPTR
Calltips__MUIM_Calltips_ParentHide(struct IClass
*cl
, Object
*obj
, Msg msg
)
242 set(obj
, MUIA_Window_Open
, FALSE
);
248 IPTR
Calltips__MUIM_Calltips_ParentWindowArranged(struct IClass
*cl
, Object
*obj
, Msg msg
)
250 setRectangle(cl
, obj
);