2 ** Amiga Workbench® Replacement
4 ** (C) Copyright 1999,2000 Aliendesign
5 ** Stefan Sommerfeld, Jörg Rebenstorf
7 ** Redistribution and use in source and binary forms are permitted provided that
8 ** the above copyright notice and this paragraph are duplicated in all such
9 ** forms and that any documentation, advertising materials, and other
10 ** materials related to such distribution and use acknowledge that the
11 ** software was developed by Aliendesign.
12 ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
13 ** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
14 ** MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 #include <proto/alib.h>
18 #include <proto/utility.h>
19 #include <proto/intuition.h>
20 #include <proto/graphics.h>
21 #include <intuition/classusr.h>
22 #include <intuition/gadgetclass.h>
23 #include <graphics/gfx.h>
26 #include "PanelViewClass.h"
27 #include "SubRoutines.h"
28 #include "WindowClass.h"
30 #include "scalos_protos.h"
33 /****** PanelView.scalos/--background ***************************************
35 * PanelView class is the group class for panel objects.
36 * It handles the input events from intuition and calls the apropriate
37 * methods of the assigned panel object.
39 *****************************************************************************
45 static ULONG
PanelView_Init(struct SC_Class
*cl
, Object
*obj
, struct opSet
*msg
, struct PanelViewInst
*inst
)
47 if (SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
))
49 if (!(inst
->panel
= (Object
*) GetTagData(SCCA_PanelView_Panel
,0,msg
->ops_AttrList
)))
51 SC_DoClassMethod(cl
,NULL
,(ULONG
) obj
,SCCM_Exit
);
54 SC_DoSuperMethod(cl
,obj
,OM_ADDMEMBER
,inst
->panel
);
56 SC_DoMethod(inst
->panel
,SCCM_Notify
,SCCA_Panel_MinX
,SCCV_EveryTime
,obj
,
57 3,SCCM_Set
,SCCA_PanelView_MinX
,SCCV_TriggerValue
);
58 SC_DoMethod(inst
->panel
,SCCM_Notify
,SCCA_Panel_MinY
,SCCV_EveryTime
,obj
,
59 3,SCCM_Set
,SCCA_PanelView_MinY
,SCCV_TriggerValue
);
60 SC_DoMethod(inst
->panel
,SCCM_Notify
,SCCA_Panel_MaxX
,SCCV_EveryTime
,obj
,
61 3,SCCM_Set
,SCCA_PanelView_MaxX
,SCCV_TriggerValue
);
62 SC_DoMethod(inst
->panel
,SCCM_Notify
,SCCA_Panel_MaxY
,SCCV_EveryTime
,obj
,
63 3,SCCM_Set
,SCCA_PanelView_MaxY
,SCCV_TriggerValue
);
65 SC_DoMethod(inst
->panel
,SCCM_Notify
,SCCA_Panel_Left
,SCCV_EveryTime
,obj
,
66 3,SCCM_Set
,SCCA_PanelView_Left
,SCCV_TriggerValue
);
67 SC_DoMethod(inst
->panel
,SCCM_Notify
,SCCA_Panel_Top
,SCCV_EveryTime
,obj
,
68 3,SCCM_Set
,SCCA_PanelView_Top
,SCCV_TriggerValue
);
77 static ULONG
PanelView_Setup(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_Setup
*msg
, struct PanelViewInst
*inst
)
79 if (SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
))
81 SC_SetAttrs(_scwinobj(obj
),SCCA_Window_SliderRight
,TRUE
,SCCA_Window_SliderBottom
,TRUE
,TAG_DONE
);
82 inst
->idcmp
= IDCMP_GADGETUP
| IDCMP_GADGETDOWN
;
83 SC_DoMethod(obj
,SCCM_Area_SetIDCMP
,0);
84 SC_DoMethod(_scwinobj(obj
),SCCM_Window_DelayedShowObject
,obj
);
93 static void PanelView_Show(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_Show
*msg
, struct PanelViewInst
*inst
)
95 SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
);
96 inst
->sliderright
= (struct Gadget
*) get(_scwinobj(obj
),SCCA_Window_SliderRight
);
97 inst
->sliderbottom
= (struct Gadget
*) get(_scwinobj(obj
),SCCA_Window_SliderBottom
);
103 static void PanelView_DelayedShow(struct SC_Class
*cl
, Object
*obj
, Msg msg
, struct PanelViewInst
*inst
)
105 SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
);
106 SetGadgetAttrs(inst
->sliderbottom
,_scwindow(obj
),NULL
,PGA_Total
,inst
->maxx
- inst
->minx
+ 1,
107 PGA_Visible
,get(inst
->panel
,SCCA_Area_InnerWidth
),PGA_Top
,inst
->left
- inst
->minx
,
109 SetGadgetAttrs(inst
->sliderright
,_scwindow(obj
),NULL
,PGA_Total
,inst
->maxy
- inst
->miny
+ 1,
110 PGA_Visible
,get(inst
->panel
,SCCA_Area_InnerHeight
),PGA_Top
,inst
->top
- inst
->miny
,
117 static void PanelView_Hide(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_Hide
*msg
, struct PanelViewInst
*inst
)
119 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
125 static void PanelView_Set(struct SC_Class
*cl
, Object
*obj
, struct opSet
*msg
, struct PanelViewInst
*inst
)
127 struct TagItem
*taglist
= msg
->ops_AttrList
;
128 struct TagItem
**tags
= &taglist
;
133 while ((tag
= NextTagItem(tags
)))
137 case SCCA_PanelView_MinX
:
138 inst
->minx
= tag
->ti_Data
;
141 case SCCA_PanelView_MaxX
:
142 inst
->maxx
= tag
->ti_Data
;
143 DEBUG1("New MaxX: %ld\n",inst
->maxx
);
146 case SCCA_PanelView_Left
:
147 inst
->left
= tag
->ti_Data
;
151 case SCCA_PanelView_MinY
:
152 inst
->miny
= tag
->ti_Data
;
155 case SCCA_PanelView_MaxY
:
156 inst
->maxy
= tag
->ti_Data
;
159 case SCCA_PanelView_Top
:
160 inst
->left
= tag
->ti_Data
;
166 if (inst
->minx
> inst
->left
)
168 inst
->left
= inst
->minx
;
169 SC_SetAttrs(inst
->panel
,SCCA_Panel_Left
,inst
->left
,TAG_DONE
);
171 if (inst
->miny
> inst
->top
)
173 inst
->top
= inst
->miny
;
174 SC_SetAttrs(inst
->panel
,SCCA_Panel_Top
,inst
->top
,TAG_DONE
);
178 if (newx
&& inst
->sliderbottom
)
179 SetGadgetAttrs(inst
->sliderbottom
,_scwindow(obj
),NULL
,PGA_Total
,inst
->maxx
- inst
->minx
+ 1,
180 PGA_Visible
,get(inst
->panel
,SCCA_Area_InnerWidth
),PGA_Top
,inst
->left
- inst
->minx
,
182 if (newy
&& inst
->sliderright
)
183 SetGadgetAttrs(inst
->sliderright
,_scwindow(obj
),NULL
,PGA_Total
,inst
->maxy
- inst
->miny
+ 1,
184 PGA_Visible
,get(inst
->panel
,SCCA_Area_InnerHeight
),PGA_Top
,inst
->top
- inst
->miny
,
187 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
193 static void PanelView_SetIDCMP(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_SetIDCMP
*msg
, struct PanelViewInst
*inst
)
195 msg
->IDCMP
|= inst
->idcmp
;
196 SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
);
202 static ULONG
PanelView_Get(struct SC_Class
*cl
, Object
*obj
, struct opGet
*msg
, struct PanelViewInst
*inst
)
204 if (msg
->opg_AttrID
== SCCA_PanelView_Left
)
206 *(msg
->opg_Storage
) = (ULONG
) inst
->left
;
209 if (msg
->opg_AttrID
== SCCA_PanelView_Top
)
211 *(msg
->opg_Storage
) = (ULONG
) inst
->top
;
214 return(SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
));
220 static void PanelView_HandleInput(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_HandleInput
*msg
, struct PanelViewInst
*inst
)
222 ULONG gadid
= ((struct Gadget
*) msg
->imsg
->IAddress
)->GadgetID
;
224 SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
);
226 switch (msg
->imsg
->Class
)
228 case IDCMP_MOUSEMOVE
:
229 switch (inst
->movegadid
)
231 case SLIDERGADID_BOTTOM
:
232 inst
->left
= get((Object
*) inst
->sliderbottom
,PGA_Top
) + inst
->minx
;
233 SC_SetAttrs(inst
->panel
,SCCA_Panel_Left
,inst
->left
,TAG_DONE
);
235 case SLIDERGADID_RIGHT
:
236 inst
->top
= get((Object
*) inst
->sliderright
,PGA_Top
) + inst
->miny
;
237 SC_SetAttrs(inst
->panel
,SCCA_Panel_Top
,inst
->top
,TAG_DONE
);
241 case IDCMP_GADGETDOWN
:
242 if ((gadid
== SLIDERGADID_BOTTOM
) || (gadid
== SLIDERGADID_RIGHT
))
244 inst
->movegadid
= gadid
;
245 inst
->idcmp
|= IDCMP_MOUSEMOVE
;
246 SC_DoMethod(obj
,SCCM_Area_SetIDCMP
,0);
250 case IDCMP_GADGETUP
:
251 if ((gadid
== SLIDERGADID_BOTTOM
) || (gadid
== SLIDERGADID_RIGHT
))
253 switch (inst
->movegadid
)
255 case SLIDERGADID_BOTTOM
:
256 inst
->left
= get((Object
*) inst
->sliderbottom
,PGA_Top
) + inst
->minx
;
257 SC_SetAttrs(inst
->panel
,SCCA_Panel_Left
,inst
->left
,TAG_DONE
);
259 case SLIDERGADID_RIGHT
:
260 inst
->top
= get((Object
*) inst
->sliderright
,PGA_Top
) + inst
->miny
;
261 SC_SetAttrs(inst
->panel
,SCCA_Panel_Top
,inst
->top
,TAG_DONE
);
265 inst
->idcmp
&= ~IDCMP_MOUSEMOVE
;
266 SC_DoMethod(obj
,SCCM_Area_SetIDCMP
,0);
274 /*-------------------------- MethodList --------------------------------*/
276 struct SC_MethodData PanelViewMethods
[] =
278 { SCCM_Init
,(ULONG
) PanelView_Init
, 0, 0, NULL
},
279 { SCCM_Area_Setup
,(ULONG
) PanelView_Setup
, 0, 0, NULL
},
280 { SCCM_Area_Show
,(ULONG
) PanelView_Show
, 0, 0, NULL
},
281 { SCCM_Area_Hide
, (ULONG
) PanelView_Hide
, 0, 0, NULL
},
282 { OM_SET
, (ULONG
) PanelView_Set
, 0, 0, NULL
},
283 { OM_GET
, (ULONG
) PanelView_Get
, 0, 0, NULL
},
284 { SCCM_Area_SetIDCMP
,(ULONG
) PanelView_SetIDCMP
, 0, 0, NULL
},
285 { SCCM_Area_HandleInput
,(ULONG
) PanelView_HandleInput
, 0, 0, NULL
},
286 { SCCM_Area_DelayedShow
,(ULONG
) PanelView_DelayedShow
, 0, 0, NULL
},
287 { SCMETHOD_DONE
, NULL
, 0, 0, NULL
}