~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gphoto2.ds/ui.c

Version: ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2 * TWAIN32 Options UI
  3 *
  4 * Copyright 2006 CodeWeavers, Aric Stewart
  5 *
  6 * This library is free software; you can redistribute it and/or
  7 * modify it under the terms of the GNU Lesser General Public
  8 * License as published by the Free Software Foundation; either
  9 * version 2.1 of the License, or (at your option) any later version.
 10 *
 11 * This library is distributed in the hope that it will be useful,
 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14 * Lesser General Public License for more details.
 15 *
 16 * You should have received a copy of the GNU Lesser General Public
 17 * License along with this library; if not, write to the Free Software
 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19 */
 20 
 21 #include "config.h"
 22 
 23 #include <stdlib.h>
 24 #include <stdarg.h>
 25 #include <stdio.h>
 26 
 27 #define NONAMELESSUNION
 28 #define NONAMELESSSTRUCT
 29 #include "windef.h"
 30 #include "winbase.h"
 31 #include "winuser.h"
 32 #include "winnls.h"
 33 #include "wingdi.h"
 34 #include "winreg.h"
 35 #include "commctrl.h"
 36 #include "prsht.h"
 37 #include "twain.h"
 38 #include "gphoto2_i.h"
 39 #include "wine/debug.h"
 40 #include "resource.h"
 41 
 42 LPCSTR settings_key = "Software\\Wine\\Gphoto2";
 43 LPCSTR settings_value = "SkipUI";
 44 static BOOL disable_dialog;
 45 static HBITMAP static_bitmap;
 46 
 47 static INT_PTR CALLBACK ConnectingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 48 {
 49         return FALSE;
 50 }
 51 
 52 static void on_disable_dialog_clicked(HWND dialog)
 53 {
 54     if (IsDlgButtonChecked(dialog, IDC_SKIP) == BST_CHECKED)
 55         disable_dialog = TRUE;
 56     else
 57         disable_dialog = FALSE;
 58 }
 59 
 60 static void UI_EndDialog(HWND hwnd, INT_PTR rc)
 61 {
 62     if (disable_dialog)
 63     {
 64         HKEY key;
 65         const DWORD data = 1;
 66         if (RegCreateKeyExA(HKEY_CURRENT_USER, settings_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS)
 67         {
 68             RegSetValueExA(key, settings_value, 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
 69             RegCloseKey(key);
 70         }
 71     }
 72     EndDialog(hwnd, rc);
 73 }
 74 
 75 static int GetAllImages(void)
 76 {
 77     struct gphoto2_file *file;
 78     int has_images = 0;
 79 
 80     LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
 81     {
 82         if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
 83         {
 84             file->download = TRUE;
 85             has_images = 1;
 86         }
 87     }
 88     return has_images;
 89 }
 90 
 91 static void PopulateListView(HWND List)
 92 {
 93         struct gphoto2_file *file;
 94         LVITEMA item;
 95         int index = 0;
 96 
 97         LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
 98         {
 99                 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg")) 
100                 {
101                         item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE ;
102                         item.iItem = index;
103                         item.iSubItem = 0;
104                         item.pszText = file->filename;
105                         item.iImage = index;
106                         item.lParam= (LPARAM)file;
107 
108                         SendMessageA(List, LVM_INSERTITEMA,0,(LPARAM)&item);
109                         index ++;
110                 }
111         }
112 }
113 
114 static void PopulateImageList(HIMAGELIST *iList, HWND list)
115 {
116         struct gphoto2_file *file;
117         HWND    progress_dialog;
118 
119         progress_dialog =
120                 CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
121                                 NULL, ConnectingProc);
122         
123         LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
124         {
125                 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg")) 
126                 {
127                         HBITMAP         bitmap;
128                         BITMAP          bmpInfo;
129 
130 #ifdef HAVE_GPHOTO2
131                         _get_gphoto2_file_as_DIB(file->folder, file->filename,
132                                         GP_FILE_TYPE_PREVIEW, 0, &bitmap); 
133 #else
134                         bitmap = 0;
135 #endif
136                         GetObjectA(bitmap,sizeof(BITMAP),(LPVOID)&bmpInfo);
137 
138                         if (*iList == 0)
139                         {
140                                 *iList = ImageList_Create(bmpInfo.bmWidth,
141                                                 bmpInfo.bmHeight,ILC_COLOR24, 10,10);
142 
143                                 SendMessageW(list, LVM_SETICONSPACING, 0,
144                                                 MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) ); }
145 
146                         ImageList_Add(*iList, bitmap, 0);
147 
148                         DeleteObject(static_bitmap);
149                         static_bitmap = bitmap;
150                         SendMessageW(GetDlgItem(progress_dialog,IDC_BITMAP),STM_SETIMAGE,
151                                         IMAGE_BITMAP, (LPARAM)static_bitmap);
152                         RedrawWindow(progress_dialog,NULL,NULL,RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
153                 }
154         }
155         EndDialog(progress_dialog,0);
156         
157 }
158 
159 static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
160 {
161         switch(msg)
162         {
163                 case WM_INITDIALOG:
164                         {
165                                 disable_dialog = FALSE;
166                                 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
167                         }
168                         break;
169                 case WM_NOTIFY:
170                         if (((LPNMHDR)lParam)->code == LVN_ITEMCHANGED)
171                         {
172                                 HWND list = GetDlgItem(hwnd,IDC_LIST1);
173                                 int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
174                                 if (count > 0)
175                                         EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),TRUE);
176                                 else
177                                         EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
178                         }
179                         break;
180                 case WM_COMMAND:
181                         switch LOWORD(wParam)
182                         {
183                                 case IDC_SKIP:
184                                         on_disable_dialog_clicked(hwnd);
185                                         break;
186                                 case IDC_EXIT:
187                                         UI_EndDialog(hwnd,0);
188                                         break;
189                                 case IDC_IMPORT:
190                                         {
191                                                 HWND list = GetDlgItem(hwnd,IDC_LIST1);
192                                                 int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
193                                                 int i;
194 
195                                                 if (count ==0)
196                                                 {
197                                                         UI_EndDialog(hwnd,0);
198                                                         return FALSE;
199                                                 }
200 
201                                                 count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
202                                                 for ( i = 0; i < count; i++)
203                                                 {
204                                                         INT state = 0x00000000;
205 
206                                                         state = SendMessageA(list,LVM_GETITEMSTATE,i,
207                                                                         LVIS_SELECTED);
208 
209                                                         if (state)
210                                                         {
211                                                                 LVITEMA item;
212                                                                 struct gphoto2_file *file;
213 
214 
215                                                                 item.mask = LVIF_PARAM;
216                                                                 item.iItem = i;
217 
218                                                                 item.iSubItem = 0;
219                                                                 SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
220 
221                                                                 file = (struct gphoto2_file*)item.lParam;
222                                                                 file->download = TRUE;
223                                                         }
224                                                 }
225 
226                                                 UI_EndDialog(hwnd,1);
227                                         }
228                                         break;
229                                 case IDC_IMPORTALL:
230                                         {
231                                                 if (!GetAllImages())
232                                                 {
233                                                         UI_EndDialog(hwnd,0);
234                                                         return FALSE;
235                                                 }
236                                                 UI_EndDialog(hwnd,1);
237                                         }
238                                         break;
239                                 case IDC_FETCH:
240                                         {
241                                                 HIMAGELIST ilist = 0;
242                                                 HWND list = GetDlgItem(hwnd,IDC_LIST1);
243                                                 PopulateImageList(&ilist,list);
244 
245                                                 SendMessageA(list, LVM_SETIMAGELIST,LVSIL_NORMAL,(LPARAM)ilist);
246                                                 PopulateListView(list);
247                                                 EnableWindow(GetDlgItem(hwnd,IDC_FETCH),FALSE);
248                                         }
249                                         break;
250                         }
251                         break;
252         }
253         return FALSE;
254 }
255 
256 BOOL DoCameraUI(void)
257 {
258         HKEY key;
259         DWORD data = 0;
260         DWORD size = sizeof(data);
261         if (RegOpenKeyExA(HKEY_CURRENT_USER, settings_key, 0, KEY_READ, &key) == ERROR_SUCCESS) {
262                 RegQueryValueExA(key, settings_value, NULL, NULL, (LPBYTE) &data, &size);
263                 RegCloseKey(key);
264                 if (data)
265                         return GetAllImages();
266         }
267         return DialogBoxW(GPHOTO2_instance,
268                         (LPWSTR)MAKEINTRESOURCE(IDD_CAMERAUI),NULL, DialogProc);
269 }
270 
271 static INT_PTR CALLBACK ProgressProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
272                 lParam)
273 {
274             return FALSE;
275 }   
276 
277 HWND TransferringDialogBox(HWND dialog, LONG progress)
278 {
279         if (!dialog)
280                 dialog = CreateDialogW(GPHOTO2_instance,
281                                 (LPWSTR)MAKEINTRESOURCE(IDD_DIALOG1), NULL, ProgressProc);
282 
283         if (progress == -1)
284         {
285                 EndDialog(dialog,0);
286                 return NULL;
287         }
288 
289         RedrawWindow(dialog,NULL,NULL,
290                         RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
291 
292         return dialog;
293 }
294 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.