annotate src/gui_xmdlg.c @ 130:964dc7d8b63d

updated for version 7.0044
author vimboss
date Tue, 25 Jan 2005 21:58:26 +0000
parents 10286edc333c
children 2463194c8cdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
2 *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
4 *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
8 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
9
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
10 /*
49
10286edc333c updated for version 7.0028
vimboss
parents: 44
diff changeset
11 * (C) 2001,2005 by Marcin Dalecki <martin@dalecki.de>
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
12 *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
13 * Implementation of dialogue functions for the Motif GUI variant.
49
10286edc333c updated for version 7.0028
vimboss
parents: 44
diff changeset
14 *
10286edc333c updated for version 7.0028
vimboss
parents: 44
diff changeset
15 * Note about Lesstif: Apparenty lesstif doesn't get the widget layout right,
10286edc333c updated for version 7.0028
vimboss
parents: 44
diff changeset
16 * when using a dynamic scrollbar policy.
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
17 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
18
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
19 #include <Xm/Form.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
20 #include <Xm/PushBG.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
21 #include <Xm/Text.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
22 #include <Xm/TextF.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
23 #include <Xm/Label.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
24 #include <Xm/Frame.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
25 #include <Xm/LabelG.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
26 #include <Xm/ToggleBG.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
27 #include <Xm/SeparatoG.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
28 #include <Xm/DialogS.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
29 #include <Xm/List.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
30 #include <Xm/RowColumn.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
31 #include <Xm/AtomMgr.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
32 #include <Xm/Protocols.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
33
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
34 #include <X11/keysym.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
35 #include <X11/Xatom.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
36 #include <X11/StringDefs.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
37 #include <X11/Intrinsic.h>
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
38
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
39 #include "vim.h"
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
40
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
41 extern Widget vimShell;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
42
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
43 #ifdef FEAT_MENU
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
44 # define apply_fontlist(w) gui_motif_menu_fontlist(w)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
45 #else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
46 # define apply_fontlist(w)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
47 #endif
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
48
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
49 /****************************************************************************
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
50 * Font selection dialogue implementation.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
51 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
52
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
53 static char wild[3] = "*";
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
54
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
55 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
56 * FIXME: This is a generic function, which should be used throughout the whole
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
57 * application.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
58 *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
59 * Add close_callback, which will be called when the user selects close from
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
60 * the window menu. The close menu item usually activates f.kill which sends a
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
61 * WM_DELETE_WINDOW protocol request for the window.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
62 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
63
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
64 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
65 add_cancel_action(Widget shell, XtCallbackProc close_callback, void *arg)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
66 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
67 static Atom wmp_atom = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
68 static Atom dw_atom = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
69 Display *display = XtDisplay(shell);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
70
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
71 /* deactivate the built-in delete response of killing the application */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
72 XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, 0);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
73
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
74 /* add a delete window protocol callback instead */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
75 if (!dw_atom)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
76 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
77 wmp_atom = XmInternAtom(display, "WM_PROTOCOLS", True);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
78 dw_atom = XmInternAtom(display, "WM_DELETE_WINDOW", True);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
79 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
80 XmAddProtocolCallback(shell, wmp_atom, dw_atom, close_callback, arg);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
81 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
82
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
83 #define MAX_FONTS 65535
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
84 #define MAX_FONT_NAME_LEN 256
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
85 #define MAX_ENTRIES_IN_LIST 5000
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
86 #define MAX_DISPLAY_SIZE 150
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
87 #define TEMP_BUF_SIZE 256
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
88
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
89 enum ListSpecifier
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
90 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
91 ENCODING,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
92 NAME,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
93 STYLE,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
94 SIZE,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
95 NONE
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
96 };
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
97
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
98 typedef struct _SharedFontSelData
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
99 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
100 Widget dialog;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
101 Widget ok;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
102 Widget cancel;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
103 Widget encoding_pulldown;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
104 Widget encoding_menu;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
105 Widget list[NONE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
106 Widget name;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
107 Widget sample;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
108 char **names; /* font name array of arrays */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
109 int num; /* number of font names */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
110 String sel[NONE]; /* selection category */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
111 Boolean in_pixels; /* toggle state - size in pixels */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
112 char *font_name; /* current font name */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
113 XFontStruct *old; /* font data structure for sample display */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
114 XmFontList old_list; /* font data structure for sample display */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
115 Boolean exit; /* used for program exit control */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
116 } SharedFontSelData;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
117
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
118 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
119 * Checking access to the font name array for validity.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
120 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
121 static char *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
122 fn(SharedFontSelData *data, int i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
123 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
124 /* Assertion checks: */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
125 if (data->num < 0)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
126 abort();
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
127 if (i >= data->num)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
128 i = data->num - 1;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
129 if (i < 0)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
130 i = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
131
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
132 return data->names[i];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
133 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
134
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
135 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
136 * Get a specific substring from a font name.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
137 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
138 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
139 get_part(char *in, int pos, char *out)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
140 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
141 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
142 int j;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
143
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
144 *out = '\0';
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
145
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
146 for (i = 0; (pos > 0) && (in[i] != '\0'); ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
147 if (in[i] == '-')
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
148 pos--;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
149
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
150 if (in[i] == '\0')
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
151 return;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
152
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
153 for (j = 0; (in[i] != '-') && (in[i] != '\0'); ++i, ++j)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
154 out[j] = in[i];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
155 out[j] = '\0';
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
156 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
157
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
158 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
159 * Given a font name this function returns the part used in the first
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
160 * scroll list.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
161 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
162 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
163 name_part(char *font, char *buf)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
164 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
165 char buf2[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
166 char buf3[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
167
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
168 get_part(font, 2, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
169 get_part(font, 1, buf3);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
170
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
171 if (strlen(buf3))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
172 sprintf(buf, "%s (%s)", buf2, buf3);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
173 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
174 sprintf(buf, "%s", buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
175 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
176
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
177 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
178 * Given a font name this function returns the part used in the second scroll list.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
179 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
180 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
181 style_part(char *font, char *buf)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
182 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
183 char buf2[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
184 char buf3[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
185
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
186 get_part(font, 3, buf3);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
187 get_part(font, 5, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
188
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
189 if (!strcmp(buf2, "normal") && !strcmp(buf2, "Normal")
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
190 && !strcmp(buf2, "NORMAL"))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
191 sprintf(buf, "%s %s", buf3, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
192 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
193 strcpy(buf, buf3);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
194
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
195 get_part(font, 6, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
196
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
197 if (buf2[0] != '\0')
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
198 sprintf(buf3, "%s %s", buf, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
199 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
200 strcpy(buf3, buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
201
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
202 get_part(font, 4, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
203
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
204 if (!strcmp(buf2, "o") || !strcmp(buf2, "O"))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
205 sprintf(buf, "%s oblique", buf3);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
206 else if (!strcmp(buf2, "i") || !strcmp(buf2, "I"))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
207 sprintf(buf, "%s italic", buf3);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
208
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
209 if (!strcmp(buf, " "))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
210 strcpy(buf, "-");
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
211 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
212
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
213 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
214 * Given a font name this function returns the part used in the third
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
215 * scroll list.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
216 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
217 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
218 size_part(char *font, char *buf, int inPixels)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
219 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
220 int size;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
221 float temp;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
222
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
223 *buf = '\0';
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
224
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
225 if (inPixels)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
226 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
227 get_part(font, 7, buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
228 if (strlen(buf) > 0)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
229 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
230 size = atoi(buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
231 sprintf(buf, "%3d", size);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
232 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
233 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
234 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
235 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
236 get_part(font, 8, buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
237 if (strlen(buf) > 0)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
238 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
239 size = atoi(buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
240 temp = (float)size / 10.0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
241 size = temp;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
242 if (buf[strlen(buf) - 1] == '0')
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
243 sprintf(buf, "%3d", size);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
244 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
245 sprintf(buf, "%4.1f", temp);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
246 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
247 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
248 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
249
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
250 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
251 * Given a font name this function returns the part used in the choice menu.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
252 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
253 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
254 encoding_part(char *font, char *buf)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
255 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
256 char buf1[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
257 char buf2[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
258
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
259 *buf = '\0';
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
260
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
261 get_part(font, 13, buf1);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
262 get_part(font, 14, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
263
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
264 if (strlen(buf1) > 0 && strlen(buf2))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
265 sprintf(buf, "%s-%s", buf1, buf2);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
266 if (!strcmp(buf, " "))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
267 strcpy(buf, "-");
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
268 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
269
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
270 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
271 * Inserts a string into correct sorted position in a list.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
272 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
273 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
274 add_to_list(char **buf, char *item, int *count)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
275 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
276 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
277 int j;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
278
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
279 if (*count == MAX_ENTRIES_IN_LIST)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
280 return;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
281
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
282 /* avoid duplication */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
283 for (i = 0; i < *count; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
284 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
285 if (!strcmp(buf[i], item))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
286 return;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
287 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
288
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
289 /* find order place, but make sure that wild card comes first */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
290 if (!strcmp(item, wild))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
291 i = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
292 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
293 for (i = 0; i < *count; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
294 if (strcmp(buf[i], item) > 0 && strcmp(buf[i], wild))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
295 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
296
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
297 /* now insert the item */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
298 for (j = *count; j > i; --j)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
299 buf[j] = buf[j-1];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
300 buf[i] = XtNewString(item);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
301
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
302 ++(*count);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
303 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
304
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
305 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
306 * True if the font matches some field.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
307 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
308 static Boolean
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
309 match(SharedFontSelData *data, enum ListSpecifier l, int i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
310 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
311 char buf[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
312
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
313 /* An empty selection or a wild card matches anything.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
314 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
315 if (!data->sel[l] || !strcmp(data->sel[l], wild))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
316 return True;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
317
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
318 /* chunk out the desired part... */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
319 switch (l)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
320 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
321 case ENCODING:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
322 encoding_part(fn(data, i), buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
323 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
324
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
325 case NAME:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
326 name_part(fn(data, i), buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
327 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
328
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
329 case STYLE:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
330 style_part(fn(data, i), buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
331 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
332
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
333 case SIZE:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
334 size_part(fn(data, i), buf, data->in_pixels);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
335 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
336 default:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
337 ;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
338 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
339
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
340 /* ...and chew it now */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
341
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
342 return !strcmp(buf, data->sel[l]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
343 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
344
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
345 static Boolean
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
346 proportional(char *font)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
347 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
348 char buf[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
349
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
350 get_part(font, 11, buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
351
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
352 return !strcmp(buf, "p") || !strcmp(buf, "P");
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
353 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
354
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
355
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
356 static void encoding_callback(Widget w, SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
357 XtPointer dummy);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
358
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
359 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
360 * Parse through the fontlist data and set up the three scroll lists. The fix
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
361 * parameter can be used to exclude a list from any changes. This is used for
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
362 * updates after selections caused by the users actions.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
363 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
364 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
365 fill_lists(enum ListSpecifier fix, SharedFontSelData *data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
366 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
367 char *list[NONE][MAX_ENTRIES_IN_LIST];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
368 int count[NONE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
369 char buf[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
370 XmString items[MAX_ENTRIES_IN_LIST];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
371 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
372 int index;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
373
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
374 for (index = (int)ENCODING; index < (int)NONE; ++index)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
375 count[index] = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
376
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
377 /* First we insert the wild char into every single list. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
378 if (fix != ENCODING)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
379 add_to_list(list[ENCODING], wild, &count[ENCODING]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
380 if (fix != NAME)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
381 add_to_list(list[NAME], wild, &count[NAME]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
382 if (fix != STYLE)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
383 add_to_list(list[STYLE], wild, &count[STYLE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
384 if (fix != SIZE)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
385 add_to_list(list[SIZE], wild, &count[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
386
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
387 for (i = 0; i < data->num && i < MAX_ENTRIES_IN_LIST; i++)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
388 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
389 if (proportional(fn(data, i)))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
390 continue;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
391
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
392 if (fix != ENCODING
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
393 && match(data, NAME, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
394 && match(data, STYLE, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
395 && match(data, SIZE, i))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
396 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
397 encoding_part(fn(data, i), buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
398 add_to_list(list[ENCODING], buf, &count[ENCODING]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
399 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
400
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
401 if (fix != NAME
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
402 && match(data, ENCODING, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
403 && match(data, STYLE, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
404 && match(data, SIZE, i))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
405 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
406 name_part(fn(data, i), buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
407 add_to_list(list[NAME], buf, &count[NAME]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
408 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
409
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
410 if (fix != STYLE
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
411 && match(data, ENCODING, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
412 && match(data, NAME, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
413 && match(data, SIZE, i))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
414 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
415 style_part(fn(data, i), buf);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
416 add_to_list(list[STYLE], buf, &count[STYLE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
417 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
418
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
419 if (fix != SIZE
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
420 && match(data, ENCODING, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
421 && match(data, NAME, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
422 && match(data, STYLE, i))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
423 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
424 size_part(fn(data, i), buf, data->in_pixels);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
425 add_to_list(list[SIZE], buf, &count[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
426 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
427 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
428
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
429 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
430 * And now do the preselection in all lists where there was one:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
431 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
432
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
433 if (fix != ENCODING)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
434 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
435 Cardinal n_items;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
436 WidgetList children;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
437 Widget selected_button = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
438
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
439 /* Get and update the current button list. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
440 XtVaGetValues(data->encoding_pulldown,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
441 XmNchildren, &children,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
442 XmNnumChildren, &n_items,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
443 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
444
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
445 for (i = 0; i < count[ENCODING]; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
446 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
447 Widget button;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
448
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
449 items[i] = XmStringCreateLocalized(list[ENCODING][i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
450
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
451 if (i < n_items)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
452 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
453 /* recycle old button */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
454 XtVaSetValues(children[i],
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
455 XmNlabelString, items[i],
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
456 XmNuserData, i,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
457 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
458 button = children[i];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
459 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
460 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
461 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
462 /* create a new button */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
463 button = XtVaCreateManagedWidget("button",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
464 xmPushButtonGadgetClass,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
465 data->encoding_pulldown,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
466 XmNlabelString, items[i],
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
467 XmNuserData, i,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
468 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
469 XtAddCallback(button, XmNactivateCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
470 (XtCallbackProc) encoding_callback, (XtPointer) data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
471 XtManageChild(button);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
472 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
473
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
474 if (data->sel[ENCODING])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
475 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
476 if (!strcmp(data->sel[ENCODING], list[ENCODING][i]))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
477 selected_button = button;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
478 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
479 XtFree(list[ENCODING][i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
480 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
481
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
482 /* Destroy all the outstandig menu items.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
483 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
484 for (i = count[ENCODING]; i < n_items; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
485 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
486 XtUnmanageChild(children[i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
487 XtDestroyWidget(children[i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
488 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
489
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
490 /* Preserve the current selection visually.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
491 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
492 if (selected_button)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
493 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
494 XtVaSetValues(data->encoding_menu,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
495 XmNmenuHistory, selected_button,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
496 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
497 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
498
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
499 for (i = 0; i < count[ENCODING]; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
500 XmStringFree(items[i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
501 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
502
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
503 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
504 * Now loop trough the remaining lists and set them up.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
505 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
506 for (index = (int)NAME; index < (int)NONE; ++index)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
507 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
508 Widget w;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
509
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
510 if (fix == (enum ListSpecifier)index)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
511 continue;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
512
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
513 switch ((enum ListSpecifier)index)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
514 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
515 case NAME:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
516 w = data->list[NAME];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
517 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
518 case STYLE:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
519 w = data->list[STYLE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
520 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
521 case SIZE:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
522 w = data->list[SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
523 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
524 default:
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
525 w = (Widget)0; /* for lint */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
526 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
527
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
528 for (i = 0; i < count[index]; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
529 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
530 items[i] = XmStringCreateLocalized(list[index][i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
531 XtFree(list[index][i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
532 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
533 XmListDeleteAllItems(w);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
534 XmListAddItems(w, items, count[index], 1);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
535 if (data->sel[index])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
536 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
537 XmStringFree(items[0]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
538 items[0] = XmStringCreateLocalized(data->sel[index]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
539 XmListSelectItem(w, items[0], False);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
540 XmListSetBottomItem(w, items[0]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
541 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
542 for (i = 0; i < count[index]; ++i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
543 XmStringFree(items[i]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
544 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
545 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
546
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
547 /*ARGSUSED*/
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
548 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
549 stoggle_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
550 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
551 XmToggleButtonCallbackStruct *call_data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
552 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
553 int i, do_sel;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
554 char newSize[10];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
555 XmString str;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
556
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
557 if (call_data->reason != (int)XmCR_VALUE_CHANGED)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
558 return;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
559
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
560 do_sel = (data->sel[SIZE] != NULL) && strcmp(data->sel[SIZE], wild);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
561
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
562 for (i = 0; do_sel && (i < data->num); i++)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
563 if (match(data, ENCODING, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
564 && match(data, NAME, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
565 && match(data, STYLE, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
566 && match(data, SIZE, i))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
567 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
568 size_part(fn(data, i), newSize, !data->in_pixels);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
569 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
570 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
571
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
572 data->in_pixels = !data->in_pixels;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
573
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
574 if (data->sel[SIZE])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
575 XtFree(data->sel[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
576 data->sel[SIZE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
577 fill_lists(NONE, data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
578
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
579 if (do_sel)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
580 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
581 str = XmStringCreateLocalized(newSize);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
582 XmListSelectItem(data->list[SIZE], str, True);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
583 XmListSetBottomItem(data->list[SIZE], str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
584 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
585 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
586 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
587
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
588 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
589 * Show the currently selected font in the sample text label.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
590 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
591 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
592 display_sample(SharedFontSelData *data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
593 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
594 Arg args[2];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
595 int n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
596 XFontStruct * font;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
597 XmFontList font_list;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
598 Display * display;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
599 XmString str;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
600
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
601 display = XtDisplay(data->dialog);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
602 font = XLoadQueryFont(display, data->font_name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
603 font_list = gui_motif_create_fontlist(font);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
604
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
605 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
606 str = XmStringCreateLocalized("AaBbZzYy 0123456789");
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
607 XtSetArg(args[n], XmNlabelString, str); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
608 XtSetArg(args[n], XmNfontList, font_list); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
609
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
610 XtSetValues(data->sample, args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
611 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
612
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
613 if (data->old)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
614 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
615 XFreeFont(display, data->old);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
616 XmFontListFree(data->old_list);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
617 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
618 data->old = font;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
619 data->old_list = font_list;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
620 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
621
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
622
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
623 static Boolean
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
624 do_choice(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
625 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
626 XmListCallbackStruct *call_data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
627 enum ListSpecifier which)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
628 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
629 char *sel;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
630
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
631 XmStringGetLtoR(call_data->item, XmSTRING_DEFAULT_CHARSET, &sel);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
632
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
633 if (!data->sel[which])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
634 data->sel[which] = XtNewString(sel);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
635 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
636 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
637 XtFree(data->sel[which]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
638 if (!strcmp(data->sel[which], sel))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
639 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
640 /* unselecting current selection */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
641 data->sel[which] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
642 if (w)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
643 XmListDeselectItem(w, call_data->item);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
644 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
645 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
646 data->sel[which] = XtNewString(sel);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
647 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
648 XtFree(sel);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
649
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
650 fill_lists(which, data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
651
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
652 /* If there is a font selection, we display it. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
653 if (data->sel[ENCODING]
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
654 && data->sel[NAME]
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
655 && data->sel[STYLE]
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
656 && data->sel[SIZE]
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
657 && strcmp(data->sel[ENCODING], wild)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
658 && strcmp(data->sel[NAME], wild)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
659 && strcmp(data->sel[STYLE], wild)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
660 && strcmp(data->sel[SIZE], wild))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
661 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
662 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
663
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
664 if (data->font_name)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
665 XtFree(data->font_name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
666 data->font_name = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
667
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
668 for (i = 0; i < data->num; i++)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
669 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
670 if (match(data, ENCODING, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
671 && match(data, NAME, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
672 && match(data, STYLE, i)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
673 && match(data, SIZE, i))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
674 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
675 data->font_name = XtNewString(fn(data, i));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
676 break;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
677 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
678 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
679
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
680 if (data->font_name)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
681 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
682 XmTextSetString(data->name, data->font_name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
683 display_sample(data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
684 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
685 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
686 do_dialog(VIM_ERROR,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
687 (char_u *)_("Error"),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
688 (char_u *)_("Invalid font specification"),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
689 (char_u *)_("&Dismiss"), 1, NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
690
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
691 return True;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
692 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
693 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
694 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
695 int n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
696 XmString str;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
697 Arg args[4];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
698 char *msg = _("no specific match");
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
699
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
700 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
701 str = XmStringCreateLocalized(msg);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
702 XtSetArg(args[n], XmNlabelString, str); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
703 XtSetValues(data->sample, args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
704 apply_fontlist(data->sample);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
705 XmTextSetString(data->name, msg);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
706 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
707
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
708 return False;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
709 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
710 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
711
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
712 /*ARGSUSED*/
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
713 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
714 encoding_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
715 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
716 XtPointer dummy)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
717 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
718 XmString str;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
719 XmListCallbackStruct fake_data;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
720
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
721 XtVaGetValues(w, XmNlabelString, &str, NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
722
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
723 if (!str)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
724 return;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
725
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
726 fake_data.item = str;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
727
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
728 do_choice(0, data, &fake_data, ENCODING);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
729 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
730
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
731 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
732 name_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
733 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
734 XmListCallbackStruct *call_data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
735 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
736 do_choice(w, data, call_data, NAME);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
737 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
738
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
739 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
740 style_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
741 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
742 XmListCallbackStruct *call_data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
743 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
744 do_choice(w, data, call_data, STYLE);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
745 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
746
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
747 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
748 size_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
749 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
750 XmListCallbackStruct *call_data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
751 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
752 do_choice(w, data, call_data, SIZE);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
753 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
754
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
755 /*ARGSUSED*/
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
756 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
757 cancel_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
758 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
759 XmListCallbackStruct *call_data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
760 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
761 if (data->sel[ENCODING])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
762 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
763 XtFree(data->sel[ENCODING]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
764 data->sel[ENCODING] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
765 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
766 if (data->sel[NAME])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
767 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
768 XtFree(data->sel[NAME]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
769 data->sel[NAME] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
770 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
771 if (data->sel[STYLE])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
772 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
773 XtFree(data->sel[STYLE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
774 data->sel[STYLE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
775 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
776 if (data->sel[SIZE])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
777 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
778 XtFree(data->sel[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
779 data->sel[SIZE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
780 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
781
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
782 if (data->font_name)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
783 XtFree(data->font_name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
784 data->font_name = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
785
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
786 data->num = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
787 XFreeFontNames(data->names);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
788 data->names = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
789 data->exit = True;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
790 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
791
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
792 /*ARGSUSED*/
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
793 static void
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
794 ok_callback(Widget w,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
795 SharedFontSelData *data,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
796 XmPushButtonCallbackStruct *call_data)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
797 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
798 char *pattern;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
799 char **name;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
800 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
801
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
802 pattern = XmTextGetString(data->name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
803 name = XListFonts(XtDisplay(data->dialog), pattern, 1, &i);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
804 XtFree(pattern);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
805
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
806 if (i != 1)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
807 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
808 do_dialog(VIM_ERROR,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
809 (char_u *)_("Error"),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
810 (char_u *)_("Invalid font specification"),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
811 (char_u *)_("&Dismiss"), 1, NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
812 XFreeFontNames(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
813 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
814 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
815 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
816 if (data->font_name)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
817 XtFree(data->font_name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
818 data->font_name = XtNewString(name[0]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
819
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
820 if (data->sel[ENCODING])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
821 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
822 XtFree(data->sel[ENCODING]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
823 data->sel[ENCODING] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
824 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
825 if (data->sel[NAME])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
826 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
827 XtFree(data->sel[NAME]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
828 data->sel[NAME] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
829 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
830 if (data->sel[STYLE])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
831 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
832 XtFree(data->sel[STYLE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
833 data->sel[STYLE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
834 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
835 if (data->sel[SIZE])
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
836 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
837 XtFree(data->sel[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
838 data->sel[SIZE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
839 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
840
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
841 XFreeFontNames(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
842
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
843 data->num = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
844 XFreeFontNames(data->names);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
845 data->names = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
846 data->exit = True;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
847 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
848 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
849
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
850 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
851 * Returns pointer to an ASCII character string that contains the name of the
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
852 * selected font (in X format for naming fonts); it is the users responsibility
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
853 * to free the space allocated to this string.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
854 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
855 char_u *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
856 gui_xm_select_font(char_u *current)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
857 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
858 static SharedFontSelData _data;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
859
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
860 Widget parent;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
861 Widget form;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
862 Widget separator;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
863 Widget sub_form;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
864 Widget size_toggle;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
865 Widget name;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
866 Widget disp_frame;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
867 Widget frame;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
868 Arg args[64];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
869 int n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
870 XmString str;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
871 char big_font[MAX_FONT_NAME_LEN];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
872 SharedFontSelData *data;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
873
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
874 data = &_data;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
875
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
876 parent = vimShell;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
877 data->names = XListFonts(XtDisplay(parent), "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
878 MAX_FONTS, &data->num);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
879
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
880 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
881 * Find the name of the biggest font less than the given limit
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
882 * MAX_DISPLAY_SIZE used to set up the initial height of the display
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
883 * widget.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
884 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
885
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
886 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
887 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
888 int max;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
889 int index = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
890 int size;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
891 char str[128];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
892
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
893 for (i = 0, max = 0; i < data->num; i++)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
894 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
895 get_part(fn(data, i), 7, str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
896 size = atoi(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
897 if ((size > max) && (size < MAX_DISPLAY_SIZE))
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
898 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
899 index = i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
900 max = size;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
901 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
902 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
903 strcpy(big_font, fn(data, index));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
904 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
905 data->old = XLoadQueryFont(XtDisplay(parent), big_font);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
906 data->old_list = gui_motif_create_fontlist(data->old);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
907
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
908 /* Set the title of the Dialog window. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
909 data->dialog = XmCreateDialogShell(parent, "fontSelector", NULL, 0);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
910 str = XmStringCreateLocalized(_("Vim - Font Selector"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
911
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
912 /* Create form popup dialog widget. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
913 form = XtVaCreateWidget("form",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
914 xmFormWidgetClass, data->dialog,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
915 XmNdialogTitle, str,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
916 XmNautoUnmanage, False,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
917 XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
918 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
919 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
920
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
921 sub_form = XtVaCreateManagedWidget("subForm",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
922 xmFormWidgetClass, form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
923 XmNbottomAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
924 XmNbottomOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
925 XmNrightAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
926 XmNrightOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
927 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
928 XmNtopOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
929 XmNorientation, XmVERTICAL,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
930 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
931
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
932 data->ok = XtVaCreateManagedWidget(_("OK"),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
933 xmPushButtonGadgetClass, sub_form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
934 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
935 XmNrightAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
936 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
937 XmNtopOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
938 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
939 apply_fontlist(data->ok);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
940
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
941 data->cancel = XtVaCreateManagedWidget(_("Cancel"),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
942 xmPushButtonGadgetClass, sub_form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
943 XmNrightAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
944 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
945 XmNtopAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
946 XmNtopWidget, data->ok,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
947 XmNtopOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
948 XmNshowAsDefault, True,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
949 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
950 apply_fontlist(data->cancel);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
951
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
952 /* Create the separator for beauty. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
953 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
954 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
955 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
956 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
957 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
958 XtSetArg(args[n], XmNrightWidget, sub_form); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
959 XtSetArg(args[n], XmNrightOffset, 4); n++;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
960 separator = XmCreateSeparatorGadget(form, "separator", args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
961 XtManageChild(separator);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
962
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
963 /* Create font name text widget and the corresponding label. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
964 data->name = XtVaCreateManagedWidget("fontName",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
965 xmTextWidgetClass, form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
966 XmNbottomAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
967 XmNbottomOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
968 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
969 XmNleftOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
970 XmNrightAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
971 XmNrightWidget, separator,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
972 XmNrightOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
973 XmNeditable, False,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
974 XmNeditMode, XmSINGLE_LINE_EDIT,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
975 XmNmaxLength, MAX_FONT_NAME_LEN,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
976 XmNcolumns, 60,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
977 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
978
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
979 str = XmStringCreateLocalized(_("Name:"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
980 name = XtVaCreateManagedWidget("fontNameLabel",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
981 xmLabelGadgetClass, form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
982 XmNlabelString, str,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
983 XmNuserData, data->name,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
984 XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
985 XmNleftWidget, data->name,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
986 XmNbottomAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
987 XmNbottomWidget, data->name,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
988 XmNtopOffset, 1,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
989 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
990 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
991 apply_fontlist(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
992
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
993 /* create sample display label widget */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
994 disp_frame = XtVaCreateManagedWidget("sampleFrame",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
995 xmFrameWidgetClass, form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
996 XmNshadowType, XmSHADOW_ETCHED_IN,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
997 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
998 XmNleftOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
999 XmNbottomAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1000 XmNbottomWidget, name,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1001 XmNrightAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1002 XmNrightWidget, separator,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1003 XmNrightOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1004 XmNalignment, XmALIGNMENT_BEGINNING,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1005 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1006
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1007 data->sample = XtVaCreateManagedWidget("sampleLabel",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1008 xmLabelWidgetClass, disp_frame,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1009 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1010 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1011 XmNbottomAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1012 XmNrightAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1013 XmNalignment, XmALIGNMENT_BEGINNING,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1014 XmNrecomputeSize, False,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1015 XmNfontList, data->old_list,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1016 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1017
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1018 /* create toggle button */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1019 str = XmStringCreateLocalized(_("Show size in Points"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1020 size_toggle = XtVaCreateManagedWidget("sizeToggle",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1021 xmToggleButtonGadgetClass, form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1022 XmNlabelString, str,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1023 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1024 XmNleftOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1025 XmNbottomAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1026 XmNbottomWidget, disp_frame,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1027 XmNbottomOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1028 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1029 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1030 apply_fontlist(size_toggle);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1031 XtManageChild(size_toggle);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1032
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1033 /* Encoding pulldown menu.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1034 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1035
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1036 data->encoding_pulldown = XmCreatePulldownMenu(form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1037 "encodingPulldown", NULL, 0);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1038 str = XmStringCreateLocalized(_("Encoding:"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1039 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1040 XtSetArg(args[n], XmNsubMenuId, data->encoding_pulldown); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1041 XtSetArg(args[n], XmNlabelString, str); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1042 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1043 XtSetArg(args[n], XmNleftOffset, 4); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1044 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1045 XtSetArg(args[n], XmNbottomWidget, size_toggle); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1046 XtSetArg(args[n], XmNbottomOffset, 4); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1047 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1048 XtSetArg(args[n], XmNrightWidget, separator); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1049 XtSetArg(args[n], XmNrightOffset, 4); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1050 data->encoding_menu = XmCreateOptionMenu(form, "encodingMenu", args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1051 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1052 XmAddTabGroup(data->encoding_menu);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1053
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1054 /*
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1055 * Create scroll list widgets in a separate subform used to manage the
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1056 * different sizes of the lists.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1057 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1058
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1059 sub_form = XtVaCreateManagedWidget("subForm",
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1060 xmFormWidgetClass, form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1061 XmNbottomAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1062 XmNbottomWidget, data->encoding_menu,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1063 XmNbottomOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1064 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1065 XmNleftOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1066 XmNrightAttachment, XmATTACH_WIDGET,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1067 XmNrightWidget, separator,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1068 XmNrightOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1069 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1070 XmNtopOffset, 2,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1071 XmNorientation, XmVERTICAL,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1072 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1073
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1074 /* font list */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1075 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1076 XmNshadowThickness, 0,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1077 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1078 XmNbottomAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1079 XmNleftAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1080 XmNrightAttachment, XmATTACH_POSITION,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1081 XmNrightPosition, 50,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1082 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1083
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1084 str = XmStringCreateLocalized(_("Font:"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1085 name = XtVaCreateManagedWidget("nameListLabel", xmLabelGadgetClass, frame,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1086 XmNchildType, XmFRAME_TITLE_CHILD,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1087 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1088 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1089 XmNlabelString, str,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1090 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1091 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1092 apply_fontlist(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1093
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1094 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1095 XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1096 XtSetArg(args[n], XmNresizable, True); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1097 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1098 XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1099 #ifdef LESSTIF_VERSION
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1100 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1101 #endif
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1102 data->list[NAME] = XmCreateScrolledList(frame, "fontList", args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1103 XtVaSetValues(name, XmNuserData, data->list[NAME], NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1104
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1105 /* style list */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1106 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1107 XmNshadowThickness, 0,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1108 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1109 XmNbottomAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1110 XmNleftAttachment, XmATTACH_POSITION,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1111 XmNleftPosition, 50,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1112 XmNleftOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1113 XmNrightAttachment, XmATTACH_POSITION,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1114 XmNrightPosition, 80,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1115 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1116
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1117 str = XmStringCreateLocalized(_("Style:"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1118 name = XtVaCreateManagedWidget("styleListLabel", xmLabelWidgetClass, frame,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1119 XmNchildType, XmFRAME_TITLE_CHILD,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1120 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1121 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1122 XmNlabelString, str,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1123 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1124 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1125 apply_fontlist(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1126
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1127 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1128 XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1129 XtSetArg(args[n], XmNresizable, True); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1130 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1131 XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1132 #ifdef LESSTIF_VERSION
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1133 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1134 #endif
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1135 data->list[STYLE] = XmCreateScrolledList(frame, "styleList", args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1136 XtVaSetValues(name, XmNuserData, data->list[STYLE], NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1137
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1138 /* size list */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1139 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1140 XmNshadowThickness, 0,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1141 XmNtopAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1142 XmNbottomAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1143 XmNleftAttachment, XmATTACH_POSITION,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1144 XmNleftPosition, 80,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1145 XmNleftOffset, 4,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1146 XmNrightAttachment, XmATTACH_FORM,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1147 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1148
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1149 str = XmStringCreateLocalized(_("Size:"));
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1150 name = XtVaCreateManagedWidget("sizeListLabel", xmLabelGadgetClass, frame,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1151 XmNchildType, XmFRAME_TITLE_CHILD,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1152 XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1153 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1154 XmNlabelString, str,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1155 NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1156 XmStringFree(str);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1157 apply_fontlist(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1158
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1159 n = 0;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1160 XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1161 XtSetArg(args[n], XmNresizable, True); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1162 XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1163 XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1164 #ifdef LESSTIF_VERSION
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1165 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1166 #endif
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1167 data->list[SIZE] = XmCreateScrolledList(frame, "sizeList", args, n);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1168 XtVaSetValues(name, XmNuserData, data->list[SIZE], NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1169
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1170 /* update form widgets cancel button */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1171 XtVaSetValues(form, XmNcancelButton, data->cancel, NULL);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1172
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1173 XtAddCallback(size_toggle, XmNvalueChangedCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1174 (XtCallbackProc)stoggle_callback, (XtPointer)data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1175 XtAddCallback(data->list[NAME], XmNbrowseSelectionCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1176 (XtCallbackProc)name_callback, (XtPointer)data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1177 XtAddCallback(data->list[STYLE], XmNbrowseSelectionCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1178 (XtCallbackProc)style_callback, (XtPointer)data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1179 XtAddCallback(data->list[SIZE], XmNbrowseSelectionCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1180 (XtCallbackProc)size_callback, (XtPointer)data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1181 XtAddCallback(data->ok, XmNactivateCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1182 (XtCallbackProc)ok_callback, (XtPointer)data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1183 XtAddCallback(data->cancel, XmNactivateCallback,
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1184 (XtCallbackProc)cancel_callback, (XtPointer)data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1185
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1186 XmProcessTraversal(data->list[NAME], XmTRAVERSE_CURRENT);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1187
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1188 /* setup tabgroups */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1189
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1190 XmAddTabGroup(data->list[NAME]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1191 XmAddTabGroup(data->list[STYLE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1192 XmAddTabGroup(data->list[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1193 XmAddTabGroup(size_toggle);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1194 XmAddTabGroup(data->name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1195 XmAddTabGroup(data->ok);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1196 XmAddTabGroup(data->cancel);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1197
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1198 add_cancel_action(data->dialog, (XtCallbackProc)cancel_callback, data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1199
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1200 /* Preset selection data. */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1201
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1202 data->exit = False;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1203 data->in_pixels= True;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1204 data->sel[ENCODING] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1205 data->sel[NAME] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1206 data->sel[STYLE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1207 data->sel[SIZE] = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1208 data->font_name = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1209
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1210 /* set up current font parameters */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1211 if (current && current[0] != '\0')
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1212 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1213 int i;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1214 char **names;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1215
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1216 names = XListFonts(XtDisplay(form), (char *) current, 1, &i);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1217
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1218 if (i != 0)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1219 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1220 char name[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1221 char style[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1222 char size[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1223 char encoding[TEMP_BUF_SIZE];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1224 char *found;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1225
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1226 found = names[0];
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1227
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1228 name_part(found, name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1229 style_part(found, style);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1230 size_part(found, size, data->in_pixels);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1231 encoding_part(found, encoding);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1232
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1233 if (strlen(name) > 0
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1234 && strlen(style) > 0
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1235 && strlen(size) > 0
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1236 && strlen(encoding) > 0)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1237 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1238 data->sel[NAME] = XtNewString(name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1239 data->sel[STYLE] = XtNewString(style);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1240 data->sel[SIZE] = XtNewString(size);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1241 data->sel[ENCODING] = XtNewString(encoding);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1242 data->font_name = XtNewString(names[0]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1243 display_sample(data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1244 XmTextSetString(data->name, data->font_name);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1245 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1246 else
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1247 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1248 /* We can't preset a symbolic name, which isn't a full font
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1249 * description. Therefore we just behave the same way as if the
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1250 * user didn't have selected anything thus far.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1251 *
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1252 * Unfortunately there is no known way to expand an abbreviated
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1253 * font name.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1254 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1255
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1256 data->font_name = NULL;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1257 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1258 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1259 XFreeFontNames(names);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1260 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1261
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1262 fill_lists(NONE, data);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1263
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1264 /* Unfortunately LessTif doesn't align the list widget's properly. I don't
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1265 * have currently any idea how to fix this problem.
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1266 */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1267 XtManageChild(data->list[NAME]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1268 XtManageChild(data->list[STYLE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1269 XtManageChild(data->list[SIZE]);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1270 XtManageChild(data->encoding_menu);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1271 manage_centered(form);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1272
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1273 /* modal event loop */
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1274 while (!data->exit)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1275 XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog),
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1276 (XtInputMask)XtIMAll);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1277
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1278 XtDestroyWidget(data->dialog);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1279
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1280 if (data->old)
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1281 {
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1282 XFreeFont(XtDisplay(data->dialog), data->old);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1283 XmFontListFree(data->old_list);
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1284 }
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1285
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1286 gui_motif_synch_fonts();
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1287
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1288 return (char_u *) data->font_name;
af1bcb9a13c0 updated for version 7.0027
vimboss
parents:
diff changeset
1289 }