4 ** Amiga Workbench® Replacement
6 ** (C) Copyright 1999,2000 Aliendesign
7 ** Stefan Sommerfeld, Jörg Rebenstorf
9 ** Redistribution and use in source and binary forms are permitted provided that
10 ** the above copyright notice and this paragraph are duplicated in all such
11 ** forms and that any documentation, advertising materials, and other
12 ** materials related to such distribution and use acknowledge that the
13 ** software was developed by Aliendesign.
14 ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15 ** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16 ** MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 #include <proto/alib.h>
20 #include <proto/utility.h>
21 #include <proto/intuition.h>
22 #include <proto/graphics.h>
23 #include <intuition/classusr.h>
24 #include <graphics/gfx.h>
28 #include "PanelClass.h"
29 #include "SubRoutines.h"
31 #include "scalos_protos.h"
36 /****** Panel.scalos/--background *******************************************
38 * Panel class provides an interface for Lists. It's just a plane where the
39 * list elements can be displayed. Any scrolling and clipping will be
40 * handled by this class.
42 *****************************************************************************
48 static ULONG
Panel_Init(struct SC_Class
*cl
, Object
*obj
, struct opSet
*msg
, struct PanelInst
*inst
)
50 if (SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
))
52 inst
->backbitmap
= (Object
*) GetTagData(SCCA_Panel_Background
, 0,msg
->ops_AttrList
);
61 static ULONG
Panel_Setup(struct SC_Class
*cl
, Object
*obj
, Msg msg
, struct PanelInst
*inst
)
63 if (SC_DoSuperMethodA(cl
,obj
,msg
))
66 if (!(SC_DoMethod(inst
->backbitmap
, SCCM_Graphic_PreThinkScreen
, scRenderInfo(obj
)->screenobj
)))
68 if ((inst
->clipregion
= NewRegion()))
71 inst
->oldleftpos
= 0x8000;
79 static void Panel_Show(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_Show
*msg
, struct PanelInst
*inst
)
81 struct Rectangle rect
;
83 SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
);
85 ClearRegion(inst
->clipregion
);
86 rect
.MinX
= _scleft(obj
);
87 rect
.MinY
= _sctop(obj
);
88 rect
.MaxX
= _scright(obj
);
89 rect
.MaxY
= _scbottom(obj
);
90 OrRectRegion(inst
->clipregion
,&rect
);
92 if (msg
->action
== SCCV_Area_Action_Resize
)
94 if ((_scleft(obj
) == inst
->oldleftpos
) && (_sctop(obj
) == inst
->oldtoppos
))
96 // if ((_scright(obj) > inst->oldright) || (_scbottom(obj) > inst->oldbottom))
98 if ((inst
->refreshregion
= NewRegion()))
100 OrRectRegion(inst
->refreshregion
,&rect
);
101 rect
.MaxX
= inst
->oldright
;
102 rect
.MaxY
= inst
->oldbottom
;
103 ClearRectRegion(inst
->refreshregion
,&rect
);
110 if (inst
->backbitmap
)
111 if (!(SC_DoMethod(inst
->backbitmap
, SCCM_Graphic_PreThinkWindow
, scRenderInfo(obj
)->rport
, msg
->action
)))
113 SC_DoMethod(inst
->backbitmap
, SCCM_Graphic_PostThinkScreen
);
114 SC_DisposeObject(inst
->backbitmap
);
115 inst
->backbitmap
= NULL
;
125 static void Panel_Hide(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_Hide
*msg
, struct PanelInst
*inst
)
127 if (msg
->action
!= SCCV_Area_Action_Resize
)
129 if (inst
->backbitmap
)
130 if (!(SC_DoMethod(inst
->backbitmap
, SCCM_Graphic_PostThinkWindow
, msg
->action
)))
132 SC_DoMethod(inst
->backbitmap
, SCCM_Graphic_PostThinkScreen
);
133 SC_DisposeObject(inst
->backbitmap
);
134 inst
->backbitmap
= NULL
;
137 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
143 static void Panel_Cleanup(struct SC_Class
*cl
, Object
*obj
, Msg msg
, struct PanelInst
*inst
)
146 SC_DoMethod(inst
->backbitmap
, SCCM_Graphic_PostThinkScreen
);
147 DisposeRegion(inst
->clipregion
);
149 SC_DoSuperMethodA(cl
, obj
, msg
);
155 static void Panel_Exit(struct SC_Class
*cl
, Object
*obj
, Msg msg
, struct PanelInst
*inst
)
158 SC_DisposeObject(inst
->backbitmap
);
160 SC_DoSuperMethodA(cl
, obj
, msg
);
166 static void Panel_AskMinMax(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_AskMinMax
*msg
, struct PanelInst
*inst
)
168 SC_DoSuperMethodA(cl
,obj
, (Msg
) msg
);
169 msg
->sizes
->minwidth
+= 1;
170 msg
->sizes
->minheight
+= 1;
171 msg
->sizes
->maxwidth
= SCCV_Area_MaxSize
;
172 msg
->sizes
->maxheight
= SCCV_Area_MaxSize
;
173 msg
->sizes
->defwidth
+= 100;
174 msg
->sizes
->defheight
+= 100;
180 static void Panel_SetIDCMP(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_SetIDCMP
*msg
, struct PanelInst
*inst
)
182 msg
->IDCMP
|= inst
->idcmp
;
183 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
189 static ULONG
Panel_BeginDraw(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_BeginDraw
*msg
, struct PanelInst
*inst
)
191 if (SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
))
193 SC_DoMethod(_scwinobj(obj
),SCCM_Window_SetClipRegion
,inst
->clipregion
);
202 static void Panel_EndDraw(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_EndDraw
*msg
, struct PanelInst
*inst
)
204 SC_DoMethod(_scwinobj(obj
),SCCM_Window_ClearClipRegion
);
206 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
213 static void Panel_Draw(struct SC_Class
*cl
, Object
*obj
, struct SCCP_Area_Draw
*msg
, struct PanelInst
*inst
)
215 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
217 DEBUG3("Old Size %ld,%ld : %ld\n",inst
->oldright
,inst
->oldbottom
,oldright
);
218 DEBUG2("New Size %ld,%ld\n",_scright(obj
),_scbottom(obj
));
220 oldright
= _scright(obj
);
221 if (inst
->refreshregion
)
223 SC_DoMethod(_scwinobj(obj
),SCCM_Window_SetClipRegion
,inst
->refreshregion
);
225 if (inst
->backbitmap
)
226 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
), inst
->left
, inst
->top
,SCCV_Bitmap_Fill_BlitType_Clipped
);
228 EraseRect(_scrport(obj
), _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
));
230 SC_DoMethod(obj
,SCCM_Panel_Redraw
,SCCV_Area_Drawtype_Complete
);
232 SC_DoMethod(_scwinobj(obj
),SCCM_Window_ClearClipRegion
);
234 DisposeRegion(inst
->refreshregion
);
236 inst
->refreshregion
= NULL
;
241 SC_DoMethod(_scwinobj(obj
),SCCM_Window_SetClipRegion
,inst
->clipregion
);
243 if (inst
->backbitmap
)
244 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
), inst
->left
, inst
->top
,SCCV_Bitmap_Fill_BlitType_Clipped
);
246 EraseRect(_scrport(obj
), _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
));
248 SC_DoMethod(obj
,SCCM_Panel_Redraw
,SCCV_Area_Drawtype_Complete
);
250 SC_DoMethod(_scwinobj(obj
),SCCM_Window_ClearClipRegion
);
252 inst
->oldleft
= inst
->left
;
253 inst
->oldtop
= inst
->top
;
255 inst
->oldleftpos
= _scleft(obj
);
256 inst
->oldtoppos
= _sctop(obj
);
257 inst
->oldright
= _scright(obj
);
258 inst
->oldbottom
= _scbottom(obj
);
261 void drawScroll(struct SC_Class
*cl
, Object
*obj
,struct PanelInst
*inst
)
263 if (SC_DoMethod(_scwinobj(obj
), SCCM_Window_BeginDraw
,obj
))
265 if ((inst
->oldleft
!= inst
->left
) || (inst
->oldtop
!= inst
->top
))
267 struct Region
*region
;
268 struct Rectangle rect
;
269 LONG diffx
= inst
->left
- inst
->oldleft
;
270 LONG diffy
= inst
->top
- inst
->oldtop
;
272 if (((_scwidth(obj
)/2) < abs(diffx
)) || ((_scheight(obj
)/2) < abs(diffy
)))
274 if (inst
->backbitmap
)
275 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
), inst
->left
, inst
->top
,SCCV_Bitmap_Fill_BlitType_Clipped
);
277 EraseRect(_scrport(obj
), _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
));
279 SC_DoMethod(obj
,SCCM_Panel_Redraw
,SCCV_Area_Drawtype_Complete
);
283 if ((region
= NewRegion()))
285 rect
.MinX
= _scleft(obj
);
286 rect
.MinY
= _sctop(obj
);
287 rect
.MaxX
= _scright(obj
);
288 rect
.MaxY
= _scbottom(obj
);
289 OrRectRegion(region
, &rect
);
293 rect
.MaxX
-= diffx
+ 1;
294 rect
.MaxY
-= diffy
+ 1;
295 ClearRectRegion(region
, &rect
);
297 ScrollWindowRaster(scRenderInfo(obj
)->window
, diffx
, diffy
,
298 _scleft(obj
), _sctop(obj
), _scright(obj
), _scbottom(obj
));
300 if (inst
->backbitmap
)
303 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scleft(obj
), _sctop(obj
), _scleft(obj
) - diffx
- 1, _scbottom(obj
), inst
->left
, inst
->top
,SCCV_Bitmap_Fill_BlitType_Clipped
);
305 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scright(obj
) - diffx
, _sctop(obj
), _scright(obj
), _scbottom(obj
), inst
->left
+ _scwidth(obj
) - diffx
, inst
->top
, SCCV_Bitmap_Fill_BlitType_Clipped
);
308 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scleft(obj
), _sctop(obj
), _scright(obj
), _sctop(obj
) - diffy
- 1, inst
->left
, inst
->top
,SCCV_Bitmap_Fill_BlitType_Clipped
);
310 DoMethod(inst
->backbitmap
,SCCM_Bitmap_Fill
, _scleft(obj
), _scbottom(obj
) - diffy
, _scright(obj
), _scbottom(obj
), inst
->left
, inst
->top
+ _scheight(obj
) - diffy
, SCCV_Bitmap_Fill_BlitType_Clipped
);
314 SC_DoMethod(_scwinobj(obj
),SCCM_Window_SetClipRegion
,region
);
315 SC_DoMethod(obj
,SCCM_Panel_Redraw
,SCCV_Area_Drawtype_Complete
);
316 SC_DoMethod(_scwinobj(obj
),SCCM_Window_ClearClipRegion
);
317 DisposeRegion(region
);
324 SC_DoMethod(obj
,SCCM_Panel_Redraw
,SCCV_Area_Drawtype_Update
);
328 inst
->oldleft
= inst
->left
;
329 inst
->oldtop
= inst
->top
;
331 inst
->oldleftpos
= _scleft(obj
);
332 inst
->oldtoppos
= _sctop(obj
);
333 inst
->oldright
= _scright(obj
);
334 inst
->oldbottom
= _scbottom(obj
);
336 SC_DoMethod(_scwinobj(obj
), SCCM_Window_EndDraw
,obj
);
342 static void Panel_Set(struct SC_Class
*cl
, Object
*obj
, struct opSet
*msg
, struct PanelInst
*inst
)
344 struct TagItem
*taglist
= msg
->ops_AttrList
;
345 struct TagItem
**tags
= &taglist
;
349 while ((tag
= NextTagItem(tags
)))
353 case SCCA_Panel_Left
:
354 inst
->left
= tag
->ti_Data
;
357 case SCCA_Panel_Top
:
358 inst
->top
= tag
->ti_Data
;
364 drawScroll(cl
,obj
,inst
);
366 SC_DoSuperMethodA(cl
, obj
, (Msg
) msg
);
372 static void Panel_Redraw(struct SC_Class
*cl
, Object
*obj
, Msg msg
, struct PanelInst
*inst
)
379 static ULONG
Panel_Get(struct SC_Class
*cl
, Object
*obj
, struct opGet
*msg
, struct PanelInst
*inst
)
381 if (msg
->opg_AttrID
== SCCA_Panel_Left
)
383 *(msg
->opg_Storage
) = (LONG
) inst
->left
;
386 if (msg
->opg_AttrID
== SCCA_Panel_Top
)
388 *(msg
->opg_Storage
) = (LONG
) inst
->top
;
391 if (msg
->opg_AttrID
== SCCA_Area_StaticContents
)
393 *(msg
->opg_Storage
) = FALSE
;
396 return(SC_DoSuperMethodA(cl
,obj
,(Msg
) msg
));
400 /*-------------------------- MethodList --------------------------------*/
402 struct SC_MethodData PanelMethods
[] =
404 { SCCM_Panel_Redraw
, (ULONG
) Panel_Redraw
, sizeof(ULONG
), 0, NULL
},
405 { SCCM_Init
, (ULONG
) Panel_Init
, 0, 0, NULL
},
406 { SCCM_Exit
, (ULONG
) Panel_Exit
, 0, 0, NULL
},
407 { SCCM_Area_Draw
, (ULONG
) Panel_Draw
, 0, 0, NULL
},
408 { SCCM_Area_BeginDraw
, (ULONG
) Panel_BeginDraw
, 0, 0, NULL
},
409 { SCCM_Area_EndDraw
, (ULONG
) Panel_EndDraw
, 0, 0, NULL
},
410 { SCCM_Area_Setup
, (ULONG
) Panel_Setup
, 0, 0, NULL
},
411 { SCCM_Area_Cleanup
, (ULONG
) Panel_Cleanup
, 0, 0, NULL
},
412 { SCCM_Area_Show
, (ULONG
) Panel_Show
, 0, 0, NULL
},
413 { SCCM_Area_Hide
, (ULONG
) Panel_Hide
, 0, 0, NULL
},
414 { SCCM_Area_AskMinMax
, (ULONG
) Panel_AskMinMax
, 0, 0, NULL
},
415 { SCCM_Area_SetIDCMP
, (ULONG
) Panel_SetIDCMP
, 0, 0, NULL
},
416 { OM_SET
, (ULONG
) Panel_Set
, 0, 0, NULL
},
417 { OM_GET
, (ULONG
) Panel_Get
, 0, 0, NULL
},
418 { SCMETHOD_DONE
, NULL
, 0, 0, NULL
}