ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/Chooser.cxx
(Generate patch)

Comparing trunk/VTBFileUtil2/Chooser.cxx (file contents):
Revision 264 by douglas, 2003-08-16T17:43:49-07:00 vs.
Revision 266 by douglas, 2003-08-17T16:39:32-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: Chooser.cxx,v 1.2 2003/08/17 00:43:49 douglas Exp $
5 > // $Id: Chooser.cxx,v 1.4 2003/08/17 23:39:32 douglas Exp $
6  
7   #include "Chooser.h"
8  
9 < struct
9 > Chooser::Chooser()
10   {
11 <        bool* shortcut;
12 <        Mode* choice;
11 >        shortcut = false;
12 >        choice = none;
13 >        number = count++;
14 >        choosers.insert(pair<unsigned, Chooser*>(number, this));
15   }
14 cheese;
16  
17 < Mode Chooser::choose(HWND parent)
17 > Chooser::~Chooser()
18   {
19 <        cheese.shortcut = &shortcut;
20 <        cheese.choice = &choice;
19 >        choosers.erase(number);
20 > }
21  
22 <        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_CHOICE), parent, smersh);
22 > Mode Chooser::choose(HWND parent)
23 > {
24 >        DialogBoxParam(gui.instance, MAKEINTRESOURCE(IDD_CHOICE), parent,
25 >                Chooser::window, number);
26  
27          desktop();
28  
29          return choice;
30   }
31  
32 + INT_PTR CALLBACK Chooser::window(HWND dialog, UINT msg, WPARAM w, LPARAM l)
33 + {
34 +        map<HWND, Chooser*>::iterator itor = windows.find(dialog);
35 +        Chooser* data = itor->second;
36 +        Mode* choice = &data->choice;
37 +        bool* shortcut = &data->shortcut;
38 +
39 +        switch (msg)
40 +        {
41 +        case WM_INITDIALOG:
42 +                center(dialog);
43 +                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
44 +                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
45 +                {
46 +                        map<unsigned, Chooser*>::iterator itor = choosers.find(l);
47 +                        
48 +                        windows.insert(pair<HWND, Chooser*>(dialog, itor->second));
49 +                }
50 +                break;
51 +        case WM_COMMAND:
52 +                switch (LOWORD(w))
53 +                {
54 +                case IDC_CHOICE_DISC:
55 +                        *choice = disc;
56 +                        if (debug) cerr << "choice = disc\n";
57 +                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
58 +                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
59 +                        break;
60 +                case IDC_CHOICE_SCAN:
61 +                        *choice = scan;
62 +                        if (debug) cerr << "choice = scan\n";
63 +                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
64 +                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
65 +                        break;
66 +                case IDC_CHOICE_ALWAYS:
67 +                        *shortcut = !*shortcut;
68 +                        if (debug) cerr << "shortcut = " << *shortcut << "\n";
69 +                        break;
70 +                case IDCANCEL:
71 +                        *choice = none;
72 +                case IDOK:
73 +                        windows.erase(dialog);
74 +                        EndDialog(dialog, w);
75 +                        return TRUE;
76 +                default:
77 +                        break;
78 +                }
79 +                break;
80 +        }
81 +
82 +        return FALSE;
83 + }
84 +
85 + unsigned Chooser::count = 0;
86 + map<unsigned, Chooser*> Chooser::choosers;
87 + map<HWND, Chooser*> Chooser::windows;
88 +
89   void Chooser::desktop(void)
90   {
91          if (!shortcut || choice == none) return;
# Line 72 | Line 133 | void Chooser::desktop(void)
133  
134          CoUninitialize();
135   }
75
76 INT_PTR CALLBACK smersh(HWND dialog, UINT msg, WPARAM w, LPARAM l)
77 {
78        switch (msg)
79        {
80        case WM_INITDIALOG:
81                center(dialog);
82                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
83                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
84                break;
85        case WM_COMMAND:
86                switch (LOWORD(w))
87                {
88                case IDC_CHOICE_DISC:
89                        *cheese.choice = disc;
90                        if (debug) cerr << "choice = disc\n";
91                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
92                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
93                        break;
94                case IDC_CHOICE_SCAN:
95                        *cheese.choice = scan;
96                        if (debug) cerr << "choice = scan\n";
97                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
98                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
99                        break;
100                case IDC_CHOICE_ALWAYS:
101                        *cheese.shortcut = !*cheese.shortcut;
102                        if (debug) cerr << "shortcut = " << *cheese.shortcut << "\n";
103                        break;
104                case IDCANCEL:
105                        *cheese.choice = none;
106                case IDOK:
107                        EndDialog(dialog, w);
108                        return TRUE;
109                default:
110                        break;
111                }
112                break;
113        }
114
115        return FALSE;
116 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines