1 /***************************************************************************
3 TheBar.mcc - Next Generation Toolbar MUI Custom Class
4 Copyright (C) 2003-2005 Alfonso Ranieri
5 Copyright (C) 2005-2013 by TheBar.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 TheBar class Support Site: http://www.sf.net/projects/thebar
21 ***************************************************************************/
26 /***********************************************************************/
29 openCatalogVR(CONST_STRPTR name
,ULONG minVer
,ULONG minRev
)
31 if ((lib_cat
= OpenCatalog(NULL
,(STRPTR
)name
,OC_BuiltInLanguage
,(IPTR
)"english",TAG_DONE
)))
33 ULONG ver
= lib_cat
->cat_Version
;
35 if ((ver
<minVer
) ? TRUE
: ((ver
==minVer
) ? (lib_cat
->cat_Revision
<minRev
) : FALSE
))
37 CloseCatalog(lib_cat
);
45 /***********************************************************************/
52 for (low
= 0, high
= (sizeof(CatCompArray
)/sizeof(CatCompArray
[0]))-1; low
<=high
; )
54 int mid
= (low
+high
) / 2, cond
;
55 struct CatCompArrayType
*cca
= (struct CatCompArrayType
*)CatCompArray
+mid
;
57 cond
= id
- cca
->cca_ID
;
60 return lib_cat
? (STRPTR
)GetCatalogStr(lib_cat
, id
, cca
->cca_Str
) : cca
->cca_Str
;
70 /****************************************************************************/
72 #define IDSSIZE(ids) (sizeof(ids)/sizeof(ids[0]))
74 static const ULONG regIDs
[] =
82 STRPTR regs
[IDSSIZE(regIDs
)];
84 static const ULONG frameIDs
[] =
86 Msg_FrameStyle_Recessed
,
87 Msg_FrameStyle_Normal
,
90 STRPTR frames
[IDSSIZE(frameIDs
)];
92 static const ULONG precisionIDs
[] =
100 STRPTR precisions
[IDSSIZE(precisionIDs
)];
102 static const ULONG dismodeIDs
[] =
106 Msg_DisMode_FullGrid
,
109 Msg_DisMode_BlendGrey
,
112 STRPTR dismodes
[IDSSIZE(dismodeIDs
)];
114 static const ULONG spacersSizeIDs
[] =
116 Msg_SpacersSize_Quarter
,
117 Msg_SpacersSize_Half
,
119 Msg_SpacersSize_None
,
120 Msg_SpacersSize_OnePoint
,
121 Msg_SpacersSize_TwoPoint
,
124 STRPTR spacersSizes
[IDSSIZE(spacersSizeIDs
)];
126 static const ULONG viewModeIDs
[] =
133 STRPTR viewModes
[IDSSIZE(viewModeIDs
)];
135 static const ULONG labelPosIDs
[] =
143 STRPTR labelPoss
[IDSSIZE(labelPosIDs
)];
146 localizeArray(STRPTR
*strings
, const ULONG
*ids
)
149 *strings
++ = tr(*ids
++);
150 // make sure the translated string array is NULL terminated
157 if (openCatalogVR((CONST_STRPTR
)"TheBar_mcp.catalog",0,0))
159 struct CatCompArrayType
*cca
;
162 for (cnt
= (sizeof(CatCompArray
)/sizeof(CatCompArray
[0]))-1, cca
= (struct CatCompArrayType
*)CatCompArray
+cnt
;
168 if ((s
= (STRPTR
)GetCatalogStr(lib_cat
, cca
->cca_ID
, cca
->cca_Str
)))
173 localizeArray(regs
,regIDs
);
174 localizeArray(frames
,frameIDs
);
175 localizeArray(precisions
,precisionIDs
);
176 localizeArray(dismodes
,dismodeIDs
);
177 localizeArray(spacersSizes
,spacersSizeIDs
);
178 localizeArray(viewModes
,viewModeIDs
);
179 localizeArray(labelPoss
,labelPosIDs
);
181 #if !defined(__MORPHOS__) && !defined(__amigaos4__) && !defined(__AROS__)
186 /***********************************************************************/
189 getKeyChar(STRPTR string
)
195 for (; *string
&& *string
!='_'; string
++);
197 res
= ToLower(*string
);
203 /***********************************************************************/