add casts to zune macros to silence some warnings
[tangerine.git] / workbench / prefs / locale / misc.c
blobf1359c072dd48483d9369e58b847d44d43749af4
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*********************************************************************************************/
11 #include "global.h"
12 #include "version.h"
14 #include <string.h>
16 /*********************************************************************************************/
18 static struct NewMenu nm[] =
20 {NM_TITLE, (STRPTR)MSG_MEN_PROJECT },
21 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_OPEN },
22 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_SAVEAS },
23 {NM_ITEM, NM_BARLABEL },
24 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_QUIT },
25 {NM_TITLE, (STRPTR)MSG_MEN_EDIT },
26 {NM_ITEM, (STRPTR)MSG_MEN_EDIT_DEFAULT },
27 {NM_ITEM, (STRPTR)MSG_MEN_EDIT_LASTSAVED },
28 {NM_ITEM, (STRPTR)MSG_MEN_EDIT_RESTORE },
29 {NM_TITLE, (STRPTR)MSG_MEN_SETTINGS },
30 {NM_ITEM, (STRPTR)MSG_MEN_SETTINGS_CREATEICONS, NULL, CHECKIT | MENUTOGGLE },
31 {NM_END}
34 /*********************************************************************************************/
36 void InitMenus(void)
38 struct NewMenu *actnm = nm;
40 for(actnm = nm; actnm->nm_Type != NM_END; actnm++)
42 if (actnm->nm_Label != NM_BARLABEL)
44 ULONG id = (ULONG)actnm->nm_Label;
45 CONST_STRPTR str = MSG(id);
47 if (actnm->nm_Type == NM_TITLE)
49 actnm->nm_Label = str;
50 } else {
51 actnm->nm_Label = str + 2;
52 if (str[0] != ' ') actnm->nm_CommKey = str;
54 actnm->nm_UserData = (APTR)id;
56 } /* if (actnm->nm_Label != NM_BARLABEL) */
58 } /* for(actnm = nm; nm->nm_Type != NM_END; nm++) */
62 /*********************************************************************************************/
64 void MakeMenus(void)
66 struct TagItem menu_tags[] =
68 {GTMN_NewLookMenus, TRUE},
69 {TAG_DONE }
72 menus = CreateMenusA(nm, NULL);
73 if (!menus) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
75 if (!LayoutMenusA(menus, vi, menu_tags)) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
79 /*********************************************************************************************/
81 void KillMenus(void)
83 if (win) ClearMenuStrip(win);
84 if (menus) FreeMenus(menus);
86 menus = NULL;
89 /*********************************************************************************************/
91 STRPTR GetFile(CONST_STRPTR title, CONST_STRPTR dir, BOOL savemode)
93 static UBYTE filebuffer[300];
94 struct FileRequester *req;
95 STRPTR retval = NULL;
97 AslBase = OpenLibrary("asl.library", 39);
98 if (AslBase)
100 req = AllocAslRequestTags(ASL_FileRequest, ASLFR_TitleText , (IPTR)title,
101 ASLFR_DoPatterns , TRUE ,
102 ASLFR_InitialDrawer, (IPTR)dir ,
103 ASLFR_DoSaveMode , savemode ,
104 TAG_DONE);
105 if (req)
107 if (AslRequest(req, NULL))
109 strncpy(filebuffer, req->fr_Drawer, 299);
110 AddPart(filebuffer, req->fr_File, 299);
112 retval = filebuffer;
114 } /* if (AslRequest(req, NULL) */
116 FreeAslRequest(req);
118 } /* if (req) */
120 CloseLibrary(AslBase);
122 } /* if (AslBase) */
124 return retval;
127 /*********************************************************************************************/
129 struct Node *FindListNode(struct List *list, WORD which)
131 struct Node *node = NULL;
133 if (which >= 0)
135 for(node = list->lh_Head; node->ln_Succ && which; node = node->ln_Succ, which--)
138 if (!node->ln_Succ) node = NULL;
141 return node;
144 /*********************************************************************************************/
146 void SortInNode(struct List *list, struct Node *node)
148 struct Node *sort, *prev = NULL;
149 struct Locale *loc;
151 loc = OpenLocale(NULL);
153 ForeachNode(list, sort)
155 if (StrnCmp(loc,
156 node->ln_Name, sort->ln_Name,
157 strlen(node->ln_Name), SC_COLLATE2)
158 < 0)
160 break;
162 prev = sort;
165 Insert(list, node, prev);
166 CloseLocale(loc);
169 /*********************************************************************************************/
171 void ScrollListview(struct Gadget *gad, WORD delta)
173 IPTR top, visible, total;
174 LONG newtop;
176 GT_GetGadgetAttrs(gad, win, NULL, GTLV_Top, (IPTR)&top,
177 GTLV_Visible, (IPTR)&visible,
178 GTLV_Total, (IPTR)&total,
179 TAG_DONE);
181 newtop = (LONG)top + delta * 3;
183 if (newtop + visible > total)
185 newtop = total - visible;
188 if (newtop < 0) newtop = 0;
190 if (newtop != top)
192 GT_SetGadgetAttrs(gad, win, NULL, GTLV_Top, newtop, TAG_DONE);
197 /*********************************************************************************************/