• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.org Installation Manager Tool


Commit MetaInfo

Révision635c5add480b9e5411e88488035f7200207402b7 (tree)
l'heure2008-10-12 01:15:23
AuteurJohn E. <tdragon@user...>
CommiterJohn E.

Message de Log

UI code restructured

Change Summary

Modification

--- a/instselect.cpp
+++ b/instselect.cpp
@@ -272,9 +272,7 @@ static BOOL CALLBACK InstSelProc
272272 }
273273
274274
275-extern "C" void SelectInst
276- (HINSTANCE hinstance,
277- HWND hparent)
275+extern "C" void SelectInst(HINSTANCE hinstance, HWND hparent)
278276 {
279277 if (!DialogBox(hinstance, MAKEINTRESOURCE(IDD_INSTSEL), hparent,
280278 InstSelProc) || !g_inst_loc[0])
--- a/main.c
+++ /dev/null
@@ -1,11 +0,0 @@
1-
2-#define WIN32_LEAN_AND_MEAN
3-#include <windows.h>
4-
5-
6-int UI_Windowed(HINSTANCE);
7-
8-int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
9-{
10- return UI_Windowed(hInstance);
11-}
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,24 @@
1+
2+#define WIN32_LEAN_AND_MEAN
3+#include <windows.h>
4+#include <string>
5+#include "pkg_index.hpp"
6+
7+
8+extern "C" HWND CreateMainWnd(HINSTANCE);
9+extern "C" int MainMessageLoop(HWND);
10+std::string GetBinDir();
11+extern "C" void SelectInst(HINSTANCE, HWND);
12+
13+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
14+{
15+ HWND mainwnd = CreateMainWnd(hInstance);
16+ if (!mainwnd)
17+ return 1;
18+
19+ PkgIndex::LoadManifest(GetBinDir() + "\\mingw_avail.mft");
20+
21+ SelectInst(hInstance, mainwnd);
22+
23+ return MainMessageLoop(mainwnd);
24+}
--- a/mainwnd.c
+++ b/mainwnd.c
@@ -90,11 +90,11 @@ static void InsertColumn
9090
9191 void SelectInst(HINSTANCE, HWND);
9292 const char* Pkg_GetSubItemText(LPARAM, int);
93-void UI_NotifyCategoryChange(int);
94-void UI_SortListView(int);
95-void UI_OnListViewSelect(int);
93+void UI_OnCategoryChange(int, HWND);
94+void UI_SortListView(int, HWND);
95+void UI_OnListViewSelect(int, HWND);
9696 void DescWnd_SetHWND(HWND);
97-void UI_OnStateCycle(int);
97+void UI_OnStateCycle(int, HWND);
9898 const char* Pkg_GetInstalledVersion(LPARAM);
9999 int Pkg_GetSelectedAction(LPARAM);
100100 void Pkg_SelectAction(LPARAM, int);
@@ -197,7 +197,7 @@ static BOOL CALLBACK MainWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
197197 case IDC_CATLIST:
198198 if (HIWORD(wParam) == LBN_SELCHANGE)
199199 {
200- UI_NotifyCategoryChange(ListBox_GetCurSel((HWND)lParam));
200+ UI_OnCategoryChange(ListBox_GetCurSel((HWND)lParam), hwndDlg);
201201 return TRUE;
202202 }
203203 break;
@@ -218,12 +218,12 @@ static BOOL CALLBACK MainWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
218218 }
219219 return 0;
220220 case LVN_COLUMNCLICK:
221- UI_SortListView(((LPNMLISTVIEW)lParam)->iSubItem);
221+ UI_SortListView(((LPNMLISTVIEW)lParam)->iSubItem, hwndDlg);
222222 return 0;
223223 case LVN_ITEMCHANGED:
224224 if ((((LPNMLISTVIEW)lParam)->uChanged & LVIF_STATE)
225225 && (((LPNMLISTVIEW)lParam)->uNewState & LVIS_SELECTED))
226- UI_OnListViewSelect(((LPNMLISTVIEW)lParam)->iItem);
226+ UI_OnListViewSelect(((LPNMLISTVIEW)lParam)->iItem, hwndDlg);
227227 return 0;
228228 case NM_CLICK:
229229 {
@@ -237,7 +237,7 @@ static BOOL CALLBACK MainWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
237237 if ((lvhti.flags & LVHT_ONITEMICON)
238238 && !(lvhti.flags & LVHT_ONITEMLABEL)
239239 && lvhti.iItem >= 0)
240- UI_OnStateCycle(lvhti.iItem);
240+ UI_OnStateCycle(lvhti.iItem, hwndDlg);
241241 }
242242 return 0;
243243 case NM_RCLICK:
@@ -406,16 +406,13 @@ static int ProcessQueuedMessages(HWND wnd)
406406 {
407407 if (msg.message == WM_QUIT)
408408 return 1;
409- if (TranslateAccelerator(wnd, g_haccel, &msg))
409+ if (!TranslateAccelerator(wnd, g_haccel, &msg))
410410 {
411- }
412- else if (IsDialogMessage(wnd, &msg))
413- {
414- }
415- else
416- {
417- TranslateMessage(&msg);
418- DispatchMessage(&msg);
411+ if (!IsDialogMessage(wnd, &msg))
412+ {
413+ TranslateMessage(&msg);
414+ DispatchMessage(&msg);
415+ }
419416 }
420417 }
421418 return 0;
@@ -453,16 +450,13 @@ int MainMessageLoop(HWND wnd)
453450 MSG msg;
454451 while (GetMessage(&msg, NULL, 0, 0))
455452 {
456- if (TranslateAccelerator(wnd, g_haccel, &msg))
453+ if (!TranslateAccelerator(wnd, g_haccel, &msg))
457454 {
458- }
459- else if (IsDialogMessage(wnd, &msg))
460- {
461- }
462- else
463- {
464- TranslateMessage(&msg);
465- DispatchMessage(&msg);
455+ if (!IsDialogMessage(wnd, &msg))
456+ {
457+ TranslateMessage(&msg);
458+ DispatchMessage(&msg);
459+ }
466460 }
467461 }
468462 return msg.wParam;
--- a/mingw-get.cbp
+++ b/mingw-get.cbp
@@ -64,9 +64,7 @@
6464 <Unit filename="instselect.cpp">
6565 <Option compilerVar="CC" />
6666 </Unit>
67- <Unit filename="main.c">
68- <Option compilerVar="CC" />
69- </Unit>
67+ <Unit filename="main.cpp" />
7068 <Unit filename="mainwnd.c">
7169 <Option compilerVar="CC" />
7270 </Unit>
@@ -100,8 +98,7 @@
10098 <Unit filename="tinyxml\tinyxmlparser.cpp" />
10199 <Unit filename="tracked_install.cpp" />
102100 <Unit filename="tracked_install.hpp" />
103- <Unit filename="ui.hpp" />
104- <Unit filename="ui_windowed.cpp" />
101+ <Unit filename="ui.cpp" />
105102 <Unit filename="versioning.c">
106103 <Option compilerVar="CC" />
107104 </Unit>
--- a/pkg_index.cpp
+++ b/pkg_index.cpp
@@ -16,7 +16,6 @@
1616 char PkgIndex::sm_lasterror[2048] = {0};
1717 std::vector< std::string > PkgIndex::sm_index_categories;
1818 PkgIndex::StringIntMap PkgIndex::sm_id_categories;
19-std::list< Package::Ref >PkgIndex::sm_packages;
2019 PkgIndex::StringPackageMap PkgIndex::sm_id_packages;
2120
2221
@@ -52,13 +51,13 @@ int PkgIndex::CategoryIndex(const char* cat_id)
5251
5352 PkgIndex::PackageIter PkgIndex::Packages_Begin()
5453 {
55- return sm_packages.begin();
54+ return sm_id_packages.begin();
5655 }
5756
5857
5958 PkgIndex::PackageIter PkgIndex::Packages_End()
6059 {
61- return sm_packages.end();
60+ return sm_id_packages.end();
6261 }
6362
6463
@@ -84,7 +83,6 @@ bool PkgIndex::LoadManifest(const std::string& mfile)
8483 continue;
8584 sm_id_categories[id] = sm_index_categories.size();
8685 sm_index_categories.push_back(name);
87- UI::NotifyNewCategory(name);
8886 }
8987 for (TiXmlElement* package_el =
9088 TiXmlHandle(doc.RootElement()->FirstChildElement("package-collection")).
@@ -100,7 +98,6 @@ bool PkgIndex::LoadManifest(const std::string& mfile)
10098 continue;
10199 Package::Ref newpkg(new Package(id, package_el));
102100 InsertPackage(newpkg);
103- UI::NotifyNewPackage(*newpkg);
104101 }
105102 return true;
106103 }
--- a/pkg_index.hpp
+++ b/pkg_index.hpp
@@ -25,8 +25,8 @@ public:
2525 static const char* GetCategory(int cat);
2626 static int CategoryIndex(const char* cat_id);
2727
28- typedef std::list< RefType< Package >::Ref >::const_iterator
29- PackageIter;
28+ typedef std::map< std::string, RefType< Package >::Ref > StringPackageMap;
29+ typedef StringPackageMap::const_iterator PackageIter;
3030 static PackageIter Packages_Begin();
3131 static PackageIter Packages_End();
3232
@@ -38,8 +38,6 @@ private:
3838 static std::vector< std::string > sm_index_categories;
3939 typedef std::map< std::string, int > StringIntMap;
4040 static StringIntMap sm_id_categories;
41- static std::list< RefType< Package >::Ref > sm_packages;
42- typedef std::map< std::string, RefType< Package >::Ref > StringPackageMap;
4341 static StringPackageMap sm_id_packages;
4442 };
4543
--- a/ui_windowed.cpp
+++ b/ui.cpp
@@ -1,43 +1,22 @@
1+/** \file ui.cpp
2+ *
3+ * Created: JohnE, 2008-10-11
4+ */
15
2-#include "ui.hpp"
36
47 #define WIN32_LEAN_AND_MEAN
58 #include <windows.h>
69 #include <windowsx.h>
710 #include <commctrl.h>
811 #include <climits>
9-#include <list>
10-#include "resource.h"
1112 #include "package.hpp"
1213 #include "pkg_index.hpp"
1314 #include "pkg_const.h"
15+#include "resource.h"
1416
1517
16-static HWND g_hmainwnd = 0;
17-
18-
19-extern "C" HWND CreateMainWnd(HINSTANCE);
20-extern "C" int MainMessageLoop(HWND);
21-extern "C" void SelectInst(HINSTANCE, HWND);
22-std::string GetBinDir();
23-
24-extern "C" int UI_Windowed(HINSTANCE hinstance)
25-{
26- g_hmainwnd = CreateMainWnd(hinstance);
27- if (!g_hmainwnd)
28- return 1;
29-
30- PkgIndex::LoadManifest(GetBinDir() + "\\mingw_avail.mft");
31-
32- SelectInst(hinstance, g_hmainwnd);
33-
34- return MainMessageLoop(g_hmainwnd);
35-}
36-
37-
38-static void LVAddPackage(const Package& pkg)
18+static void LVAddPackage(HWND hlist, const Package& pkg)
3919 {
40- HWND hlist = GetDlgItem(g_hmainwnd, IDC_COMPLIST);
4120 LVITEM lvi;
4221 lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
4322 lvi.iItem = INT_MAX;
@@ -56,15 +35,15 @@ static void LVAddPackage(const Package& pkg)
5635 }
5736 if (lvi.iItem == 0)
5837 {
59- ListView_SetItemState(GetDlgItem(g_hmainwnd, IDC_COMPLIST), 0,
38+ ListView_SetItemState(hlist, 0,
6039 LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
6140 }
6241 }
6342
6443
65-extern "C" void UI_NotifyCategoryChange(int sel)
44+extern "C" void UI_OnCategoryChange(int sel, HWND hmainwnd)
6645 {
67- ListView_DeleteAllItems(GetDlgItem(g_hmainwnd, IDC_COMPLIST));
46+ ListView_DeleteAllItems(GetDlgItem(hmainwnd, IDC_COMPLIST));
6847 bool have_item = false;
6948 if (sel == 0)
7049 {
@@ -72,7 +51,7 @@ extern "C" void UI_NotifyCategoryChange(int sel)
7251 it != PkgIndex::Packages_End();
7352 ++it)
7453 {
75- LVAddPackage(**it);
54+ LVAddPackage(GetDlgItem(hmainwnd, IDC_COMPLIST), *it->second);
7655 have_item = true;
7756 }
7857 }
@@ -82,46 +61,46 @@ extern "C" void UI_NotifyCategoryChange(int sel)
8261 it != PkgIndex::Packages_End();
8362 ++it)
8463 {
85- if ((*it)->m_categories.count(sel - 1) > 0)
64+ if (it->second->m_categories.count(sel - 1) > 0)
8665 {
87- LVAddPackage(**it);
66+ LVAddPackage(GetDlgItem(hmainwnd, IDC_COMPLIST), *it->second);
8867 have_item = true;
8968 }
9069 }
9170 }
9271 if (have_item)
9372 {
94- ListView_SetItemState(GetDlgItem(g_hmainwnd, IDC_COMPLIST), 0,
73+ ListView_SetItemState(GetDlgItem(hmainwnd, IDC_COMPLIST), 0,
9574 LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
9675 }
9776 else
9877 {
99- Static_SetText(GetDlgItem(g_hmainwnd, IDC_DESCTITLE), "");
100- Edit_SetText(GetDlgItem(g_hmainwnd, IDC_FULLDESC), "");
101- ComboBox_ResetContent(GetDlgItem(g_hmainwnd, IDC_INSTVERSION));
102- EnableWindow(GetDlgItem(g_hmainwnd, IDC_INSTVERSION), FALSE);
78+ Static_SetText(GetDlgItem(hmainwnd, IDC_DESCTITLE), "");
79+ Edit_SetText(GetDlgItem(hmainwnd, IDC_FULLDESC), "");
80+ ComboBox_ResetContent(GetDlgItem(hmainwnd, IDC_INSTVERSION));
81+ EnableWindow(GetDlgItem(hmainwnd, IDC_INSTVERSION), FALSE);
10382 }
10483 }
10584
10685
10786 void DescWnd_SetDescription(const std::string&);
10887
109-extern "C" void UI_OnListViewSelect(int sel)
88+extern "C" void UI_OnListViewSelect(int sel, HWND hmainwnd)
11089 {
11190 LVITEM lvitem;
11291 lvitem.iItem = sel;
11392 lvitem.iSubItem = 0;
11493 lvitem.mask = LVIF_PARAM;
115- ListView_GetItem(GetDlgItem(g_hmainwnd, IDC_COMPLIST), &lvitem);
94+ ListView_GetItem(GetDlgItem(hmainwnd, IDC_COMPLIST), &lvitem);
11695 Package* pkg = reinterpret_cast< Package* >(lvitem.lParam);
117- Edit_SetText(GetDlgItem(g_hmainwnd, IDC_FULLDESC),
96+ Edit_SetText(GetDlgItem(hmainwnd, IDC_FULLDESC),
11897 pkg->m_description.c_str());
119- Static_SetText(GetDlgItem(g_hmainwnd, IDC_DESCTITLE),
98+ Static_SetText(GetDlgItem(hmainwnd, IDC_DESCTITLE),
12099 pkg->m_title.c_str());
121- ComboBox_ResetContent(GetDlgItem(g_hmainwnd, IDC_INSTVERSION));
100+ ComboBox_ResetContent(GetDlgItem(hmainwnd, IDC_INSTVERSION));
122101 if (pkg->m_versions.size() > 0)
123102 {
124- EnableWindow(GetDlgItem(g_hmainwnd, IDC_INSTVERSION), TRUE);
103+ EnableWindow(GetDlgItem(hmainwnd, IDC_INSTVERSION), TRUE);
125104 std::string vstr;
126105 for (std::vector< PkgVersion::Ref >::const_iterator it = pkg->m_versions.begin();
127106 it != pkg->m_versions.end();
@@ -132,29 +111,29 @@ extern "C" void UI_OnListViewSelect(int sel)
132111 else
133112 vstr = "Stable: ";
134113 vstr += (*it)->m_version;
135- ComboBox_AddString(GetDlgItem(g_hmainwnd, IDC_INSTVERSION),
114+ ComboBox_AddString(GetDlgItem(hmainwnd, IDC_INSTVERSION),
136115 vstr.c_str());
137116 }
138117 pkg->m_selected_version = 0;
139- ComboBox_SetCurSel(GetDlgItem(g_hmainwnd, IDC_INSTVERSION), 0);
118+ ComboBox_SetCurSel(GetDlgItem(hmainwnd, IDC_INSTVERSION), 0);
140119 }
141120 else
142121 {
143122 pkg->m_selected_version = -1;
144- EnableWindow(GetDlgItem(g_hmainwnd, IDC_INSTVERSION), FALSE);
123+ EnableWindow(GetDlgItem(hmainwnd, IDC_INSTVERSION), FALSE);
145124 }
146125 }
147126
148127
149128 extern "C" int VersionCompare(const char*, const char*);
150129
151-extern "C" void UI_OnStateCycle(int sel)
130+extern "C" void UI_OnStateCycle(int sel, HWND hmainwnd)
152131 {
153132 LVITEM lvitem;
154133 lvitem.iItem = sel;
155134 lvitem.iSubItem = 0;
156135 lvitem.mask = LVIF_PARAM;
157- ListView_GetItem(GetDlgItem(g_hmainwnd, IDC_COMPLIST), &lvitem);
136+ ListView_GetItem(GetDlgItem(hmainwnd, IDC_COMPLIST), &lvitem);
158137 Package* pkg = reinterpret_cast< Package* >(lvitem.lParam);
159138 if (pkg->m_installed_version.length() > 0)
160139 {
@@ -172,7 +151,7 @@ extern "C" void UI_OnStateCycle(int sel)
172151 }
173152 lvitem.mask = LVIF_IMAGE;
174153 lvitem.iImage = pkg->GetStateImage();
175- ListView_SetItem(GetDlgItem(g_hmainwnd, IDC_COMPLIST), &lvitem);
154+ ListView_SetItem(GetDlgItem(hmainwnd, IDC_COMPLIST), &lvitem);
176155 }
177156
178157
@@ -226,7 +205,7 @@ int CALLBACK LVSortCompare(LPARAM lp1, LPARAM lp2, LPARAM lpsort)
226205 };
227206
228207
229-extern "C" void UI_SortListView(int column)
208+extern "C" void UI_SortListView(int column, HWND hmainwnd)
230209 {
231210 static int cur_column = 0;
232211
@@ -236,11 +215,12 @@ extern "C" void UI_SortListView(int column)
236215 cur_column = column;
237216
238217 LVSortType st(cur_column % 6, (cur_column >= 6));
239- ListView_SortItems(GetDlgItem(g_hmainwnd, IDC_COMPLIST), LVSortCompare,
218+ ListView_SortItems(GetDlgItem(hmainwnd, IDC_COMPLIST), LVSortCompare,
240219 reinterpret_cast< LPARAM >(&st));
241220 }
242221
243222
223+#if 0
244224 void UI::ResetLists()
245225 {
246226 ListBox_SetCurSel(GetDlgItem(g_hmainwnd, IDC_CATLIST), 0);
@@ -263,3 +243,4 @@ void UI::NotifyNewPackage(const Package& pkg)
263243 if (sel <= 0 || pkg.m_categories.count(sel - 1) > 0)
264244 LVAddPackage(pkg);
265245 }
246+#endif
--- a/ui.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
1-#ifndef UI_HPP_INC
2-#define UI_HPP_INC
3-
4-
5-#include <string>
6-
7-
8-class Package;
9-
10-
11-class UI
12-{
13-public:
14- static void ResetLists();
15- static void NotifyNewCategory(const char* name);
16- static void NotifyNewPackage(const Package& pkg);
17-};
18-
19-
20-#endif // UI_HPP_INC