The MinGW.org Installation Manager Tool
リビジョン | 896f3ec1a4d16096c72faebecaa3c5d501ccf004 (tree) |
---|---|
日時 | 2012-12-13 00:56:26 |
作者 | Keith Marshall <keithmarshall@user...> |
コミッター | Keith Marshall |
Make a clone of the package menu available as a pop-up.
@@ -1,5 +1,15 @@ | ||
1 | 1 | 2012-12-12 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 2 | |
3 | + Make a clone of the package menu available as a pop-up. | |
4 | + | |
5 | + * src/guimain.h (AppWindowMaker::SelectPackageAction): New private | |
6 | + method; declare it. | |
7 | + | |
8 | + * src/pkgdata.cpp (AppWindowMaker::SelectPackageAction): Implement it. | |
9 | + (AppWindowMaker::OnNotify) [ID_PACKAGE_LISTVIEW]: Use it. | |
10 | + | |
11 | +2012-12-12 Keith Marshall <keithmarshall@users.sourceforge.net> | |
12 | + | |
3 | 13 | Improve conditionally enabled state manipulation for menu items. |
4 | 14 | |
5 | 15 | * src/guidata.rc (IDM_REPO_APPLY): Set its initial state as GRAYED. |
@@ -203,6 +203,7 @@ class AppWindowMaker: public WTK::MainWindowMaker | ||
203 | 203 | void UpdatePackageMenuBindings( void ); |
204 | 204 | void Schedule( unsigned long, const char * = NULL, const char * = NULL ); |
205 | 205 | inline void MarkSchedule( pkgActionItem * ); |
206 | + void SelectPackageAction( unsigned ); | |
206 | 207 | void UnmarkSelectedPackage( void ); |
207 | 208 | |
208 | 209 | DataSheetMaker *DataSheet; |
@@ -25,6 +25,8 @@ | ||
25 | 25 | * arising from the use of this software. |
26 | 26 | * |
27 | 27 | */ |
28 | +#define _WIN32_IE 0x0300 | |
29 | + | |
28 | 30 | #include <stdlib.h> |
29 | 31 | #include <string.h> |
30 | 32 |
@@ -38,6 +40,8 @@ | ||
38 | 40 | #include "pkglist.h" |
39 | 41 | #include "pkgtask.h" |
40 | 42 | |
43 | +#include <windowsx.h> | |
44 | + | |
41 | 45 | using WTK::StringResource; |
42 | 46 | using WTK::WindowClassMaker; |
43 | 47 | using WTK::ChildWindowMaker; |
@@ -1128,6 +1132,47 @@ void AppWindowMaker::UnmarkSelectedPackage( void ) | ||
1128 | 1132 | } |
1129 | 1133 | } |
1130 | 1134 | |
1135 | +void AppWindowMaker::SelectPackageAction( unsigned mode ) | |
1136 | +{ | |
1137 | + /* Helper method to present the package menu as a floating pop-up. | |
1138 | + */ | |
1139 | + HMENU popup; | |
1140 | + LVHITTESTINFO whence; | |
1141 | + | |
1142 | + /* Before presenting the menu, ensure that its selection bindings | |
1143 | + * are current, as determined for the selected package; note that | |
1144 | + * we do this unconditionally, to ensure that the bindings remain | |
1145 | + * current, when the user accesses the menu from the menu bar. | |
1146 | + */ | |
1147 | + UpdatePackageMenuBindings(); | |
1148 | + | |
1149 | + /* Locate the cursor position, mapping it into the co-ordinate | |
1150 | + * system of the list view client window. | |
1151 | + */ | |
1152 | + whence.pt.y = GetMessagePos(); | |
1153 | + whence.pt.x = GET_X_LPARAM( whence.pt.y ); | |
1154 | + whence.pt.y = GET_Y_LPARAM( whence.pt.y ); | |
1155 | + ScreenToClient( PackageListView, &whence.pt ); | |
1156 | + | |
1157 | + /* Perform a hit-test, to confirm that either the left mouse | |
1158 | + * button was clicked on the package status icon, or the right | |
1159 | + * button was clicked anywhere on the package list entry; only | |
1160 | + * if one of these is detected, do we then proceed to retrieve | |
1161 | + * a handle for the pop-up menu itself... | |
1162 | + */ | |
1163 | + if( (ListView_SubItemHitTest( PackageListView, &whence ) >= 0) | |
1164 | + && ((whence.flags & mode) != 0) && ((popup = GetMenu( AppWindow )) != NULL) | |
1165 | + && ((popup = GetSubMenu( popup, 1 )) != NULL) ) | |
1166 | + { | |
1167 | + /* ...and provided it is valid, we remap the cursor position | |
1168 | + * back into the screen co-ordinate system, and present the | |
1169 | + * menu at the resultant position. | |
1170 | + */ | |
1171 | + ClientToScreen( PackageListView, &whence.pt ); | |
1172 | + TrackPopupMenu( popup, 0, whence.pt.x, whence.pt.y, 0, AppWindow, NULL ); | |
1173 | + } | |
1174 | +} | |
1175 | + | |
1131 | 1176 | long AppWindowMaker::OnNotify( WPARAM client_id, LPARAM data ) |
1132 | 1177 | { |
1133 | 1178 | /* Handler for notifiable events to be processed in the context |
@@ -1143,6 +1188,19 @@ long AppWindowMaker::OnNotify( WPARAM client_id, LPARAM data ) | ||
1143 | 1188 | * package list view and data sheet tab control panes... |
1144 | 1189 | */ |
1145 | 1190 | case ID_PACKAGE_LISTVIEW: |
1191 | + if( ((NMHDR *)(data))->code == NM_RCLICK ) | |
1192 | + { | |
1193 | + /* A right button mouse click within the package list view | |
1194 | + * selects the package under the cursor, and offers a pop-up | |
1195 | + * menu of actions which may be performed on it. | |
1196 | + */ | |
1197 | + SelectPackageAction( LVHT_ONITEMICON | LVHT_ONITEMLABEL ); | |
1198 | + break; | |
1199 | + } | |
1200 | + /* Any other notification from the list view control is handled | |
1201 | + * in common with similar notifications from the tab control, so | |
1202 | + * we do not break here, but simply fall through. | |
1203 | + */ | |
1146 | 1204 | case ID_PACKAGE_TABCONTROL: |
1147 | 1205 | if( ((NMHDR *)(data))->code == NM_CLICK ) |
1148 | 1206 | { |
@@ -1151,14 +1209,12 @@ long AppWindowMaker::OnNotify( WPARAM client_id, LPARAM data ) | ||
1151 | 1209 | */ |
1152 | 1210 | DataSheet->DisplayData( PackageTabControl, PackageListView ); |
1153 | 1211 | |
1212 | + /* Additionally, for a left click on the package status | |
1213 | + * icon within the list view, we present a pop-up menu | |
1214 | + * offering a selection of available actions. | |
1215 | + */ | |
1154 | 1216 | if( client_id == ID_PACKAGE_LISTVIEW ) |
1155 | - { | |
1156 | - /* A change of package selection, within the list view, | |
1157 | - * may also require an update of the available choices in | |
1158 | - * the "Package" drop-down menu. | |
1159 | - */ | |
1160 | - UpdatePackageMenuBindings(); | |
1161 | - } | |
1217 | + SelectPackageAction( LVHT_ONITEMICON ); | |
1162 | 1218 | } |
1163 | 1219 | break; |
1164 | 1220 | } |