1 /*
2 * TTTTTTTTTTTTTT EEEEEEEEEEEEEE OOOOOOOOOOOOOO
3 * TTTTTTTTTTTTTT EEEEEEEEEEEEEE OOOOOOOOOOOOOO
4 * TT EE OO OO
5 * TT EE OO OO
6 * TT EE OO OO
7 * TT EEEEEEEEEE OO OO
8 * TT EEEEEEEEEE OO OO
9 * TT EE OO OO
10 * TT EE OO OO
11 * TT EE OO OO
12 * TT EEEEEEEEEEEEEE OOOOOOOOOOOOOO
13 * TT EEEEEEEEEEEEEE OOOOOOOOOOOOOO
14 *
15 * L'�mulateur Thomson TO8
16 *
17 * Copyright (C) 1997-2017 Gilles F�tis, Eric Botcazou, Alexandre Pukall,
18 * J�r�mie Guillaume, Fran�ois Mouret
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 */
34
35 /*
36 * Module : win/wgui/wprinter.c
37 * Version : 1.8.4
38 * Cr�� par : Fran�ois Mouret 22/04/2012
39 * Modifi� par: Fran�ois Mouret 24/10/2012 20/09/2013 10/05/2014
40 *
41 * Gestion des imprimantes.
42 */
43
44
45 #ifndef SCAN_DEPEND
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <unistd.h>
50 #endif
51
52 #include "std.h"
53 #include "teo.h"
54 #include "media/printer.h"
55 #include "win/gui.h"
56
57
update_options(HWND hWnd,int number)58 static void update_options (HWND hWnd, int number)
59 {
60 if (number >= PRINTER_NUMBER)
61 number = 0;
62
63 teo.lprt.number = printer_code_list[number].number;
64
65 if (teo.lprt.number < 600)
66 {
67 Button_Enable(GetDlgItem (hWnd, IDC_PRINTER_DIP_CHECK), FALSE);
68 Button_Enable(GetDlgItem (hWnd, IDC_PRINTER_NLQ_CHECK), FALSE);
69 }
70 else
71 {
72 Button_Enable(GetDlgItem (hWnd, IDC_PRINTER_DIP_CHECK), TRUE);
73 Button_Enable(GetDlgItem (hWnd, IDC_PRINTER_NLQ_CHECK), TRUE);
74 }
75 }
76
77
78
79 /*
80 * Callback pour la bo�te de dialogue du r�pertoire.
81 */
BrowseCallbackProc(HWND hWnd,UINT uMsg,LPARAM lParam,LPARAM lpData)82 static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg,
83 LPARAM lParam, LPARAM lpData)
84 {
85 if (uMsg == BFFM_INITIALIZED)
86 SendMessage(hWnd, BFFM_SETSELECTION, TRUE, lpData);
87 return 0;
88
89 (void) lParam;
90 }
91
92
93
94 /* open_folder:
95 * S�lection d'un r�pertoire.
96 */
open_folder(HWND hWnd)97 static void open_folder (HWND hWnd)
98 {
99 BROWSEINFO bi;
100 ITEMIDLIST *pidl;
101 static char folder[MAX_PATH] = "";
102
103 bi.hwndOwner = hWnd;
104 bi.pidlRoot = NULL;
105 bi.pszDisplayName = (LPTSTR)folder;
106 bi.lpszTitle = is_fr ? "Choisir un r�pertoire":"Choose a directory";
107 bi.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
108 bi.lpfn = BrowseCallbackProc;
109 bi.lParam = (LPARAM)folder;
110 pidl = SHBrowseForFolder(&bi);
111 if (SHGetPathFromIDList(pidl, (LPTSTR)folder) == TRUE)
112 {
113 SetWindowText(GetDlgItem(hWnd, IDC_PRINTER_MORE_EDIT),
114 std_LastDir(folder));
115 teo.lprt.folder = std_free (teo.lprt.folder);
116 teo.lprt.folder = std_strdup_printf ("%s", folder);
117 }
118 }
119
120
121 /* ------------------------------------------------------------------------- */
122
123
124 /* wprinter_TabProc:
125 * Proc�dure pour l'onglet des imprimantes
126 */
wprinter_TabProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)127 int CALLBACK wprinter_TabProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
128 {
129 int i;
130 int state;
131 int combo_index = 0;
132 int first = 1;
133 HANDLE himg;
134 char str[MAX_PATH+1] = "";
135 HWND hw;
136
137 switch(uMsg)
138 {
139 case WM_INITDIALOG:
140 if (first != 0)
141 {
142 if (teo.lprt.folder == NULL)
143 {
144 (void)getcwd (str, MAX_PATH);
145 teo.lprt.folder = std_free (teo.lprt.folder);
146 teo.lprt.folder = std_strdup_printf ("%s", str);
147 }
148 first = 0;
149 }
150
151 /* initialisation du combo */
152 SendDlgItemMessage(hWnd,
153 IDC_PRINTER_CHOOSE_COMBO,
154 CB_RESETCONTENT,
155 0,
156 0);
157 for (i=0; i<PRINTER_NUMBER; i++)
158 {
159 SendDlgItemMessage(hWnd,
160 IDC_PRINTER_CHOOSE_COMBO,
161 CB_ADDSTRING,
162 0,
163 (LPARAM) printer_code_list[i].name);
164 if (teo.lprt.number == printer_code_list[i].number)
165 combo_index = i;
166 }
167 SendDlgItemMessage(hWnd,
168 IDC_PRINTER_CHOOSE_COMBO,
169 CB_SETCURSEL,
170 combo_index,
171 0);
172
173 /* initialisation des cases � cocher */
174 state = (teo.lprt.dip == TRUE) ? BST_CHECKED : BST_UNCHECKED;
175 CheckDlgButton(hWnd, IDC_PRINTER_DIP_CHECK, state);
176 state = (teo.lprt.nlq == TRUE) ? BST_CHECKED : BST_UNCHECKED;
177 CheckDlgButton(hWnd, IDC_PRINTER_NLQ_CHECK, state);
178 state = (teo.lprt.raw_output == TRUE) ? BST_CHECKED : BST_UNCHECKED;
179 CheckDlgButton(hWnd, IDC_PRINTER_RAW_CHECK, state);
180 state = (teo.lprt.txt_output == TRUE) ? BST_CHECKED : BST_UNCHECKED;
181 CheckDlgButton(hWnd, IDC_PRINTER_TXT_CHECK, state);
182 state = (teo.lprt.gfx_output == TRUE) ? BST_CHECKED : BST_UNCHECKED;
183 CheckDlgButton(hWnd, IDC_PRINTER_GFX_CHECK, state);
184
185 /* initialisation des images pour les boutons */
186 himg = LoadImage (prog_inst,
187 "folder_ico",
188 IMAGE_ICON,
189 0,
190 0,
191 LR_DEFAULTCOLOR);
192 hw = GetDlgItem(hWnd, IDC_PRINTER_MORE_BUTTON);
193 SendMessage(hw, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)himg );
194
195 /* initialisation des textes */
196 hw = GetDlgItem(hWnd, IDC_PRINTER_OPTIONS_GROUP);
197 SetWindowText(hw, is_fr?"Imprimante":"Printer");
198 hw = GetDlgItem(hWnd, IDC_PRINTER_CHOOSE_RTEXT);
199 SetWindowText(hw, "Type ");
200 hw = GetDlgItem(hWnd, IDC_PRINTER_DIP_CHECK);
201 SetWindowText(hw, is_fr?"Double interligne":"Double spacing");
202 hw = GetDlgItem(hWnd, IDC_PRINTER_NLQ_CHECK);
203 SetWindowText(hw, is_fr?"Imprime en haute qualit�"
204 :"High quality print");
205 hw = GetDlgItem(hWnd, IDC_PRINTER_OUTPUT_GROUP);
206 SetWindowText(hw, is_fr?"Sortie":"Output");
207 hw = GetDlgItem(hWnd, IDC_PRINTER_RAW_CHECK);
208 SetWindowText(hw, is_fr?"brute":"raw");
209 hw = GetDlgItem(hWnd, IDC_PRINTER_TXT_CHECK);
210 SetWindowText(hw, is_fr?"texte":"text");
211 hw = GetDlgItem(hWnd, IDC_PRINTER_GFX_CHECK);
212 SetWindowText(hw, is_fr?"graphique":"graphic");
213 hw = GetDlgItem(hWnd, IDC_PRINTER_MORE_EDIT);
214 SetWindowText(hw, std_LastDir(teo.lprt.folder));
215 hw = GetDlgItem(hWnd, IDC_PRINTER_MORE_RTEXT);
216 SetWindowText(hw, is_fr?"Sauver les fichiers dans "
217 :"Saving output files in ");
218
219 /* initialisation des info-bulles */
220 wgui_CreateTooltip (hWnd,
221 IDC_PRINTER_MORE_BUTTON,
222 is_fr?"Choisir un r�pertoire de sauvegarde"
223 :"Choose a save folder");
224 update_options (hWnd, combo_index);
225 return TRUE;
226
227 case WM_COMMAND:
228 switch(LOWORD(wParam))
229 {
230 case IDC_PRINTER_MORE_BUTTON:
231 open_folder (hWnd);
232 break;
233
234 case IDC_PRINTER_DIP_CHECK:
235 state = IsDlgButtonChecked(hWnd, IDC_PRINTER_DIP_CHECK);
236 teo.lprt.dip = (state == BST_CHECKED) ? TRUE : FALSE;
237 break;
238
239 case IDC_PRINTER_NLQ_CHECK:
240 state = IsDlgButtonChecked(hWnd, IDC_PRINTER_NLQ_CHECK);
241 teo.lprt.nlq = (state == BST_CHECKED) ? TRUE : FALSE;
242 break;
243
244 case IDC_PRINTER_RAW_CHECK:
245 state = IsDlgButtonChecked(hWnd, IDC_PRINTER_RAW_CHECK);
246 teo.lprt.raw_output = (state == BST_CHECKED) ? TRUE : FALSE;
247 break;
248
249 case IDC_PRINTER_TXT_CHECK:
250 state = IsDlgButtonChecked(hWnd, IDC_PRINTER_TXT_CHECK);
251 teo.lprt.txt_output = (state == BST_CHECKED) ? TRUE : FALSE;
252 break;
253
254 case IDC_PRINTER_GFX_CHECK:
255 state = IsDlgButtonChecked(hWnd, IDC_PRINTER_GFX_CHECK);
256 teo.lprt.gfx_output = (state == BST_CHECKED) ? TRUE : FALSE;
257 break;
258
259 case IDC_PRINTER_CHOOSE_COMBO:
260 if (HIWORD(wParam)==CBN_SELCHANGE)
261 {
262 combo_index = SendDlgItemMessage(hWnd,
263 IDC_PRINTER_CHOOSE_COMBO,
264 CB_GETCURSEL,
265 0,
266 0);
267 update_options (hWnd, combo_index);
268 }
269 break;
270 }
271 return TRUE;
272
273 default:
274 return FALSE;
275 }
276 }
277