2 Copyright © 1995-2004, 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 const 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
));
265 retval
= (ULONG
)SMGadLayout(ld
, ASLB(AslBase
));
268 case LDCMD_HANDLEEVENTS
:
269 retval
= (ULONG
)SMHandleEvents(ld
, ASLB(AslBase
));
273 SMGadCleanup(ld
, ASLB(AslBase
));
287 /*****************************************************************************************/
294 #if USE_SHARED_COOLIMAGES
297 const struct CoolImage
*coolimage
;
299 const struct CoolImage
*coolimage
;
304 /*****************************************************************************************/
306 STATIC BOOL
SMGadInit(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
308 struct SMUserData
*udata
= ld
->ld_UserData
;
309 struct IntSMReq
*ismreq
= (struct IntSMReq
*)ld
->ld_IntReq
;
311 #if USE_SHARED_COOLIMAGES
312 struct ButtonInfo bi
[NUMBUTS
] =
314 { ID_BUTOK
, GetIR(ismreq
)->ir_PositiveText
, MSG_MODEREQ_POSITIVE_GAD
, COOL_MONITORIMAGE_ID
, &udata
->OKBut
},
315 { ID_BUTCANCEL
, GetIR(ismreq
)->ir_NegativeText
, MSG_MODEREQ_NEGATIVE_GAD
, COOL_CANCELIMAGE_ID
, &udata
->CancelBut
}
318 struct ButtonInfo bi
[NUMBUTS
] =
320 { ID_BUTOK
, GetIR(ismreq
)->ir_PositiveText
, MSG_MODEREQ_POSITIVE_GAD
, &cool_monitorimage
, &udata
->OKBut
},
321 { ID_BUTCANCEL
, GetIR(ismreq
)->ir_NegativeText
, MSG_MODEREQ_NEGATIVE_GAD
, &cool_cancelimage
, &udata
->CancelBut
}
326 WORD gadrows
, x
, y
, w
, h
, i
, y2
;
327 WORD labelwidth
= 0, maxcyclewidth
= 0;
330 NEWLIST(&udata
->ListviewList
);
332 error
= SMGetModes(ld
, AslBase
);
333 if (error
) goto failure
;
335 error
= ERROR_NO_FREE_STORE
;
337 /* calc. min. size */
340 for(i
= 0; i
< NUMBUTS
; i
++)
342 if(!bi
[i
].text
) bi
[i
].text
= GetString(bi
[i
].deftextid
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
344 x
= TextLength(&ld
->ld_DummyRP
, bi
[i
].text
, strlen(bi
[i
].text
));
346 #if SREQ_COOL_BUTTONS
347 #if USE_SHARED_COOLIMAGES
350 bi
[i
].coolimage
= (const struct CoolImage
*)COOL_ObtainImageA(bi
[i
].coolid
, NULL
);
355 if (ld
->ld_TrueColor
)
357 x
+= IMAGEBUTTONEXTRAWIDTH
+ bi
[i
].coolimage
->width
;
364 udata
->ButWidth
= w
+ BUTTONEXTRAWIDTH
;
366 ld
->ld_ButWidth
= udata
->ButWidth
;
367 ld
->ld_NumButtons
= 4;
369 #if SREQ_COOL_BUTTONS
371 #if USE_SHARED_COOLIMAGES
375 y
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
376 if (ld
->ld_TrueColor
)
378 y2
= IMAGEBUTTONEXTRAHEIGHT
+ DEF_COOLIMAGEHEIGHT
;
382 udata
->ButHeight
= (y
> y2
) ? y
: y2
;
383 #if USE_SHARED_COOLIMAGES
387 udata
->ButHeight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
392 udata
->ButHeight
= BUTTONEXTRAHEIGHT
+ ld
->ld_Font
->tf_YSize
;
395 gadrows
= 1; /* button row */
396 if (ismreq
->ism_Flags
& ISMF_DOOVERSCAN
) gadrows
++;
397 if (ismreq
->ism_Flags
& ISMF_DOWIDTH
) gadrows
++;
398 if (ismreq
->ism_Flags
& ISMF_DOHEIGHT
) gadrows
++;
399 if (ismreq
->ism_Flags
& ISMF_DODEPTH
) gadrows
++;
400 if (ismreq
->ism_Flags
& ISMF_DOAUTOSCROLL
) gadrows
++;
402 ld
->ld_MinWidth
= OUTERSPACINGX
* 2 +
404 udata
->ButWidth
* NUMBUTS
;
406 ld
->ld_MinHeight
= OUTERSPACINGY
* 2 +
407 (GADGETSPACINGY
+ udata
->ButHeight
) * gadrows
+
408 BORDERLVSPACINGY
* 2 +
409 (ld
->ld_Font
->tf_YSize
+ BORDERLVITEMSPACINGY
* 2) * SREQ_MIN_VISIBLELINES
;
411 /* make listview gadget */
413 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
414 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
;
415 w
= -ld
->ld_WBorRight
- ld
->ld_WBorLeft
- OUTERSPACINGX
* 2 - PROPSIZE
;
416 h
= -ld
->ld_WBorBottom
- ld
->ld_WBorTop
- OUTERSPACINGY
* 2 -
417 udata
->ButHeight
* gadrows
-
418 GADGETSPACINGY
* gadrows
;
421 struct TagItem lv_tags
[] =
427 {GA_UserData
, (IPTR
)ld
},
428 {GA_ID
, ID_LISTVIEW
},
429 {GA_RelVerify
, TRUE
},
430 {ASLLV_Labels
, (IPTR
)&udata
->ListviewList
},
431 {ASLLV_Font
, (IPTR
)ld
->ld_Font
},
435 udata
->Listview
= gad
= NewObjectA(AslBase
->asllistviewclass
, NULL
, lv_tags
);
436 if (!udata
->Listview
) goto failure
;
440 /* make scroller gadget for listview */
442 x
= -ld
->ld_WBorRight
- OUTERSPACINGX
- PROPSIZE
+ 1;
443 y
= ld
->ld_WBorTop
+ OUTERSPACINGY
;
445 h
= -ld
->ld_WBorBottom
- ld
->ld_WBorTop
- OUTERSPACINGY
* 2 -
446 udata
->ButHeight
* gadrows
-
447 GADGETSPACINGY
* gadrows
;
449 struct TagItem scroller_tags
[] =
455 {GA_ID
, ID_LISTVIEW
},
456 {PGA_NewLook
, TRUE
},
457 {PGA_Borderless
, TRUE
},
458 {PGA_Freedom
, FREEVERT
},
462 {GA_Previous
, (IPTR
)gad
},
466 if (!makescrollergadget(&udata
->ScrollGad
, ld
, scroller_tags
, AslBase
)) goto failure
;
467 gad
= udata
->ScrollGad
.arrow2
;
470 connectscrollerandlistview(&udata
->ScrollGad
, udata
->Listview
, AslBase
);
472 /* make button row */
474 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
+ 1;
477 struct TagItem button_tags
[] =
482 #if SREQ_COOL_BUTTONS
483 {ASLBT_CoolImage
, 0 },
487 {GA_UserData
, (IPTR
)ld
},
490 {GA_Width
, udata
->ButWidth
},
491 {GA_Height
, udata
->ButHeight
},
492 {GA_RelVerify
, TRUE
},
493 {GA_Image
, 0 }, /* means we want a frame */
497 for(i
= 0; i
< NUMBUTS
; i
++)
499 button_tags
[0].ti_Data
= (IPTR
)bi
[i
].text
;
500 button_tags
[1].ti_Data
= (IPTR
)gad
;
501 button_tags
[2].ti_Data
= bi
[i
].gadid
;
503 #if USE_SHARED_COOLIMAGES
504 if (CoolImagesBase
== NULL
) button_tags
[3].ti_Tag
= TAG_IGNORE
;
506 button_tags
[3].ti_Data
= (IPTR
)bi
[i
].coolimage
;
508 *(bi
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, button_tags
);
509 if (!gad
) goto failure
;
516 if (ismreq
->ism_Flags
& (ISMF_DOOVERSCAN
| ISMF_DOWIDTH
| ISMF_DOHEIGHT
| ISMF_DODEPTH
| ISMF_DOAUTOSCROLL
))
518 #define FSET(x) ((ismreq->ism_Flags & x) ? TRUE : FALSE)
527 {FSET(ISMF_DOOVERSCAN
) , (STRPTR
)MSG_MODEREQ_OVERSCAN_LABEL
, &udata
->OverscanLabel
},
528 {FSET(ISMF_DOWIDTH
) , (STRPTR
)MSG_MODEREQ_WIDTH_LABEL
, &udata
->WidthLabel
},
529 {FSET(ISMF_DOHEIGHT
) , (STRPTR
)MSG_MODEREQ_HEIGHT_LABEL
, &udata
->HeightLabel
},
530 {FSET(ISMF_DODEPTH
) , (STRPTR
)MSG_MODEREQ_COLORS_LABEL
, &udata
->DepthLabel
},
531 {FSET(ISMF_DOAUTOSCROLL
), (STRPTR
)MSG_MODEREQ_AUTOSCROLL_LABEL
, &udata
->AutoScrollLabel
}
536 struct TagItem label_tags
[] =
541 {GA_Height
, udata
->ButHeight
},
543 {GA_Previous
, (IPTR
)gad
},
544 {GA_UserData
, (IPTR
)ld
},
545 {GA_Disabled
, TRUE
},
550 for(i
= 0, i2
= 0; i
< 5; i
++)
554 li
[i
].text
= GetString((LONG
)li
[i
].text
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
555 str
[i2
++] = li
[i
].text
;
559 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
;
560 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
-
561 (udata
->ButHeight
+ GADGETSPACINGY
) * (gadrows
- 1) + 1;
564 w
= labelwidth
= BiggestTextLength(str
, i2
, &(ld
->ld_DummyRP
), AslBase
);
566 label_tags
[1].ti_Data
= y
;
568 for(i
= 0; i
< 5;i
++)
570 if (!li
[i
].doit
) continue;
572 label_tags
[2].ti_Data
= TextLength(&ld
->ld_DummyRP
, li
[i
].text
, strlen(li
[i
].text
));
573 label_tags
[0].ti_Data
= x
+ w
- label_tags
[2].ti_Data
;
574 label_tags
[4].ti_Data
= (IPTR
)li
[i
].text
;
575 label_tags
[5].ti_Data
= (IPTR
)gad
;
577 *(li
[i
].objvar
) = gad
= NewObjectA(AslBase
->aslbuttonclass
, NULL
, label_tags
);
578 if (!gad
) goto failure
;
580 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
581 label_tags
[1].ti_Data
= y
;
584 y
= -ld
->ld_WBorBottom
- OUTERSPACINGY
- udata
->ButHeight
-
585 (udata
->ButHeight
+ GADGETSPACINGY
) * (gadrows
- 1) + 1;
586 x
= ld
->ld_WBorLeft
+ OUTERSPACINGX
+ w
+ LABELSPACINGX
;
588 w
= -ld
->ld_WBorLeft
- ld
->ld_WBorRight
- OUTERSPACINGX
* 2 -
591 /* Make Overscan gadget */
593 if (ismreq
->ism_Flags
& ISMF_DOOVERSCAN
)
595 struct TagItem cycle_tags
[] =
597 {GA_Previous
, (IPTR
)gad
},
601 {GA_Height
, udata
->ButHeight
},
602 {GA_RelVerify
, TRUE
},
603 {GA_UserData
, (IPTR
)ld
},
604 {GA_ID
, ID_OVERSCAN
},
605 {ASLCY_Labels
, (IPTR
)&ismreq
->ism_Overscan1Text
},
606 {ASLCY_Active
, ismreq
->ism_OverscanType
- 1 },
607 {ASLCY_Font
, (IPTR
)ld
->ld_Font
},
611 static LONG labelids
[] =
613 MSG_MODEREQ_OVERSCAN_TEXT
,
614 MSG_MODEREQ_OVERSCAN_GRAPHICS
,
615 MSG_MODEREQ_OVERSCAN_EXTREME
,
616 MSG_MODEREQ_OVERSCAN_MAXIMUM
,
619 STRPTR
*labels
= (STRPTR
*)&ismreq
->ism_Overscan1Text
;
621 for(i
= 0; i
< 4; i
++)
623 labels
[i
] = GetString(labelids
[i
], GetIR(ismreq
)->ir_Catalog
, AslBase
);
626 i
= CYCLEEXTRAWIDTH
+ BiggestTextLength(&ismreq
->ism_Overscan1Text
,
630 if (i
> maxcyclewidth
) maxcyclewidth
= i
;
632 udata
->OverscanGadget
= gad
= NewObjectA(AslBase
->aslcycleclass
, NULL
, cycle_tags
);
633 if (!gad
) goto failure
;
635 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
637 } /* if (ismreq->ism_Flags & ISMF_DOOVERSCAN) */
640 struct TagItem string_tags
[] =
642 {GA_Previous
, (IPTR
)gad
},
644 {STRINGA_LongVal
, ismreq
->ism_DisplayWidth
},
648 {GA_Height
, udata
->ButHeight
},
649 {GA_RelVerify
, TRUE
},
650 {GA_UserData
, (IPTR
)ld
},
651 {GA_TabCycle
, TRUE
},
652 {STRINGA_MaxChars
, 8 },
653 {STRINGA_Font
, (IPTR
)ld
->ld_Font
},
657 /* Make width gadget */
659 if (ismreq
->ism_Flags
& ISMF_DOWIDTH
)
661 udata
->WidthGadget
= gad
= NewObjectA(AslBase
->aslstringclass
, NULL
, string_tags
);
662 if (!gad
) goto failure
;
664 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
667 /* Make height gadget */
669 if (ismreq
->ism_Flags
& ISMF_DOHEIGHT
)
671 string_tags
[0].ti_Data
= (IPTR
)gad
;
672 string_tags
[1].ti_Data
= ID_HEIGHT
;
673 string_tags
[2].ti_Data
= ismreq
->ism_DisplayHeight
;
674 string_tags
[3].ti_Data
= y
;
676 udata
->HeightGadget
= gad
= NewObjectA(AslBase
->aslstringclass
, NULL
, string_tags
);
677 if (!gad
) goto failure
;
679 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
684 struct TagItem cycle_tags
[] =
686 {GA_Previous
, (IPTR
)gad
},
687 {GA_ID
, ID_COLORS
},
693 {GA_Height
, udata
->ButHeight
},
694 {GA_RelVerify
, TRUE
},
695 {GA_UserData
, (IPTR
)ld
},
696 {ASLCY_Font
, (IPTR
)ld
->ld_Font
},
701 /* Make Colors gadget */
703 if (ismreq
->ism_Flags
& ISMF_DODEPTH
)
705 i
= CYCLEEXTRAWIDTH
+ TextLength(&ld
->ld_DummyRP
, "16777216", 8);
706 if (i
> maxcyclewidth
) maxcyclewidth
= i
;
708 udata
->DepthGadget
= gad
= NewObjectA(AslBase
->aslcycleclass
, NULL
, cycle_tags
);
709 if (!gad
) goto failure
;
711 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
714 /* Make AutoScroll gadget */
716 if (ismreq
->ism_Flags
& ISMF_DOAUTOSCROLL
)
718 cycle_tags
[0].ti_Data
= (IPTR
)gad
;
719 cycle_tags
[1].ti_Data
= ID_AUTOSCROLL
;
720 cycle_tags
[2].ti_Data
= (IPTR
)&ismreq
->ism_AutoScrollOFFText
;
721 cycle_tags
[3].ti_Data
= ismreq
->ism_AutoScroll
;
722 cycle_tags
[4].ti_Data
= y
;
724 ismreq
->ism_AutoScrollOFFText
= GetString(MSG_MODEREQ_AUTOSCROLL_OFF
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
725 ismreq
->ism_AutoScrollONText
= GetString(MSG_MODEREQ_AUTOSCROLL_ON
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
727 i
= CYCLEEXTRAWIDTH
+ BiggestTextLength(&ismreq
->ism_AutoScrollOFFText
,
731 if (i
> maxcyclewidth
) maxcyclewidth
= i
;
733 udata
->AutoScrollGadget
= gad
= NewObjectA(AslBase
->aslcycleclass
, NULL
, cycle_tags
);
734 if (!gad
) goto failure
;
736 y
+= udata
->ButHeight
+ GADGETSPACINGY
;
741 } /* if (ismreq->ism_Flags & (ISMF_DOOVERSCAN | ISMF_DOWIDTH | ISMF_DOHEIGHT | ISMF_DODEPTH | ISMF_DOAUTOSCROLL)) */
745 struct TagItem eraser_tags
[] =
747 {GA_Previous
, (IPTR
)gad
},
751 udata
->EraserGadget
= gad
= NewObjectA(AslBase
->asleraserclass
, NULL
, eraser_tags
);
752 /* Doesn't matter if this failed */
756 w
= OUTERSPACINGX
+ labelwidth
+ LABELSPACINGX
+ maxcyclewidth
+ OUTERSPACINGX
;
757 if (w
> ld
->ld_MinWidth
) ld
->ld_MinWidth
= w
;
759 ld
->ld_GList
= (struct Gadget
*)udata
->Listview
;
763 struct NewMenu nm
[] =
765 {NM_TITLE
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL
},
766 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_LASTMODE
, 0, 0, 0, (APTR
)SMMEN_LASTMODE
},
767 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_NEXTMODE
, 0, 0, 0, (APTR
)SMMEN_NEXTMODE
},
768 {NM_ITEM
, NM_BARLABEL
},
769 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_PROPERTIES
, 0, 0, 0, (APTR
)SMMEN_PROPERTYLIST
},
770 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_RESTORE
, 0, 0, 0, (APTR
)SMMEN_RESTORE
},
771 {NM_ITEM
, NM_BARLABEL
},
772 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_OK
, 0, 0, 0, (APTR
)SMMEN_OK
},
773 {NM_ITEM
, (STRPTR
)MSG_MODEREQ_MEN_CONTROL_CANCEL
, 0, 0, 0, (APTR
)SMMEN_CANCEL
},
777 struct TagItem menu_tags
[] =
779 {GTMN_NewLookMenus
, TRUE
},
780 {GTMN_TextAttr
, (IPTR
)GetIR(ismreq
)->ir_TextAttr
},
784 if (menu_tags
[1].ti_Data
== 0) menu_tags
[1].ti_Tag
= TAG_IGNORE
;
786 LocalizeMenus(nm
, GetIR(ismreq
)->ir_Catalog
, AslBase
);
788 /* Don't fail, if menus cannot be created/layouted, because a requester
789 without menus is still better than no requester at all */
791 if ((ld
->ld_Menu
= CreateMenusA(nm
, NULL
)))
793 if (!LayoutMenusA(ld
->ld_Menu
, ld
->ld_VisualInfo
, menu_tags
))
795 FreeMenus(ld
->ld_Menu
);ld
->ld_Menu
= NULL
;
800 SMRestore(ld
, AslBase
);
803 ReturnBool ("SMGadInit", TRUE
);
810 SMGadCleanup(ld
, ASLB(AslBase
));
812 ReturnBool ("SMGadInit", FALSE
);
816 /*****************************************************************************************/
818 STATIC VOID
SMWindowOpened(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
820 struct IntSMReq
*ismreq
= (struct IntSMReq
*)ld
->ld_IntReq
;
822 if (ismreq
->ism_InfoOpened
)
824 SMOpenPropertyWindow(ld
, AslBase
);
828 /*****************************************************************************************/
830 STATIC BOOL
SMGadLayout(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
832 ReturnBool ("SMGadLayout", TRUE
);
835 /*****************************************************************************************/
837 STATIC ULONG
SMHandleEvents(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
839 struct IntuiMessage
*imsg
= ld
->ld_Event
;
840 struct SMUserData
*udata
= (struct SMUserData
*)ld
->ld_UserData
;
842 ULONG retval
= GHRET_OK
;
844 EnterFunc(bug("SMHandleEvents: Class: %d\n", imsg
->Class
));
846 if (imsg
->IDCMPWindow
== ld
->ld_Window2
)
848 return SMHandlePropertyEvents(ld
, imsg
, AslBase
);
853 case IDCMP_CLOSEWINDOW
:
861 SMChangeActiveLVItem(ld
, -1, imsg
->Qualifier
, AslBase
);
865 SMChangeActiveLVItem(ld
, -1, IEQUALIFIER_LSHIFT
, AslBase
);
869 SMChangeActiveLVItem(ld
, -1, IEQUALIFIER_LALT
, AslBase
);
872 case RAWKEY_NM_WHEEL_UP
:
873 SMChangeActiveLVItem(ld
, -3, imsg
->Qualifier
, AslBase
);
877 SMChangeActiveLVItem(ld
, 1, imsg
->Qualifier
, AslBase
);
880 case RAWKEY_PAGEDOWN
:
881 SMChangeActiveLVItem(ld
, 1, IEQUALIFIER_LSHIFT
, AslBase
);
885 SMChangeActiveLVItem(ld
, 1, IEQUALIFIER_LALT
, AslBase
);
888 case RAWKEY_NM_WHEEL_DOWN
:
889 SMChangeActiveLVItem(ld
, 3, imsg
->Qualifier
, AslBase
);
894 case IDCMP_VANILLAKEY
:
904 gadid
= ((struct Gadget
*)imsg
->IAddress
)->GadgetID
;
906 D(bug("GADGETUP! gadgetid=%d\n", gadid
));
915 retval
= SMGetSelectedMode(ld
, AslBase
);
920 struct DisplayMode
*dispmode
;
923 GetAttr(ASLLV_Active
, udata
->Listview
, &active
);
925 if ((dispmode
= (struct DisplayMode
*)FindListNode(&udata
->ListviewList
, (WORD
)active
)))
927 SMActivateMode(ld
, active
, 0, AslBase
);
929 if (imsg
->Code
) /* TRUE if double clicked */
931 retval
= SMGetSelectedMode(ld
, AslBase
);
938 SMChangeActiveLVItem(ld
, 0, 0, AslBase
);
943 struct DisplayMode
*dispmode
;
946 dispmode
= SMGetActiveMode(ld
, AslBase
);
947 ASSERT_VALID_PTR(dispmode
);
949 width
= SMGetWidth (ld
, AslBase
);
951 SMFixValues(ld
, dispmode
, &width
, 0, 0, AslBase
);
957 struct DisplayMode
*dispmode
;
960 dispmode
= SMGetActiveMode(ld
, AslBase
);
961 ASSERT_VALID_PTR(dispmode
);
963 height
= SMGetWidth (ld
, AslBase
);
965 SMFixValues(ld
, dispmode
, 0, &height
, 0, AslBase
);
969 } /* switch (gadget ID) */
971 break; /* case IDCMP_GADGETUP: */
976 UWORD men
= imsg
->Code
;
978 while(men
!= MENUNULL
)
980 struct MenuItem
*item
;
982 if ((item
= ItemAddress(ld
->ld_Menu
, men
)))
984 switch((IPTR
)GTMENUITEM_USERDATA(item
))
989 SMChangeActiveLVItem(ld
, -1, 0, AslBase
);
993 SMChangeActiveLVItem(ld
, 1, 0, AslBase
);
996 case SMMEN_PROPERTYLIST
:
999 SMClosePropertyWindow(ld
, AslBase
);
1001 SMOpenPropertyWindow(ld
, AslBase
);
1006 SMRestore(ld
, AslBase
);
1010 retval
= SMGetSelectedMode(ld
, AslBase
);
1019 men
= item
->NextSelect
;
1020 } /* if ((item = ItemAddress(ld->ld_Menu, men))) */
1026 } /* while(men != MENUNULL) */
1028 } /* if (ld->ld_Menu) */
1030 break; /* case IDCMP_MENUPICK: */
1032 } /* switch (imsg->Class) */
1034 ReturnInt ("SMHandleEvents", ULONG
, retval
);
1037 /*****************************************************************************************/
1039 STATIC VOID
SMGadCleanup(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1041 struct SMUserData
*udata
= (struct SMUserData
*)ld
->ld_UserData
;
1042 struct ScreenModeRequester
*req
= (struct ScreenModeRequester
*)ld
->ld_Req
;
1043 struct IntReq
*intreq
= ld
->ld_IntReq
;
1044 struct IntSMReq
*ismreq
= (struct IntSMReq
*)intreq
;
1046 EnterFunc(bug("SMGadCleanup(ld=%p)\n", ld
));
1048 if (ld
->ld_Window
&& ld
->ld_GList
)
1050 RemoveGList(ld
->ld_Window
, ld
->ld_GList
, -1);
1053 killscrollergadget(&udata
->ScrollGad
, AslBase
);
1055 FreeObjects(&SREQ_FIRST_OBJECT(udata
), &SREQ_LAST_OBJECT(udata
), AslBase
);
1057 req
->sm_InfoOpened
= ismreq
->ism_InfoOpened
= ld
->ld_Window2
? TRUE
: FALSE
;
1061 req
->sm_LeftEdge
= intreq
->ir_LeftEdge
= ld
->ld_Window
->LeftEdge
;
1062 req
->sm_TopEdge
= intreq
->ir_TopEdge
= ld
->ld_Window
->TopEdge
;
1063 req
->sm_Width
= intreq
->ir_Width
= ld
->ld_Window
->Width
;
1064 req
->sm_Height
= intreq
->ir_Height
= ld
->ld_Window
->Height
;
1066 req
->sm_InfoLeftEdge
= ismreq
->ism_InfoLeftEdge
;
1067 req
->sm_InfoTopEdge
= ismreq
->ism_InfoTopEdge
;
1069 if (ld
->ld_Window2
) /* can only be open if ld->ld_Window is open, too */
1071 req
->sm_InfoWidth
= ld
->ld_Window2
->Width
;
1072 req
->sm_InfoHeight
= ld
->ld_Window2
->Height
;
1074 SMClosePropertyWindow(ld
, AslBase
);
1078 ReturnVoid("SMGadCleanup");
1081 /*****************************************************************************************/
1083 STATIC ULONG
SMGetSelectedMode(struct LayoutData
*ld
, struct AslBase_intern
*AslBase
)
1085 /*struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData; */
1086 struct IntReq
*intreq
= ld
->ld_IntReq
;
1087 struct IntSMReq
*ismreq
= (struct IntSMReq
*)intreq
;
1088 struct ScreenModeRequester
*req
= (struct ScreenModeRequester
*)ld
->ld_Req
;
1089 struct DisplayMode
*dispmode
;
1090 struct Rectangle
*rect
;
1093 dispmode
= SMGetActiveMode(ld
, AslBase
);
1094 ASSERT_VALID_PTR(dispmode
);
1096 ismreq
->ism_DisplayID
=
1097 req
->sm_DisplayID
= dispmode
->dm_DimensionInfo
.Header
.DisplayID
;
1099 /* OverscanType: This must be before width/height because of rect variable!
1100 ** SMGetOverscan() can handle the case when ASLSM_DoOverscanType
1101 ** is not set to TRUE
1104 ismreq
->ism_OverscanType
=
1105 req
->sm_OverscanType
= SMGetOverscan(ld
, dispmode
, &rect
, AslBase
);
1109 if (ismreq
->ism_Flags
& ISMF_DOWIDTH
)
1111 width
= SMGetWidth(ld
, AslBase
);
1113 width
= rect
->MaxX
- rect
->MinX
+ 1;
1116 SMFixValues(ld
, dispmode
, &width
, 0, 0, AslBase
);
1118 ismreq
->ism_DisplayWidth
=
1119 req
->sm_DisplayWidth
= width
;
1123 if (ismreq
->ism_Flags
& ISMF_DOHEIGHT
)
1125 height
= SMGetHeight(ld
, AslBase
);
1127 height
= rect
->MaxY
- rect
->MinY
+ 1;
1130 SMFixValues(ld
, dispmode
, 0, &height
, 0, AslBase
);
1132 ismreq
->ism_DisplayHeight
=
1133 req
->sm_DisplayHeight
= height
;
1137 if (ismreq
->ism_Flags
& ISMF_DODEPTH
)
1139 ismreq
->ism_DisplayDepth
= SMGetDepth(ld
, 0, AslBase
);
1141 req
->sm_DisplayDepth
= ismreq
->ism_DisplayDepth
;
1144 if (ismreq
->ism_Flags
& ISMF_DOAUTOSCROLL
)
1146 ismreq
->ism_AutoScroll
= SMGetAutoScroll(ld
, AslBase
);
1148 req
->sm_AutoScroll
= ismreq
->ism_AutoScroll
;
1150 return GHRET_FINISHED_OK
;
1153 /*****************************************************************************************/
1154 /*****************************************************************************************/
1155 /*****************************************************************************************/
1156 /*****************************************************************************************/