make sure "S" is generated.
[AROS-Contrib.git] / scalos / main / Prefs.c
blobe2dce23602be812a391ae47bca63159c94b9774e
1 // Prefs.c
2 // $Date$
3 // $Revision$
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 <workbench/startup.h>
15 #include <libraries/gadtools.h>
16 #include <libraries/pm.h>
17 #include <libraries/iffparse.h>
18 #include <libraries/ttengine.h>
19 #include <libraries/mcpgfx.h>
20 #include <prefs/font.h>
21 #include <prefs/prefhdr.h>
22 #include <prefs/pointer.h>
23 #include <prefs/workbench.h>
24 #include <dos/dostags.h>
26 #define __USE_SYSBASE
28 #include <proto/dos.h>
29 #include <proto/exec.h>
30 #include <proto/layers.h>
31 #include <proto/intuition.h>
32 #include <proto/graphics.h>
33 #include <proto/utility.h>
34 #include <proto/icon.h>
35 #include <proto/iconobject.h>
36 #ifdef __AROS__
37 #include <proto/popupmenu.h>
38 #else
39 #include <proto/pm.h>
40 #endif
41 #include <proto/iffparse.h>
42 #include <proto/preferences.h>
43 #include <proto/datatypes.h>
44 #include <proto/guigfx.h>
45 #include <proto/gadtools.h>
46 #include <proto/diskfont.h>
47 #include "debug.h"
48 #include <proto/scalos.h>
50 #include <clib/alib_protos.h>
52 #include <defs.h>
53 #include <datatypes/iconobject.h>
54 #include <scalos/palette.h>
55 #include <scalos/pattern.h>
56 #include <scalos/scalos.h>
57 #include <scalos/scalosprefs.h>
58 #include <scalos/GadgetBar.h>
59 #include <scalos/scalospreviewplugin.h>
61 #include <stdlib.h>
62 #include <stdio.h>
63 #include <ctype.h>
64 #include <string.h>
65 #include <stddef.h>
66 #include <assert.h>
68 #include "scalos_structures.h"
69 #include "FsAbstraction.h"
70 #include "functions.h"
71 #include "locale.h"
72 #include "Variables.h"
74 #include "IconImageClass.h"
76 //----------------------------------------------------------------------------
78 // local data structures
80 #define INITIAL_CRC ((ULONG) ~0)
82 #define ID_MAIN MAKE_ID('M','A','I','N')
83 #define PS_DATA(prefsstruct) ((STRPTR) (prefsstruct)) + sizeof((prefsstruct)->ps_Size)
85 struct WBCFChunk
87 ULONG wbcf_Version; // 1
88 WORD wbcf_XOffset;
89 WORD wbcf_YOffset;
90 WORD wbcf_LeftEdge;
91 WORD wbcf_TopEdge;
92 WORD wbcf_Width;
93 WORD wbcf_Height;
94 ULONG wbcf_Flags;
97 #define WBCF_FLAGF_Backdrop 0x00010000
99 //----------------------------------------------------------------------------
101 // local data items
103 static const char DefaultMainWindowTitle[] = "%pa %d( %dp%% full, %DF free, %DU in use %d)";
104 static const char DefaultWindowTitle[] = "%pa";
105 static const char DefaultScreenTitle[] = "Scalos V%wb %fc graphics mem %ff other mem";
107 static BYTE UnderlineSoftLinkNames = TRUE;
109 static ULONG PalettePrefsCRC = 0;
110 static ULONG PatternPrefsCRC = 0;
111 static ULONG FontPrefsCRC = 0;
112 static ULONG MainPrefsCRC = 0;
114 //----------------------------------------------------------------------------
116 // public data items
118 struct Hook *globalCopyHook = NULL;
119 struct Hook *globalDeleteHook = NULL;
120 struct Hook *globalTextInputHook = NULL;
122 struct List globalCloseWBHookList; // Hooks in this list will be called on AppSleep/AppWakeup
124 struct List ControlBarGadgetListNormal; // List of control bar gadgets for standard windows
125 struct List ControlBarGadgetListBrowser; // List of control bar gadgets for browser-mode windows
127 SCALOSSEMAPHORE CopyHookSemaphore;
128 SCALOSSEMAPHORE DeleteHookSemaphore;
129 SCALOSSEMAPHORE TextInputHookSemaphore;
130 SCALOSSEMAPHORE CloseWBHookListSemaphore;
132 struct PatternNode *PatternNodes = NULL; // +jl+ 20010826
134 static const struct ScalosFontPrefs DefaultFontPrefs =
136 1, // fprf_FontFrontPen
137 0, // fprf_FontBackPen
138 JAM1, // fprf_TextDrawModeSel
139 JAM1, // fprf_TextDrawMode
140 { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT }, // fprf_TextAttr
141 NULL, // fprf_AllocName
144 static const struct ScalosPalettePrefs DefaultPalettePrefs =
146 NULL, // pal_ScreenColorList
147 { 0 }, // pal_AllocatedPens
149 0, 0, // PENIDX_HSHINEPEN, PENIDX_HSHADOWPEN
150 2, // PENIDX_ICONTEXTOUTLINEPEN
151 3, 2, // PENIDX_DRAWERTEXT, PENIDX_DRAWERTEXTSEL
152 3, // PENIDX_DRAWERBG
153 1, 2, // PENIDX_FILETEXT, PENIDX_FILETEXTSEL
154 1, // PENIDX_FILEBG
155 0, 0, // PENIDX_BACKDROPDETAIL, PENIDX_BACKDROPBLOCK
156 1, 2, // PENIDX_TOOLTIP_TEXT, PENIDX_TOOLTIP_BG
157 1, 2, // PENIDX_DRAGINFOTEXT_TEXT, PENIDX_DRAGINFOTEXT_BG
158 2, 1, // PENIDX_STATUSBAR_BG, PENIDX_STATUSBAR_TEXT
159 1, // PENIDX_ICONTEXTPEN,
160 2, 0, // PENIDX_ICONTEXTPENSEL, PENIDX_ICONTEXTSHADOWPEN
161 0, // PENIDX_THUMBNAILBACKGROUNDPEN
162 0, // PENIDX_THUMBNAILBACKGROUNDPENSEL
163 3, // PENIDX_ICONTEXTPENBGSEL
164 }, // pal_PensList
165 { 0 }, // pal_origPensList
166 { -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1 }, // pal_driPens
169 static const struct ScalosPrefs DefaultPrefs =
171 NULL, // pref_Handle
173 FALSE, // pref_AutoCleanupOnResize
174 FALSE, // pref_AutoLeaveOut
175 FALSE, // pref_MarkIconUnderMouse
177 DRAGTYPE_ImageAndText, // pref_DragType
178 TRUE, // pref_AutoRemoveFlag
179 DRAGMETHOD_Custom, // pref_DragMethod
181 64, // pref_ThumbNailWidth
182 64, // pref_ThumbNailHeight
183 14, // pref_ThumbnailMaxAge
184 128, // pref_ThumbnailMinSizeLimit
185 THUMBNAILS_Never, // pref_ShowThumbnails
186 TRUE, // pref_ShowThumbnailsAsDefault
187 SCALOSPREVIEWA_Quality_Max, // pref_ThumbnailQuality
188 FALSE, // pref_ThumbnailsSquare
190 { 2, 2, 2, 2 }, // pref_ThumbnailImageBorders
191 FALSE, // pref_ThumbnailFillBackground
192 50, // pref_ThumbnailBackgroundTransparency
194 { 0xff, 0x22, 0x22, 0x22 }, // pref_IconHighlightK
195 DRAGTRANSPMODE_SolidAndTransp, // pref_DragTranspMode
197 DRAGTRANSPF_DiskIcons | DRAGTRANSPB_DrawerIcons | DRAGTRANSPB_TrashcanIcons, // pref_DragTranspObjects
199 TRUE, // pref_RealTransFlag
200 IDTV_WinDropMark_WindowedOnly, // pref_WindowDropMarkMode
202 FALSE, // pref_DefaultShowAllFiles
203 IDTV_ViewModes_Icon, // pref_DefaultViewBy
205 FALSE, // pref_SelectTextIconName
207 { 5, 4, 5, 3 }, // pref_CleanupSpace
209 #ifdef __AROS__
210 "ENVARC:sys", // pref_DefIconPath
211 #else
212 "ENV:sys", // pref_DefIconPath
213 #endif
215 FALSE, // pref_TextWindowStriped
216 TRUE, // pref_ShowDDCountText
217 TRUE, // pref_DDIconsMayOverlap
218 FALSE, // pref_UseOldDragIcons
219 TRUE, // pref_DisplayStatusBar
220 TRUE, // pref_EnableTooltips
221 TRUE, // pref_EnableSplash
222 TRUE, // pref_EnablePopupWindows
223 5, // pref_SplashHoldTime
225 { 0, 1, 2, 3, 4, 5, -1 }, // pref_ColumnsArray
227 3, // pref_TypeRestartTime
229 3, // pref_PopupWindowDelaySeconds
231 60000, // pref_FileCountTimeout (ms)
232 1000, // pref_FileTransWindowDelay
234 "CON:0/11//150/Scalos Output Window/AUTO/WAIT", // pref_ConsoleName
236 DefaultMainWindowTitle, // pref_MainWindowTitle
237 DefaultWindowTitle, // pref_StandardWindowTitle
239 "SYS:WBStartup", // pref_WBStartupDir
240 "Scalos:", // pref_ScalosHomeDir
241 "Sys:System/DiskCopy", // pref_DefDiskCopy
242 "Scalos:Thumbnails.db", // pref_ThumbDatabasePath
243 "Scalos:Themes", // pref_ThemesDir
244 "t:", // pref_ImageCacheDir
245 "t:", // pref_SQLiteTempDir
247 '.', // GroupSeparator
248 5, // pref_TitleRefreshSec
249 FALSE, // pref_RefreshOnMemChg
251 5, // pref_WinTitleRefreshSec
252 FALSE, // pref_WinRefreshOnMemChg
254 #if defined(__MORPHOS__)
255 TRUE, // pref_CheckOverlappingIcons
256 #else /* __MORPHOS__ */
257 FALSE, // pref_CheckOverlappingIcons
258 #endif /* __MORPHOS__ */
260 IDTV_TextMode_Normal, // pref_TextMode
261 FALSE, // pref_MenuCurrentDir
262 TRUE, // pref_SaveDefIcons
263 TRUE, // pref_DefIconsFirst
264 TRUE, // pref_ClickTransp
265 FALSE, // pref_SmartRefresh
266 TRUE, // pref_UseExAll
267 FALSE, // pref_CreateSoftLinks
268 5, // pref_DiskRefresh
269 5, // pref_DoWaitDelay
270 FALSE, // pref_MMBMoveFlag
271 FALSE, // pref_FullPopupFlag
272 FALSE, // pref_HideHiddenFlag
274 FALSE, // pref_HideProtectHiddenFlag
276 FALSE, // pref_DragStartFlag
277 FALSE, // pref_EasyMultiselectFlag
278 FALSE, // pref_EasyMultiDragFlag
279 FALSE, // pref_DisableCloseWorkbench
280 FALSE, // pref_PopTitleFlag
281 FALSE, // pref_FullBenchFlag
282 TRUE, // pref_HardEmulation
283 TRUE, // pref_WBBackdrop
284 FALSE, // pref_IconTextMuliLine
285 FALSE, // pref_EnableDropMenu
286 FALSE, // pref_SelectedTextRectangle
288 MF_FRAME_NONE, // pref_FrameType
289 MF_FRAME_NONE | 0x8000, // pref_FrameTypeSel
290 MF_FRAME_NONE, // pref_ThumbnailFrameType
291 MF_FRAME_NONE | 0x8000, // pref_ThumbnailFrameTypeSel
292 { 2, 2, 2, 2 }, // pref_ImageBorders
293 1, // pref_TextSkip
295 4, // pref_SelTextRectBorderX
296 2, // pref_SelTextRectBorderY
297 5, // pref_SelTextRectRadius
299 0xff00, // pref_DefaultLinePattern
300 3, // pref_DefLineSpeed
302 20, // pref_WindowHScroll
303 20, // pref_WindowVScroll
305 { 100, 100, 200, 100 }, // pref_DefWindowBox
306 { 0, 0, 200, 100 }, // pref_WBWindowBox
308 0, // pref_WBWindowXOffset
309 0, // pref_WBWindowYOffset
311 IEQUALIFIER_CONTROL, // pref_CopyQualifier
312 IEQUALIFIER_LSHIFT, // pref_PopupApplySelectedQualifier
313 IEQUALIFIER_LALT, // pref_MakeLinkQualifier
314 IEQUALIFIER_CONTROL | IEQUALIFIER_LSHIFT, // pref_ForceMoveQualifier
315 IEQUALIFIER_CONTROL, // pref_SingleWindowLassoQualifier
316 FALSE, // pref_PopupApplySelectedAlways
318 #if defined(__AROS__)
319 { { 0 }, { 200000 } }, // pref_ClickDelay
320 #else
321 { 0, 200000 }, // pref_ClickDelay
322 #endif
324 IDTV_IconType_NewIcon | IDTV_IconType_ColorIcon, // pref_SupportedIconTypes
326 FSF_UNDERLINED, // pref_LinkTextStyle
328 2, // pref_ToolTipDelaySeconds
330 16384, // pref_DefaultStackSize
332 600, // pref_WindowTitleSize
333 1000, // pref_ScreenTitleSize
335 DefaultScreenTitle, // pref_ScreenTitle
337 50, // pref_DragTransparency
338 25, // pref_IconShadowTransparency
339 70, // pref_DefaultIconTransparency
340 PREFS_TRANSPARENCY_OPAQUE, // pref_TooltipsTransparency
342 2, // pref_iCandy
344 TT_Antialias_Auto, // pref_TTFontAntialias
345 2500, // pref_TTFontGamma
346 "0/400/11/Arial", // pref_ScreenTTFontDescriptor
347 "0/400/11/Arial", // pref_IconTTFontDescriptor
348 "0/400/11/Arial", // pref_TextWindowTTFontDescriptor
350 FALSE, // pref_UseScreenTTFont
351 FALSE, // pref_UseIconTTFont
352 FALSE, // pref_UseTextWindowTTFont
354 262144, // pref_CopyBuffLen
356 { 0, 0, SHRT_MAX, SHRT_MAX }, // pref_IconSizeConstraints
358 100, // pref_IconScaleFactor
361 ICONLAYOUT_Columns,
362 ICONLAYOUT_Columns, //WBDISK
363 ICONLAYOUT_Columns, //WBDRAWER
364 ICONLAYOUT_Rows, //WBTOOL
365 ICONLAYOUT_Rows, //WBPROJECT
366 ICONLAYOUT_Columns, //WBGARBAGE
367 ICONLAYOUT_Columns, //WBDEVICE
368 ICONLAYOUT_Columns, //WBKICK
369 ICONLAYOUT_Rows, //WBAPPICON
370 }, // pref_DeviceWindowLayoutModes
372 ICONLAYOUT_Columns,
373 ICONLAYOUT_Columns, //WBDISK
374 ICONLAYOUT_Columns, //WBDRAWER
375 ICONLAYOUT_Columns, //WBTOOL
376 ICONLAYOUT_Columns, //WBPROJECT
377 ICONLAYOUT_Columns, //WBGARBAGE
378 ICONLAYOUT_Columns, //WBDEVICE
379 ICONLAYOUT_Columns, //WBKICK
380 ICONLAYOUT_Columns, //WBAPPICON
381 }, // pref_IconWindowLayoutModes
384 { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT },
385 NULL
386 }, // pref_TextModeTextAttr
389 { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT },
390 NULL
391 }, // pref_IconFontAttr
393 PREFS_TRANSPARENCY_OPAQUE, // pref_ActiveWindowTransparency
394 PREFS_TRANSPARENCY_OPAQUE, // pref_InactiveWindowTransparency
396 { (UBYTE) ~0, 133, 195, 221 }, // pref_SelectMarkerBaseColor
397 128, // pref_SelectMarkerTransparency
398 10, // pref_MaxUndoSteps
399 DRAWER_SORT_First, // pref_DrawerSortMode
402 static const struct ScalosPatternPrefs DefaultPatternPrefs =
404 TRUE, // pref_AsyncBackFill
405 FALSE, // pref_UseFriendBitMap
406 FALSE, // pref_NewRenderFlag
407 TRUE, // pref_RandomizeEverytime
409 1, // pref_DefWBPatternNr
410 3, // pref_DefWindowPatternNr
411 0, // pref_DefTextWinPatternNr
412 2, // pref_DefScreenPatternNr
414 -3, // AsyncProcTaskPri
417 struct ScalosPrefs CurrentPrefs;
418 struct ScalosPalettePrefs PalettePrefs;
419 struct ScalosPatternPrefs PatternPrefs;
420 struct ScalosFontPrefs FontPrefs;
422 //----------------------------------------------------------------------------
424 // local functions
426 static CONST_STRPTR GetPrefsConfigString(APTR prefsHandle, ULONG Id, CONST_STRPTR DefaultString);
427 static void InternalFreeScalosPrefs(struct ScalosPrefs *Prefs);
428 static void CreatePatternNode(struct IFFHandle *iff, const struct ContextNode *cn);
429 static void ReadPatternDefaults(struct IFFHandle *iff);
430 static SAVEDS(LONG) PatternNodeCompareFunc(struct Hook *theHook, struct PatternNode *pNode2,
431 struct PatternNode *pNode1);
432 static void FreePatternNode(struct PatternNode **PatternNodeList, struct PatternNode *pNode);
433 static ULONG NewPaletteProc(APTR arg, struct SM_RunProcess *msg);
434 static void ShowScreenTitle(BOOL showTitle);
435 static void SetTextAttr(struct ScalosTextAttr *Attr, struct PrefsStruct *ps);
436 static void CleanupControlBarGadgetsList(struct List *CbGadgetsList);
437 static void ReadControlBarGadgetList(APTR p_MyPrefsHandle, LONG lID, struct List *CbGadgetsList,
438 ULONG prefsIDGadgets, ULONG prefsIDStrings);
440 //----------------------------------------------------------------------------
442 ULONG ReadPalettePrefs(void)
444 LONG n, Result;
445 struct IFFHandle *iff;
446 BOOL iffOpened = FALSE;
448 do {
449 iff = AllocIFF();
450 if (NULL == iff)
452 Result = IoErr();
453 break;
456 InitIFFasDOS(iff);
458 iff->iff_Stream = (IPTR) Open("ENV:Scalos/Palette13.prefs", MODE_OLDFILE);
459 if (0 == iff->iff_Stream)
460 iff->iff_Stream = (IPTR) Open("ENV:Scalos/Palette.prefs", MODE_OLDFILE);
462 PalettePrefsCRC = GetPrefsCRCFromFH((BPTR) iff->iff_Stream);
463 d1(KPrintF("%s/%s/%ld: PalettePrefsCRC=%08lx\n", __FILE__, __FUNC__, __LINE__, PalettePrefsCRC));
465 if (0 == iff->iff_Stream)
467 Result = IoErr();
468 break;
471 FreePalettePrefs();
473 PalettePrefs.pal_driPens[0] = 0;
474 PalettePrefs.pal_driPens[1] = 1;
476 for (n=2; n<sizeof(PalettePrefs.pal_driPens)/sizeof(PalettePrefs.pal_driPens[0]); n++)
478 PalettePrefs.pal_driPens[n] = ~0;
481 Result = OpenIFF(iff, IFFF_READ);
482 if (RETURN_OK != Result)
483 break;
485 iffOpened = TRUE;
487 Result = StopChunk(iff, ID_PREF, ID_SPAL);
488 if (RETURN_OK != Result)
489 break;
491 Result = StopChunk(iff, ID_PREF, ID_PENS);
492 if (RETURN_OK != Result)
493 break;
495 while (RETURN_OK == Result)
497 struct ContextNode *cn;
499 Result = ParseIFF(iff, IFFPARSE_SCAN);
500 if (RETURN_OK != Result)
501 break;
503 cn = CurrentChunk(iff);
504 if (NULL == cn)
505 continue;
507 if (ID_PENS == cn->cn_ID)
509 LONG Actual;
510 WORD Pen, PenCount;
512 Actual = ReadChunkBytes(iff, &PenCount, sizeof(PenCount));
513 if (Actual < 0)
514 break;
516 PenCount = SCA_BE2WORD(PenCount);
518 d1(KPrintF("%s/%s/%ld: PenCount=%ld\n", __FILE__, __FUNC__, __LINE__, PenCount));
520 if (PenCount < 2)
521 break;
523 for (Pen=0; Pen<PenCount; Pen++)
525 struct ScalosPen sPen;
527 if (ReadChunkBytes(iff, &sPen, sizeof(sPen)) >= 0)
529 WORD Index = sPen.sp_pentype = SCA_BE2WORD(sPen.sp_pentype);
530 sPen.sp_pen = SCA_BE2WORD(sPen.sp_pen);
532 d1(KPrintF("%s/%s/%ld: Pen=%ld Index=%ld PenNr=%ld\n", __FILE__, __FUNC__, __LINE__, Pen, Index, sPen.sp_pen));
534 if (Index >= 0)
536 // leave room for trailing "-1" in driPens
537 if (Index < sizeof(PalettePrefs.pal_driPens)-2)
539 PalettePrefs.pal_driPens[Index] = sPen.sp_pen;
542 else
544 Index = ~Index; // -1 ==> 0 !!!
546 if (Index < PENIDX_MAX)
548 PalettePrefs.pal_origPensList[Index] = PalettePrefs.pal_PensList[Index] = sPen.sp_pen;
549 d1(KPrintF("%s/%s/%ld: PalettePrefs.pal_PensList[%ld]=%ld\n", __FILE__, __FUNC__, __LINE__, \
550 Index, PalettePrefs.pal_PensList[Index]));
556 else if (ID_SPAL == cn->cn_ID)
558 LONG Actual;
560 PalettePrefs.pal_ScreenColorList = ScalosAlloc(cn->cn_Size + 16);
561 d1(KPrintF("%s/%s/%ld: ScreenColorList=%08lx\n", __FILE__, __FUNC__, __LINE__, PalettePrefs.pal_ScreenColorList));
562 if (NULL == PalettePrefs.pal_ScreenColorList)
563 continue;
565 Actual = ReadChunkBytes(iff, PalettePrefs.pal_ScreenColorList, cn->cn_Size);
567 d1(KPrintF("%s/%s/%ld: Read Palette Size=%ld Actual=%ld\n", __FILE__, __FUNC__, __LINE__, cn->cn_Size, Actual));
568 if (Actual < 0)
570 Result = IoErr();
572 ScalosFree(PalettePrefs.pal_ScreenColorList);
573 PalettePrefs.pal_ScreenColorList = NULL;
574 break;
578 } while (0);
580 if (iff)
582 if (iffOpened)
583 CloseIFF(iff);
585 if (iff->iff_Stream)
586 Close((BPTR) iff->iff_Stream);
588 FreeIFF(iff);
591 if (NULL == PalettePrefs.pal_ScreenColorList)
593 // couldn't read palette prefs
594 PalettePrefs.pal_driPens[0] = ~0;
597 return (ULONG) Result;
601 void FreePalettePrefs(void)
603 d1(KPrintF("%s/%s/%ld: ScreenColorList=%08lx\n", __FILE__, __FUNC__, __LINE__, PalettePrefs.pal_ScreenColorList));
605 UnlockScalosPens();
607 if (PalettePrefs.pal_ScreenColorList)
609 ScalosFree(PalettePrefs.pal_ScreenColorList);
610 PalettePrefs.pal_ScreenColorList = NULL;
615 void ReadFontPrefs(void)
617 struct IFFHandle *iff;
618 struct FontPrefs *FontChunk = NULL;
619 BOOL IffOpened = FALSE;
621 FreeFontPrefs();
622 FontPrefs = DefaultFontPrefs;
624 do {
625 iff = AllocIFF();
626 if (NULL == iff)
627 break;
629 InitIFFasDOS(iff);
631 iff->iff_Stream = (IPTR) Open("ENV:sys/font.prefs", MODE_OLDFILE);
633 d1(KPrintF("%s/%s/%ld: iff_Stream=%08lx\n", __FILE__, __FUNC__, __LINE__, iff->iff_Stream));
634 if (0 == iff->iff_Stream)
635 break;
637 FontPrefsCRC = GetPrefsCRCFromFH((BPTR) iff->iff_Stream);
638 d1(KPrintF("%s/%s/%ld: FontPrefsCRC=%08lx\n", __FILE__, __FUNC__, __LINE__, FontPrefsCRC));
640 if (RETURN_OK != OpenIFF(iff, IFFF_READ))
641 break;
643 d1(KPrintF("%s/%s/%ld: OpenIFF() OK\n", __FILE__, __FUNC__, __LINE__));
644 IffOpened = TRUE;
646 if (RETURN_OK != StopChunk(iff, ID_PREF, ID_FONT))
647 break;
649 d1(KPrintF("%s/%s/%ld: StopChunk() OK\n", __FILE__, __FUNC__, __LINE__));
651 while (1)
653 // We should read three successive FontChunk's, with different fp_Type:
654 // FP_WBFONT = Workbench icon font
655 // FP_SYSFONT = System default font
656 // FP_SCREENFONT = Screen font
657 struct ContextNode *cn;
659 if (RETURN_OK != ParseIFF(iff, IFFPARSE_SCAN))
660 break;
662 d1(KPrintF("%s/%s/%ld: ParseIFF() OK\n", __FILE__, __FUNC__, __LINE__));
664 cn = CurrentChunk(iff);
666 d1(KPrintF("%s/%s/%ld: CurrentChunk=%08lx\n", __FILE__, __FUNC__, __LINE__, cn));
667 if (NULL == cn)
668 break;
670 d1(KPrintF("%s/%s/%ld: CurrentChunk=%08lx Size=%lu\n", __FILE__, __FUNC__, __LINE__, cn, cn->cn_Size));
672 FontChunk = ScalosAlloc(cn->cn_Size);
673 d1(KPrintF("%s/%s/%ld: FontChunk=%08lx\n", __FILE__, __FUNC__, __LINE__, FontChunk));
674 if (NULL == FontChunk)
675 break;
677 if (ReadChunkBytes(iff, FontChunk, cn->cn_Size) < 0)
678 break;
680 d1(KPrintF("%s/%s/%ld: ReadChunkBytes OK\n", __FILE__, __FUNC__, __LINE__));
682 FontChunk->fp_Type = SCA_BE2WORD(FontChunk->fp_Type);
683 FontChunk->fp_TextAttr.ta_YSize = SCA_BE2WORD(FontChunk->fp_TextAttr.ta_YSize);
685 if (FP_WBFONT == FontChunk->fp_Type)
687 FontPrefs.fprf_FontFrontPen = FontChunk->fp_FrontPen;
688 FontPrefs.fprf_FontBackPen = FontChunk->fp_BackPen;
689 FontPrefs.fprf_TextDrawModeSel = FontPrefs.fprf_TextDrawMode = FontChunk->fp_DrawMode;
691 d1(KPrintF("%s/%s/%ld: FrontPen=%ld BackPen=%ld DrawMode=%ld\n", \
692 __FILE__, __FUNC__, __LINE__, FontChunk->fp_FrontPen, FontChunk->fp_BackPen, FontChunk->fp_DrawMode));
694 if (FontPrefs.fprf_AllocName)
695 ScalosFree(FontPrefs.fprf_AllocName);
697 FontPrefs.fprf_TextAttr = FontChunk->fp_TextAttr;
698 FontPrefs.fprf_AllocName = ScalosAlloc(1 + strlen(FontChunk->fp_Name));
699 if (FontPrefs.fprf_AllocName)
701 strcpy(FontPrefs.fprf_AllocName, FontChunk->fp_Name);
702 FontPrefs.fprf_TextAttr.ta_Name = FontPrefs.fprf_AllocName;
704 else
706 FontPrefs.fprf_TextAttr.ta_Name = (STRPTR) "topaz.font";
709 d1(KPrintF("%s/%s/%ld: fp_Name=<%s>\n", __FILE__, __FUNC__, __LINE__, FontChunk->fp_Name));
710 d1(KPrintF("%s/%s/%ld: iconfont=<%s> YSize=%ld\n", __FILE__, __FUNC__, __LINE__, \
711 FontPrefs.fprf_TextAttr.ta_Name, FontPrefs.fprf_TextAttr.ta_YSize));
714 d1(KPrintF("%s/%s/%ld: FontAttr.ta_Name=<%s>\n", __FILE__, __FUNC__, __LINE__, FontPrefs.fprf_TextAttr.ta_Name));
716 ScalosFree(FontChunk);
717 FontChunk = NULL;
719 } while (0);
721 if (FontChunk)
722 ScalosFree(FontChunk);
723 if (iff)
725 if (IffOpened)
726 CloseIFF(iff);
727 if (iff->iff_Stream)
728 Close((BPTR) iff->iff_Stream);
729 FreeIFF(iff);
734 void FreeFontPrefs(void)
739 LONG WriteWBConfig(void)
741 struct IFFHandle *iff;
742 struct PrefHeader prhd;
743 struct WBCFChunk wbcf;
744 BOOL IffOpen = FALSE;
745 LONG Result = RETURN_OK;
746 struct internalScaWindowTask *iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
748 memset(&prhd, 0, sizeof(prhd));
750 d1(KPrintF("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
752 do {
753 iff = AllocIFF();
754 if (NULL == iff)
755 break;
757 d1(KPrintF("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
759 InitIFFasDOS(iff);
761 iff->iff_Stream = (IPTR) Open("ENVARC:sys/wbconfig.prefs", MODE_NEWFILE);
762 if (0 == iff->iff_Stream)
763 break;
765 d1(KPrintF("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
767 Result = OpenIFF(iff, IFFF_WRITE);
768 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
769 if (RETURN_OK != Result)
770 break;
772 IffOpen = TRUE;
774 Result = PushChunk(iff, ID_PREF, ID_FORM, IFFSIZE_UNKNOWN);
775 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
776 if (RETURN_OK != Result)
777 break;
779 Result = PushChunk(iff, 0, ID_PRHD, IFFSIZE_UNKNOWN);
780 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
781 if (RETURN_OK != Result)
782 break;
784 if (WriteChunkBytes(iff, &prhd, sizeof(prhd)) < 0)
785 break;
787 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
789 Result = PopChunk(iff);
790 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
791 if (RETURN_OK != Result)
792 break;
794 Result = PushChunk(iff, 0, MAKE_ID('W','B','C','F'), IFFSIZE_UNKNOWN);
795 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
796 if (RETURN_OK != Result)
797 break;
799 wbcf.wbcf_Version = 1;
801 if (iwtMain->iwt_BackDrop)
803 wbcf.wbcf_XOffset = CurrentPrefs.pref_WBWindowXOffset;
804 wbcf.wbcf_YOffset = CurrentPrefs.pref_WBWindowYOffset;
806 wbcf.wbcf_LeftEdge = CurrentPrefs.pref_WBWindowBox.Left;
807 wbcf.wbcf_TopEdge = CurrentPrefs.pref_WBWindowBox.Top;
808 wbcf.wbcf_Width = CurrentPrefs.pref_WBWindowBox.Width;
809 wbcf.wbcf_Height = CurrentPrefs.pref_WBWindowBox.Height;
811 wbcf.wbcf_Flags = WBCF_FLAGF_Backdrop;
813 else
815 wbcf.wbcf_XOffset = iInfos.xii_iinfos.ii_MainWindowStruct->ws_xoffset;
816 wbcf.wbcf_YOffset = iInfos.xii_iinfos.ii_MainWindowStruct->ws_yoffset;
817 wbcf.wbcf_LeftEdge = iInfos.xii_iinfos.ii_MainWindowStruct->ws_Left;
818 wbcf.wbcf_TopEdge = iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top;
819 wbcf.wbcf_Width = iInfos.xii_iinfos.ii_MainWindowStruct->ws_Width;
820 wbcf.wbcf_Height = iInfos.xii_iinfos.ii_MainWindowStruct->ws_Height;
822 wbcf.wbcf_Flags = 0;
825 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
827 wbcf.wbcf_Version = SCA_LONG2BE(wbcf.wbcf_Version);
828 wbcf.wbcf_XOffset = SCA_WORD2BE(wbcf.wbcf_XOffset);
829 wbcf.wbcf_YOffset = SCA_WORD2BE(wbcf.wbcf_YOffset);
830 wbcf.wbcf_LeftEdge = SCA_WORD2BE(wbcf.wbcf_LeftEdge);
831 wbcf.wbcf_TopEdge = SCA_WORD2BE(wbcf.wbcf_TopEdge);
832 wbcf.wbcf_Width = SCA_WORD2BE(wbcf.wbcf_Width);
833 wbcf.wbcf_Height = SCA_WORD2BE(wbcf.wbcf_Height);
834 wbcf.wbcf_Flags = SCA_LONG2BE(wbcf.wbcf_Flags);
836 if (WriteChunkBytes(iff, &wbcf, sizeof(wbcf)) < 0)
837 break;
839 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
841 Result = PopChunk(iff);
842 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
843 if (RETURN_OK != Result)
844 break;
846 Result = PopChunk(iff);
847 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
848 if (RETURN_OK != Result)
849 break;
851 CloseIFF(iff);
852 IffOpen = FALSE;
853 } while (0);
855 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
857 if (iff)
859 if (IffOpen)
860 CloseIFF(iff);
861 if (iff->iff_Stream)
862 Close((BPTR) iff->iff_Stream);
864 FreeIFF(iff);
867 return Result;
871 LONG ReadWBConfig(void)
873 struct IFFHandle *iff;
874 struct PrefHeader prhd;
875 struct WBCFChunk wbcf;
876 BOOL IffOpen = FALSE;
877 LONG Result = RETURN_OK;
879 memset(&prhd, 0, sizeof(prhd));
881 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
883 do {
884 iff = AllocIFF();
885 if (NULL == iff)
886 break;
888 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
890 InitIFFasDOS(iff);
892 iff->iff_Stream = (IPTR) Open("ENVARC:sys/wbconfig.prefs", MODE_OLDFILE);
893 if (0 == iff->iff_Stream)
894 break;
896 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
898 Result = OpenIFF(iff, IFFF_READ);
899 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
900 if (RETURN_OK != Result)
901 break;
903 IffOpen = TRUE;
905 Result = StopChunk(iff, ID_PREF, MAKE_ID('W','B','C','F'));
906 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
907 if (RETURN_OK != Result)
908 break;
910 Result = ParseIFF(iff, IFFPARSE_SCAN);
911 d1(kprintf("%s/%s/%ld: Result=%08lx\n", __FILE__, __FUNC__, __LINE__, Result));
912 if (RETURN_OK != Result)
913 break;
915 if (sizeof(wbcf) == ReadChunkBytes(iff, &wbcf, sizeof(wbcf)))
917 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__, wbcf.wbcf_Version));
919 if (1 != SCA_BE2LONG(wbcf.wbcf_Version))
920 break;
922 CurrentPrefs.pref_WBWindowXOffset = SCA_BE2WORD(wbcf.wbcf_XOffset);
923 CurrentPrefs.pref_WBWindowYOffset = SCA_BE2WORD(wbcf.wbcf_YOffset);
925 CurrentPrefs.pref_WBWindowBox.Left = SCA_BE2WORD(wbcf.wbcf_LeftEdge);
926 CurrentPrefs.pref_WBWindowBox.Top = SCA_BE2WORD(wbcf.wbcf_TopEdge);
927 CurrentPrefs.pref_WBWindowBox.Width = SCA_BE2WORD(wbcf.wbcf_Width);
928 CurrentPrefs.pref_WBWindowBox.Height = SCA_BE2WORD(wbcf.wbcf_Height);
930 CurrentPrefs.pref_WBBackdrop = 0 != (SCA_BE2LONG(wbcf.wbcf_Flags) & WBCF_FLAGF_Backdrop);
933 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
934 } while (0);
936 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
938 if (iff)
940 if (IffOpen)
941 CloseIFF(iff);
942 if (iff->iff_Stream)
943 Close((BPTR) iff->iff_Stream);
945 FreeIFF(iff);
948 return Result;
952 void InitScalosPrefs(void)
954 CurrentPrefs = DefaultPrefs;
955 PalettePrefs = DefaultPalettePrefs;
959 BOOL ReadScalosPrefs(void)
961 struct ScalosPrefs *NewPrefs;
962 BOOL Success = FALSE;
964 d1(KPrintF("%s/%s/%ld: START\n", __FILE__, __FUNC__, __LINE__));
966 do {
967 WORD PluginArray[304];
968 struct PrefsStruct *ps;
969 UWORD uw;
970 LONG Entry;
971 CONST_STRPTR MainPrefsFileName = "ENV:Scalos/Scalos.prefs";
973 NewPrefs = ScalosAlloc(sizeof(struct ScalosPrefs));
974 d1(KPrintF("%s/%s/%ld: NewPrefs=%08lx\n", __FILE__, __FUNC__, __LINE__, NewPrefs));
975 if (NULL == NewPrefs)
976 break;
978 *NewPrefs = DefaultPrefs;
980 NewPrefs->pref_Handle = AllocPrefsHandle((STRPTR) "Scalos");
981 if (NULL == NewPrefs->pref_Handle)
982 break;
984 MainPrefsCRC = GetPrefsCRCFromName(MainPrefsFileName);
985 d1(KPrintF("%s/%s/%ld: MainPrefsCRC=%08lx\n", __FILE__, __FUNC__, __LINE__, MainPrefsCRC));
987 while (RemEntry(NewPrefs->pref_Handle, ID_MAIN, SCP_PlugInList, 0))
989 while (RemEntry(NewPrefs->pref_Handle, ID_MAIN, SCP_ControlBarGadgetsStd, 0))
991 while (RemEntry(NewPrefs->pref_Handle, ID_MAIN, SCP_ControlBarGadgetsBr, 0))
994 ReadPrefsHandle(NewPrefs->pref_Handle, (STRPTR) MainPrefsFileName);
996 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconOffsets, &NewPrefs->pref_ImageBorders, sizeof(NewPrefs->pref_ImageBorders)))
998 NewPrefs->pref_ImageBorders.Left = SCA_BE2WORD(NewPrefs->pref_ImageBorders.Left);
999 NewPrefs->pref_ImageBorders.Top = SCA_BE2WORD(NewPrefs->pref_ImageBorders.Top);
1000 NewPrefs->pref_ImageBorders.Right = SCA_BE2WORD(NewPrefs->pref_ImageBorders.Right);
1001 NewPrefs->pref_ImageBorders.Bottom = SCA_BE2WORD(NewPrefs->pref_ImageBorders.Bottom);
1004 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconNormFrame, &NewPrefs->pref_FrameType, sizeof(NewPrefs->pref_FrameType)))
1006 NewPrefs->pref_FrameType = SCA_BE2WORD(NewPrefs->pref_FrameType);
1009 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconSelFrame, &NewPrefs->pref_FrameTypeSel, sizeof(NewPrefs->pref_FrameTypeSel)))
1011 NewPrefs->pref_FrameTypeSel = SCA_BE2WORD(NewPrefs->pref_FrameTypeSel);
1014 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconNormThumbnailFrame, &NewPrefs->pref_ThumbnailFrameType, sizeof(NewPrefs->pref_ThumbnailFrameType)))
1016 NewPrefs->pref_ThumbnailFrameType = SCA_BE2WORD(NewPrefs->pref_ThumbnailFrameType);
1019 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconSelThumbnailFrame, &NewPrefs->pref_ThumbnailFrameTypeSel, sizeof(NewPrefs->pref_ThumbnailFrameTypeSel)))
1021 NewPrefs->pref_ThumbnailFrameTypeSel = SCA_BE2WORD(NewPrefs->pref_ThumbnailFrameTypeSel);
1024 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconTextSkip, &NewPrefs->pref_TextSkip, sizeof(NewPrefs->pref_TextSkip)))
1026 NewPrefs->pref_TextSkip = SCA_BE2WORD(NewPrefs->pref_TextSkip);
1029 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelTextRectBorderX, &NewPrefs->pref_SelTextRectBorderX, sizeof(NewPrefs->pref_SelTextRectBorderX)))
1031 NewPrefs->pref_SelTextRectBorderX = SCA_BE2WORD(NewPrefs->pref_SelTextRectBorderX);
1034 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelTextRectBorderY, &NewPrefs->pref_SelTextRectBorderY, sizeof(NewPrefs->pref_SelTextRectBorderY)))
1036 NewPrefs->pref_SelTextRectBorderY = SCA_BE2WORD(NewPrefs->pref_SelTextRectBorderY);
1039 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelTextRectRadius, &NewPrefs->pref_SelTextRectRadius, sizeof(NewPrefs->pref_SelTextRectRadius)))
1041 NewPrefs->pref_SelTextRectRadius = SCA_BE2WORD(NewPrefs->pref_SelTextRectRadius);
1044 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconSecLine, &NewPrefs->pref_IconTextMuliLine, sizeof(NewPrefs->pref_IconTextMuliLine));
1045 // UBYTE
1047 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_EnableDropMenu, &NewPrefs->pref_EnableDropMenu, sizeof(NewPrefs->pref_EnableDropMenu));
1048 // UBYTE
1050 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelectedTextRectangle, &NewPrefs->pref_SelectedTextRectangle, sizeof(NewPrefs->pref_SelectedTextRectangle));
1051 // UBYTE
1053 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconTextMode, &uw, sizeof(uw)))
1055 NewPrefs->pref_TextMode = SCA_BE2WORD(uw);
1058 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_CleanupOnResize, &NewPrefs->pref_AutoCleanupOnResize, sizeof(NewPrefs->pref_AutoCleanupOnResize));
1059 // UBYTE
1061 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_AutoLeaveOut, &NewPrefs->pref_AutoLeaveOut, sizeof(NewPrefs->pref_AutoLeaveOut));
1062 // UBYTE
1064 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconHiliteUnderMouse, &NewPrefs->pref_MarkIconUnderMouse, sizeof(NewPrefs->pref_MarkIconUnderMouse));
1065 // UBYTE
1067 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_BobsType, &NewPrefs->pref_DragType, sizeof(NewPrefs->pref_DragType));
1068 // UBYTE
1070 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_BobsMethod, &NewPrefs->pref_DragMethod, sizeof(NewPrefs->pref_DragMethod));
1071 // UBYTE
1073 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_BobsTranspMode, &NewPrefs->pref_DragTranspMode, sizeof(NewPrefs->pref_DragTranspMode));
1074 // UBYTE
1076 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_BobsTranspType, &NewPrefs->pref_RealTransFlag, sizeof(NewPrefs->pref_RealTransFlag));
1077 // UBYTE
1079 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_BobsTransp, &NewPrefs->pref_DragTranspObjects, sizeof(NewPrefs->pref_DragTranspObjects)))
1081 NewPrefs->pref_DragTranspObjects = SCA_BE2LONG(NewPrefs->pref_DragTranspObjects);
1084 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ShowThumbnails, &NewPrefs->pref_ShowThumbnails, sizeof(NewPrefs->pref_ShowThumbnails));
1085 // UBYTE
1086 d1(KPrintF("%s/%s/%ld: pref_ShowThumbnails=%ld\n", __FILE__, __FUNC__, __LINE__, NewPrefs->pref_ShowThumbnails));
1088 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailSize, &NewPrefs->pref_ThumbNailWidth, sizeof(NewPrefs->pref_ThumbNailWidth)))
1090 NewPrefs->pref_ThumbNailWidth = SCA_BE2WORD(NewPrefs->pref_ThumbNailWidth);
1093 NewPrefs->pref_ThumbNailHeight = NewPrefs->pref_ThumbNailWidth; // Thumbnails are square by default
1095 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailMaxAge, &NewPrefs->pref_ThumbnailMaxAge, sizeof(NewPrefs->pref_ThumbnailMaxAge)))
1097 NewPrefs->pref_ThumbnailMaxAge = SCA_BE2WORD(NewPrefs->pref_ThumbnailMaxAge);
1100 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailMinSizeLimit, &NewPrefs->pref_ThumbnailMinSizeLimit, sizeof(NewPrefs->pref_ThumbnailMinSizeLimit)))
1102 NewPrefs->pref_ThumbnailMinSizeLimit = SCA_BE2WORD(NewPrefs->pref_ThumbnailMinSizeLimit);
1105 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ShowThumbnailsAsDefault, &NewPrefs->pref_ShowThumbnailsAsDefault, sizeof(NewPrefs->pref_ShowThumbnailsAsDefault)); // +jmc+
1106 // BYTE
1108 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailQuality, &NewPrefs->pref_ThumbnailQuality, sizeof(NewPrefs->pref_ThumbnailQuality)))
1110 NewPrefs->pref_ThumbnailQuality = SCA_BE2LONG(NewPrefs->pref_ThumbnailQuality);
1113 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailsSquare, &NewPrefs->pref_ThumbnailsSquare, sizeof(NewPrefs->pref_ThumbnailsSquare));
1114 // BYTE
1116 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailOffsets, &NewPrefs->pref_ThumbnailImageBorders, sizeof(NewPrefs->pref_ThumbnailImageBorders)))
1118 NewPrefs->pref_ThumbnailImageBorders.Left = SCA_BE2WORD(NewPrefs->pref_ThumbnailImageBorders.Left);
1119 NewPrefs->pref_ThumbnailImageBorders.Top = SCA_BE2WORD(NewPrefs->pref_ThumbnailImageBorders.Top);
1120 NewPrefs->pref_ThumbnailImageBorders.Right = SCA_BE2WORD(NewPrefs->pref_ThumbnailImageBorders.Right);
1121 NewPrefs->pref_ThumbnailImageBorders.Bottom = SCA_BE2WORD(NewPrefs->pref_ThumbnailImageBorders.Bottom);
1124 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ThumbnailsFillBackground, &NewPrefs->pref_ThumbnailFillBackground, sizeof(NewPrefs->pref_ThumbnailFillBackground));
1125 // UBYTE
1127 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TransparencyThumbnailsBack, &NewPrefs->pref_ThumbnailBackgroundTransparency, sizeof(NewPrefs->pref_ThumbnailBackgroundTransparency)))
1129 NewPrefs->pref_ThumbnailBackgroundTransparency = SCA_BE2WORD(NewPrefs->pref_ThumbnailBackgroundTransparency);
1132 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconNormFrame, &NewPrefs->pref_FrameType, sizeof(NewPrefs->pref_FrameType)))
1134 NewPrefs->pref_FrameType = SCA_BE2WORD(NewPrefs->pref_FrameType);
1137 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DragDropCopyQualifier, &NewPrefs->pref_CopyQualifier, sizeof(NewPrefs->pref_CopyQualifier)))
1139 NewPrefs->pref_CopyQualifier = SCA_BE2LONG(NewPrefs->pref_CopyQualifier);
1142 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_PopupApplySelectedQualifier, &NewPrefs->pref_PopupApplySelectedQualifier, sizeof(NewPrefs->pref_PopupApplySelectedQualifier)))
1144 NewPrefs->pref_PopupApplySelectedQualifier = SCA_BE2LONG(NewPrefs->pref_PopupApplySelectedQualifier);
1147 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DragDropMakeLinkQualifier, &NewPrefs->pref_MakeLinkQualifier, sizeof(NewPrefs->pref_MakeLinkQualifier)))
1149 NewPrefs->pref_MakeLinkQualifier = SCA_BE2LONG(NewPrefs->pref_MakeLinkQualifier);
1152 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DragDropMoveQualifier, &NewPrefs->pref_ForceMoveQualifier, sizeof(NewPrefs->pref_ForceMoveQualifier)))
1154 NewPrefs->pref_ForceMoveQualifier = SCA_BE2LONG(NewPrefs->pref_ForceMoveQualifier);
1157 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SingleWindowLassoQualifier, &NewPrefs->pref_SingleWindowLassoQualifier, sizeof(NewPrefs->pref_SingleWindowLassoQualifier)))
1159 NewPrefs->pref_SingleWindowLassoQualifier = SCA_BE2LONG(NewPrefs->pref_SingleWindowLassoQualifier);
1162 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TransparencyIconDrag, &NewPrefs->pref_DragTransparency, sizeof(NewPrefs->pref_DragTransparency)))
1164 NewPrefs->pref_DragTransparency = SCA_BE2WORD(NewPrefs->pref_DragTransparency);
1167 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TransparencyIconShadow, &NewPrefs->pref_IconShadowTransparency, sizeof(NewPrefs->pref_IconShadowTransparency)))
1169 NewPrefs->pref_IconShadowTransparency = SCA_BE2WORD(NewPrefs->pref_IconShadowTransparency);
1172 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TransparencyDefaultIcon, &NewPrefs->pref_DefaultIconTransparency, sizeof(NewPrefs->pref_DefaultIconTransparency)))
1174 NewPrefs->pref_DefaultIconTransparency = SCA_BE2WORD(NewPrefs->pref_DefaultIconTransparency);
1177 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ToolTipTransparency, &NewPrefs->pref_TooltipsTransparency, sizeof(NewPrefs->pref_TooltipsTransparency)))
1179 NewPrefs->pref_TooltipsTransparency = SCA_BE2WORD(NewPrefs->pref_TooltipsTransparency);
1182 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DefaultStackSize, &NewPrefs->pref_DefaultStackSize, sizeof(NewPrefs->pref_DefaultStackSize)))
1184 NewPrefs->pref_DefaultStackSize = SCA_BE2LONG(NewPrefs->pref_DefaultStackSize);
1187 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ConsoleName, &NewPrefs->pref_ConsoleName, sizeof(NewPrefs->pref_ConsoleName));
1188 // BYTE[256]
1190 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TTScreenFontDesc, NewPrefs->pref_ScreenTTFontDescriptor, sizeof(NewPrefs->pref_ScreenTTFontDescriptor) );
1191 // char[256]
1193 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TTIconFontDesc, NewPrefs->pref_IconTTFontDescriptor, sizeof(NewPrefs->pref_IconTTFontDescriptor) );
1194 // char[256]
1196 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TTTextWindowFontDesc, NewPrefs->pref_TextWindowTTFontDescriptor, sizeof(NewPrefs->pref_TextWindowTTFontDescriptor) );
1197 // char[256]
1199 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_UseTTScreenFont, &NewPrefs->pref_UseScreenTTFont, sizeof(NewPrefs->pref_UseScreenTTFont) );
1200 // BYTE
1202 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_UseTTIconFont, &NewPrefs->pref_UseIconTTFont, sizeof(NewPrefs->pref_UseIconTTFont) );
1203 // BYTE
1205 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_UseTTTextWindowFont, &NewPrefs->pref_UseTextWindowTTFont, sizeof(NewPrefs->pref_UseTextWindowTTFont) );
1206 // BYTE
1208 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TTfAntialiasing, &NewPrefs->pref_TTFontAntialias, sizeof(NewPrefs->pref_TTFontAntialias) );
1209 // UBYTE
1211 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TTfGamma, &NewPrefs->pref_TTFontGamma, sizeof(NewPrefs->pref_TTFontGamma) ))
1213 NewPrefs->pref_TTFontGamma = SCA_BE2WORD(NewPrefs->pref_TTFontGamma);
1216 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_CopyBuffLen, &NewPrefs->pref_CopyBuffLen, sizeof(NewPrefs->pref_CopyBuffLen) ))
1218 NewPrefs->pref_CopyBuffLen = SCA_BE2LONG(NewPrefs->pref_CopyBuffLen);
1221 NewPrefs->pref_ScreenTitle = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_ScreenTitle, DefaultScreenTitle);
1223 SetAttrs(ScreenTitleObject,
1224 SCCA_Title_Format, (IPTR) NewPrefs->pref_ScreenTitle,
1225 TAG_END);
1227 NewPrefs->pref_MainWindowTitle = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_RootWinTitle, DefaultMainWindowTitle);
1228 NewPrefs->pref_StandardWindowTitle = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_WindowTitle, DefaultWindowTitle);
1230 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TitleRefresh, &NewPrefs->pref_TitleRefreshSec, sizeof(NewPrefs->pref_TitleRefreshSec));
1231 // UBYTE
1233 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_RefreshOnMemoryChange, &NewPrefs->pref_RefreshOnMemChg, sizeof(NewPrefs->pref_RefreshOnMemChg));
1234 // UBYTE
1236 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_WinTitleRefresh, &NewPrefs->pref_WinTitleRefreshSec, sizeof(NewPrefs->pref_WinTitleRefreshSec));
1237 // UBYTE
1239 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_WinRefreshOnMemoryChange, &NewPrefs->pref_WinRefreshOnMemChg, sizeof(NewPrefs->pref_WinRefreshOnMemChg));
1240 // BYTE
1242 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_CheckOverlappingIcons, &NewPrefs->pref_CheckOverlappingIcons, sizeof(NewPrefs->pref_CheckOverlappingIcons));
1243 // UBYTE
1245 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscAutoRemove, &NewPrefs->pref_AutoRemoveFlag, sizeof(NewPrefs->pref_AutoRemoveFlag));
1246 // UBYTE
1248 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscClickTransp, &NewPrefs->pref_ClickTransp, sizeof(NewPrefs->pref_ClickTransp));
1249 // UBYTE
1251 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscHardEmulation, &NewPrefs->pref_HardEmulation, sizeof(NewPrefs->pref_HardEmulation));
1252 // UBYTE
1254 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscUseExAll, &NewPrefs->pref_UseExAll, sizeof(NewPrefs->pref_UseExAll));
1255 // UBYTE
1257 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_CreateSoftLinks, &NewPrefs->pref_CreateSoftLinks, sizeof(NewPrefs->pref_CreateSoftLinks));
1258 // UBYTE
1260 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscWindowType, &NewPrefs->pref_SmartRefresh, sizeof(NewPrefs->pref_SmartRefresh));
1261 // UBYTE
1263 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscDoWaitDelay, &NewPrefs->pref_DoWaitDelay, sizeof(NewPrefs->pref_DoWaitDelay));
1264 // UBYTE
1266 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscDiskiconsRefresh, &NewPrefs->pref_DiskRefresh, sizeof(NewPrefs->pref_DiskRefresh));
1267 // UBYTE
1269 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MiscMenuCurrentDir, &NewPrefs->pref_MenuCurrentDir, sizeof(NewPrefs->pref_MenuCurrentDir));
1270 // BYTE
1272 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MMB_Move, &NewPrefs->pref_MMBMoveFlag, sizeof(NewPrefs->pref_MMBMoveFlag));
1273 // UBYTE
1275 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_FullBench, &NewPrefs->pref_FullBenchFlag, sizeof(NewPrefs->pref_FullBenchFlag));
1276 // UBYTE
1278 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_WindowPopupTitleOnly, &NewPrefs->pref_FullPopupFlag, sizeof(NewPrefs->pref_FullPopupFlag));
1279 // UBYTE
1281 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DefaultIconsSaveable, &NewPrefs->pref_SaveDefIcons, sizeof(NewPrefs->pref_SaveDefIcons));
1282 // UBYTE
1284 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_LoadDefIconsFirst, &NewPrefs->pref_DefIconsFirst, sizeof(NewPrefs->pref_DefIconsFirst));
1285 // UBYTE
1287 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_EasyMultiSelect, &NewPrefs->pref_EasyMultiselectFlag, sizeof(NewPrefs->pref_EasyMultiselectFlag));
1288 // UBYTE
1290 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_EasyMultiDrag, &NewPrefs->pref_EasyMultiDragFlag, sizeof(NewPrefs->pref_EasyMultiDragFlag));
1291 // UBYTE
1293 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DropStart, &NewPrefs->pref_DragStartFlag, sizeof(NewPrefs->pref_DragStartFlag));
1294 // UBYTE
1296 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_HideHiddenFiles, &NewPrefs->pref_HideHiddenFlag, sizeof(NewPrefs->pref_HideHiddenFlag));
1297 // UBYTE
1299 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_HideProtectHiddenFiles, &NewPrefs->pref_HideProtectHiddenFlag, sizeof(NewPrefs->pref_HideProtectHiddenFlag)); // jmc
1300 // UBYTE
1302 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_PopScreenTitle, &NewPrefs->pref_PopTitleFlag, sizeof(NewPrefs->pref_PopTitleFlag));
1303 // UBYTE
1305 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DefaultWindowSize, &NewPrefs->pref_DefWindowBox, sizeof(NewPrefs->pref_DefWindowBox)))
1307 NewPrefs->pref_DefWindowBox.Left = SCA_BE2WORD(NewPrefs->pref_DefWindowBox.Left);
1308 NewPrefs->pref_DefWindowBox.Top = SCA_BE2WORD(NewPrefs->pref_DefWindowBox.Top);
1309 NewPrefs->pref_DefWindowBox.Width = SCA_BE2WORD(NewPrefs->pref_DefWindowBox.Width);
1310 NewPrefs->pref_DefWindowBox.Height = SCA_BE2WORD(NewPrefs->pref_DefWindowBox.Height);
1313 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconCleanupSpace, &NewPrefs->pref_CleanupSpace, sizeof(NewPrefs->pref_CleanupSpace)))
1315 NewPrefs->pref_CleanupSpace.Left = SCA_BE2WORD(NewPrefs->pref_CleanupSpace.Left);
1316 NewPrefs->pref_CleanupSpace.Top = SCA_BE2WORD(NewPrefs->pref_CleanupSpace.Top);
1317 NewPrefs->pref_CleanupSpace.XSkip = SCA_BE2WORD(NewPrefs->pref_CleanupSpace.XSkip);
1318 NewPrefs->pref_CleanupSpace.YSkip = SCA_BE2WORD(NewPrefs->pref_CleanupSpace.YSkip);
1321 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SplashWindowEnable, &NewPrefs->pref_EnableSplash, sizeof(NewPrefs->pref_EnableSplash));
1322 // BYTE
1324 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_PopupWindowsEnable, &NewPrefs->pref_EnablePopupWindows, sizeof(NewPrefs->pref_EnablePopupWindows));
1325 // BYTE
1327 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SplashWindowHoldTime, &NewPrefs->pref_SplashHoldTime, sizeof(NewPrefs->pref_SplashHoldTime)))
1329 NewPrefs->pref_SplashHoldTime = SCA_BE2WORD(NewPrefs->pref_SplashHoldTime);
1332 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_StatusBarEnable, &NewPrefs->pref_DisplayStatusBar, sizeof(NewPrefs->pref_DisplayStatusBar));
1333 // BYTE
1335 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ToolTipsEnable, &NewPrefs->pref_EnableTooltips, sizeof(NewPrefs->pref_EnableTooltips));
1336 // BYTE
1338 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ToolTipPopupDelay, &NewPrefs->pref_ToolTipDelaySeconds, sizeof(NewPrefs->pref_ToolTipDelaySeconds)))
1340 NewPrefs->pref_ToolTipDelaySeconds = SCA_BE2LONG(NewPrefs->pref_ToolTipDelaySeconds);
1343 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_PopupWindowsDelay, &NewPrefs->pref_PopupWindowDelaySeconds, sizeof(NewPrefs->pref_PopupWindowDelaySeconds)))
1345 NewPrefs->pref_PopupWindowDelaySeconds = SCA_BE2WORD(NewPrefs->pref_PopupWindowDelaySeconds);
1348 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ShowDragDropObjCount, &NewPrefs->pref_ShowDDCountText, sizeof(NewPrefs->pref_ShowDDCountText));
1349 // UBYTE
1351 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DragDropIconsSingle, &NewPrefs->pref_UseOldDragIcons, sizeof(NewPrefs->pref_UseOldDragIcons));
1352 // BYTE
1354 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TextWindowsStriped, &NewPrefs->pref_TextWindowStriped, sizeof(NewPrefs->pref_TextWindowStriped));
1355 // BYTE
1357 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DropMarkMode, &NewPrefs->pref_WindowDropMarkMode, sizeof(NewPrefs->pref_WindowDropMarkMode));
1358 // UBYTE
1360 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ShowAllDefault, &NewPrefs->pref_DefaultShowAllFiles, sizeof(NewPrefs->pref_DefaultShowAllFiles));
1361 // UBYTE
1363 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ViewByDefault, &NewPrefs->pref_DefaultViewBy, sizeof(NewPrefs->pref_DefaultViewBy));
1364 // UBYTE
1366 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelectTextIconName, &NewPrefs->pref_SelectTextIconName, sizeof(NewPrefs->pref_SelectTextIconName));
1367 // UBYTE
1369 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconSizeConstraints, &NewPrefs->pref_IconSizeConstraints, sizeof(NewPrefs->pref_IconSizeConstraints)))
1371 NewPrefs->pref_IconSizeConstraints.MinX = SCA_BE2WORD(NewPrefs->pref_IconSizeConstraints.MinX);
1372 NewPrefs->pref_IconSizeConstraints.MinY = SCA_BE2WORD(NewPrefs->pref_IconSizeConstraints.MinY);
1373 NewPrefs->pref_IconSizeConstraints.MaxX = SCA_BE2WORD(NewPrefs->pref_IconSizeConstraints.MaxX);
1374 NewPrefs->pref_IconSizeConstraints.MaxY = SCA_BE2WORD(NewPrefs->pref_IconSizeConstraints.MaxY);
1377 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconNominalSize, &NewPrefs->pref_IconScaleFactor, sizeof(NewPrefs->pref_IconScaleFactor)))
1379 NewPrefs->pref_IconScaleFactor = SCA_BE2WORD(NewPrefs->pref_IconScaleFactor);
1382 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DeviceWinIconLayout, &NewPrefs->pref_DeviceWindowLayoutModes, sizeof(NewPrefs->pref_DeviceWindowLayoutModes));
1383 // UBYTE[]
1385 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_IconWinIconLayout, &NewPrefs->pref_IconWindowLayoutModes, sizeof(NewPrefs->pref_IconWindowLayoutModes));
1386 // UBYTE[]
1388 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_PopupApplySelectedAlways, &NewPrefs->pref_PopupApplySelectedAlways, sizeof(NewPrefs->pref_PopupApplySelectedAlways));
1389 // BYTE
1391 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_ActiveWindowTransparency, &NewPrefs->pref_ActiveWindowTransparency, sizeof(NewPrefs->pref_ActiveWindowTransparency)))
1393 NewPrefs->pref_ActiveWindowTransparency = SCA_BE2WORD(NewPrefs->pref_ActiveWindowTransparency);
1396 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_InactiveWindowTransparency, &NewPrefs->pref_InactiveWindowTransparency, sizeof(NewPrefs->pref_InactiveWindowTransparency)))
1398 NewPrefs->pref_InactiveWindowTransparency = SCA_BE2WORD(NewPrefs->pref_InactiveWindowTransparency);
1401 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelectMarkerBaseColor, &NewPrefs->pref_SelectMarkerBaseColor, sizeof(NewPrefs->pref_SelectMarkerBaseColor));
1402 // struct ARGB
1404 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_SelectMarkerTransparency, &NewPrefs->pref_SelectMarkerTransparency, sizeof(NewPrefs->pref_SelectMarkerTransparency));
1405 // UBYTE
1407 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_MaxUndoSteps, &NewPrefs->pref_MaxUndoSteps, sizeof(NewPrefs->pref_MaxUndoSteps)))
1409 NewPrefs->pref_MaxUndoSteps = SCA_BE2LONG(NewPrefs->pref_MaxUndoSteps);
1412 if (GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_DrawerSortMode, &NewPrefs->pref_DrawerSortMode, sizeof(NewPrefs->pref_DrawerSortMode)))
1414 NewPrefs->pref_DrawerSortMode = SCA_BE2LONG(NewPrefs->pref_DrawerSortMode);
1417 // Plausibility check for icon size constraints
1418 // make sure that max never smaller than min
1419 if (NewPrefs->pref_IconSizeConstraints.MinX > NewPrefs->pref_IconSizeConstraints.MaxX)
1420 NewPrefs->pref_IconSizeConstraints.MaxX = NewPrefs->pref_IconSizeConstraints.MinX;
1421 if (NewPrefs->pref_IconSizeConstraints.MinY > NewPrefs->pref_IconSizeConstraints.MaxY)
1422 NewPrefs->pref_IconSizeConstraints.MaxY = NewPrefs->pref_IconSizeConstraints.MinY;
1424 GetPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_UnderSoftLinkNames, &UnderlineSoftLinkNames, sizeof(UnderlineSoftLinkNames));
1425 // BYTE
1426 if (UnderlineSoftLinkNames)
1427 NewPrefs->pref_LinkTextStyle = FSF_UNDERLINED;
1428 else
1429 NewPrefs->pref_LinkTextStyle = FS_NORMAL;
1431 NewPrefs->pref_DefIconPath = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsDefIcons, DefaultPrefs.pref_DefIconPath);
1432 NewPrefs->pref_DefDiskCopy = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsDiskCopy, DefaultPrefs.pref_DefDiskCopy);
1433 NewPrefs->pref_WBStartupDir = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsWBStartup, DefaultPrefs.pref_WBStartupDir);
1434 NewPrefs->pref_ScalosHomeDir = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsHome, DefaultPrefs.pref_ScalosHomeDir);
1435 NewPrefs->pref_ThemesDir = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsTheme, DefaultPrefs.pref_ThemesDir);
1436 NewPrefs->pref_ImageCacheDir = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsImagecache, DefaultPrefs.pref_ImageCacheDir);
1437 NewPrefs->pref_SQLiteTempDir = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsSQLiteTempDir, DefaultPrefs.pref_SQLiteTempDir);
1439 NewPrefs->pref_ThumbDatabasePath = GetPrefsConfigString(NewPrefs->pref_Handle, SCP_PathsThumbnailDb, DefaultPrefs.pref_ThumbDatabasePath);
1441 ps = FindPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TextModeFont);
1443 if (ps)
1445 ps->ps_Size = SCA_BE2WORD(ps->ps_Size);
1446 SetTextAttr(&NewPrefs->pref_TextModeTextAttr, ps);
1447 d1(KPrintF("%s/%s/%ld: textfont=<%s> YSize=%ld\n", __FILE__, __FUNC__, __LINE__, \
1448 NewPrefs->pref_TextModeTextAttr.sta_TextAttr.ta_Name, NewPrefs->pref_TextModeTextAttr.sta_TextAttr.ta_YSize));
1451 SetAttrs(ScreenTitleObject,
1452 SCCA_Title_Format, (IPTR) NewPrefs->pref_ScreenTitle,
1453 TAG_END);
1455 ps = FindPreferences(NewPrefs->pref_Handle, ID_MAIN, SCP_TextMode_ListColumns);
1456 if (ps)
1458 BYTE *pu = (BYTE *) PS_DATA(ps);
1459 short n = 0;
1461 while (~0 != *pu && n < Sizeof(NewPrefs->pref_ColumnsArray) - 1)
1463 BYTE col = *pu++;
1465 d1(kprintf("%s/%s/%ld: Column=%ld\n", __FILE__, __FUNC__, __LINE__, col));
1467 if (!(col & 0x80))
1469 NewPrefs->pref_ColumnsArray[n++] = col;
1470 d1(kprintf("%s/%s/%ld: ColumnsArray[%ld]=%ld\n", __FILE__, __FUNC__, __LINE__, n-1, NewPrefs->pref_ColumnsArray[n-1]));
1474 NewPrefs->pref_ColumnsArray[n] = (UBYTE)-1;
1477 Entry = 0;
1479 while (GetEntry(NewPrefs->pref_Handle, ID_MAIN, SCP_PlugInList, PluginArray, sizeof(PluginArray), Entry) > 0)
1481 struct SCP_PluginEntry *pey = (struct SCP_PluginEntry *) PluginArray;
1483 d1(kprintf("%s/%s/%ld: MinVersion=%ld\n", __FILE__, __FUNC__, __LINE__, pey->pey_NeededVersion));
1485 if (SCA_BE2WORD(pey->pey_NeededVersion) <= ScalosBase->scb_LibNode.lib_Version)
1487 STRPTR lp;
1488 struct PluginClass *pl = (struct PluginClass *) SCA_AllocStdNode((struct ScalosNodeList *)(APTR) &ScalosPluginList, NTYP_PluginNode);
1490 if (pl)
1492 pl->plug_priority = SCA_BE2WORD(pey->pey_Priority);
1493 pl->plug_instsize = SCA_BE2WORD(pey->pey_InstSize);
1495 d1(kprintf("%s/%s/%ld: priority=%ld instsize=%ld\n", __FILE__, __FUNC__, __LINE__, pl->plug_priority, pl->plug_instsize));
1497 lp = pey->pey_Path;
1499 pl->plug_filename = AllocCopyString(lp);
1500 d1(kprintf("%s/%s/%ld: filename=<%s>\n", __FILE__, __FUNC__, __LINE__, pl->plug_filename));
1502 lp += 1 + strlen(lp);
1503 pl->plug_classname = AllocCopyString(lp);
1504 d1(kprintf("%s/%s/%ld: classname=<%s>\n", __FILE__, __FUNC__, __LINE__, pl->plug_classname));
1506 lp += 1 + strlen(lp);
1507 pl->plug_superclassname = AllocCopyString(lp);
1509 d1(kprintf("%s/%s/%ld: superclassname=<%s>\n", __FILE__, __FUNC__, __LINE__, pl->plug_superclassname));
1512 Entry++;
1515 Success = TRUE;
1516 } while (0);
1518 if (Success)
1520 ReadControlBarGadgetList(NewPrefs->pref_Handle, ID_MAIN,
1521 &ControlBarGadgetListNormal, SCP_ControlBarGadgetsStd, SCP_ControlBarGadgetStringsStd);
1522 ReadControlBarGadgetList(NewPrefs->pref_Handle, ID_MAIN,
1523 &ControlBarGadgetListBrowser, SCP_ControlBarGadgetsBr, SCP_ControlBarGadgetStringsBr);
1525 InternalFreeScalosPrefs(&CurrentPrefs);
1526 CurrentPrefs = *NewPrefs;
1529 if (NewPrefs)
1530 ScalosFree(NewPrefs);
1532 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__, Success));
1534 return Success;
1538 static CONST_STRPTR GetPrefsConfigString(APTR prefsHandle, ULONG Id, CONST_STRPTR DefaultString)
1540 struct PrefsStruct *ps = FindPreferences(prefsHandle, ID_MAIN, Id);
1542 if (ps)
1543 return (CONST_STRPTR) PS_DATA(ps);
1545 return DefaultString;
1549 void FreeScalosPrefs(void)
1551 InternalFreeScalosPrefs(&CurrentPrefs);
1552 CleanupControlBarGadgetsList(&ControlBarGadgetListNormal);
1553 CleanupControlBarGadgetsList(&ControlBarGadgetListBrowser);
1557 static void InternalFreeScalosPrefs(struct ScalosPrefs *Prefs)
1559 d1(KPrintF("%s/%s/%ld: START\n", __FILE__, __FUNC__, __LINE__));
1561 if (Prefs->pref_TextModeTextAttr.sta_AllocName)
1563 ScalosFree(Prefs->pref_TextModeTextAttr.sta_AllocName);
1564 Prefs->pref_TextModeTextAttr.sta_AllocName = NULL;
1565 Prefs->pref_TextModeTextAttr.sta_TextAttr.ta_Name = (STRPTR) "topaz.font";
1567 if (Prefs->pref_IconFontAttr.sta_AllocName)
1569 ScalosFree(Prefs->pref_IconFontAttr.sta_AllocName);
1570 Prefs->pref_IconFontAttr.sta_AllocName = NULL;
1571 Prefs->pref_IconFontAttr.sta_TextAttr.ta_Name = (STRPTR) "topaz.font";
1574 Prefs->pref_MainWindowTitle = DefaultPrefs.pref_MainWindowTitle;
1575 Prefs->pref_StandardWindowTitle = DefaultPrefs.pref_StandardWindowTitle;
1576 Prefs->pref_ScreenTitle = DefaultPrefs.pref_ScreenTitle;
1578 Prefs->pref_DefIconPath = DefaultPrefs.pref_DefIconPath;
1579 Prefs->pref_DefDiskCopy = DefaultPrefs.pref_DefDiskCopy;
1580 Prefs->pref_WBStartupDir = DefaultPrefs.pref_WBStartupDir;
1581 Prefs->pref_ScalosHomeDir = DefaultPrefs.pref_ScalosHomeDir;
1582 Prefs->pref_ThemesDir = DefaultPrefs.pref_ThemesDir;
1583 Prefs->pref_ImageCacheDir = DefaultPrefs.pref_ImageCacheDir;
1585 if (Prefs->pref_Handle)
1587 FreePrefsHandle(Prefs->pref_Handle);
1588 Prefs->pref_Handle = NULL;
1591 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
1595 LONG ReadPatternPrefs(void)
1597 static const LONG ReadPatternPrefsStopChunks[] =
1599 ID_PREF, ID_DEFS,
1600 ID_PREF, ID_PATT,
1602 struct IFFHandle *iff;
1603 BOOL IffOpen = FALSE;
1605 d1(KPrintF("%s/%s/%ld: START\n", __FILE__, __FUNC__, __LINE__));
1607 ScalosObtainSemaphore(&PatternSema);
1609 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1611 FreePatternPrefs();
1613 PatternPrefs = DefaultPatternPrefs;
1615 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1617 do {
1618 LONG Result;
1620 iff = AllocIFF();
1621 if (NULL == iff)
1622 break;
1624 InitIFFasDOS(iff);
1626 iff->iff_Stream = (IPTR) Open("ENV:Scalos/Pattern.prefs", MODE_OLDFILE);
1627 if (0 == iff->iff_Stream)
1628 break;
1630 PatternPrefsCRC = GetPrefsCRCFromFH((BPTR) iff->iff_Stream);
1631 d1(KPrintF("%s/%s/%ld: PatternPrefsCRC=%08lx\n", __FILE__, __FUNC__, __LINE__, PatternPrefsCRC));
1633 Result = OpenIFF(iff, IFFF_READ);
1634 if (RETURN_OK != Result)
1635 break;
1637 IffOpen = TRUE;
1639 Result = StopChunks(iff, (LONG *) ReadPatternPrefsStopChunks, 2);
1640 if (RETURN_OK != Result)
1641 break;
1643 while (RETURN_OK == Result)
1645 const struct ContextNode *cn;
1647 Result = ParseIFF(iff, IFFPARSE_SCAN);
1648 if (RETURN_OK != Result)
1649 break;
1651 cn = CurrentChunk(iff);
1652 if (NULL == cn)
1653 break;
1655 switch (cn->cn_ID)
1657 case ID_DEFS:
1658 ReadPatternDefaults(iff);
1659 break;
1661 case ID_PATT:
1662 CreatePatternNode(iff, cn);
1663 break;
1666 } while (0);
1668 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1670 if (iff)
1672 if (IffOpen)
1673 CloseIFF(iff);
1675 if (iff->iff_Stream)
1677 Close((BPTR) iff->iff_Stream);
1678 iff->iff_Stream = 0;
1680 FreeIFF(iff);
1683 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1685 if (PatternNodes)
1687 struct Hook SortHook;
1689 SETHOOKFUNC(SortHook, PatternNodeCompareFunc);
1690 SortHook.h_Data = NULL;
1692 SCA_SortNodes((struct ScalosNodeList *)(APTR) &PatternNodes, &SortHook, SCA_SortType_Best);
1694 if (!PatternPrefs.patt_RandomizeEverytime)
1696 struct PatternNode *pNode1 = PatternNodes;
1698 while (pNode1)
1700 struct PatternNode *pNode2 = pNode1;
1701 ULONG Count;
1703 for (Count=0; pNode1 && pNode2->ptn_number == pNode1->ptn_number;
1704 pNode1 = (struct PatternNode *) pNode1->ptn_Node.mln_Succ)
1706 Count++;
1709 if (Count > 1)
1711 LONG n;
1712 LONG Number = RandomNumber(Count - 1);
1714 // Remove all PatternNodes with the same number
1715 // except the one selected by random number.
1716 for (n=0; n<Count; n++)
1718 struct PatternNode *pNode3 = pNode2;
1720 pNode2 = (struct PatternNode *) pNode2->ptn_Node.mln_Succ;
1722 if (n != Number)
1723 FreePatternNode(&PatternNodes, pNode3);
1730 ScalosReleaseSemaphore(&PatternSema);
1732 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
1734 return TRUE;
1738 static void CreatePatternNode(struct IFFHandle *iff, const struct ContextNode *cn)
1740 struct ScaPatternPrefs *pPrefs;
1741 struct PatternNode *patNode = NULL;
1743 do {
1744 pPrefs = ScalosAlloc(cn->cn_Size);
1745 if (NULL == pPrefs)
1746 break;
1748 if (cn->cn_Size != ReadChunkBytes(iff, pPrefs, cn->cn_Size))
1749 break;
1751 pPrefs->scp_Number = SCA_BE2WORD(pPrefs->scp_Number);
1752 pPrefs->scp_RenderType = SCA_BE2WORD(pPrefs->scp_RenderType);
1753 pPrefs->scp_Flags = SCA_BE2WORD(pPrefs->scp_Flags);
1754 pPrefs->scp_NumColors = SCA_BE2WORD(pPrefs->scp_NumColors);
1755 pPrefs->scp_DitherMode = SCA_BE2WORD(pPrefs->scp_DitherMode);
1756 pPrefs->scp_DitherAmount = SCA_BE2WORD(pPrefs->scp_DitherAmount);
1758 patNode = (struct PatternNode *) SCA_AllocStdNode((struct ScalosNodeList *)(APTR) &PatternNodes, NTYP_PatternNode);
1759 if (NULL == patNode)
1760 break;
1762 patNode->ptn_semaphore = ScalosCreateSemaphore();
1763 if (NULL == patNode->ptn_semaphore)
1764 break;
1766 patNode->ptn_number = pPrefs->scp_Number;
1767 patNode->ptn_type = pPrefs->scp_RenderType;
1768 patNode->ptn_BgMode = pPrefs->scp_Type;
1769 patNode->ptn_flags = pPrefs->scp_Flags;
1770 patNode->ptn_weight = pPrefs->scp_NumColors;
1771 patNode->ptn_dithermode = pPrefs->scp_DitherMode;
1772 patNode->ptn_ditheramount = pPrefs->scp_DitherAmount;
1773 patNode->ptn_prec = pPrefs->scp_Precision;
1774 memcpy(patNode->ptn_BgColor1, pPrefs->scp_color1, sizeof(patNode->ptn_BgColor1));
1775 memcpy(patNode->ptn_BgColor2, pPrefs->scp_color2, sizeof(patNode->ptn_BgColor2));
1777 patNode->ptn_filename = AllocCopyString((STRPTR) (pPrefs + 1));
1779 d1(kprintf("%s/%s/%ld: <%s> number=%ld type=%ld cn_size=%ld\n", __FILE__, __FUNC__, __LINE__, \
1780 patNode->ptn_filename, patNode->ptn_number, patNode->ptn_type, cn->cn_Size));
1782 // do not free patNode
1783 patNode = NULL;
1784 } while (0);
1786 if (patNode)
1787 SCA_FreeNode((struct ScalosNodeList *)(APTR) &PatternNodes, &patNode->ptn_Node);
1788 if (pPrefs)
1789 ScalosFree(pPrefs);
1793 static void ReadPatternDefaults(struct IFFHandle *iff)
1795 LONG Len;
1796 struct ScaPatternDefs pdp;
1798 Len = ReadChunkBytes(iff, &pdp, sizeof(pdp));
1799 if (Len <= 0)
1800 return;
1802 pdp.scd_Flags = SCA_BE2WORD(pdp.scd_Flags);
1803 pdp.scd_WorkbenchPattern = SCA_BE2WORD(pdp.scd_WorkbenchPattern);
1804 pdp.scd_ScreenPattern = SCA_BE2WORD(pdp.scd_ScreenPattern);
1805 pdp.scd_WindowPattern = SCA_BE2WORD(pdp.scd_WindowPattern);
1806 pdp.scd_TextModePattern = SCA_BE2WORD(pdp.scd_TextModePattern);
1808 d1(kprintf("%s/%s/%ld: Len=%ld\n", __FILE__, __FUNC__, __LINE__, Len));
1810 PatternPrefs.patt_AsyncBackFill = 0 != (pdp.scd_Flags & SCDF_ASYNCLAYOUT);
1811 PatternPrefs.patt_UseFriendBitMap = 0 != (pdp.scd_Flags & SCDF_USEFRIENDBM);
1812 PatternPrefs.patt_NewRenderFlag = 0 != (pdp.scd_Flags & SCDF_RELAYOUT);
1813 PatternPrefs.patt_RandomizeEverytime = 0 != (pdp.scd_Flags & SCDF_RANDOM);
1815 d1(kprintf("%s/%s/%ld: PatternPrefs.patt_AsyncBackFill=%ld PatternPrefs.patt_UseFriendBitMap=%ld\n", \
1816 __FILE__, __FUNC__, __LINE__, PatternPrefs.patt_AsyncBackFill, PatternPrefs.patt_UseFriendBitMap));
1817 d1(kprintf("%s/%s/%ld: PatternPrefs.patt_NewRenderFlag=%ld PatternPrefs.patt_RandomizeEverytime=%ld\n", \
1818 __FILE__, __FUNC__, __LINE__, PatternPrefs.patt_NewRenderFlag, PatternPrefs.patt_RandomizeEverytime));
1820 PatternPrefs.patt_DefWBPatternNr = pdp.scd_WorkbenchPattern;
1821 PatternPrefs.patt_DefScreenPatternNr = pdp.scd_ScreenPattern;
1822 PatternPrefs.patt_DefWindowPatternNr = pdp.scd_WindowPattern;
1824 d1(kprintf("%s/%s/%ld: PatternPrefs.patt_DefWBPatternNr=%ld PatternPrefs.patt_DefScreenPatternNr=%ld PatternPrefs.patt_DefWindowPatternNr=%ld\n", \
1825 __FILE__, __FUNC__, __LINE__, PatternPrefs.patt_DefWBPatternNr, PatternPrefs.patt_DefScreenPatternNr, PatternPrefs.patt_DefWindowPatternNr));
1827 if (Len > offsetof(struct ScaPatternDefs, scd_TextModePattern))
1829 PatternPrefs.patt_DefTextWinPatternNr = pdp.scd_TextModePattern;
1830 PatternPrefs.patt_AsyncProcTaskPri = pdp.scd_TaskPriority;
1832 d1(kprintf("%s/%s/%ld: PatternPrefs.patt_DefTextWinPatternNr=%ld AsyncProcTaskPri=%ld\n", \
1833 __FILE__, __FUNC__, __LINE__, PatternPrefs.patt_DefTextWinPatternNr, PatternPrefs.patt_AsyncProcTaskPri));
1838 static SAVEDS(LONG) PatternNodeCompareFunc(
1839 struct Hook *theHook,
1840 struct PatternNode *pNode2,
1841 struct PatternNode *pNode1)
1843 (void) theHook;
1845 return pNode1->ptn_number - pNode2->ptn_number;
1849 static void FreePatternNode(struct PatternNode **PatternNodeList, struct PatternNode *pNode)
1851 d1(kprintf("%s/%s/%ld: pNode=%08lx\n", __FILE__, __FUNC__, __LINE__, pNode));
1853 ScalosDeleteSemaphore(pNode->ptn_semaphore);
1855 if (pNode->ptn_bitmap && (pNode->ptn_flags & PTNF_FreeBitmap))
1856 FreeBitMap(pNode->ptn_bitmap);
1858 if (pNode->ptn_object)
1859 DisposeDTObject(pNode->ptn_object);
1861 if (GuiGFXBase && pNode->ptn_drawhandle)
1863 ReleaseDrawHandle(pNode->ptn_drawhandle);
1865 d1(kprintf("%s/%s/%ld: ptn_colorhandle=%08lx\n", __FILE__, __FUNC__, __LINE__, pNode->ptn_colorhandle));
1867 if (pNode->ptn_colorhandle)
1868 RemColorHandle(pNode->ptn_colorhandle);
1869 if (pNode->ptn_picture)
1870 DeletePicture(pNode->ptn_picture);
1873 if (pNode->ptn_filename)
1874 FreeCopyString(pNode->ptn_filename);
1876 SCA_FreeNode((struct ScalosNodeList *) PatternNodeList, &pNode->ptn_Node);
1880 void FreePatternPrefs(void)
1882 struct PatternNode *pNode, *pNodeNext;
1884 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1886 ScalosObtainSemaphore(&PatternSema);
1888 for (pNode = PatternNodes; pNode; pNode=pNodeNext)
1890 pNodeNext = (struct PatternNode *) pNode->ptn_Node.mln_Succ;
1891 FreePatternNode(&PatternNodes, pNode);
1894 ScalosReleaseSemaphore(&PatternSema);
1898 ULONG RandomNumber(ULONG MaxRand)
1900 RandomSeed = RandomSeed * 1103515245 + 12345;
1901 return (ULONG)(RandomSeed / 65536) % (1 + MaxRand);
1902 // RandomSeed = (RandomSeed * 51479u) + 3715436908u;
1904 // return (((RandomSeed & 0xffff) * MaxRand) / 65535u) & 0xffff;
1908 void NewPatternPrefs(struct internalScaWindowTask *iwt, struct NotifyMessage *msg)
1910 struct SM_NewPreferences *smnp;
1912 d1(KPrintF("%s/%s/%ld: smnp_PrefsFlags=%08lx\n", __FILE__, __FUNC__, __LINE__, SMNPFLAGF_PATTERNPREFS));
1914 smnp = (struct SM_NewPreferences *) SCA_AllocMessage(MTYP_NewPreferences, 0);
1915 if (smnp)
1917 smnp->smnp_PrefsFlags = SMNPFLAGF_PATTERNPREFS;
1918 PutMsg(iInfos.xii_iinfos.ii_MainMsgPort, &smnp->ScalosMessage.sm_Message);
1923 BOOL ChangedPatternPrefs(struct MainTask *mt)
1925 ULONG NewPatternPrefsCRC;
1926 BOOL Changed = FALSE;
1928 NewPatternPrefsCRC = GetPrefsCRCFromName("ENV:Scalos/Pattern.prefs");
1929 d1(KPrintF("%s/%s/%ld: NewPatternPrefsCRC=%08lx PatternPrefsCRC=%08lx\n",
1930 __FILE__, __FUNC__, __LINE__, NewPatternPrefsCRC, PatternPrefsCRC));
1932 if (INITIAL_CRC != NewPatternPrefsCRC &&
1933 NewPatternPrefsCRC != PatternPrefsCRC)
1935 Changed = TRUE;
1936 PatternsOff(mt, iInfos.xii_iinfos.ii_MainMsgPort);
1937 FreePatternPrefs();
1938 ReadPatternPrefs();
1939 PatternsOn(mt);
1941 else
1943 RandomizePatterns();
1946 return Changed;
1950 void NewMainPrefs(struct internalScaWindowTask *iwt, struct NotifyMessage *msg)
1952 struct SM_NewPreferences *smnp;
1954 d1(KPrintF("%s/%s/%ld: smnp_PrefsFlags=%08lx\n", __FILE__, __FUNC__, __LINE__, SMNPFLAGF_SCALOSPREFS));
1956 smnp = (struct SM_NewPreferences *) SCA_AllocMessage(MTYP_NewPreferences, 0);
1957 if (smnp)
1959 smnp->smnp_PrefsFlags = SMNPFLAGF_SCALOSPREFS;
1960 PutMsg(iInfos.xii_iinfos.ii_MainMsgPort, &smnp->ScalosMessage.sm_Message);
1965 BOOL ChangedMainPrefs(struct MainTask *mt)
1967 ULONG NewMainPrefsCRC;
1968 BOOL Changed = FALSE;
1970 NewMainPrefsCRC = GetPrefsCRCFromName("ENV:Scalos/Scalos.prefs");
1971 d1(KPrintF("%s/%s/%ld: NewMainPrefsCRC=%08lx MainPrefsCRC=%08lx\n",
1972 __FILE__, __FUNC__, __LINE__, NewMainPrefsCRC, MainPrefsCRC));
1974 if (INITIAL_CRC != NewMainPrefsCRC &&
1975 NewMainPrefsCRC != MainPrefsCRC)
1977 struct internalScaWindowTask *iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
1978 BOOL oldPrefFullBenchFlag, oldPrefPopTitleFlag;
1979 BOOL oldPrefMarkIconUnderMouse;
1980 UWORD oldPrefActiveWindowTransparency;
1981 UWORD oldPrefInactiveWindowTransparency;
1983 Changed = TRUE;
1985 oldPrefFullBenchFlag = CurrentPrefs.pref_FullBenchFlag;
1986 oldPrefPopTitleFlag = CurrentPrefs.pref_PopTitleFlag;
1987 oldPrefMarkIconUnderMouse = CurrentPrefs.pref_MarkIconUnderMouse;
1988 oldPrefActiveWindowTransparency = CurrentPrefs.pref_ActiveWindowTransparency;
1989 oldPrefInactiveWindowTransparency = CurrentPrefs.pref_InactiveWindowTransparency;
1991 ReadScalosPrefs();
1993 if (oldPrefFullBenchFlag != CurrentPrefs.pref_FullBenchFlag
1994 || oldPrefPopTitleFlag != CurrentPrefs.pref_PopTitleFlag
1995 || oldPrefMarkIconUnderMouse != CurrentPrefs.pref_MarkIconUnderMouse)
1997 if (CurrentPrefs.pref_FullBenchFlag)
1999 FreeBackFill(&iwtMain->iwt_WindowTask.wt_PatternInfo);
2001 iwtMain->iwt_WindowTask.wt_PatternInfo.ptinf_height = iwtMain->iwt_WinScreen->Height;
2002 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top = 0;
2003 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Height =
2004 iwtMain->iwt_WinScreen->Height - iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top;
2006 ChangeWindowBox(iwtMain->iwt_WindowTask.wt_Window,
2007 iwtMain->iwt_WindowTask.wt_Window->LeftEdge,
2008 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top,
2009 iwtMain->iwt_WindowTask.wt_Window->Width,
2010 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Height);
2012 SetBackFill(iwtMain, iInfos.xii_iinfos.ii_MainWindowStruct->ws_PatternNode,
2013 &iwtMain->iwt_WindowTask.wt_PatternInfo,
2015 iwtMain->iwt_WinScreen);
2017 else
2019 FreeBackFill(&iwtMain->iwt_WindowTask.wt_PatternInfo);
2021 iwtMain->iwt_WindowTask.wt_PatternInfo.ptinf_height =
2022 iwtMain->iwt_WinScreen->Height - iwtMain->iwt_WinScreen->BarHeight + 1;
2024 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top = iwtMain->iwt_WinScreen->BarHeight + 1;
2025 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Height =
2026 iwtMain->iwt_WinScreen->Height - iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top;
2028 ChangeWindowBox(iwtMain->iwt_WindowTask.wt_Window,
2029 iwtMain->iwt_WindowTask.wt_Window->LeftEdge,
2030 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Top,
2031 iwtMain->iwt_WindowTask.wt_Window->Width,
2032 iInfos.xii_iinfos.ii_MainWindowStruct->ws_Height);
2034 SetBackFill(iwtMain, iInfos.xii_iinfos.ii_MainWindowStruct->ws_PatternNode,
2035 &iwtMain->iwt_WindowTask.wt_PatternInfo,
2037 iwtMain->iwt_WinScreen);
2039 CurrentPrefs.pref_PopTitleFlag = FALSE;
2042 d1(KPrintF("%s/%s/%ld: oldPrefMarkIconUnderMouse=[%ld] CurrentPrefs.pref_MarkIconUnderMouse=[%ld] [] \n", \
2043 __FILE__, __FUNC__, __LINE__, oldPrefMarkIconUnderMouse, CurrentPrefs.pref_MarkIconUnderMouse));
2045 InitCx();
2047 ShowScreenTitle(!CurrentPrefs.pref_PopTitleFlag ? !CurrentPrefs.pref_FullBenchFlag : CurrentPrefs.pref_FullBenchFlag); // +jmc+
2049 d1(KPrintF("%s/%s/%ld:\nSTART\n ShowScreenTitle(!CurrentPrefs.pref_PopTitleFlag)=[%ld]\n CurrentPrefs.pref_PopTitleFlag=[%ld]\n CurrentPrefs.pref_FullBenchFlag=[%ld]\nEND\n\n", \
2050 __FILE__, __FUNC__, __LINE__, (!CurrentPrefs.pref_PopTitleFlag ? !CurrentPrefs.pref_FullBenchFlag : CurrentPrefs.pref_FullBenchFlag), CurrentPrefs.pref_PopTitleFlag, CurrentPrefs.pref_FullBenchFlag));
2053 // Update iwt_IconLayoutInfo and transparency for all windows
2054 if (SCA_LockWindowList(SCA_LockWindowList_AttemptShared))
2056 struct ScaWindowStruct *ws;
2058 for (ws=winlist.wl_WindowStruct; ws; ws = (struct ScaWindowStruct *) ws->ws_Node.mln_Succ)
2060 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ws->ws_WindowTask;
2061 const UBYTE *LayoutModes;
2063 // if default transparency is used, update window transparency
2064 if (oldPrefActiveWindowTransparency == ws->ws_WindowOpacityActive)
2066 ws->ws_WindowOpacityActive = CurrentPrefs.pref_ActiveWindowTransparency;
2067 SetAttrs(iwt->iwt_WindowTask.mt_MainObject,
2068 SCCA_IconWin_ActiveTransparency, CurrentPrefs.pref_ActiveWindowTransparency,
2069 TAG_END);
2071 if (oldPrefInactiveWindowTransparency == ws->ws_WindowOpacityInactive)
2073 SetAttrs(iwt->iwt_WindowTask.mt_MainObject,
2074 SCCA_IconWin_InactiveTransparency, CurrentPrefs.pref_InactiveWindowTransparency,
2075 TAG_END);
2078 if (WSV_Type_DeviceWindow == ws->ws_WindowType)
2079 LayoutModes = CurrentPrefs.pref_DeviceWindowLayoutModes;
2080 else
2081 LayoutModes = CurrentPrefs.pref_IconWindowLayoutModes;
2083 memcpy(iwt->iwt_IconLayoutInfo.ili_IconTypeLayoutModes,
2084 LayoutModes, sizeof(iwt->iwt_IconLayoutInfo.ili_IconTypeLayoutModes));
2086 SCA_UnLockWindowList();
2089 // Screen TrueType Font
2090 Scalos_CloseFont(NULL, &ScreenTTFont);
2091 if (CurrentPrefs.pref_UseScreenTTFont)
2092 Scalos_OpenTTFont(CurrentPrefs.pref_ScreenTTFontDescriptor, &ScreenTTFont);
2094 // Text window font
2095 OpenTextWindowFont();
2097 d1(KPrintF("%s/%s/%ld: iwtMain=%08lx\n", __FILE__, __FUNC__, __LINE__, iwtMain));
2099 // update icon window font
2100 OpenIconWindowFont();
2102 d1(KPrintF("%s/%s/%ld: IconWindowFont=%08lx\n", __FILE__, __FUNC__, __LINE__, IconWindowFont));
2104 if (IsIwtViewByIcon(iwtMain))
2106 iwtMain->iwt_IconFont = IconWindowFont;
2107 iwtMain->iwt_IconTTFont = IconWindowTTFont;
2109 else
2111 iwtMain->iwt_IconFont = TextWindowFont;
2112 iwtMain->iwt_IconTTFont = TextWindowTTFont;
2115 // AppIcons will not get re-created like other icons,
2116 // so we do a ReLayout here
2117 DoMethod(iwtMain->iwt_WindowTask.mt_MainObject, SCCM_IconWin_Redraw, REDRAWF_ReLayoutIcons);
2119 // Force flushing of cached FileType descriptors
2120 // to get rid of still open fonts
2121 FileTypeFlush(FALSE);
2124 return Changed;
2128 void NewPalettePrefs(struct internalScaWindowTask *iwt, struct NotifyMessage *msg)
2130 struct MainTask *mt = MainWindowTask;
2132 d1(KPrintF("%s/%s/%ld: smnp_PrefsFlags=%08lx\n", __FILE__, __FUNC__, __LINE__, SMNPFLAGF_PALETTEPREFS));
2134 if (mt->mt_ChangedPalettePrefsName)
2135 FreeCopyString(mt->mt_ChangedPalettePrefsName);
2136 mt->mt_ChangedPalettePrefsName = AllocCopyString(msg->nm_NReq->nr_FullName);
2138 if (mt->mt_ChangedPalettePrefsName)
2140 struct SM_NewPreferences *smnp;
2142 smnp = (struct SM_NewPreferences *) SCA_AllocMessage(MTYP_NewPreferences, 0);
2143 if (smnp)
2145 smnp->smnp_PrefsFlags = SMNPFLAGF_PALETTEPREFS;
2146 PutMsg(iInfos.xii_iinfos.ii_MainMsgPort, &smnp->ScalosMessage.sm_Message);
2152 BOOL ChangedPalettePrefs(struct MainTask *mt)
2154 BOOL Changed = FALSE;
2156 if (mt->emulation)
2158 ULONG NewPalettePrefsCRC;
2160 NewPalettePrefsCRC = GetPrefsCRCFromName(mt->mt_ChangedPalettePrefsName);
2161 d1(KPrintF("%s/%s/%ld: NewPalettePrefsCRC=%08lx PalettePrefsCRC=%08lx\n",
2162 __FILE__, __FUNC__, __LINE__, NewPalettePrefsCRC, PalettePrefsCRC));
2164 if (INITIAL_CRC != NewPalettePrefsCRC &&
2165 NewPalettePrefsCRC != PalettePrefsCRC)
2167 Changed = TRUE;
2168 RunProcess(&mt->mwt.iwt_WindowTask, NewPaletteProc, 0, NULL, iInfos.xii_iinfos.ii_MainMsgPort);
2172 return Changed;
2176 static ULONG NewPaletteProc(APTR arg, struct SM_RunProcess *msg)
2178 BOOL oldCloseWBDisabled;
2180 d1(KPrintF("%s/%s/%ld: START\n", __FILE__, __FUNC__, __LINE__));
2182 oldCloseWBDisabled = CurrentPrefs.pref_DisableCloseWorkbench;
2183 CurrentPrefs.pref_DisableCloseWorkbench = FALSE;
2185 while (1)
2187 if (CloseWorkBench())
2189 break;
2191 else
2193 if (!UseRequest(NULL, MSGID_CLOSEWBNAME, MSGID_GADGETSNAME, NULL))
2194 break;
2198 CurrentPrefs.pref_DisableCloseWorkbench = oldCloseWBDisabled;
2200 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
2201 FreePalettePrefs();
2202 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
2203 ReadPalettePrefs();
2204 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
2206 OpenWorkBench();
2208 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
2210 return 0;
2214 void NewFontPrefs(struct internalScaWindowTask *iwt, struct NotifyMessage *msg)
2216 struct SM_NewPreferences *smnp;
2218 d1(KPrintF("%s/%s/%ld: smnp_PrefsFlags=%08lx\n", __FILE__, __FUNC__, __LINE__, SMNPFLAGF_FONTPREFS));
2220 smnp = (struct SM_NewPreferences *) SCA_AllocMessage(MTYP_NewPreferences, 0);
2221 if (smnp)
2223 smnp->smnp_PrefsFlags = SMNPFLAGF_FONTPREFS;
2224 PutMsg(iInfos.xii_iinfos.ii_MainMsgPort, &smnp->ScalosMessage.sm_Message);
2229 BOOL ChangedFontPrefs(struct MainTask *mt)
2231 ULONG NewFontPrefsCRC;
2232 struct internalScaWindowTask *iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
2233 BOOL Changed = FALSE;
2235 NewFontPrefsCRC = GetPrefsCRCFromName("ENV:sys/font.prefs");
2236 d1(KPrintF("%s/%s/%ld: NewFontPrefsCRC=%08lx FontPrefsCRC=%08lx\n",
2237 __FILE__, __FUNC__, __LINE__, NewFontPrefsCRC, FontPrefsCRC));
2239 if (NewFontPrefsCRC != FontPrefsCRC)
2241 d1(KPrintF("%s/%s/%ld: Changed font prefs detected\n", __FILE__, __FUNC__, __LINE__));
2243 Changed = TRUE;
2245 ReadFontPrefs();
2247 OpenIconWindowFont();
2249 d1(KPrintF("%s/%s/%ld: IconWindowFont=%08lx\n", __FILE__, __FUNC__, __LINE__, IconWindowFont));
2251 if (IsIwtViewByIcon(iwtMain))
2253 iwtMain->iwt_IconFont = IconWindowFont;
2254 iwtMain->iwt_IconTTFont = IconWindowTTFont;
2256 else
2258 iwtMain->iwt_IconFont = TextWindowFont;
2259 iwtMain->iwt_IconTTFont = TextWindowTTFont;
2262 // AppIcons will not get re-created like other icons,
2263 // so we do a ReLayout here
2264 DoMethod(iwtMain->iwt_WindowTask.mt_MainObject, SCCM_IconWin_Redraw, REDRAWF_ReLayoutIcons);
2267 return Changed;
2271 static void ShowScreenTitle(BOOL showTitle)
2273 struct SM_ShowTitle *sMsg;
2275 d1(kprintf("%s/%s/%ld: Screen Title ON\n", __FILE__, __FUNC__, __LINE__));
2277 sMsg = (struct SM_ShowTitle *) SCA_AllocMessage(MTYP_ShowTitle, 0);
2278 if (sMsg)
2280 sMsg->smst_showTitle = showTitle;
2281 PutMsg(iInfos.xii_iinfos.ii_MainMsgPort, &sMsg->ScalosMessage.sm_Message);
2286 ULONG GetPrefsCRCFromFH(BPTR fh)
2288 UBYTE buffer[256];
2289 ULONG crc = INITIAL_CRC;
2290 SLONG64 FilePos;
2291 LONG len;
2293 if (BNULL == fh)
2294 return 0;
2296 d1(KPrintF("%s/%s/%ld: START fh=%08lx\n", __FILE__, __FUNC__, __LINE__, fh));
2297 FilePos = ScalosSeek(fh, MakeS64(0), OFFSET_BEGINNING);
2299 while ((len = FRead(fh, buffer, 1, sizeof(buffer))) > 0)
2301 crc = update_crc(crc, buffer, len);
2303 ScalosSeek(fh, FilePos, OFFSET_BEGINNING);
2305 d1(KPrintF("%s/%s/%ld: END fh=%08lx crc=%08lx\n", __FILE__, __FUNC__, __LINE__, fh, crc));
2307 return crc;
2311 ULONG GetPrefsCRCFromName(CONST_STRPTR FileName)
2313 ULONG crc = 0;
2314 BPTR fh;
2316 fh = Open((STRPTR) FileName, MODE_OLDFILE);
2317 d1(KPrintF("%s/%s/%ld: FileName=<%s> fh=%08lx\n", __FILE__, __FUNC__, __LINE__, FileName, fh));
2318 if (fh)
2320 crc = GetPrefsCRCFromFH(fh);
2321 Close(fh);
2324 d1(KPrintF("%s/%s/%ld: END crc=%08lx\n", __FILE__, __FUNC__, __LINE__, crc));
2326 return crc;
2330 static void SetTextAttr(struct ScalosTextAttr *sta, struct PrefsStruct *ps)
2332 CONST_STRPTR fontName = (CONST_STRPTR) PS_DATA(ps);
2333 CONST_STRPTR fp;
2334 size_t fnLen;
2335 LONG l;
2337 if (sta->sta_AllocName)
2339 ScalosFree(sta->sta_AllocName);
2340 sta->sta_AllocName = NULL;
2343 for (fp=fontName, fnLen=0; *fp && '/' != *fp; fnLen++)
2344 fp++;
2346 sta->sta_TextAttr.ta_Name = sta->sta_AllocName = ScalosAlloc(fnLen + 5 + 1);
2347 if (sta->sta_TextAttr.ta_Name)
2349 stccpy(sta->sta_TextAttr.ta_Name, fontName, 1 + fnLen);
2351 // append ".font" if not already present
2352 if (0 != strcmp(sta->sta_TextAttr.ta_Name + fnLen - 5, ".font"))
2353 strcat(sta->sta_TextAttr.ta_Name, ".font");
2356 if ('/' == *fp)
2357 fp++;
2359 if (StrToLong((STRPTR) fp, &l))
2360 sta->sta_TextAttr.ta_YSize = l;
2361 else
2362 sta->sta_TextAttr.ta_YSize = 8;
2366 void OpenIconWindowFont(void)
2368 static struct TextAttr Topaz8Attr = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT };
2370 Scalos_CloseFont(&IconWindowFont, &IconWindowTTFont);
2372 d1(KPrintF("%s/%s/%ld: %s/%ld\n", __FILE__, __FUNC__, __LINE__, FontPrefs.fprf_TextAttr.ta_Name, FontPrefs.fprf_TextAttr.ta_YSize));
2374 IconWindowFont = OpenDiskFont(&FontPrefs.fprf_TextAttr);
2376 d1(KPrintF("%s/%s/%ld: IconWindowFont=%08lx\n", __FILE__, __FUNC__, __LINE__, IconWindowFont));
2377 if (NULL == IconWindowFont)
2378 IconWindowFont = OpenFont(&Topaz8Attr);
2380 // Icon Window TrueType Font
2381 if (CurrentPrefs.pref_UseIconTTFont)
2382 Scalos_OpenTTFont(CurrentPrefs.pref_IconTTFontDescriptor, &IconWindowTTFont);
2386 void OpenTextWindowFont(void)
2388 static struct TextAttr Topaz8Attr = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT };
2390 Scalos_CloseFont(&TextWindowFont, &TextWindowTTFont);
2392 d1(KPrintF("%s/%s/%ld: %s/%ld\n", __FILE__, __FUNC__, __LINE__, CurrentPrefs.pref_TextModeTextAttr.sta_TextAttr.ta_Name, CurrentPrefs.pref_TextModeTextAttr.sta_TextAttr.ta_YSize));
2394 TextWindowFont = OpenDiskFont(&CurrentPrefs.pref_TextModeTextAttr.sta_TextAttr);
2395 d1(KPrintF("%s/%s/%ld: TextWindowFont=%08lx\n", __FILE__, __FUNC__, __LINE__, TextWindowFont));
2397 if (NULL == TextWindowFont)
2398 TextWindowFont = OpenFont(&Topaz8Attr);
2400 if (CurrentPrefs.pref_UseTextWindowTTFont)
2401 Scalos_OpenTTFont(CurrentPrefs.pref_TextWindowTTFontDescriptor, &TextWindowTTFont);
2405 static void CleanupControlBarGadgetsList(struct List *CbGadgetsList)
2407 struct ControlBarGadgetEntry *cgy;
2409 d1(KPrintF("%s/%s/%ld: START\n", __FILE__, __FUNC__, __LINE__));
2411 while ((cgy = (struct ControlBarGadgetEntry *) RemHead(CbGadgetsList)))
2413 if (cgy->cgy_NormalImage)
2415 FreeCopyString(cgy->cgy_NormalImage);
2416 cgy->cgy_NormalImage = NULL;
2418 if (cgy->cgy_SelectedImage)
2420 FreeCopyString(cgy->cgy_SelectedImage);
2421 cgy->cgy_SelectedImage = NULL;
2423 if (cgy->cgy_DisabledImage)
2425 FreeCopyString(cgy->cgy_DisabledImage);
2426 cgy->cgy_DisabledImage = NULL;
2428 if (cgy->cgy_HelpText)
2430 FreeCopyString(cgy->cgy_HelpText);
2431 cgy->cgy_HelpText = NULL;
2433 ScalosFree(cgy);
2436 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
2440 static void ReadControlBarGadgetList(APTR p_MyPrefsHandle, LONG lID, struct List *CbGadgetsList,
2441 ULONG prefsIDGadgets, ULONG prefsIDStrings)
2443 struct SCP_GadgetStringEntry *gse;
2445 d1(KPrintF("%s/%s/%ld: START\n", __FILE__, __FUNC__, __LINE__));
2447 do {
2448 struct SCP_GadgetStringEntry gseTemp;
2449 struct SCP_GadgetEntry sgy;
2450 size_t size;
2451 LONG Entry;
2453 CleanupControlBarGadgetsList(CbGadgetsList);
2455 memset(&gseTemp, 0, sizeof(gseTemp));
2456 Entry = 0;
2458 // first determine required size of prefsIDStrings
2459 GetPreferences(p_MyPrefsHandle, lID, prefsIDStrings, &gseTemp, sizeof(gseTemp) );
2460 gseTemp.gse_Length = SCA_BE2LONG(gseTemp.gse_Length);
2461 size = sizeof(struct SCP_GadgetStringEntry) + gseTemp.gse_Length;
2462 d1(KPrintF("%s/%s/%ld: gse_Length=%lu size=%lu\n", __FILE__, __FUNC__, __LINE__, gseTemp.gse_Length, size));
2464 gse = ScalosAlloc(size);
2465 d1(KPrintF("%s/%s/%ld: gse=%08lx\n", __FILE__, __FUNC__, __LINE__, gse));
2466 if (NULL == gse)
2467 break;
2469 // now read complete prefsIDStrings
2470 GetPreferences(p_MyPrefsHandle, lID, prefsIDStrings, gse, size );
2471 gse->gse_Length = SCA_BE2LONG(gse->gse_Length);
2473 // read array of prefsIDGadgets
2474 while ((size = GetEntry(p_MyPrefsHandle, lID, prefsIDGadgets, &sgy, sizeof(sgy), Entry)) > 0)
2476 struct ControlBarGadgetEntry *cgy;
2478 d1(KPrintF("%s/%s/%ld: size=%lu\n", __FILE__, __FUNC__, __LINE__, size));
2480 d1(KPrintF("%s/%s/%ld: sgy_Action=<%s>\n", __FILE__, __FUNC__, __LINE__, sgy.sgy_Action));
2481 d1(KPrintF("%s/%s/%ld: sgy_NormalImageIndex=%lu sgy_SelectedImageIndex=%lu\n", __FILE__, __FUNC__, __LINE__, sgy.sgy_NormalImageIndex, sgy.sgy_SelectedImageIndex));
2482 d1(KPrintF("%s/%s/%ld: sgy_DisabledImageIndex=%lu sgy_HelpTextIndex=%lu\n", __FILE__, __FUNC__, __LINE__, sgy.sgy_DisabledImageIndex, sgy.sgy_HelpTextIndex));
2484 cgy = ScalosAlloc(sizeof(struct ControlBarGadgetEntry));
2485 d1(KPrintF("%s/%s/%ld: cgy=%08lx Entry=%ld sgy_GadgetType=%ld\n", __FILE__, __FUNC__, __LINE__, cgy, Entry, sgy.sgy_GadgetType));
2486 if (NULL == cgy)
2487 break;
2489 // create ControlBarGadgetEntry from SCP_GadgetEntry
2490 cgy->cgy_GadgetType = SCA_BE2WORD(sgy.sgy_GadgetType);
2491 stccpy(cgy->cgy_Action, sgy.sgy_Action, sizeof(cgy->cgy_Action));
2492 cgy->cgy_NormalImage = AllocCopyString(&gse->gse_Strings[SCA_BE2LONG(sgy.sgy_NormalImageIndex)]);
2493 cgy->cgy_SelectedImage = AllocCopyString(&gse->gse_Strings[SCA_BE2LONG(sgy.sgy_SelectedImageIndex)]);
2494 cgy->cgy_DisabledImage = AllocCopyString(&gse->gse_Strings[SCA_BE2LONG(sgy.sgy_DisabledImageIndex)]);
2495 cgy->cgy_HelpText = AllocCopyString(&gse->gse_Strings[SCA_BE2LONG(sgy.sgy_HelpTextIndex)]);
2497 // add new ControlBarGadgetEntry to CbGadgetsList
2498 AddTail(CbGadgetsList, &cgy->cgy_Node);
2500 Entry++;
2502 } while (0);
2504 if (gse)
2505 ScalosFree(gse);
2507 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
2510 #if 0
2511 static void ByteDump(unsigned char *Data, size_t Length)
2513 unsigned long count;
2514 unsigned char Line[80], *lp;
2516 lp = Line;
2517 for (count=0; count<Length; count++)
2519 *lp++ = isprint(*Data) ? *Data : '.';
2520 KPrintF("%02x ", *Data++);
2521 if ((count+1) % 16 == 0)
2523 *lp = '\0';
2524 lp = Line;
2525 KPrintF("\t%s\n", Line);
2529 *lp = '\0';
2530 while (count % 16 != 0)
2532 KPrintF(" ");
2533 count++;
2535 KPrintF("\t%s\n", Line);
2537 #endif