1 /***************************************************************************
3 BetterString.mcc - A better String gadget MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005 by BetterString.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 BetterString class Support Site: http://www.sf.net/projects/bstring-mcc/
21 ***************************************************************************/
26 #include <clib/alib_protos.h>
27 #include <libraries/mui.h>
28 #include <proto/intuition.h>
29 #include <proto/muimaster.h>
30 #include <proto/graphics.h>
31 #include <proto/diskfont.h>
32 #include <proto/dos.h>
34 #include "BetterString_mcp.h"
37 ULONG
GetCol (Object
*obj
, ULONG item
, struct MUI_PenSpec
*defaultcol
, struct InstData
*data
)
40 struct MUI_PenSpec
*spec
;
42 if(DoMethod(obj
, MUIM_GetConfigItem
, item
, &spec
))
43 res
= MUI_ObtainPen(muiRenderInfo(obj
), spec
, 0L);
44 else res
= MUI_ObtainPen(muiRenderInfo(obj
), defaultcol
, 0L);
49 void InitConfig (Object
*obj
, struct InstData
*data
)
54 if((data
->Flags
& FLG_SetFrame
) && MUIMasterBase
->lib_Version
>= 20)
55 set(obj
, MUIA_Frame
, DoMethod(obj
, MUIM_GetConfigItem
, MUICFG_BetterString_Frame
, &setting
) ? (STRPTR
)setting
: (STRPTR
)"302211");
57 #warning "AROS: FIXME, MUIA_Frame stuff!"
59 data
->InactiveText
= GetCol(obj
, MUICFG_BetterString_InactiveText
, (struct MUI_PenSpec
*)"m5", data
);
60 data
->ActiveText
= GetCol(obj
, MUICFG_BetterString_ActiveText
, (struct MUI_PenSpec
*)"m5", data
);
61 data
->CursorColor
= GetCol(obj
, MUICFG_BetterString_Cursor
, (struct MUI_PenSpec
*)"m0", data
);
62 data
->MarkedColor
= GetCol(obj
, MUICFG_BetterString_MarkedBack
, (struct MUI_PenSpec
*)"m6", data
);
63 data
->MarkedTextColor
= GetCol(obj
, MUICFG_BetterString_MarkedText
, (struct MUI_PenSpec
*)"m5", data
);
65 if(DoMethod(obj
, MUIM_GetConfigItem
, MUICFG_BetterString_InactiveBack
, &setting
))
66 data
->InactiveBackground
= (STRPTR
)setting
;
67 else data
->InactiveBackground
= (STRPTR
)MUII_BACKGROUND
;
69 if(DoMethod(obj
, MUIM_GetConfigItem
, MUICFG_BetterString_ActiveBack
, &setting
))
70 data
->ActiveBackground
= (STRPTR
)setting
;
71 else data
->ActiveBackground
= (STRPTR
)"2:m1";
73 if(!(data
->Flags
& FLG_OwnFont
) && DoMethod(obj
, MUIM_GetConfigItem
, MUICFG_BetterString_Font
, &setting
))
75 STRPTR src
= (STRPTR
)setting
;
77 struct TextAttr myfont
= { fontname
, 8, FS_NORMAL
, 0 };
80 while(src
[c
] != '/' && src
[c
] != '\0' && c
< 32)
82 fontname
[c
-1] = src
[c
++];
84 strncpy(&fontname
[c
], ".font", 6);
85 StrToLong(&src
[c
+1], &c
);
88 data
->Font
= OpenDiskFont(&myfont
);
95 if(!(data
->Flags
& FLG_OwnBackground
))
96 set(obj
, MUIA_Background
, data
->InactiveBackground
);
99 VOID
FreeConfig (struct MUI_RenderInfo
*mri
, struct InstData
*data
)
101 MUI_ReleasePen(mri
, data
->InactiveText
);
102 MUI_ReleasePen(mri
, data
->ActiveText
);
103 MUI_ReleasePen(mri
, data
->CursorColor
);
104 MUI_ReleasePen(mri
, data
->MarkedColor
);
105 MUI_ReleasePen(mri
, data
->MarkedTextColor
);
108 CloseFont(data
->Font
);