6 #include <exec/types.h>
7 #include <graphics/gels.h>
8 #include <graphics/rastport.h>
9 #include <intuition/classes.h>
10 #include <intuition/classusr.h>
11 #include <utility/hooks.h>
12 #include <intuition/gadgetclass.h>
13 #include <workbench/workbench.h>
14 #include <dos/dostags.h>
15 #include <dos/datetime.h>
19 #include <proto/dos.h>
20 #include <proto/exec.h>
21 #include <proto/intuition.h>
22 #include <proto/graphics.h>
23 #include <proto/utility.h>
24 #include <proto/locale.h>
26 #include <proto/scalos.h>
28 #include <clib/alib_protos.h>
31 #include <scalos/scalos.h>
32 #include <scalos/GadgetBar.h>
38 #include "scalos_structures.h"
39 #include "functions.h"
40 #include "Variables.h"
42 //----------------------------------------------------------------------------
44 BOOL
StatusBarAdd(struct internalScaWindowTask
*iwt
)
48 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
50 if (iwt
->iwt_StatusBar
)
51 return TRUE
; // StatusBar already present
52 if (iwt
->iwt_BackDrop
)
53 return FALSE
; // no statusbar for backdrop windows
55 d1(kprintf("%s/%s/%ld: StatusBar BgPen=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
56 PalettePrefs
.pal_PensList
[PENIDX_STATUSBAR_BG
]));
58 iwt
->iwt_StatusBar
= (struct Gadget
*) SCA_NewScalosObjectTags("GadgetBar.sca",
59 GBDTA_WindowTask
, (ULONG
) iwt
,
60 GBDTA_Position
, GBPOS_Bottom
,
63 GA_ID
, GADGETID_STATUSBAR
,
64 GBDTA_BGPen
, PalettePrefs
.pal_PensList
[PENIDX_STATUSBAR_BG
],
65 GBDTA_BackgroundImageName
, (ULONG
) "THEME:Window/StatusBar/Background",
68 if (NULL
== iwt
->iwt_StatusBar
)
71 d1(KPrintF("%s/%s/%ld: Height=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Height
));
72 d1(KPrintF("%s/%s/%ld: tf_YSize=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iInfos
.xii_iinfos
.ii_Screen
->RastPort
.Font
->tf_YSize
));
74 iwt
->iwt_StatusBarMembers
[STATUSBARGADGET_StatusText
] = (struct Gadget
*) SCA_NewScalosObjectTags("GadgetBarText.sca",
75 GBTDTA_Text
, (ULONG
) "Ä???g",
76 GBTDTA_TextFont
, (ULONG
) iInfos
.xii_iinfos
.ii_Screen
->RastPort
.Font
,
77 GBTDTA_TTFont
, (ULONG
) &ScreenTTFont
,
78 GBTDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_STATUSBAR_TEXT
],
79 GBTDTA_Justification
, GACT_STRINGCENTER
,
80 GA_ID
, SBAR_GadgetID_Text
,
82 if (NULL
== iwt
->iwt_StatusBarMembers
[STATUSBARGADGET_StatusText
])
85 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_AddToStatusBar
,
86 iwt
->iwt_StatusBarMembers
[STATUSBARGADGET_StatusText
],
90 if (IsShowAll(iwt
->iwt_WindowTask
.mt_WindowStruct
))
92 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
93 iwt
->iwt_StatusBarMembers
[STATUSBARGADGET_ShowAll
] = (struct Gadget
*) SCA_NewScalosObjectTags("GadgetBarImage.sca",
94 DTA_Name
, (ULONG
) "THEME:Window/StatusBar/ShowAll",
95 GBIDTA_WindowTask
, (ULONG
) iwt
,
96 GA_ID
, SBAR_GadgetID_ShowAll
,
99 if (NULL
== iwt
->iwt_StatusBarMembers
[STATUSBARGADGET_ShowAll
])
102 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
,
103 SCCM_IconWin_AddToStatusBar
,
104 iwt
->iwt_StatusBarMembers
[STATUSBARGADGET_ShowAll
],
108 d1(KPrintF("%s/%s/%ld: Height=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Height
));
110 if (iwt
->iwt_WindowTask
.wt_Window
)
111 AddGList(iwt
->iwt_WindowTask
.wt_Window
, iwt
->iwt_StatusBar
, ~0, 1, NULL
);
113 // Layout Status bar so we can query the required height
114 DoGadgetMethod(iwt
->iwt_StatusBar
,
115 iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_Window
, NULL
,
117 NULL
, // GadgetInfo is filled in by DoGadgetMethod
120 GetAttr(GA_Height
, (Object
*) iwt
->iwt_StatusBar
, &Height
);
122 d1(KPrintF("%s/%s/%ld: Height=%ld gg->Height=%ld iwt_GadgetBarHeightBottom=%ld\n", \
123 __FILE__
, __FUNC__
, __LINE__
, Height
, iwt
->iwt_StatusBar
->Height
, iwt
->iwt_GadgetBarHeightBottom
));
124 d1(KPrintF("%s/%s/%ld: iwt_ExtraHeight=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_ExtraHeight
));
125 d1(KPrintF("%s/%s/%ld: iwt_InnerBottom=%ld\n", \
126 __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_InnerBottom
));
128 iwt
->iwt_ExtraHeight
+= Height
;
129 iwt
->iwt_InnerBottom
+= iwt
->iwt_GadgetBarHeightBottom
;
130 iwt
->iwt_InnerHeight
-= iwt
->iwt_InnerBottom
;
132 d1(KPrintF("%s/%s/%ld: iwt_ExtraHeight=%ld iwt_GadgetBarHeightBottom=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_ExtraHeight
, iwt
->iwt_GadgetBarHeightBottom
));
133 d1(KPrintF("%s/%s/%ld: iwt_InnerBottom=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_InnerBottom
));
138 //----------------------------------------------------------------------------
140 void StatusBarRemove(struct internalScaWindowTask
*iwt
)
142 if (iwt
->iwt_StatusBar
)
144 d1(kprintf("%s/%s/%ld: iwt_ExtraHeight=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_ExtraHeight
));
146 if (iwt
->iwt_WindowTask
.wt_Window
)
147 RemoveGList(iwt
->iwt_WindowTask
.wt_Window
, iwt
->iwt_StatusBar
, 1);
149 d1(KPrintF("%s/%s/%ld: iwt_InnerBottom=%ld\n", \
150 __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_InnerBottom
));
152 iwt
->iwt_ExtraHeight
-= iwt
->iwt_GadgetBarHeightBottom
;
153 iwt
->iwt_InnerBottom
-= iwt
->iwt_GadgetBarHeightBottom
;
154 iwt
->iwt_InnerHeight
+= iwt
->iwt_GadgetBarHeightBottom
;
156 DisposeObject((Object
*) iwt
->iwt_StatusBar
);
157 iwt
->iwt_StatusBar
= NULL
;
159 memset(iwt
->iwt_StatusBarMembers
, 0, sizeof(iwt
->iwt_StatusBarMembers
));
161 d1(KPrintF("%s/%s/%ld: iwt_InnerBottom=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_InnerBottom
));
165 //----------------------------------------------------------------------------
167 UWORD
StatusBarQueryGadgetID(struct internalScaWindowTask
*iwt
,
168 const struct ExtGadget
*gg
, WORD x
, WORD y
)
173 d1(KPrintF("%s/%s/%ld: x=%ld y=%ld\n", __FILE__
, __FUNC__
, __LINE__
, x
, y
));
175 xy
= ((x
- gg
->LeftEdge
) << 16) + y
- gg
->TopEdge
;
177 d1(KPrintF("%s/%s/%ld: LeftEdge=%ld TopEdge=%ld\n", __FILE__
, __FUNC__
, __LINE__
, gg
->LeftEdge
, gg
->TopEdge
));
178 d1(KPrintF("%s/%s/%ld: MoreFlags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, gg
->MoreFlags
));
182 // for some unknown reason, DoGadgetMethod(GM_HELPTEST) always
183 // seems to return GMR_NOHELPHIT (0).
184 // So, as a work-around, the GadgetInfo is built here manually,
185 // and DoMethod() is called directly, wich works as expected.
186 struct GadgetInfo GInfo
;
188 memset(&GInfo
, 0, sizeof(GInfo
));
190 GInfo
.gi_Screen
= iwt
->iwt_WindowTask
.wt_Window
->WScreen
;
191 GInfo
.gi_Window
= iwt
->iwt_WindowTask
.wt_Window
;
192 GInfo
.gi_Requester
= NULL
;
193 GInfo
.gi_RastPort
= iwt
->iwt_WindowTask
.wt_Window
->RPort
;
194 GInfo
.gi_Layer
= iwt
->iwt_WindowTask
.wt_Window
->RPort
->Layer
;
195 GInfo
.gi_Domain
.Left
= 0;
196 GInfo
.gi_Domain
.Top
= 0;
197 GInfo
.gi_Domain
.Width
= iwt
->iwt_WindowTask
.wt_Window
->Width
;
198 GInfo
.gi_Domain
.Height
= iwt
->iwt_WindowTask
.wt_Window
->Height
;
199 GInfo
.gi_DrInfo
= iInfos
.xii_iinfos
.ii_DrawInfo
;
200 GInfo
.gi_Pens
.DetailPen
= iInfos
.xii_iinfos
.ii_DrawInfo
->dri_Pens
[DETAILPEN
];
201 GInfo
.gi_Pens
.BlockPen
= iInfos
.xii_iinfos
.ii_DrawInfo
->dri_Pens
[BLOCKPEN
];
202 GInfo
.gi_Gadget
= (struct Gadget
*) gg
;
204 Code
= DoMethod((Object
*) gg
,
209 #else // __amigaos4__
210 Code
= DoGadgetMethod((struct Gadget
*) gg
, iwt
->iwt_WindowTask
.wt_Window
, NULL
,
212 NULL
, // GadgetInfo is inserted here
214 #endif // __amigaos4__
215 d1(KPrintF("%s/%s/%ld: Code=%04lx\n", __FILE__
, __FUNC__
, __LINE__
, Code
));
220 //----------------------------------------------------------------------------