grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / asl / modereqsupport.c
blob828f9677b3924d96cd069e512755ffbf542b2fdd
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
7 #include <proto/exec.h>
8 #include <proto/dos.h>
9 #include <proto/intuition.h>
10 #include <proto/graphics.h>
11 #include <proto/utility.h>
12 #include <exec/memory.h>
13 #include <exec/initializers.h>
14 #include <dos/dos.h>
15 #include <graphics/modeid.h>
16 #include <graphics/displayinfo.h>
17 #include <graphics/monitor.h>
18 #include <intuition/gadgetclass.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <clib/macros.h>
23 #include "asl_intern.h"
24 #include "modereqsupport.h"
25 #include "modereqhooks.h"
26 #include "layout.h"
28 #define CATCOMP_NUMBERS
29 #include "strings.h"
31 #define SDEBUG 0
32 #define DEBUG 0
33 //#define ADEBUG 0
35 #include <aros/debug.h>
37 /*****************************************************************************************/
39 static WORD SMCompareNodes(struct IntSMReq *ismreq, struct DisplayMode *node1,
40 struct DisplayMode *node2, struct AslBase_intern *AslBase)
42 return Stricmp(node1->dm_Node.ln_Name, node2->dm_Node.ln_Name);
45 /*****************************************************************************************/
47 LONG SMGetModes(struct LayoutData *ld, struct AslBase_intern *AslBase)
49 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
50 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
51 struct DisplayMode *dispmode;
52 struct DimensionInfo diminfo;
53 struct DisplayInfo dispinfo;
54 struct NameInfo nameinfo;
55 UBYTE name[DISPLAYNAMELEN + 1];
56 ULONG displayid = INVALID_ID;
58 while(INVALID_ID != (displayid = NextDisplayInfo(displayid)))
60 D(bug("SMGetModes: DisplayID 0x%8x\n", displayid));
62 if ((GetDisplayInfoData(NULL, (APTR)&diminfo , sizeof(diminfo) , DTAG_DIMS, displayid) > 0) &&
63 (GetDisplayInfoData(NULL, (APTR)&dispinfo, sizeof(dispinfo), DTAG_DISP, displayid) > 0))
65 D(bug("SMGetModes: Got DimensionInfo and DisplayInfo\n"));
67 D(bug("SMGetModes: diminfo.displayid = 0x%8x\n", diminfo.Header.DisplayID));
69 if (GetDisplayInfoData(NULL, (APTR)&nameinfo, sizeof(nameinfo), DTAG_NAME, displayid) > 0)
71 D(bug("SMGetModes: Got NameInfo. Name = \"%s\"\n", nameinfo.Name));
73 strcpy(name, nameinfo.Name);
74 } else {
75 sprintf(name, "%dx%dx%d",
76 diminfo.Nominal.MaxX - diminfo.Nominal.MinX + 1,
77 diminfo.Nominal.MaxY - diminfo.Nominal.MinY + 1,
78 diminfo.MaxDepth);
79 D(bug("SMGetModes: No NameInfo. Making by hand. Name = \"%s\"\n", name));
82 if ((dispinfo.PropertyFlags & ismreq->ism_PropertyMask) !=
83 (ismreq->ism_PropertyFlags & ismreq->ism_PropertyMask)) continue;
85 if (diminfo.MaxDepth < ismreq->ism_MinDepth) continue;
86 if (diminfo.MaxDepth > 8)
88 if (ismreq->ism_MaxDepth < diminfo.MaxDepth) continue;
90 else
92 if (dispinfo.PropertyFlags & (DIPF_IS_HAM | DIPF_IS_EXTRAHALFBRITE))
94 if (ismreq->ism_MaxDepth < 6) continue;
98 if ((diminfo.MinRasterWidth > ismreq->ism_MaxWidth ) ||
99 (diminfo.MaxRasterWidth < ismreq->ism_MinWidth ) ||
100 (diminfo.MinRasterHeight > ismreq->ism_MaxHeight) ||
101 (diminfo.MaxRasterHeight < ismreq->ism_MinHeight)) continue;
103 if (ismreq->ism_FilterFunc)
105 #ifdef __MORPHOS__
107 ULONG ret;
109 REG_A4 = (ULONG)ismreq->ism_IntReq.ir_BasePtr; /* Compatability */
110 REG_A0 = (ULONG)ismreq->ism_FilterFunc;
111 REG_A2 = (ULONG)ld->ld_Req;
112 REG_A1 = (ULONG)displayid;
113 ret = (*MyEmulHandle->EmulCallDirect68k)(ismreq->ism_FilterFunc->h_Entry);
115 if (ret == 0)
116 continue;
118 #else
119 if (CallHookPkt(ismreq->ism_FilterFunc, ld->ld_Req, (APTR)(IPTR)displayid) == 0)
120 continue;
121 #endif
124 dispmode = AllocPooled(ld->ld_IntReq->ir_MemPool, sizeof(struct DisplayMode));
125 if (!dispmode) return ERROR_NO_FREE_STORE;
127 diminfo.Header.DisplayID = displayid; /* AROS bug? */
129 dispmode->dm_DimensionInfo = diminfo;
130 dispmode->dm_PropertyFlags = dispinfo.PropertyFlags;
131 dispmode->dm_Node.ln_Name = PooledCloneString(name, NULL, ld->ld_IntReq->ir_MemPool, AslBase);
133 SortInNode(ismreq, &udata->ListviewList, &dispmode->dm_Node, (APTR)SMCompareNodes, AslBase);
135 } /* if diminfo and dispinfo could be retrieved */
137 } /* while(INVALID_ID != (displayid = NextDisplayInfo(displayid))) */
139 if (ismreq->ism_CustomSMList)
141 struct DisplayMode *succ;
143 ForeachNodeSafe(ismreq->ism_CustomSMList, dispmode, succ)
145 /* custom modes must have displayID from range 0xFFFF0000 .. 0xFFFFFFFF */
147 if (dispmode->dm_DimensionInfo.Header.DisplayID < 0xFFFF0000) continue;
149 Remove(&dispmode->dm_Node);
150 SortInNode(ismreq, &udata->ListviewList, &dispmode->dm_Node, (APTR)SMCompareNodes, AslBase);
154 return IsListEmpty(&udata->ListviewList) ? ERROR_NO_MORE_ENTRIES : 0;
159 /*****************************************************************************************/
161 struct DisplayMode *SMGetActiveMode(struct LayoutData *ld, struct AslBase_intern *AslBase)
163 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
164 IPTR active;
166 GetAttr(ASLLV_Active, udata->Listview, &active);
168 return (struct DisplayMode *)FindListNode(&udata->ListviewList, active);
171 /*****************************************************************************************/
173 void SMChangeActiveLVItem(struct LayoutData *ld, WORD delta, UWORD quali, struct AslBase_intern *AslBase)
175 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
176 IPTR active, total, visible;
178 GetAttr(ASLLV_Active , udata->Listview, &active );
179 GetAttr(ASLLV_Total , udata->Listview, &total );
180 GetAttr(ASLLV_Visible, udata->Listview, &visible);
182 if (quali & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
184 delta *= (visible - 1);
186 else if (quali & (IEQUALIFIER_LALT | IEQUALIFIER_RALT | IEQUALIFIER_CONTROL))
188 delta *= total;
191 active += delta;
193 if (((LONG)active) < 0) active = 0;
194 if (active >= total) active = total - 1;
196 SMActivateMode(ld, active, 0, AslBase);
200 /*****************************************************************************************/
202 UWORD SMGetOverscan(struct LayoutData *ld, struct DisplayMode *dispmode,
203 struct Rectangle **rect, struct AslBase_intern *AslBase)
205 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
206 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
207 UWORD overscantype = ismreq->ism_OverscanType;
208 IPTR val;
210 if (ismreq->ism_Flags & ISMF_DOOVERSCAN)
212 GetAttr(ASLCY_Active, udata->OverscanGadget, &val);
213 overscantype = val + 1;
216 if (rect)
218 *rect = &dispmode->dm_DimensionInfo.Nominal;
220 if (overscantype == OSCAN_TEXT)
222 *rect = &dispmode->dm_DimensionInfo.TxtOScan;
224 else if (overscantype == OSCAN_STANDARD)
226 *rect = &dispmode->dm_DimensionInfo.StdOScan;
228 else if (overscantype == OSCAN_MAX)
230 *rect = &dispmode->dm_DimensionInfo.MaxOScan;
232 else if (overscantype == OSCAN_VIDEO)
234 *rect = &dispmode->dm_DimensionInfo.VideoOScan;
238 return overscantype;
241 /*****************************************************************************************/
243 void SMFixValues(struct LayoutData *ld, struct DisplayMode *dispmode,
244 LONG *width, LONG *height, LONG *depth, struct AslBase_intern *AslBase)
246 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
247 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
248 struct Rectangle *rect;
249 struct TagItem set_tags[] =
251 {STRINGA_LongVal , 0 },
252 {TAG_DONE }
255 SMGetOverscan(ld, dispmode, &rect, AslBase);
257 if (width)
259 if (*width < ismreq->ism_MinWidth)
260 *width = ismreq->ism_MinWidth;
261 else if (*width > ismreq->ism_MaxWidth)
262 *width = ismreq->ism_MaxWidth;
264 if (*width < dispmode->dm_DimensionInfo.MinRasterWidth)
265 *width = dispmode->dm_DimensionInfo.MinRasterWidth;
266 else if (*width > dispmode->dm_DimensionInfo.MaxRasterWidth)
267 *width = dispmode->dm_DimensionInfo.MaxRasterWidth;
269 if (ismreq->ism_Flags & ISMF_DOWIDTH)
271 set_tags[0].ti_Data = *width;
273 SetGadgetAttrsA((struct Gadget *)udata->WidthGadget, ld->ld_Window, NULL, set_tags);
276 } /* if (width) */
278 if (height)
280 if (*height < ismreq->ism_MinHeight)
281 *height = ismreq->ism_MinHeight;
282 else if (*height > ismreq->ism_MaxHeight)
283 *height = ismreq->ism_MaxHeight;
285 if (*height < dispmode->dm_DimensionInfo.MinRasterHeight)
286 *height = dispmode->dm_DimensionInfo.MinRasterHeight;
287 else if (*height > dispmode->dm_DimensionInfo.MaxRasterHeight)
288 *height = dispmode->dm_DimensionInfo.MaxRasterHeight;
290 if (ismreq->ism_Flags & ISMF_DOHEIGHT)
292 set_tags[0].ti_Data = *height;
294 SetGadgetAttrsA((struct Gadget *)udata->HeightGadget, ld->ld_Window, NULL, set_tags);
297 } /* if (height) */
301 /*****************************************************************************************/
303 void SMActivateMode(struct LayoutData *ld, WORD which, LONG depth, struct AslBase_intern *AslBase)
305 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
306 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
307 struct DisplayMode *dispmode;
308 struct Rectangle *rect;
309 struct TagItem set_tags[] =
311 {ASLLV_Active , 0 },
312 {ASLLV_MakeVisible , 0 },
313 {TAG_DONE }
315 LONG width, height;
317 dispmode = (struct DisplayMode *)FindListNode(&udata->ListviewList, which);
319 if (!dispmode) return; /* Should never happen */
321 set_tags[0].ti_Data = set_tags[1].ti_Data = which;
323 SetGadgetAttrsA((struct Gadget *)udata->Listview, ld->ld_Window, NULL, set_tags);
325 if (ismreq->ism_Flags & ISMF_DODEPTH)
327 STRPTR *array = udata->Colorarray;
328 STRPTR text = udata->Colortext;
329 WORD i = 0, min, max, bestmatch;
331 set_tags[0].ti_Tag = ASLCY_Labels;
332 set_tags[0].ti_Data = 0;
333 set_tags[1].ti_Tag = ASLCY_Active;
334 set_tags[2].ti_Data = 0;
336 if (depth == 0) depth = SMGetDepth(ld, 0, AslBase);
338 SetGadgetAttrsA((struct Gadget *)udata->DepthGadget, ld->ld_Window, NULL, set_tags);
340 if (dispmode->dm_DimensionInfo.MaxDepth > 8)
342 sprintf(text, "%ld", 1L << dispmode->dm_DimensionInfo.MaxDepth);
343 *array++ = text;
345 udata->ColorDepth[0] =
346 udata->RealColorDepth[0] = dispmode->dm_DimensionInfo.MaxDepth;
348 udata->NumColorEntries = 1;
351 else if (dispmode->dm_PropertyFlags & DIPF_IS_EXTRAHALFBRITE)
353 *array++ = "64";
355 udata->ColorDepth[0] =
356 udata->RealColorDepth[0] = 6;
358 udata->NumColorEntries = 1;
360 else if (dispmode->dm_PropertyFlags & DIPF_IS_HAM)
362 udata->NumColorEntries = 0;
364 if (ismreq->ism_MinDepth <= 6)
366 *array++ = "4096";
368 udata->ColorDepth[udata->NumColorEntries] = 6;
369 udata->RealColorDepth[udata->NumColorEntries] = 12;
371 udata->NumColorEntries++;
374 if ((dispmode->dm_DimensionInfo.MaxDepth == 8) &&
375 (ismreq->ism_MaxDepth >= 8))
377 *array++ = "16777216";
379 udata->ColorDepth[udata->NumColorEntries] = 8;
380 udata->RealColorDepth[udata->NumColorEntries] = 24;
382 udata->NumColorEntries++;
385 else
387 max = ismreq->ism_MaxDepth;
388 if (dispmode->dm_DimensionInfo.MaxDepth < max)
389 max = dispmode->dm_DimensionInfo.MaxDepth;
391 min = ismreq->ism_MinDepth;
392 if (min > max) max = min;
394 for(i = min; i <= max; i++)
396 sprintf(text, "%ld", 1L << i);
397 *array++ = text;
399 udata->ColorDepth[i - min] =
400 udata->RealColorDepth[i - min] = i;
402 text += strlen(text) + 1;
405 udata->NumColorEntries = max - min + 1;
409 *array++ = NULL;
411 set_tags[0].ti_Data = (IPTR)udata->Colorarray;
413 bestmatch = 1000;
414 for(i = 0; i < udata->NumColorEntries; i++)
416 WORD match = depth - udata->ColorDepth[i];
418 if (match < 0) match = -match;
420 if (match < bestmatch)
422 bestmatch = match;
423 set_tags[1].ti_Data = i;
427 SetGadgetAttrsA((struct Gadget *)udata->DepthGadget, ld->ld_Window, NULL, set_tags);
429 } /* if (ismreq->ism_Flags & ISMF_DODEPTH) */
431 SMGetOverscan(ld, dispmode, &rect, AslBase);
433 width = rect->MaxX - rect->MinX + 1;
434 height = rect->MaxY - rect->MinY + 1;
436 SMFixValues(ld, dispmode, &width, &height, 0, AslBase);
438 SMRefreshPropertyWindow(ld, dispmode, AslBase);
441 /*****************************************************************************************/
443 void SMRestore(struct LayoutData *ld, struct AslBase_intern *AslBase)
445 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
446 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
447 struct DisplayMode *dispmode;
448 LONG i = 0, active = 0;
449 LONG width = ismreq->ism_DisplayWidth;
450 LONG height = ismreq->ism_DisplayHeight;
452 /* the order of the function calls is important! */
454 if (ismreq->ism_Flags & ISMF_DOOVERSCAN)
456 SMSetOverscan(ld, ismreq->ism_OverscanType, AslBase);
459 if (ismreq->ism_Flags & ISMF_DOAUTOSCROLL)
461 SMSetAutoScroll(ld, ismreq->ism_AutoScroll, AslBase);
464 ForeachNode(&udata->ListviewList, dispmode)
466 if (dispmode->dm_DimensionInfo.Header.DisplayID == ismreq->ism_DisplayID)
468 active = i;
469 break;
471 i++;
474 SMActivateMode(ld, active, ismreq->ism_DisplayDepth, AslBase);
476 dispmode = SMGetActiveMode(ld, AslBase);
477 ASSERT_VALID_PTR(dispmode);
479 SMFixValues(ld, dispmode, &width, &height, 0, AslBase);
483 /*****************************************************************************************/
485 LONG SMGetStringValue(struct LayoutData *ld, Object *obj, struct AslBase_intern *AslBase)
487 IPTR val;
489 ASSERT_VALID_PTR(obj);
491 GetAttr(STRINGA_LongVal, obj, &val);
493 return (LONG)val;
496 /*****************************************************************************************/
498 LONG SMGetWidth(struct LayoutData *ld, struct AslBase_intern *AslBase)
500 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
502 ASSERT(udata->WidthGadget);
504 return SMGetStringValue(ld, udata->WidthGadget, AslBase);
507 /*****************************************************************************************/
509 LONG SMGetHeight(struct LayoutData *ld, struct AslBase_intern *AslBase)
511 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
513 ASSERT(udata->HeightGadget);
515 return SMGetStringValue(ld, udata->HeightGadget, AslBase);
518 /*****************************************************************************************/
520 LONG SMGetDepth(struct LayoutData *ld, LONG *realdepth, struct AslBase_intern *AslBase)
522 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
523 IPTR active;
525 ASSERT(udata->DepthGadget);
527 GetAttr(ASLCY_Active, udata->DepthGadget, &active);
529 if (realdepth) *realdepth = udata->RealColorDepth[active];
531 return udata->ColorDepth[active];
534 /*****************************************************************************************/
536 BOOL SMGetAutoScroll(struct LayoutData *ld, struct AslBase_intern *AslBase)
538 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
539 IPTR active;
541 ASSERT(udata->AutoScrollGadget);
543 GetAttr(ASLCY_Active, udata->AutoScrollGadget, &active);
545 return active ? TRUE : FALSE;
548 /*****************************************************************************************/
550 void SMSetDepth(struct LayoutData *ld, UWORD id, struct AslBase_intern *AslBase)
552 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
553 struct TagItem set_tags[] =
555 {ASLCY_Active , id },
556 {TAG_DONE }
559 ASSERT(udata->DepthGadget);
561 SetGadgetAttrsA((struct Gadget *)udata->DepthGadget, ld->ld_Window, NULL, set_tags);
565 /*****************************************************************************************/
567 void SMSetOverscan(struct LayoutData *ld, UWORD oscan, struct AslBase_intern *AslBase)
569 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
570 struct TagItem set_tags[] =
572 {ASLCY_Active , oscan - 1 },
573 {TAG_DONE }
576 ASSERT(udata->OverscanGadget);
578 SetGadgetAttrsA((struct Gadget *)udata->OverscanGadget, ld->ld_Window, NULL, set_tags);
582 /*****************************************************************************************/
584 void SMSetAutoScroll(struct LayoutData *ld, BOOL onoff, struct AslBase_intern *AslBase)
586 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
587 struct TagItem set_tags[] =
589 {ASLCY_Active , onoff },
590 {TAG_DONE }
593 ASSERT(udata->AutoScrollGadget);
595 SetGadgetAttrsA((struct Gadget *)udata->AutoScrollGadget, ld->ld_Window, NULL, set_tags);
599 /*****************************************************************************************/
601 void SMOpenPropertyWindow(struct LayoutData *ld, struct AslBase_intern *AslBase)
603 static WORD propertyids[] =
605 MSG_MODEREQ_PROPERTIES_NOTWB,
606 MSG_MODEREQ_PROPERTIES_NOTGENLOCK,
607 MSG_MODEREQ_PROPERTIES_NOTDRAG,
608 MSG_MODEREQ_PROPERTIES_HAM,
609 MSG_MODEREQ_PROPERTIES_EHB,
610 MSG_MODEREQ_PROPERTIES_LACE,
611 MSG_MODEREQ_PROPERTIES_ECS,
612 MSG_MODEREQ_PROPERTIES_WB,
613 MSG_MODEREQ_PROPERTIES_GENLOCK,
614 MSG_MODEREQ_PROPERTIES_DRAG,
615 MSG_MODEREQ_PROPERTIES_DPFPRI2,
616 MSG_MODEREQ_PROPERTIES_REFRESHRATE,
620 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
621 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
622 struct DisplayMode *dispmode;
623 STRPTR *properties = (STRPTR *)&ismreq->ism_PropertyList_NotWB;
624 WORD i, x, y, w, h;
626 if (ld->ld_Window2) return;
628 for(i = 0; propertyids[i] != -1; i++)
630 properties[i] = GetString(propertyids[i], GetIR(ismreq)->ir_Catalog, AslBase);
633 x = ld->ld_Window->LeftEdge + ismreq->ism_InfoLeftEdge;
634 y = ld->ld_Window->TopEdge + ismreq->ism_InfoTopEdge;
636 i = (&SREQ_LAST_PROPERTY_ITEM(ismreq) - &SREQ_FIRST_PROPERTY_ITEM(ismreq)) /
637 sizeof(STRPTR) + 1;
640 w = BiggestTextLength(&SREQ_FIRST_PROPERTY_ITEM(ismreq),
642 &(ld->ld_DummyRP),
643 AslBase);
645 w += OUTERSPACINGX * 2 + BORDERLVSPACINGX * 2 + BORDERLVITEMSPACINGX * 2;
647 h = SREQ_MAX_PROPERTIES * (ld->ld_Font->tf_YSize + BORDERLVITEMSPACINGY * 2);
649 h += OUTERSPACINGY * 2 + BORDERLVSPACINGY * 2;
652 struct TagItem lv_tags[] =
654 {GA_Left , ld->ld_WBorLeft + OUTERSPACINGX },
655 {GA_Top , ld->ld_WBorTop + OUTERSPACINGY },
656 {GA_Width , w - OUTERSPACINGX * 2 },
657 {GA_Height , h - OUTERSPACINGY * 2 },
658 {GA_UserData , (IPTR)ld },
659 {ASLLV_ReadOnly , TRUE },
660 {ASLLV_Font , (IPTR)ld->ld_Font },
661 {TAG_DONE }
664 udata->PropertyGadget = NewObjectA(AslBase->asllistviewclass, NULL, lv_tags);
665 if (!udata->PropertyGadget) return;
670 struct TagItem win_tags[] =
672 {WA_CustomScreen , (IPTR)ld->ld_Screen },
673 {WA_Title , 0 },
674 {WA_Left , x },
675 {WA_Top , y },
676 {WA_InnerWidth , w },
677 {WA_InnerHeight , h },
678 {WA_AutoAdjust , TRUE },
679 {WA_CloseGadget , TRUE },
680 {WA_DepthGadget , TRUE },
681 {WA_DragBar , TRUE },
682 {WA_SimpleRefresh , TRUE },
683 {WA_NoCareRefresh , TRUE },
684 {WA_IDCMP , 0 },
685 {WA_Gadgets , (IPTR)udata->PropertyGadget },
686 {TAG_DONE }
689 win_tags[1].ti_Data = (IPTR)GetString(MSG_MODEREQ_PROPERTIES_TITLE, GetIR(ismreq)->ir_Catalog, AslBase);
691 ld->ld_Window2 = OpenWindowTagList(0, win_tags);
692 if (!ld->ld_Window2)
694 DisposeObject(udata->PropertyGadget);
695 udata->PropertyGadget = 0;
696 return;
699 ld->ld_Window2->UserPort = ld->ld_Window->UserPort;
700 ModifyIDCMP(ld->ld_Window2, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY);
703 dispmode = SMGetActiveMode(ld, AslBase);
704 ASSERT_VALID_PTR(dispmode);
706 SMRefreshPropertyWindow(ld, dispmode, AslBase);
709 /*****************************************************************************************/
711 void SMClosePropertyWindow(struct LayoutData *ld, struct AslBase_intern *AslBase)
713 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
714 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
716 if (!ld->ld_Window2) return;
718 RemoveGadget(ld->ld_Window2, (struct Gadget *)udata->PropertyGadget);
719 DisposeObject(udata->PropertyGadget);
720 udata->PropertyGadget = 0;
722 ismreq->ism_InfoLeftEdge = ld->ld_Window2->LeftEdge - ld->ld_Window->LeftEdge;
723 ismreq->ism_InfoTopEdge = ld->ld_Window2->TopEdge - ld->ld_Window->TopEdge;
725 CloseWindowSafely(ld->ld_Window2, AslBase);
727 ld->ld_Window2 = 0;
730 /*****************************************************************************************/
732 ULONG SMHandlePropertyEvents(struct LayoutData *ld, struct IntuiMessage *imsg, struct AslBase_intern *AslBase)
734 switch(imsg->Class)
736 case IDCMP_VANILLAKEY:
737 if (imsg->Code != 27) break;
738 /* fall through */
740 case IDCMP_CLOSEWINDOW:
741 SMClosePropertyWindow(ld, AslBase);
742 break;
744 } /* switch(imsg->Class) */
746 return GHRET_OK;
749 /*****************************************************************************************/
751 void SMRefreshPropertyWindow(struct LayoutData *ld, struct DisplayMode *dispmode, struct AslBase_intern *AslBase)
753 struct SMUserData *udata = (struct SMUserData *)ld->ld_UserData;
754 struct IntSMReq *ismreq = (struct IntSMReq *)ld->ld_IntReq;
755 struct TagItem set_tags[] =
757 {ASLLV_Labels, 0 },
758 {TAG_DONE }
760 struct Node *node = udata->PropertyNodes;
762 #define OF(x) (ULONG)(OFFSET(IntSMReq, ism_PropertyList_ ## x))
764 static struct propertyinfo
766 ULONG mask;
767 ULONG flags;
768 ULONG offset;
769 } *pi, pitable [] =
771 {DIPF_IS_WB , 0 , OF(NotWB) },
772 {DIPF_IS_GENLOCK , 0 , OF(NotGenlock) },
773 {DIPF_IS_DRAGGABLE , 0 , OF(NotDraggable) },
774 {DIPF_IS_HAM , DIPF_IS_HAM , OF(HAM) },
775 {DIPF_IS_EXTRAHALFBRITE , DIPF_IS_EXTRAHALFBRITE, OF(EHB) },
776 {DIPF_IS_LACE , DIPF_IS_LACE , OF(Interlace) },
777 {DIPF_IS_ECS , DIPF_IS_ECS , OF(ECS) },
778 {DIPF_IS_WB , DIPF_IS_WB , OF(WB) },
779 {DIPF_IS_GENLOCK , DIPF_IS_GENLOCK , OF(Genlock) },
780 {DIPF_IS_DRAGGABLE , DIPF_IS_DRAGGABLE , OF(Draggable) },
781 {DIPF_IS_PF2PRI , DIPF_IS_PF2PRI , OF(DPFPri2) },
782 {0 , 0 , 0 }
785 if (!ld->ld_Window2) return;
787 SetGadgetAttrsA((struct Gadget *)udata->PropertyGadget, ld->ld_Window2, NULL, set_tags);
789 NEWLIST(&udata->PropertyList);
791 for(pi = pitable; pi->mask != 0; pi++)
793 if ((dispmode->dm_PropertyFlags & pi->mask) == pi->flags)
795 node->ln_Name = *(STRPTR *)(((UBYTE *)ismreq) + pi->offset);
796 AddTail(&udata->PropertyList, node);
797 node++;
800 set_tags[0].ti_Data = (IPTR)&udata->PropertyList;
802 SetGadgetAttrsA((struct Gadget *)udata->PropertyGadget, ld->ld_Window2, NULL, set_tags);
806 /*****************************************************************************************/
807 /*****************************************************************************************/
808 /*****************************************************************************************/
809 /*****************************************************************************************/