2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
6 #include <proto/alib.h>
7 #include <proto/exec.h>
8 #include <proto/graphics.h>
9 #include <proto/intuition.h>
10 #include <proto/utility.h>
12 #include <intuition/cghooks.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/gadgetclass.h>
16 #include <intuition/intuition.h>
17 #include <intuition/imageclass.h>
22 #include "partitions.h"
23 #include "partitiontables.h"
29 #define G(a) ((struct Gadget *)a)
31 #define DPTYPE_EMPTY 0
32 #define DPTYPE_EMPTY_SELECTED 1
34 #define DPTYPE_USED_SELECTED 3
36 #define PARTITIONBLOCK_FRAMEWIDTH 2
40 #define EMPTY1_RED 0x99999999
41 #define EMPTY1_GREEN 0x99999999
42 #define EMPTY1_BLUE 0x99999999
44 #define EMPTY2_RED 0x65656565
45 #define EMPTY2_GREEN 0x65656565
46 #define EMPTY2_BLUE 0x65656565
48 #define EMPTY1_DARK_RED 0x66666666
49 #define EMPTY1_DARK_GREEN 0x66666666
50 #define EMPTY1_DARK_BLUE 0x66666666
52 #define EMPTY2_DARK_RED 0x42424242
53 #define EMPTY2_DARK_GREEN 0x42424242
54 #define EMPTY2_DARK_BLUE 0x42424242
56 #define EMPTY1_SEL_RED 0x40404040
57 #define EMPTY1_SEL_GREEN 0x85858585
58 #define EMPTY1_SEL_BLUE 0x99999999
60 #define EMPTY2_SEL_RED 0x29292929
61 #define EMPTY2_SEL_GREEN 0x56565656
62 #define EMPTY2_SEL_BLUE 0x63636363
64 #define USED_RED 0x02020202
65 #define USED_GREEN 0x75757575
66 #define USED_BLUE 0x02020202
68 #define USED_SEL_RED 0x66666666
69 #define USED_SEL_GREEN 0xc9c9c9c9
70 #define USED_SEL_BLUE 0x66666666
74 #define PEN_EMPTY1_SEL 2
75 #define PEN_EMPTY2_SEL 3
76 #define PEN_EMPTY1_DARK 4
77 #define PEN_EMPTY2_DARK 5
79 #define PEN_USED_SEL 7
83 STATIC CONST ULONG rgbtable
[] =
85 EMPTY1_RED
, EMPTY1_GREEN
, EMPTY1_BLUE
,
86 EMPTY2_RED
, EMPTY2_GREEN
, EMPTY2_BLUE
,
87 EMPTY1_SEL_RED
, EMPTY1_SEL_GREEN
, EMPTY1_SEL_BLUE
,
88 EMPTY2_SEL_RED
, EMPTY2_SEL_GREEN
, EMPTY2_SEL_BLUE
,
89 EMPTY1_DARK_RED
, EMPTY1_DARK_GREEN
, EMPTY1_DARK_BLUE
,
90 EMPTY2_DARK_RED
, EMPTY2_DARK_GREEN
, EMPTY2_DARK_BLUE
,
91 USED_RED
, USED_GREEN
, USED_BLUE
,
92 USED_SEL_RED
, USED_SEL_GREEN
, USED_SEL_BLUE
98 struct HDTBPartition
*table
;
99 struct HDTBPartition
*active
; /* active partition, or the DE for free space */
112 STATIC CONST UWORD pattern
[] =
118 STATIC CONST UWORD pattern2
[] =
138 #define SetPattern(r,p,s) {r->AreaPtrn = (UWORD *)p; r->AreaPtSz = s;}
142 static void PrepareRP(struct RastPort
*rp
, struct PTableData
*data
, WORD dptype
)
144 D(bug("[HDToolBox] PrepareRP()\n"));
146 if (data
->multicolor
)
151 SetPattern(rp
, pattern2
, 4);
152 SetABPenDrMd(rp
, data
->pens
[PEN_EMPTY1
], data
->pens
[PEN_EMPTY2
], JAM2
);
155 case DPTYPE_EMPTY_SELECTED
:
156 SetPattern(rp
, pattern2
, 4);
157 SetABPenDrMd(rp
, data
->pens
[PEN_EMPTY1_SEL
], data
->pens
[PEN_EMPTY2_SEL
], JAM2
);
161 SetPattern(rp
, NULL
, 0);
162 SetABPenDrMd(rp
, data
->pens
[PEN_USED
], 0, JAM2
);
165 case DPTYPE_USED_SELECTED
:
166 SetPattern(rp
, NULL
, 0);
167 SetABPenDrMd(rp
, data
->pens
[PEN_USED_SEL
], 0, JAM2
);
170 } /* if (data->multicolor) */
176 SetPattern(rp
, NULL
, 0);
177 SetABPenDrMd(rp
, 0, 0, JAM2
);
180 case DPTYPE_EMPTY_SELECTED
:
181 SetPattern(rp
, pattern
, 2);
182 SetABPenDrMd(rp
, 1, 0, JAM2
);
186 SetPattern(rp
, pattern
, 2);
187 SetABPenDrMd(rp
, 2, 0, JAM2
);
190 case DPTYPE_USED_SELECTED
:
191 SetPattern(rp
, pattern
, 2);
192 SetABPenDrMd(rp
, 3, 0, JAM2
);
195 } /* if (data->multicolor) */
198 STATIC IPTR
pt_new(Class
*cl
, Object
*obj
, struct opSet
*msg
)
200 struct PTableData
*data
;
201 struct DrawInfo
*dri
;
203 struct HDTBPartition
*table
;
206 struct TagItem tags
[] =
210 {IA_Resolution
, 0UL },
211 {IA_FrameType
, FRAME_BUTTON
},
215 D(bug("[HDToolBox] pt_new()\n"));
217 dri
= (struct DrawInfo
*)GetTagData(GA_DrawInfo
, (IPTR
)NULL
, msg
->ops_AttrList
);
221 tags
[0].ti_Data
= GetTagData(GA_Width
, 0, msg
->ops_AttrList
);
222 tags
[1].ti_Data
= GetTagData(GA_Height
, 0, msg
->ops_AttrList
);
223 table
= (struct HDTBPartition
*)GetTagData(PTCT_PartitionTable
, 0, msg
->ops_AttrList
);
224 flags
= GetTagData(PTCT_Flags
, 0, msg
->ops_AttrList
);
225 tags
[2].ti_Data
= (dri
->dri_Resolution
.X
<< 16) + dri
->dri_Resolution
.Y
;
227 frame
= (struct Image
*) NewObjectA(NULL
, FRAMEICLASS
, tags
);
231 tags
[0].ti_Tag
= GA_Image
;
232 tags
[0].ti_Data
= (IPTR
) frame
;
233 tags
[1].ti_Tag
= TAG_MORE
;
234 tags
[1].ti_Data
= (IPTR
) msg
->ops_AttrList
;
235 obj
= (Object
*) DoSuperMethodA(cl
, obj
, (Msg
)msg
);
238 DisposeObject(frame
);
242 data
= INST_DATA(cl
, obj
);
250 data
->selected
= FALSE
;
251 data
->firstdraw
= TRUE
;
256 STATIC IPTR
pt_set(Class
*cl
, Object
*obj
, struct opSet
*msg
)
258 struct PTableData
*data
= INST_DATA(cl
, obj
);
261 struct TagItem
*taglist
;
262 struct RastPort
*rport
;
264 D(bug("[HDToolBox] pt_set()\n"));
266 if (msg
->MethodID
!= OM_NEW
)
267 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
269 taglist
= (struct TagItem
*)msg
->ops_AttrList
;
270 while ((tag
= NextTagItem(&taglist
)))
278 if (msg
->MethodID
== OM_NEW
)
279 data
->dri
= (struct DrawInfo
*)tag
->ti_Data
;
281 case PTCT_PartitionTable
:
282 data
->table
= (struct HDTBPartition
*)tag
->ti_Data
;
285 case PTCT_ActivePartition
:
286 data
->active
= (struct HDTBPartition
*)tag
->ti_Data
;
292 /* redraw if one attribute has changed something */
293 if ((retval
) && (OCLASS(obj
) == cl
))
295 rport
= ObtainGIRPort(msg
->ops_GInfo
);
298 DoMethod(obj
, GM_RENDER
, (IPTR
) msg
->ops_GInfo
, (IPTR
) rport
, GREDRAW_UPDATE
);
299 ReleaseGIRPort(rport
);
306 STATIC IPTR
pt_get(Class
*cl
, Object
*obj
, struct opGet
*msg
)
308 struct PTableData
*data
= INST_DATA(cl
, obj
);
311 D(bug("[HDToolBox] pt_get()\n"));
313 switch (msg
->opg_AttrID
)
315 case PTCT_PartitionTable
:
316 *msg
->opg_Storage
= (IPTR
)data
->table
;
319 case PTCT_ActivePartition
:
320 *msg
->opg_Storage
= (IPTR
)data
->active
;
323 case PTCT_ActiveType
:
324 if ((struct DosEnvec
*)data
->active
== &data
->gap
)
325 *msg
->opg_Storage
= (IPTR
)PTS_EMPTY_AREA
;
326 else if (data
->active
== NULL
)
327 *msg
->opg_Storage
= (IPTR
)PTS_NOTHING
;
329 *msg
->opg_Storage
= (IPTR
)PTS_PARTITION
;
337 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
342 struct DosEnvec
*findSpace(struct HDTBPartition
*table
, struct DosEnvec
*de
, ULONG block
)
344 struct HDTBPartition
*pn
;
347 ULONG last
= 0xFFFFFFFF;
349 D(bug("[HDToolBox] findSpace()\n"));
352 CopyMem(&table
->de
, de
, sizeof(struct DosEnvec
));
353 de
->de_SizeBlock
= table
->dg
.dg_SectorSize
>>2;
354 de
->de_Surfaces
= table
->dg
.dg_Heads
;
355 de
->de_BlocksPerTrack
= table
->dg
.dg_TrackSectors
;
356 de
->de_BufMemType
= table
->dg
.dg_BufMemType
;
358 pn
= (struct HDTBPartition
*)table
->listnode
.list
.lh_Head
;
359 while (pn
->listnode
.ln
.ln_Succ
!= NULL
)
364 if (pn
->listnode
.ln
.ln_Type
!= LNT_Parent
)
366 spc
= pn
->de
.de_Surfaces
*pn
->de
.de_BlocksPerTrack
;
367 start
= pn
->de
.de_LowCyl
*spc
;
368 end
= ((pn
->de
.de_HighCyl
+1)*spc
)-1;
380 pn
= (struct HDTBPartition
*)pn
->listnode
.ln
.ln_Succ
;
383 spc
= table
->dg
.dg_Heads
*table
->dg
.dg_TrackSectors
;
385 first
= table
->table
->reserved
;
387 first
= (first
- 1) / spc
+ 1;
389 last
= ((last
+1)/spc
)-1;
390 if (last
>=table
->dg
.dg_Cylinders
)
391 last
=table
->dg
.dg_Cylinders
-1;
393 de
->de_LowCyl
= first
;
394 de
->de_HighCyl
= last
;
400 * Find the partition containing the currently selected block, or the DE
401 * describing the empty space.
403 struct HDTBPartition
*getActive(struct PTableData
*data
)
405 struct HDTBPartition
*pn
;
407 D(bug("[HDToolBox] getActive()\n"));
409 pn
= (struct HDTBPartition
*)data
->table
->listnode
.list
.lh_Head
;
410 while (pn
->listnode
.ln
.ln_Succ
!= NULL
)
415 if (pn
->listnode
.ln
.ln_Type
!= LNT_Parent
)
417 start
= pn
->de
.de_LowCyl
*pn
->de
.de_Surfaces
*pn
->de
.de_BlocksPerTrack
;
418 end
= (pn
->de
.de_HighCyl
+1)*pn
->de
.de_Surfaces
*pn
->de
.de_BlocksPerTrack
;
419 if ((data
->block
>=start
) && (data
->block
<end
))
422 pn
= (struct HDTBPartition
*)pn
->listnode
.ln
.ln_Succ
;
424 return (struct HDTBPartition
*)findSpace(data
->table
,&data
->gap
,data
->block
);
427 void DrawBox(struct RastPort
*rport
, struct DrawInfo
*dri
,
428 UWORD sx
, UWORD sy
, UWORD ex
, UWORD ey
, BOOL recessed
)
430 D(bug("[HDToolBox] DrawBox(rport @ %p, dri @ %p, %d,%dx%d,%d)\n", rport
, dri
, sx
, sy
, ex
, ey
));
432 SetAPen(rport
, dri
->dri_Pens
[recessed
? SHINEPEN
: SHADOWPEN
]);
436 SetAPen(rport
, dri
->dri_Pens
[recessed
? SHADOWPEN
: SHINEPEN
]);
441 void DrawFilledBox(struct RastPort
*rport
, struct DrawInfo
*dri
,
442 UWORD sx
, UWORD sy
, UWORD ex
, UWORD ey
)
444 D(bug("[HDToolBox] DrawFilledBox()\n"));
446 RectFill(rport
, sx
+1, sy
+1, ex
-1, ey
-1);
447 DrawBox(rport
, dri
, sx
, sy
, ex
, ey
, FALSE
);
450 void DrawPartition(struct RastPort
*rport
, struct PTableData
*data
,
451 struct Gadget
*gadget
, struct HDTBPartition
*table
, struct DosEnvec
*pn
, WORD drawtype
)
460 D(bug("[HDToolBox] DrawPartition()\n"));
466 (table
->table
->de_HighCyl
+1)*
467 table
->table
->de_Surfaces
*
468 table
->table
->de_BlocksPerTrack
;
470 blocks
= table
->dg
.dg_Heads
*table
->dg
.dg_TrackSectors
;
471 skipcyl
= table
->table
->reserved
/blocks
;
472 cyls
= (table
->dg
.dg_Cylinders
-1)-skipcyl
;
475 spc
= pn
->de_Surfaces
*pn
->de_BlocksPerTrack
;
477 start
= pn
->de_LowCyl
*spc
*gadget
->Width
/blocks
;
478 end
= (((pn
->de_HighCyl
+1)*spc
)-1)*gadget
->Width
/blocks
;
480 start
= pn
->de_LowCyl
;
481 end
= pn
->de_HighCyl
;
483 (pn
->de_Surfaces
!=table
->dg
.dg_Heads
) ||
484 (pn
->de_BlocksPerTrack
!=table
->dg
.dg_TrackSectors
)
487 start
= start
*spc
/blocks
;
488 end
= end
*spc
/blocks
;
494 start
= (start
*(gadget
->Width
- PARTITIONBLOCK_FRAMEWIDTH
)/cyls
)+1;
496 end
= ((end
+ 1) *(gadget
->Width
- PARTITIONBLOCK_FRAMEWIDTH
)/cyls
) + 1 - 1;
498 end
= (end
*(gadget
->Width
- PARTITIONBLOCK_FRAMEWIDTH
)/cyls
);
500 start
+= gadget
->LeftEdge
;
501 end
+= gadget
->LeftEdge
;
504 PrepareRP(rport
, data
, drawtype
);
506 if (drawtype
== DPTYPE_EMPTY
)
508 RectFill(rport
, start
, gadget
->TopEdge
+1+(gadget
->Height
/2),
509 end
, gadget
->TopEdge
+(gadget
->Height
)-2);
517 start
, gadget
->TopEdge
+1+(gadget
->Height
/2),
518 end
, gadget
->TopEdge
+(gadget
->Height
)-2
522 SetPattern(rport
, NULL
, 0);
525 ULONG
getBlock(UWORD mousex
, UWORD width
, struct HDTBPartition
*table
)
529 if ((WORD
)mousex
< 0) mousex
= 0;
531 block
= mousex
*(table
->dg
.dg_Cylinders
-1)/width
;
532 block
*= table
->dg
.dg_Heads
*table
->dg
.dg_TrackSectors
;
533 block
+= table
->table
->reserved
;
537 STATIC VOID
notify_all(Class
*cl
, Object
*obj
, struct GadgetInfo
*gi
, BOOL interim
, BOOL userinput
)
539 struct PTableData
*data
= INST_DATA(cl
, obj
);
542 struct TagItem tags
[] =
544 {GA_ID
, G(obj
)->GadgetID
},
546 {GA_UserInput
, userinput
},
548 {PTCT_ActivePartition
,(IPTR
)data
->active
},
549 {PTCT_PartitionTable
, (IPTR
)data
->table
},
550 {PTCT_PartitionMove
, (IPTR
)data
->move
},
551 {PTCT_Selected
, (IPTR
)data
->selected
},
555 D(bug("[HDToolBox] notify_all()\n"));
557 opu
.MethodID
= OM_NOTIFY
;
558 opu
.opu_AttrList
= tags
;
560 opu
.opu_Flags
= interim
? OPUF_INTERIM
: 0;
561 DoMethodA(obj
, (Msg
)&opu
);
564 STATIC IPTR
pt_goactive(Class
*cl
, Object
*obj
, struct gpInput
*msg
)
566 struct PTableData
*data
= INST_DATA(cl
, obj
);
567 IPTR retval
= GMR_MEACTIVE
;
569 struct RastPort
*rport
;
572 D(bug("[HDToolBox] pt_goactive()\n"));
574 data
->block
= getBlock(msg
->gpi_Mouse
.X
, G(obj
)->Width
- PARTITIONBLOCK_FRAMEWIDTH
,data
->table
);
575 rport
= ObtainGIRPort(msg
->gpi_GInfo
);
576 if (data
->active
!= NULL
)
578 /* draw previous active as unselected */
579 if ((struct DosEnvec
*)data
->active
== &data
->gap
)
581 drawtype
= DPTYPE_EMPTY
;
586 drawtype
= DPTYPE_USED
;
587 de
= &data
->active
->de
;
589 DrawPartition(rport
, data
, (struct Gadget
*)obj
, data
->table
, de
, drawtype
);
591 data
->active
= getActive(data
);
593 if ((struct DosEnvec
*)data
->active
== &data
->gap
)
595 drawtype
= DPTYPE_EMPTY_SELECTED
;
600 drawtype
= DPTYPE_USED_SELECTED
;
601 de
= &data
->active
->de
;
602 if (data
->flags
& PTCTF_EmptySelectOnly
)
605 data
->selected
= TRUE
;
606 notify_all(cl
, obj
, msg
->gpi_GInfo
, TRUE
, TRUE
);
607 data
->selected
= FALSE
;
608 if (data
->active
&& rport
)
610 DrawPartition(rport
, data
, (struct Gadget
*)obj
, data
->table
, de
, drawtype
);
613 if (rport
) ReleaseGIRPort(rport
);
618 STATIC IPTR
pt_goinactive(Class
*cl
, Object
*obj
, struct gpInput
*msg
)
620 struct PTableData
*data
= INST_DATA(cl
, obj
);
623 struct RastPort
*rport
;
626 D(bug("[HDToolBox] pt_goinactive()\n"));
630 // data->block = getBlock(msg->gpi_Mouse.X, G(obj)->Width - PARTITIONBLOCK_FRAMEWIDTH, data->table);
631 if (getActive(data
) == data
->active
)
633 if ((rport
= ObtainGIRPort(msg
->gpi_GInfo
)))
635 if ((struct DosEnvec
*)data
->active
== &data
->gap
)
637 drawtype
= DPTYPE_EMPTY_SELECTED
;
642 drawtype
= DPTYPE_USED_SELECTED
;
643 de
= &data
->active
->de
;
645 DrawPartition(rport
, data
, (struct Gadget
*)obj
, data
->table
, de
, drawtype
);
647 ReleaseGIRPort(rport
);
654 ULONG
overflow_add(ULONG a
, LONG b
)
666 ULONG
underflow_add(ULONG a
, LONG b
)
678 BOOL
overlap(ULONG a
, ULONG b
, ULONG c
, ULONG d
)
689 (((a
>= c
) && (a
< d
)) || ((b
>= c
) && (b
< d
))) ||
690 (((c
>= a
) && (c
< b
)) || ((d
>= a
) && (d
< b
)))
694 LONG
getBetterDiff(struct HDTBPartition
*table
, struct HDTBPartition
*current
, LONG diff
)
696 struct HDTBPartition
*pn
;
705 spc
= current
->de
.de_Surfaces
*current
->de
.de_BlocksPerTrack
;
706 start
= current
->de
.de_LowCyl
*spc
;
707 end
= ((current
->de
.de_HighCyl
+1)*spc
)-1;
712 block
= overflow_add(end
, diff
);
718 block
= underflow_add(start
, diff
);
719 other
= block
+size
; /* use correct partition size */
721 if (block
< table
->table
->reserved
)
723 diff
= table
->table
->reserved
-oldblock
;
726 return getBetterDiff(table
, current
, diff
);
728 spc
= table
->dg
.dg_Heads
*table
->dg
.dg_TrackSectors
;
729 if (block
>= ((table
->dg
.dg_Cylinders
)*spc
))
731 diff
= (((table
->dg
.dg_Cylinders
)*spc
)-1)-oldblock
;
734 return getBetterDiff(table
, current
, diff
);
737 for (pn
= (struct HDTBPartition
*)table
->listnode
.list
.lh_Head
;
738 pn
->listnode
.ln
.ln_Succ
;
739 pn
= (struct HDTBPartition
*)pn
->listnode
.ln
.ln_Succ
)
741 /* do NOT include anything that is NOT a partition */
742 if (pn
->listnode
.ln
.ln_Type
!= LNT_Partition
)
744 /* don't check currently processed partition */
747 spc
= pn
->de
.de_Surfaces
*pn
->de
.de_BlocksPerTrack
;
752 pn
->de
.de_LowCyl
*spc
, ((pn
->de
.de_HighCyl
+1)*spc
)-1
757 diff
= ((pn
->de
.de_LowCyl
*spc
)-1)-oldblock
;
759 diff
= ((pn
->de
.de_HighCyl
+1)*spc
)-oldblock
;
760 return getBetterDiff(table
, current
, diff
);
767 STATIC IPTR
pt_handleinput(Class
*cl
, Object
*obj
, struct gpInput
*msg
)
769 struct PTableData
*data
= INST_DATA(cl
, obj
);
770 IPTR retval
= GMR_MEACTIVE
;
771 struct InputEvent
*ie
;
772 struct RastPort
*rport
;
775 ie
= msg
->gpi_IEvent
;
776 if (ie
->ie_Class
== IECLASS_RAWMOUSE
)
778 D(bug("[HDToolBox] pt_handleinput(): %x / %x / %x\n", IECODE_NOBUTTON
, IECODE_LBUTTON
| IECODE_UP_PREFIX
, ie
->ie_Code
));
781 case IECODE_NOBUTTON
:
783 ((struct DosEnvec
*)data
->active
!= &data
->gap
) &&
784 (!(data
->flags
& PTCTF_NoPartitionMove
))
794 D(bug("[HDToolBox] - attempting to obtain block\n", diff
));
795 block
= getBlock(msg
->gpi_Mouse
.X
, G(obj
)->Width
- PARTITIONBLOCK_FRAMEWIDTH
, data
->table
);
796 D(bug("[HDToolBox] - block location: %ld\n", diff
));
797 diff
= block
-data
->block
;
800 D(bug("[HDToolBox] - odiff: %ld\n", diff
));
801 diff
= getBetterDiff(data
->table
, data
->active
, diff
);
802 D(bug("[HDToolBox] - diff : %ld\n", diff
));
805 spc
=data
->active
->de
.de_Surfaces
*data
->active
->de
.de_BlocksPerTrack
;
806 D(bug("[HDToolBox] - spc : %ld\n", spc
));
807 start
= data
->active
->de
.de_LowCyl
*spc
;
808 D(bug("[HDToolBox] - start: %ld\n", start
));
810 end
= ((data
->active
->de
.de_HighCyl
+1)*spc
)-1;
811 D(bug("[HDToolBox] - end : %ld\n", end
));
813 tocheck
= (diff
>0) ? end
: start
;
814 if (validValue(data
->table
, data
->active
, tocheck
))
817 end
= ((end
+1)/spc
)-1;
819 rport
= ObtainGIRPort(msg
->gpi_GInfo
);
825 (struct Gadget
*)obj
,
830 data
->active
->de
.de_LowCyl
=start
;
831 data
->active
->de
.de_HighCyl
=end
;
836 (struct Gadget
*)obj
,
841 if (rport
) ReleaseGIRPort(rport
);
845 notify_all(cl
, obj
, msg
->gpi_GInfo
, TRUE
, TRUE
);
849 D(bug("[HDToolBox] pt_handleinput: !!!!!!!!!!!!!!!!!!!not valid\n"));
855 case (IECODE_LBUTTON
| IECODE_UP_PREFIX
):
857 notify_all(cl
, obj
, msg
->gpi_GInfo
, FALSE
, TRUE
);
858 data
->selected
= FALSE
;
859 retval
= GMR_NOREUSE
|GMR_VERIFY
;
865 D(bug("[HDToolBox] pt_handleinput(): Other class: %x\n", ie
->ie_Class
));
867 D(bug("[HDToolBox] pt_handleinput(): successful\n", ie
->ie_Class
));
871 void DrawLegend(struct RastPort
*rport
, struct DrawInfo
*dri
, LONG sx
, LONG sy
, LONG ex
, LONG ey
, char *text
)
873 D(bug("[HDToolBox] DrawLegend()\n"));
875 RectFill(rport
, sx
+1, sy
+1, ex
-1, ey
-1);
876 DrawBox(rport
, dri
, sx
, sy
, ex
, ey
, FALSE
);
879 SetDrMd(rport
, JAM1
);
881 Move(rport
, sx
, ey
+rport
->TxHeight
+1);
882 Text(rport
, text
, strlen(text
));
885 STATIC IPTR
pt_render(Class
*cl
, Object
*obj
, struct gpRender
*msg
)
887 struct PTableData
*data
= INST_DATA(cl
, obj
);
888 struct HDTBPartition
*pn
;
891 D(bug("[HDToolBox] pt_render()\n"));
893 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
897 struct TagItem obp_tags
[] =
899 {OBP_Precision
, PRECISION_EXACT
},
900 {OBP_FailIfBad
, TRUE
},
906 data
->firstdraw
= FALSE
;
908 data
->cm
= msg
->gpr_GInfo
->gi_Screen
->ViewPort
.ColorMap
;
910 for(i
= 0; i
< NUM_PENS
; i
++)
912 data
->pens
[i
] = ObtainBestPenA(data
->cm
,
918 if (data
->pens
[i
] == -1)
922 ReleasePen(data
->cm
, data
->pens
[i
]);
930 data
->multicolor
= TRUE
;
931 data
->pensallocated
= TRUE
;
940 G(obj
)->LeftEdge
+G(obj
)->Width
- 1,
941 G(obj
)->TopEdge
+(G(obj
)->Height
- 1)
944 PrepareRP(msg
->gpr_RPort
, data
, DPTYPE_EMPTY
);
951 G(obj
)->LeftEdge
+(G(obj
)->Width
/5),
952 G(obj
)->TopEdge
+(G(obj
)->Height
/2)-(G(obj
)->Height
/4),
956 PrepareRP(msg
->gpr_RPort
, data
, DPTYPE_EMPTY_SELECTED
);
961 G(obj
)->LeftEdge
+(G(obj
)->Width
/5)+(G(obj
)->Width
/15),
963 G(obj
)->LeftEdge
+(G(obj
)->Width
/5*2)+(G(obj
)->Width
/15),
964 G(obj
)->TopEdge
+(G(obj
)->Height
/2)-(G(obj
)->Height
/4),
968 PrepareRP(msg
->gpr_RPort
, data
, DPTYPE_USED
);
973 G(obj
)->LeftEdge
+(G(obj
)->Width
/5*2)+(G(obj
)->Width
/15*2),
975 G(obj
)->LeftEdge
+(G(obj
)->Width
/5*3)+(G(obj
)->Width
/15*2),
976 G(obj
)->TopEdge
+(G(obj
)->Height
/2)-(G(obj
)->Height
/4),
980 PrepareRP(msg
->gpr_RPort
, data
, DPTYPE_USED_SELECTED
);
985 G(obj
)->LeftEdge
+(G(obj
)->Width
/5*3)+(G(obj
)->Width
/15*3),
987 G(obj
)->LeftEdge
+(G(obj
)->Width
/5*4)+(G(obj
)->Width
/15*3),
988 G(obj
)->TopEdge
+(G(obj
)->Height
/2)-(G(obj
)->Height
/4),
992 PrepareRP(msg
->gpr_RPort
, data
, DPTYPE_EMPTY
);
998 G(obj
)->TopEdge
+(G(obj
)->Height
/2),
999 G(obj
)->LeftEdge
+G(obj
)->Width
- 1,
1000 G(obj
)->TopEdge
+(G(obj
)->Height
- 1)
1002 SetPattern(msg
->gpr_RPort
, NULL
, 0);
1009 G(obj
)->TopEdge
+(G(obj
)->Height
/2),
1010 G(obj
)->LeftEdge
+G(obj
)->Width
- 1,
1011 G(obj
)->TopEdge
+(G(obj
)->Height
- 1),
1017 SetPattern(msg
->gpr_RPort
, &pattern
, 2);
1018 pn
= (struct HDTBPartition
*)data
->table
->listnode
.list
.lh_Head
;
1019 while (pn
->listnode
.ln
.ln_Succ
)
1021 if (pn
->listnode
.ln
.ln_Type
== LNT_Partition
)
1027 (struct Gadget
*)obj
,
1030 (data
->active
== pn
) ? DPTYPE_USED_SELECTED
: DPTYPE_USED
1033 pn
= (struct HDTBPartition
*)pn
->listnode
.ln
.ln_Succ
;
1035 if ((struct DosEnvec
*)data
->active
== &data
->gap
)
1041 (struct Gadget
*)obj
,
1044 DPTYPE_EMPTY_SELECTED
1047 SetPattern(msg
->gpr_RPort
, 0, 0);
1052 STATIC IPTR
pt_dispose(Class
*cl
, Object
*obj
, Msg msg
)
1054 struct PTableData
*data
= INST_DATA(cl
, obj
);
1056 D(bug("[HDToolBox] pt_dispose()\n"));
1058 if (data
->pensallocated
)
1062 for(i
= 0; i
< NUM_PENS
; i
++)
1064 ReleasePen(data
->cm
, data
->pens
[i
]);
1068 return DoSuperMethodA(cl
, obj
, msg
);
1071 STATIC IPTR
pt_hittest(Class
*cl
, Object
*obj
, struct gpHitTest
*msg
)
1073 D(bug("[HDToolBox] pt_hittest()\n"));
1075 return GMR_GADGETHIT
;
1078 AROS_UFH3S(IPTR
, dispatch_ptclass
,
1079 AROS_UFHA(Class
*, cl
, A0
),
1080 AROS_UFHA(Object
*, obj
, A2
),
1081 AROS_UFHA(Msg
, msg
, A1
))
1087 D(bug("[HDToolBox] dispatch_ptclass()\n"));
1089 switch (msg
->MethodID
)
1092 retval
= pt_new(cl
, obj
, (struct opSet
*)msg
);
1095 retval
= pt_dispose(cl
, obj
, msg
);
1099 retval
= pt_set(cl
, obj
, (struct opSet
*)msg
);
1102 retval
= pt_get(cl
, obj
, (struct opGet
*)msg
);
1105 retval
= pt_hittest(cl
, obj
, (struct gpHitTest
*)msg
);
1108 retval
= pt_render(cl
, obj
, (struct gpRender
*)msg
);
1111 retval
= pt_goactive(cl
, obj
, (struct gpInput
*)msg
);
1114 retval
= pt_goinactive(cl
, obj
, (struct gpInput
*)msg
);
1116 case GM_HANDLEINPUT
:
1117 retval
= pt_handleinput(cl
, obj
, (struct gpInput
*)msg
);
1120 D(bug("[HDToolBox] dispatch_ptclass:default %ld\n", msg
->MethodID
));
1121 retval
= DoSuperMethodA(cl
, obj
, msg
);
1129 Class
*makePTClass(void)
1131 D(bug("[HDToolBox] makePTClass()\n"));
1135 ptcl
= MakeClass(NULL
, GADGETCLASS
, NULL
, sizeof(struct PTableData
), 0);
1138 ptcl
->cl_Dispatcher
.h_Entry
= AROS_ASMSYMNAME(dispatch_ptclass
);
1139 ptcl
->cl_Dispatcher
.h_SubEntry
= NULL
;
1140 ptcl
->cl_UserData
= (IPTR
)NULL
;