2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 File requester specific code.
9 #include <proto/exec.h>
10 #include <proto/dos.h>
11 #include <proto/utility.h>
12 #include <proto/intuition.h>
13 #include <proto/graphics.h>
14 #include <proto/gadtools.h>
15 #include <exec/memory.h>
17 #include <intuition/screens.h>
18 #include <intuition/icclass.h>
19 #include <intuition/gadgetclass.h>
20 #include <graphics/displayinfo.h>
21 #include <graphics/modeid.h>
22 #include <graphics/monitor.h>
23 #include <graphics/gfx.h>
24 #include <devices/rawkeycodes.h>
25 #include <libraries/gadtools.h>
26 #include <workbench/startup.h>
30 #include "asl_intern.h"
31 #include "modereqhooks.h"
32 #include "modereqsupport.h"
35 #if USE_SHARED_COOLIMAGES
36 #include <libraries/coolimages.h>
37 #include <proto/coolimages.h>
39 #include "coolimages.h"
42 #define CATCOMP_NUMBERS
48 #include <aros/debug.h>
50 /*****************************************************************************************/
52 STATIC BOOL
SMGadInit(struct LayoutData
*, struct AslBase_intern
*);
53 STATIC VOID
SMWindowOpened(struct LayoutData
*, struct AslBase_intern
*);
54 STATIC BOOL
SMGadLayout(struct LayoutData
*, struct AslBase_intern
*);
55 STATIC VOID
SMGadCleanup(struct LayoutData
*, struct AslBase_intern
*);
56 STATIC ULONG
SMHandleEvents(struct LayoutData
*, struct AslBase_intern
*);
57 STATIC ULONG
SMGetSelectedMode(struct LayoutData
*, struct AslBase_intern
*AslBase
);
59 /*****************************************************************************************/
61 #define ID_BUTOK ID_MAINBUTTON_OK
62 #define ID_BUTCANCEL ID_MAINBUTTON_CANCEL
69 #define ID_AUTOSCROLL 6
74 #define CLASS_ASLBASE ((struct AslBase_intern *)cl->cl_UserData)
75 #define HOOK_ASLBASE ((struct AslBase_intern *)hook->h_Data)
78 /*****************************************************************************************/
80 AROS_UFH3(VOID
, SMTagHook
,
81 AROS_UFHA(struct Hook
*, hook
, A0
),
82 AROS_UFHA(struct ParseTagArgs
*, pta
, A2
),
83 AROS_UFHA(struct AslBase_intern
*, AslBase
, A1
)
89 struct TagItem
*tstate
;
90 struct IntSMReq
*ismreq
;
92 EnterFunc(bug("SMTagHook(hook=%p, pta=%p)\n", hook
, pta
));
94 ismreq
= (struct IntSMReq
*)pta
->pta_IntReq
;
96 tstate
= pta
->pta_Tags
;
97 while ((tag
= NextTagItem(&tstate
)) != NULL
)
99 IPTR tidata
= tag
->ti_Data
;
103 case ASLSM_CustomSMList
:
104 ismreq
->ism_CustomSMList
= (struct List
*)tidata
;
107 case ASLSM_FilterFunc
:
108 ismreq
->ism_FilterFunc
= (struct Hook
*)tidata
;
111 case ASLSM_DoAutoScroll
:
113 ismreq
->ism_Flags
|= ISMF_DOAUTOSCROLL
;
115 ismreq
->ism_Flags
&= ~ISMF_DOAUTOSCROLL
;
120 ismreq
->ism_Flags
|= ISMF_DODEPTH
;
122 ismreq
->ism_Flags
&= ~ISMF_DODEPTH
;
127 ismreq
->ism_Flags
|= ISMF_DOWIDTH
;
129 ismreq
->ism_Flags
&= ~ISMF_DOWIDTH
;
134 ismreq
->ism_Flags
|= ISMF_DOHEIGHT
;
136 ismreq
->ism_Flags
&= ~ISMF_DOHEIGHT
;
139 case ASLSM_DoOverscanType
:
141 ismreq
->ism_Flags
|= ISMF_DOOVERSCAN
;
143 ismreq
->ism_Flags
&= ~ISMF_DOOVERSCAN
;
147 ((struct ScreenModeRequester
*)pta
->pta_Req
)->sm_UserData
= (APTR
)tidata
;
150 case ASLSM_InitialAutoScroll
:
151 ismreq
->ism_AutoScroll
= tidata
? TRUE
: FALSE
;
154 case ASLSM_InitialDisplayDepth
:
155 ismreq
->ism_DisplayDepth
= tidata
;
158 case ASLSM_InitialDisplayWidth
:
159 ismreq
->ism_DisplayWidth
= tidata
;
162 case ASLSM_InitialDisplayHeight
:
163 ismreq
->ism_DisplayHeight
= tidata
;
166 case ASLSM_InitialDisplayID
:
167 ismreq
->ism_DisplayID
= tidata
;
170 case ASLSM_InitialInfoLeftEdge
:
171 ismreq
->ism_InfoLeftEdge
= tidata
;
174 case ASLSM_InitialInfoTopEdge
:
175 ismreq
->ism_InfoTopEdge
= tidata
;
178 case ASLSM_InitialInfoOpened
:
179 ismreq
->ism_InfoOpened
= tidata
? TRUE
: FALSE
;
182 case ASLSM_InitialOverscanType
:
183 ismreq
->ism_OverscanType
= (((LONG
)tidata
>= OSCAN_TEXT
) &&
184 ((LONG
)tidata
<= OSCAN_VIDEO
)) ? tidata
: OSCAN_TEXT
;
188 ismreq
->ism_MinWidth
= tidata
;
192 ismreq
->ism_MaxWidth
= tidata
;
195 case ASLSM_MinHeight
:
196 ismreq
->ism_MinHeight
= tidata
;
199 case ASLSM_MaxHeight
:
200 ismreq
->ism_MaxHeight
= tidata
;
204 ismreq
->ism_MinDepth
= tidata
;
208 ismreq
->ism_MaxDepth
= tidata
;
211 case ASLSM_PropertyFlags
:
212 ismreq
->ism_PropertyFlags
= tidata
;
215 case ASLSM_PropertyMask
:
216 ismreq
->ism_PropertyMask
= tidata
;
222 } /* switch (tag->ti_Tag) */
224 } /* while ((tag = NextTagItem(&tstate)) != 0) */
226 if (ismreq
->ism_MinDepth
< 1) ismreq
->ism_MinDepth
= 1;
228 if (ismreq
->ism_MaxDepth
< ismreq
->ism_MinDepth
)
229 ismreq
->ism_MaxDepth
= ismreq
->ism_MinDepth
;
231 if (ismreq
->ism_DisplayDepth
< ismreq
->ism_MinDepth
)
232 ismreq
->ism_DisplayDepth
= ismreq
->ism_MinDepth
;
234 if (ismreq
->ism_DisplayDepth
> ismreq
->ism_MaxDepth
)
235 ismreq
->ism_DisplayDepth
= ismreq
->ism_MaxDepth
;
237 ReturnVoid("SMTagHook");
242 /*****************************************************************************************/
244 AROS_UFH3(ULONG
, SMGadgetryHook
,
245 AROS_UFHA(struct Hook
*, hook
, A0
),
246 AROS_UFHA(struct LayoutData
*, ld
, A2
),
247 AROS_UFHA(struct AslBase_intern
*, AslBase
, A1
)
254 switch (ld
->ld_Command
)
257 retval
= (ULONG
)SMGadInit(ld
, ASLB(AslBase
));
260 case LDCMD_WINDOWOPENED
:
261 SMWindowOpened(ld
, ASLB(AslBase
));
266 retval
= (ULONG
)SMGadLayout(ld
, ASLB(AslBase
));
269 case LDCMD_HANDLEEVENTS
:
270 retval
= (ULONG
)SMHandleEvents(ld
, ASLB(AslBase
));
274 SMGadCleanup(ld
, ASLB(AslBase
));
288 /*****************************************************************************************/
295 #if USE_SHARED_COOLIMAGES
298 const struct CoolImage
*coolimage
;
300 const struct CoolImage
*coolimage
;
305 /*****************************************************************************************/
307 STATIC BOOL
SMGadInit(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
309 struct SMUserData
*udata
= ld
->ld_UserData
;
310 struct IntSMReq
*ismreq
= (struct IntSMReq
*)ld
->ld_IntReq
;
312 #if USE_SHARED_COOLIMAGES
313 struct ButtonInfo bi
[NUMBUTS
] =
315 { ID_BUTOK
, GetIR(ismreq
)->ir_PositiveText
, MSG_MODEREQ_POSITIVE_GAD
, COOL_MONITORIMAGE_ID
, &udata
->OKBut
},
316 { ID_BUTCANCEL
, GetIR(ismreq
)->ir_NegativeText
, MSG_MODEREQ_NEGATIVE_GAD
, COOL_CANCELIMAGE_ID
, &udata
->CancelBut
}
319 struct ButtonInfo bi
[NUMBUTS
] =
321 { ID_BUTOK
, GetIR(ismreq
)->ir_PositiveText
, MSG_MODEREQ_POSITIVE_GAD
, &cool_monitorimage
, &udata
->OKBut
},
322 { ID_BUTCANCEL
, GetIR(ismreq
)->ir_NegativeText
, MSG_MODEREQ_NEGATIVE_GAD
, &cool_cancelimage
, &udata
->CancelBut
}
327 WORD gadrows
, x
, y
, w
, h
, i
, y2
;
328 WORD labelwidth
= 0, maxcyclewidth
= 0;
331 NEWLIST(&udata
->ListviewList
);
333 error
= SMGetModes(ld
, AslBase
);
334 if (error
) goto failure
;
336 error
= ERROR_NO_FREE_STORE
;
338 /* calc. min. size */
341 for(i
= 0; i
< NUMBUTS
; i
++)
343 if(!bi
[i
].text
) bi
[i
].text
= GetString(bi
[i
].deftextid
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
345 x
= TextLength(&ld
->ld_DummyRP
, bi
[i
].text
, strlen(bi
[i
].text
));
347 #if SREQ_COOL_BUTTONS
348 #if USE_SHARED_COOLIMAGES
351 bi
[i
].coolimage
= (const struct CoolImage
*)COOL_ObtainImageA(bi
[i
].coolid
, NULL
);
356 if (ld
->ld_TrueColor
)
358 x
+= IMAGEBUTTONEXTRAWIDTH
+ bi
[i
].coolimage
->width
;
365 udata
->ButWidth
= w
+ BUTTONEXTRAWIDTH
;
367 ld
->ld_ButWidth
= udata
->ButWidth
;
368 ld
->ld_NumButtons
= 4;
370 #if SREQ_COOL_BUTTONS
372 #if USE_SHARED_COOLIMAGES
376 y
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
377 if (ld
->ld_TrueColor
)
379 y2
= IMAGEBUTTONEXTRAHEIGHT
+ DEF_COOLIMAGEHEIGHT
;
383 udata
->ButHeight
= (y
> y2
) ? y
: y2
;
384 #if USE_SHARED_COOLIMAGES
388 udata
->ButHeight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
393 udata
->ButHeight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
396 gadrows
= 1; /* button row */
397 if (ismreq
->ism_Flags
& ISMF_DOOVERSCAN
) gadrows
++;
398 if (ismreq
->ism_Flags
& ISMF_DOWIDTH
) gadrows
++;
399 if (ismreq
->ism_Flags
& ISMF_DOHEIGHT
) gadrows
++;
400 if (ismreq
->ism_Flags
& ISMF_DODEPTH
) gadrows
++;
401 if (ismreq
->ism_Flags
& ISMF_DOAUTOSCROLL
) gadrows
++;
403 ld
->ld_MinWidth
= OUTERSPACINGX
* 2 +
405 udata
->ButWidth
* NUMBUTS
;
407 ld
->ld_MinHeight
= OUTERSPACINGY
* 2 +
408 (GADGETSPACINGY
+ udata
->ButHeight
) * gadrows
+
409 BORDERLVSPACINGY
* 2 +
410 (ld
->ld_Font
->tf_YSize
+ BORDERLVITEMSPACINGY
* 2) * SREQ_MIN_VISIBLELINES
;
412 /* make listview gadget */
414 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
415 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
;
416 w
= -ld
->ld_WBorRight
- ld
->ld_WBorLeft
- OUTERSPACINGX
* 2 - PROPSIZE
;
417 h
= -ld
->ld_WBorBottom
- ld
->ld_WBorTop
- OUTERSPACINGY
* 2 -
418 udata
->ButHeight
* gadrows
-
419 GADGETSPACINGY
* gadrows
;
422 struct TagItem lv_tags
[] =
428 {GA_UserData
, (IPTR
)ld
},
429 {GA_ID
, ID_LISTVIEW
},
430 {GA_RelVerify
, TRUE
},
431 {ASLLV_Labels
, (IPTR
)&udata
->ListviewList
},
432 {ASLLV_Font
, (IPTR
)ld
->ld_Font
},
436 udata
->Listview
= gad
= NewObjectA(AslBase
->asllistviewclass
, NULL
, lv_tags
);
437 if (!udata
->Listview
) goto failure
;
441 /* make scroller gadget for listview */
443 x
= -ld
->ld_WBorRight
- OUTERSPACINGX
- PROPSIZE
+ 1;
444 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
;
446 h
= -ld
->ld_WBorBottom
- ld
->ld_WBorTop
- OUTERSPACINGY
* 2 -
447 udata
->ButHeight
* gadrows
-
448 GADGETSPACINGY
* gadrows
;
450 struct TagItem scroller_tags
[] =
456 {GA_ID
, ID_LISTVIEW
},
457 {PGA_NewLook
, TRUE
},
458 {PGA_Borderless
, TRUE
},
459 {PGA_Freedom
, FREEVERT
},
463 {GA_Previous
, (IPTR
)gad
},
467 if (!makescrollergadget(&udata
->ScrollGad
, ld
, scroller_tags
, AslBase
)) goto failure
;
468 gad
= udata
->ScrollGad
.arrow2
;
471 connectscrollerandlistview(&udata
->ScrollGad
, udata
->Listview
, AslBase
);
473 /* make button row */
475 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
+ 1;
478 struct TagItem button_tags
[] =
483 #if SREQ_COOL_BUTTONS
484 {ASLBT_CoolImage
, 0 },
488 {GA_UserData
, (IPTR
)ld
},
491 {GA_Width
, udata
->ButWidth
},
492 {GA_Height
, udata
->ButHeight
},
493 {GA_RelVerify
, TRUE
},
494 {GA_Image
, 0 }, /* means we want a frame */
498 for(i
= 0; i
< NUMBUTS
; i
++)
500 button_tags
[0].ti_Data
= (IPTR
)bi
[i
].text
;
501 button_tags
[1].ti_Data
= (IPTR
)gad
;
502 button_tags
[2].ti_Data
= bi
[i
].gadid
;
504 #if USE_SHARED_COOLIMAGES
505 if (CoolImagesBase
== NULL
) button_tags
[3].ti_Tag
= TAG_IGNORE
;
507 button_tags
[3].ti_Data
= (IPTR
)bi
[i
].coolimage
;
509 *(bi
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, button_tags
);
510 if (!gad
) goto failure
;
517 if (ismreq
->ism_Flags
& (ISMF_DOOVERSCAN
| ISMF_DOWIDTH
| ISMF_DOHEIGHT
| ISMF_DODEPTH
| ISMF_DOAUTOSCROLL
))
519 #define FSET(x) ((ismreq->ism_Flags & x) ? TRUE : FALSE)
528 {FSET(ISMF_DOOVERSCAN
) , (STRPTR
)MSG_MODEREQ_OVERSCAN_LABEL
, &udata
->OverscanLabel
},
529 {FSET(ISMF_DOWIDTH
) , (STRPTR
)MSG_MODEREQ_WIDTH_LABEL
, &udata
->WidthLabel
},
530 {FSET(ISMF_DOHEIGHT
) , (STRPTR
)MSG_MODEREQ_HEIGHT_LABEL
, &udata
->HeightLabel
},
531 {FSET(ISMF_DODEPTH
) , (STRPTR
)MSG_MODEREQ_COLORS_LABEL
, &udata
->DepthLabel
},
532 {FSET(ISMF_DOAUTOSCROLL
), (STRPTR
)MSG_MODEREQ_AUTOSCROLL_LABEL
, &udata
->AutoScrollLabel
}
537 struct TagItem label_tags
[] =
542 {GA_Height
, udata
->ButHeight
},
544 {GA_Previous
, (IPTR
)gad
},
545 {GA_UserData
, (IPTR
)ld
},
546 {GA_Disabled
, TRUE
},
551 for(i
= 0, i2
= 0; i
< 5; i
++)
555 li
[i
].text
= GetString((IPTR
)li
[i
].text
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
556 str
[i2
++] = li
[i
].text
;
560 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
561 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
-
562 (udata
->ButHeight
+ GADGETSPACINGY
) * (gadrows
- 1) + 1;
565 w
= labelwidth
= BiggestTextLength(str
, i2
, &(ld
->ld_DummyRP
), AslBase
);
567 label_tags
[1].ti_Data
= y
;
569 for(i
= 0; i
< 5;i
++)
571 if (!li
[i
].doit
) continue;
573 label_tags
[2].ti_Data
= TextLength(&ld
->ld_DummyRP
, li
[i
].text
, strlen(li
[i
].text
));
574 label_tags
[0].ti_Data
= x
+ w
- label_tags
[2].ti_Data
;
575 label_tags
[4].ti_Data
= (IPTR
)li
[i
].text
;
576 label_tags
[5].ti_Data
= (IPTR
)gad
;
578 *(li
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, label_tags
);
579 if (!gad
) goto failure
;
581 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
582 label_tags
[1].ti_Data
= y
;
585 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
-
586 (udata
->ButHeight
+ GADGETSPACINGY
) * (gadrows
- 1) + 1;
587 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
+ w
+ LABELSPACINGX
;
589 w
= -ld
->ld_WBorLeft
- ld
->ld_WBorRight
- OUTERSPACINGX
* 2 -
592 /* Make Overscan gadget */
594 if (ismreq
->ism_Flags
& ISMF_DOOVERSCAN
)
596 struct TagItem cycle_tags
[] =
598 {GA_Previous
, (IPTR
)gad
},
602 {GA_Height
, udata
->ButHeight
},
603 {GA_RelVerify
, TRUE
},
604 {GA_UserData
, (IPTR
)ld
},
605 {GA_ID
, ID_OVERSCAN
},
606 {ASLCY_Labels
, (IPTR
)&ismreq
->ism_Overscan1Text
},
607 {ASLCY_Active
, ismreq
->ism_OverscanType
- 1 },
608 {ASLCY_Font
, (IPTR
)ld
->ld_Font
},
612 static LONG labelids
[] =
614 MSG_MODEREQ_OVERSCAN_TEXT
,
615 MSG_MODEREQ_OVERSCAN_GRAPHICS
,
616 MSG_MODEREQ_OVERSCAN_EXTREME
,
617 MSG_MODEREQ_OVERSCAN_MAXIMUM
,
620 STRPTR
*labels
= (STRPTR
*)&ismreq
->ism_Overscan1Text
;
622 for(i
= 0; i
< 4; i
++)
624 labels
[i
] = GetString(labelids
[i
], GetIR(ismreq
)->ir_Catalog
, AslBase
);
627 i
= CYCLEEXTRAWIDTH
+ BiggestTextLength(&ismreq
->ism_Overscan1Text
,
631 if (i
> maxcyclewidth
) maxcyclewidth
= i
;
633 udata
->OverscanGadget
= gad
= NewObjectA(AslBase
->aslcycleclass
, NULL
, cycle_tags
);
634 if (!gad
) goto failure
;
636 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
638 } /* if (ismreq->ism_Flags & ISMF_DOOVERSCAN) */
641 struct TagItem string_tags
[] =
643 {GA_Previous
, (IPTR
)gad
},
645 {STRINGA_LongVal
, ismreq
->ism_DisplayWidth
},
649 {GA_Height
, udata
->ButHeight
},
650 {GA_RelVerify
, TRUE
},
651 {GA_UserData
, (IPTR
)ld
},
652 {GA_TabCycle
, TRUE
},
653 {STRINGA_MaxChars
, 8 },
654 {STRINGA_Font
, (IPTR
)ld
->ld_Font
},
658 /* Make width gadget */
660 if (ismreq
->ism_Flags
& ISMF_DOWIDTH
)
662 udata
->WidthGadget
= gad
= NewObjectA(AslBase
->aslstringclass
, NULL
, string_tags
);
663 if (!gad
) goto failure
;
665 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
668 /* Make height gadget */
670 if (ismreq
->ism_Flags
& ISMF_DOHEIGHT
)
672 string_tags
[0].ti_Data
= (IPTR
)gad
;
673 string_tags
[1].ti_Data
= ID_HEIGHT
;
674 string_tags
[2].ti_Data
= ismreq
->ism_DisplayHeight
;
675 string_tags
[3].ti_Data
= y
;
677 udata
->HeightGadget
= gad
= NewObjectA(AslBase
->aslstringclass
, NULL
, string_tags
);
678 if (!gad
) goto failure
;
680 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
685 struct TagItem cycle_tags
[] =
687 {GA_Previous
, (IPTR
)gad
},
688 {GA_ID
, ID_COLORS
},
694 {GA_Height
, udata
->ButHeight
},
695 {GA_RelVerify
, TRUE
},
696 {GA_UserData
, (IPTR
)ld
},
697 {ASLCY_Font
, (IPTR
)ld
->ld_Font
},
702 /* Make Colors gadget */
704 if (ismreq
->ism_Flags
& ISMF_DODEPTH
)
706 i
= CYCLEEXTRAWIDTH
+ TextLength(&ld
->ld_DummyRP
, "16777216", 8);
707 if (i
> maxcyclewidth
) maxcyclewidth
= i
;
709 udata
->DepthGadget
= gad
= NewObjectA(AslBase
->aslcycleclass
, NULL
, cycle_tags
);
710 if (!gad
) goto failure
;
712 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
715 /* Make AutoScroll gadget */
717 if (ismreq
->ism_Flags
& ISMF_DOAUTOSCROLL
)
719 cycle_tags
[0].ti_Data
= (IPTR
)gad
;
720 cycle_tags
[1].ti_Data
= ID_AUTOSCROLL
;
721 cycle_tags
[2].ti_Data
= (IPTR
)&ismreq
->ism_AutoScrollOFFText
;
722 cycle_tags
[3].ti_Data
= ismreq
->ism_AutoScroll
;
723 cycle_tags
[4].ti_Data
= y
;
725 ismreq
->ism_AutoScrollOFFText
= GetString(MSG_MODEREQ_AUTOSCROLL_OFF
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
726 ismreq
->ism_AutoScrollONText
= GetString(MSG_MODEREQ_AUTOSCROLL_ON
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
728 i
= CYCLEEXTRAWIDTH
+ BiggestTextLength(&ismreq
->ism_AutoScrollOFFText
,
732 if (i
> maxcyclewidth
) maxcyclewidth
= i
;
734 udata
->AutoScrollGadget
= gad
= NewObjectA(AslBase
->aslcycleclass
, NULL
, cycle_tags
);
735 if (!gad
) goto failure
;
737 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
742 } /* if (ismreq->ism_Flags & (ISMF_DOOVERSCAN | ISMF_DOWIDTH | ISMF_DOHEIGHT | ISMF_DODEPTH | ISMF_DOAUTOSCROLL)) */
746 struct TagItem eraser_tags
[] =
748 {GA_Previous
, (IPTR
)gad
},
752 udata
->EraserGadget
= gad
= NewObjectA(AslBase
->asleraserclass
, NULL
, eraser_tags
);
753 /* Doesn't matter if this failed */
757 w
= OUTERSPACINGX
+ labelwidth
+ LABELSPACINGX
+ maxcyclewidth
+ OUTERSPACINGX
;
758 if (w
> ld
->ld_MinWidth
) ld
->ld_MinWidth
= w
;
760 ld
->ld_GList
= (struct Gadget
*)udata
->Listview
;
764 struct NewMenu nm
[] =
766 {NM_TITLE
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL
},
767 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_LASTMODE
, 0, 0, 0, (APTR
)SMMEN_LASTMODE
},
768 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_NEXTMODE
, 0, 0, 0, (APTR
)SMMEN_NEXTMODE
},
769 {NM_ITEM
, NM_BARLABEL
},
770 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_PROPERTIES
, 0, 0, 0, (APTR
)SMMEN_PROPERTYLIST
},
771 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_RESTORE
, 0, 0, 0, (APTR
)SMMEN_RESTORE
},
772 {NM_ITEM
, NM_BARLABEL
},
773 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_OK
, 0, 0, 0, (APTR
)SMMEN_OK
},
774 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_CANCEL
, 0, 0, 0, (APTR
)SMMEN_CANCEL
},
778 struct TagItem menu_tags
[] =
780 {GTMN_NewLookMenus
, TRUE
},
781 {GTMN_TextAttr
, (IPTR
)GetIR(ismreq
)->ir_TextAttr
},
785 if (menu_tags
[1].ti_Data
== 0) menu_tags
[1].ti_Tag
= TAG_IGNORE
;
787 LocalizeMenus(nm
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
789 /* Don't fail, if menus cannot be created/layouted, because a requester
790 without menus is still better than no requester at all */
792 if ((ld
->ld_Menu
= CreateMenusA(nm
, NULL
)))
794 if (!LayoutMenusA(ld
->ld_Menu
, ld
->ld_VisualInfo
, menu_tags
))
796 FreeMenus(ld
->ld_Menu
);ld
->ld_Menu
= NULL
;
801 SMRestore(ld
, AslBase
);
804 ReturnBool ("SMGadInit", TRUE
);
811 SMGadCleanup(ld
, ASLB(AslBase
));
813 ReturnBool ("SMGadInit", FALSE
);
817 /*****************************************************************************************/
819 STATIC VOID
SMWindowOpened(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
821 struct IntSMReq
*ismreq
= (struct IntSMReq
*)ld
->ld_IntReq
;
823 if (ismreq
->ism_InfoOpened
)
825 SMOpenPropertyWindow(ld
, AslBase
);
829 /*****************************************************************************************/
831 STATIC BOOL
SMGadLayout(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
833 ReturnBool ("SMGadLayout", TRUE
);
836 /*****************************************************************************************/
838 STATIC ULONG
SMHandleEvents(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
840 struct IntuiMessage
*imsg
= ld
->ld_Event
;
841 struct SMUserData
*udata
= (struct SMUserData
*)ld
->ld_UserData
;
843 ULONG retval
= GHRET_OK
;
845 EnterFunc(bug("SMHandleEvents: Class: %d\n", imsg
->Class
));
847 if (imsg
->IDCMPWindow
== ld
->ld_Window2
)
849 return SMHandlePropertyEvents(ld
, imsg
, AslBase
);
854 case IDCMP_CLOSEWINDOW
:
862 SMChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, AslBase
);
866 SMChangeActiveLVItem(ld
, -1, IEQUALIFIER_LSHIFT
, AslBase
);
870 SMChangeActiveLVItem(ld
, -1, IEQUALIFIER_LALT
, AslBase
);
873 case RAWKEY_NM_WHEEL_UP
:
874 SMChangeActiveLVItem(ld
, -3, imsg
->Qualifier
, AslBase
);
878 SMChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, AslBase
);
881 case RAWKEY_PAGEDOWN
:
882 SMChangeActiveLVItem(ld
, 1, IEQUALIFIER_LSHIFT
, AslBase
);
886 SMChangeActiveLVItem(ld
, 1, IEQUALIFIER_LALT
, AslBase
);
889 case RAWKEY_NM_WHEEL_DOWN
:
890 SMChangeActiveLVItem(ld
, 3, imsg
->Qualifier
, AslBase
);
895 case IDCMP_VANILLAKEY
:
905 gadid
= ((struct Gadget
*)imsg
->IAddress
)->GadgetID
;
907 D(bug("GADGETUP! gadgetid=%d\n", gadid
));
916 retval
= SMGetSelectedMode(ld
, AslBase
);
921 struct DisplayMode
*dispmode
;
924 GetAttr(ASLLV_Active
, udata
->Listview
, &active
);
926 if ((dispmode
= (struct DisplayMode
*)FindListNode(&udata
->ListviewList
, (WORD
)active
)))
928 SMActivateMode(ld
, active
, 0, AslBase
);
930 if (imsg
->Code
) /* TRUE if double clicked */
932 retval
= SMGetSelectedMode(ld
, AslBase
);
939 SMChangeActiveLVItem(ld
, 0, 0, AslBase
);
944 struct DisplayMode
*dispmode
;
947 dispmode
= SMGetActiveMode(ld
, AslBase
);
948 ASSERT_VALID_PTR(dispmode
);
950 width
= SMGetWidth (ld
, AslBase
);
952 SMFixValues(ld
, dispmode
, &width
, 0, 0, AslBase
);
958 struct DisplayMode
*dispmode
;
961 dispmode
= SMGetActiveMode(ld
, AslBase
);
962 ASSERT_VALID_PTR(dispmode
);
964 height
= SMGetWidth (ld
, AslBase
);
966 SMFixValues(ld
, dispmode
, 0, &height
, 0, AslBase
);
970 } /* switch (gadget ID) */
972 break; /* case IDCMP_GADGETUP: */
977 UWORD men
= imsg
->Code
;
979 while(men
!= MENUNULL
)
981 struct MenuItem
*item
;
983 if ((item
= ItemAddress(ld
->ld_Menu
, men
)))
985 switch((IPTR
)GTMENUITEM_USERDATA(item
))
990 SMChangeActiveLVItem(ld
, -1, 0, AslBase
);
994 SMChangeActiveLVItem(ld
, 1, 0, AslBase
);
997 case SMMEN_PROPERTYLIST
:
1000 SMClosePropertyWindow(ld
, AslBase
);
1002 SMOpenPropertyWindow(ld
, AslBase
);
1007 SMRestore(ld
, AslBase
);
1011 retval
= SMGetSelectedMode(ld
, AslBase
);
1020 men
= item
->NextSelect
;
1021 } /* if ((item = ItemAddress(ld->ld_Menu, men))) */
1027 } /* while(men != MENUNULL) */
1029 } /* if (ld->ld_Menu) */
1031 break; /* case IDCMP_MENUPICK: */
1033 } /* switch (imsg->Class) */
1035 ReturnInt ("SMHandleEvents", ULONG
, retval
);
1038 /*****************************************************************************************/
1040 STATIC VOID
SMGadCleanup(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1042 struct SMUserData
*udata
= (struct SMUserData
*)ld
->ld_UserData
;
1043 struct ScreenModeRequester
*req
= (struct ScreenModeRequester
*)ld
->ld_Req
;
1044 struct IntReq
*intreq
= ld
->ld_IntReq
;
1045 struct IntSMReq
*ismreq
= (struct IntSMReq
*)intreq
;
1047 EnterFunc(bug("SMGadCleanup(ld=%p)\n", ld
));
1049 if (ld
->ld_Window
&& ld
->ld_GList
)
1051 RemoveGList(ld
->ld_Window
, ld
->ld_GList
, -1);
1054 killscrollergadget(&udata
->ScrollGad
, AslBase
);
1056 FreeObjects(&SREQ_FIRST_OBJECT(udata
), &SREQ_LAST_OBJECT(udata
), AslBase
);
1058 req
->sm_InfoOpened
= ismreq
->ism_InfoOpened
= ld
->ld_Window2
? TRUE
: FALSE
;
1062 req
->sm_LeftEdge
= intreq
->ir_LeftEdge
= ld
->ld_Window
->LeftEdge
;
1063 req
->sm_TopEdge
= intreq
->ir_TopEdge
= ld
->ld_Window
->TopEdge
;
1064 req
->sm_Width
= intreq
->ir_Width
= ld
->ld_Window
->Width
;
1065 req
->sm_Height
= intreq
->ir_Height
= ld
->ld_Window
->Height
;
1067 req
->sm_InfoLeftEdge
= ismreq
->ism_InfoLeftEdge
;
1068 req
->sm_InfoTopEdge
= ismreq
->ism_InfoTopEdge
;
1070 if (ld
->ld_Window2
) /* can only be open if ld->ld_Window is open, too */
1072 req
->sm_InfoWidth
= ld
->ld_Window2
->Width
;
1073 req
->sm_InfoHeight
= ld
->ld_Window2
->Height
;
1075 SMClosePropertyWindow(ld
, AslBase
);
1079 ReturnVoid("SMGadCleanup");
1082 /*****************************************************************************************/
1084 STATIC ULONG
SMGetSelectedMode(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1086 /*struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData; */
1087 struct IntReq
*intreq
= ld
->ld_IntReq
;
1088 struct IntSMReq
*ismreq
= (struct IntSMReq
*)intreq
;
1089 struct ScreenModeRequester
*req
= (struct ScreenModeRequester
*)ld
->ld_Req
;
1090 struct DisplayMode
*dispmode
;
1091 struct Rectangle
*rect
;
1094 dispmode
= SMGetActiveMode(ld
, AslBase
);
1095 ASSERT_VALID_PTR(dispmode
);
1097 ismreq
->ism_DisplayID
=
1098 req
->sm_DisplayID
= dispmode
->dm_DimensionInfo
.Header
.DisplayID
;
1100 /* OverscanType: This must be before width/height because of rect variable!
1101 ** SMGetOverscan() can handle the case when ASLSM_DoOverscanType
1102 ** is not set to TRUE
1105 ismreq
->ism_OverscanType
=
1106 req
->sm_OverscanType
= SMGetOverscan(ld
, dispmode
, &rect
, AslBase
);
1110 if (ismreq
->ism_Flags
& ISMF_DOWIDTH
)
1112 width
= SMGetWidth(ld
, AslBase
);
1114 width
= rect
->MaxX
- rect
->MinX
+ 1;
1117 SMFixValues(ld
, dispmode
, &width
, 0, 0, AslBase
);
1119 ismreq
->ism_DisplayWidth
=
1120 req
->sm_DisplayWidth
= width
;
1124 if (ismreq
->ism_Flags
& ISMF_DOHEIGHT
)
1126 height
= SMGetHeight(ld
, AslBase
);
1128 height
= rect
->MaxY
- rect
->MinY
+ 1;
1131 SMFixValues(ld
, dispmode
, 0, &height
, 0, AslBase
);
1133 ismreq
->ism_DisplayHeight
=
1134 req
->sm_DisplayHeight
= height
;
1138 if (ismreq
->ism_Flags
& ISMF_DODEPTH
)
1140 ismreq
->ism_DisplayDepth
= SMGetDepth(ld
, 0, AslBase
);
1144 ismreq
->ism_DisplayDepth
= dispmode
->dm_DimensionInfo
.MaxDepth
;
1147 req
->sm_DisplayDepth
= ismreq
->ism_DisplayDepth
;
1150 if (ismreq
->ism_Flags
& ISMF_DOAUTOSCROLL
)
1152 ismreq
->ism_AutoScroll
= SMGetAutoScroll(ld
, AslBase
);
1154 req
->sm_AutoScroll
= ismreq
->ism_AutoScroll
;
1156 return GHRET_FINISHED_OK
;
1159 /*****************************************************************************************/