• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

The MinGW.org Installation Manager Tool


コミットメタ情報

リビジョンc9be7426a933ebd82859d29f4980144108a61742 (tree)
日時2013-06-14 00:55:23
作者Keith Marshall <keithmarshall@user...>
コミッターKeith Marshall

ログメッセージ

Implement some GUI progress metering dialogue enhancements.

変更サマリ

差分

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
1+2013-06-13 Keith Marshall <keithmarshall@users.sourceforge.net>
2+
3+ Implement some GUI progress metering dialogue enhancements.
4+
5+ * src/pkgbase.h (pkgProgressMeter): Don't pre-empt private features
6+ of derived progress metering classes; hence, we no longer need this...
7+ (AppWindowMaker): ...as a forward class declaration; delete it.
8+
9+ * src/guimain.rc (IDD_REPO_UPDATE): Resize, and adjust layout.
10+ (IDD_PROGRESS_VAL, IDD_PROGRESS_MAX, IDD_PROGRESS_PCT): Add these
11+ dialogue box progress counter display elements.
12+
13+ * src/pkgbind.cpp (pkgRepository::GetPackageList): Adjust style of
14+ progress status messages, to suit reporting via GUI dialogue box or
15+ CLI console, as appropriate.
16+
17+ * src/guiexec.cpp (ProgressMeterMaker): Redefine class, in terms of...
18+ (PROGRESS_METER_CLASS): ...this new generic class name macro.
19+ Reimplement private members, previously inherited from base class;
20+ adjust class constructor to ensure that they are initialised.
21+ Delete explicit destructor; a default destructor is now sufficient.
22+ (ProgressMeterMaker::SetRange, ProgressMeterMaker::SetValue):
23+ (ProgressMeterMaker::Annotate): Factor out; reimplement them...
24+
25+ * src/pmihook.cpp: ...in this new file, as generalised methods of...
26+ (PROGRESS_METER_CLASS): ...the class named by this macro.
27+ (PROGRESS_METER_CLASS::PutVal): New private method; implement it.
28+
129 2013-05-31 Keith Marshall <keithmarshall@users.sourceforge.net>
230
331 Avoid a potential macro definition conflict.
--- a/src/guiexec.cpp
+++ b/src/guiexec.cpp
@@ -43,20 +43,26 @@
4343 */
4444 EXTERN_C void dmh_setpty( HWND );
4545
46-class ProgressMeterMaker: public pkgProgressMeter
46+#define PROGRESS_METER_CLASS ProgressMeterMaker
47+
48+class PROGRESS_METER_CLASS: public pkgProgressMeter
4749 {
4850 /* A locally defined class, supporting progress metering
4951 * for package catalogue update and load operations.
5052 */
5153 public:
52- ProgressMeterMaker( HWND, HWND, AppWindowMaker * );
54+ PROGRESS_METER_CLASS( HWND, AppWindowMaker * );
55+ ~PROGRESS_METER_CLASS(){ referrer->DetachProgressMeter( this ); }
5356
5457 virtual int Annotate( const char *, ... );
5558 virtual void SetRange( int, int );
5659 virtual void SetValue( int );
5760
58- protected:
59- HWND message_line, progress_bar;
61+ private:
62+ AppWindowMaker *referrer;
63+ HWND annotation, count, lim, frac, progress_bar;
64+ void PutVal( HWND, const char *, ... );
65+ int total;
6066 };
6167
6268 inline
@@ -82,55 +88,23 @@ inline void AppWindowMaker::DetachProgressMeter( pkgProgressMeter *meter )
8288 }
8389 }
8490
85-/* We need to provide a destructor for the abstract base class, from which
86- * our progress meters are derived; here is as good a place as any.
87- */
88-pkgProgressMeter::~pkgProgressMeter(){ referrer->DetachProgressMeter( this ); }
89-
9091 /* We must also provide the implementation of our local progress meter class.
9192 */
92-ProgressMeterMaker::ProgressMeterMaker
93-( HWND annotation, HWND indicator, AppWindowMaker *owner ):
94-pkgProgressMeter( owner ), message_line( annotation ), progress_bar( indicator )
93+#define IDD( DLG, ITEM ) GetDlgItem( DLG, IDD_PROGRESS_##ITEM )
94+PROGRESS_METER_CLASS::PROGRESS_METER_CLASS( HWND dlg, AppWindowMaker *owner ):
95+referrer( owner ), annotation( IDD( dlg, MSG ) ), progress_bar( IDD( dlg, BAR ) ),
96+count( IDD( dlg, VAL ) ), lim( IDD( dlg, MAX ) ), frac( IDD( dlg, PCT ) )
9597 {
9698 /* Constructor creates an instance of the progress meter class, attaching it
9799 * to the main application window, with an initial metering range of 0..100%,
98100 * and a starting indicated completion state of 0%.
99101 */
100102 owner->AttachProgressMeter( this );
101- SetRange( 0, 100 );
103+ SetRange( 0, 1 ); SetValue( 0 );
102104 SetValue( 0 );
103105 }
104106
105-int ProgressMeterMaker::Annotate( const char *fmt, ... )
106-{
107- /* Method to add a printf() style annotation to the progress meter dialogue.
108- */
109- va_list argv;
110- va_start( argv, fmt );
111- char annotation[1 + vsnprintf( NULL, 0, fmt, argv )];
112- int len = vsnprintf( annotation, sizeof( annotation ), fmt, argv );
113- va_end( argv );
114-
115- SendMessage( message_line, WM_SETTEXT, 0, (LPARAM)(annotation) );
116- return len;
117-}
118-
119-void ProgressMeterMaker::SetRange( int min, int max )
120-{
121- /* Method to adjust the range of the progress meter, to represent any
122- * arbitrary range of discrete values, rather than percentage units.
123- */
124- SendMessage( progress_bar, PBM_SETRANGE, 0, MAKELPARAM( min, max ) );
125-}
126-
127-void ProgressMeterMaker::SetValue( int value )
128-{
129- /* Method to update the indicated completion state of a progress meter,
130- * to represent any arbitrary value within its assigned metering range.
131- */
132- SendMessage( progress_bar, PBM_SETPOS, value, 0 );
133-}
107+#include "pmihook.cpp"
134108
135109 /* Implementation of service routines, for loading the package catalogue
136110 * from its defining collection of XML files.
@@ -215,20 +189,18 @@ static void pkgInvokeInitDataLoad( void *window )
215189 * we subject it to progress metering, to ensure that the user is
216190 * not left staring at an apparently hung, blank window.
217191 */
218- HWND msg = GetDlgItem( (HWND)(window), IDD_PROGRESS_MSG );
219- HWND dlg = GetDlgItem( (HWND)(window), IDD_PROGRESS_BAR );
220192 AppWindowMaker *app = GetAppWindow( GetParent( (HWND)(window) ));
221193 SendMessage( (HWND)(window),
222194 WM_SETTEXT, 0, (LPARAM)("Loading Package Catalogue")
223195 );
224- ProgressMeterMaker ui( msg, dlg, app );
196+ ProgressMeterMaker ui( (HWND)(window), app );
225197
226198 /* For this activity, we request automatic dismissal of the dialogue,
227199 * when loading has been completed; the user will have an opportunity
228200 * to countermand this choice, if loading is delayed by the required
229201 * download of any missing local catalogue file.
230202 */
231- dlg = GetDlgItem( (HWND)(window), IDD_AUTO_CLOSE_OPTION );
203+ HWND dlg = GetDlgItem( (HWND)(window), IDD_AUTO_CLOSE_OPTION );
232204 SendMessage( dlg, WM_SETTEXT, 0,
233205 (LPARAM)("Close dialogue automatically, when loading is complete.")
234206 );
@@ -267,10 +239,8 @@ static void pkgInvokeUpdate( void *window )
267239 * subject it to progress metering, to ensure that the user is
268240 * not left staring at an apparently hung, blank window.
269241 */
270- HWND msg = GetDlgItem( (HWND)(window), IDD_PROGRESS_MSG );
271- HWND dlg = GetDlgItem( (HWND)(window), IDD_PROGRESS_BAR );
272242 AppWindowMaker *app = GetAppWindow( GetParent( (HWND)(window) ));
273- ProgressMeterMaker ui( msg, dlg, app );
243+ ProgressMeterMaker ui( (HWND)(window), app );
274244
275245 /* After setting up the progress meter, we clear out any data
276246 * which was previously loaded into the package list, reload it
@@ -292,8 +262,8 @@ static void pkgInvokeUpdate( void *window )
292262 else
293263 { /* ...otherwise, we activate the manual dismissal button...
294264 */
295- if( (dlg = GetDlgItem( (HWND)(window), IDOK )) != NULL )
296- EnableWindow( dlg, TRUE );
265+ HWND dlg = GetDlgItem( (HWND)(window), IDOK );
266+ if( dlg != NULL ) EnableWindow( dlg, TRUE );
297267
298268 /* ...and notify the user that it must be clicked to continue.
299269 */
--- a/src/guimain.rc
+++ b/src/guimain.rc
@@ -151,25 +151,30 @@ ID_PKGSTATE_BROKEN ICON DISCARDABLE "state11.ico"
151151 ID_PKGSTATE_REMOVE ICON DISCARDABLE "state12.ico"
152152 ID_PKGSTATE_PURGE ICON DISCARDABLE "state13.ico"
153153
154+#define SS_CTEXTBOX SS_SUNKEN | SS_CENTER
155+#define ES_VT100 ES_LEFT | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL
156+
154157 /* Template for progress meter dialogue box.
155158 */
156-IDD_REPO_UPDATE DIALOG DISCARDABLE 10, 20, 270, 60
159+IDD_REPO_UPDATE DIALOG DISCARDABLE 10, 20, 270, 78
157160 CAPTION "Update Package Catalogue"
158161 STYLE DS_MODALFRAME | DS_SETFONT | WS_POPUP | WS_CAPTION | WS_DLGFRAME
159162 FONT 10, "Verdana"
160163 BEGIN
161- GROUPBOX "Actions", IDD_CLOSE_OPTIONS, 5, 31, 260, 25
162- DEFPUSHBUTTON "Close", IDOK, 219, 39, 40, 12, WS_GROUP | WS_DISABLED
164+ GROUPBOX "Actions", IDD_CLOSE_OPTIONS, 5, 48, 260, 25
165+ DEFPUSHBUTTON "Close", IDOK, 219, 56, 40, 12, WS_GROUP | WS_DISABLED
163166 AUTOCHECKBOX "Close dialogue automatically, when update is complete.", \
164- IDD_AUTO_CLOSE_OPTION, 10, 41, 200, 11
167+ IDD_AUTO_CLOSE_OPTION, 10, 58, 200, 11
168+ CONTROL "", IDD_PROGRESS_VAL, "STATIC", SS_CTEXTBOX, 6, 19, 96, 10
169+ CTEXT "of", IDD_PROGRESS_TXT, 102, 19, 18, 10
170+ CONTROL "", IDD_PROGRESS_MAX, "STATIC", SS_CTEXTBOX, 120, 19, 96, 10
171+ CTEXT ":", IDD_PROGRESS_TXT, 213, 19, 10, 10
172+ CONTROL "", IDD_PROGRESS_PCT, "STATIC", SS_CTEXTBOX, 223, 19, 41, 10
165173 CONTROL "", IDD_PROGRESS_BAR, PROGRESS_CLASS, WS_CHILD \
166- | PBS_SMOOTH, 6, 20, 258, 10
174+ | PBS_SMOOTH, 6, 34, 258, 10
167175 LTEXT "", IDD_PROGRESS_MSG, 7, 6, 256, 12
168176 END
169177
170-#define SS_CTEXTBOX SS_SUNKEN | SS_CENTER
171-#define ES_VT100 ES_LEFT | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL
172-
173178 /* Template for dialogue requesting user confirmation of intent
174179 * to proceed with scheduled change actions.
175180 */
--- a/src/pkgbase.h
+++ b/src/pkgbase.h
@@ -50,10 +50,6 @@ EXTERN_C int pkgPutEnv( int, char* );
5050 class pkgSpecs;
5151 class pkgDirectory;
5252
53-#ifndef GUIMAIN_H
54-class AppWindowMaker;
55-#endif
56-
5753 class pkgProgressMeter
5854 {
5955 /* An abstract base class, from which the controller class
@@ -63,11 +59,6 @@ class pkgProgressMeter
6359 virtual void SetValue( int ) = 0;
6460 virtual void SetRange( int, int ) = 0;
6561 virtual int Annotate( const char *, ... ) = 0;
66-
67- protected:
68- AppWindowMaker *referrer;
69- pkgProgressMeter( AppWindowMaker *ref = NULL ): referrer( ref ){}
70- ~pkgProgressMeter();
7162 };
7263
7364 class pkgXmlNode : public TiXmlElement
--- a/src/pkgbind.cpp
+++ b/src/pkgbind.cpp
@@ -104,8 +104,10 @@ void pkgRepository::GetPackageList( const char *dname )
104104
105105 /* Set up diagnostics for reporting catalogue loading progress.
106106 */
107- const char *mode = force_update ? "Retaining" : "Loading";
108- const char *fmt = "%s catalogue: %s.xml; (item %d of %d)\n";
107+ const char *mode = force_update ? "Checking" : "Loading";
108+ const char *fmt = (owner->ProgressMeter() == NULL)
109+ ? "%s catalogue: %s.xml; (item %d of %d)\n"
110+ : "%s catalogue: %s.xml\n";
109111
110112 /* Check for a locally cached copy of the "package-list" file...
111113 */
--- /dev/null
+++ b/src/pmihook.cpp
@@ -0,0 +1,78 @@
1+/*
2+ * pmihook.cpp
3+ *
4+ * $Id$
5+ *
6+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
7+ * Copyright (C) 2013, MinGW.org Project
8+ *
9+ *
10+ * Implementation of the generic methods required by an "item counting"
11+ * progress meter, such as used by the setup tool and GUI installer, when
12+ * synchronising local catalogue files with the repository. This file is
13+ * compiled by inclusion at point of use, after PROGRESS_METER_CLASS has
14+ * been defined to appropriately identify the name of the class with
15+ * which these methods are to be associated.
16+ *
17+ *
18+ * This is free software. Permission is granted to copy, modify and
19+ * redistribute this software, under the provisions of the GNU General
20+ * Public License, Version 3, (or, at your option, any later version),
21+ * as published by the Free Software Foundation; see the file COPYING
22+ * for licensing details.
23+ *
24+ * Note, in particular, that this software is provided "as is", in the
25+ * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
26+ * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
27+ * PARTICULAR PURPOSE. Under no circumstances will the author, or the
28+ * MinGW Project, accept liability for any damages, however caused,
29+ * arising from the use of this software.
30+ *
31+ */
32+void PROGRESS_METER_CLASS::SetRange( int min, int max )
33+{
34+ /* Method to adjust the range of the progress meter, to represent any
35+ * arbitrary range of discrete values, rather than percentage units.
36+ */
37+ SendMessage( progress_bar, PBM_SETRANGE, 0, MAKELPARAM( min, total = max ) );
38+}
39+
40+void PROGRESS_METER_CLASS::SetValue( int value )
41+{
42+ /* Method to update the indicated completion state of a progress meter,
43+ * to represent any arbitrary value within its assigned metering range.
44+ */
45+ const char *plural = "s";
46+ if( total == 1 ) ++plural;
47+ PutVal( count, "Processed %d", value );
48+ PutVal( lim, "%d item%s", total, plural );
49+ SendMessage( progress_bar, PBM_SETPOS, value, 0 );
50+ PutVal( frac, "%d %%", (value * 100UL) / total );
51+}
52+
53+int PROGRESS_METER_CLASS::Annotate( const char *fmt, ... )
54+{
55+ /* Method to add a printf() style annotation to the progress meter dialogue.
56+ */
57+ va_list argv;
58+ va_start( argv, fmt );
59+ char text[1 + vsnprintf( NULL, 0, fmt, argv )];
60+ int len = vsnprintf( text, sizeof( text ), fmt, argv );
61+ va_end( argv );
62+
63+ SendMessage( annotation, WM_SETTEXT, 0, (LPARAM)(text) );
64+ return len;
65+};
66+
67+void PROGRESS_METER_CLASS::PutVal( HWND viewport, const char *fmt, ... )
68+{
69+ /* Private method, called by SetValue(), to display the numeric values
70+ * of the progress counters, in their appropriate viewports.
71+ */
72+ va_list argv; va_start( argv, fmt );
73+ char text[1 + vsnprintf( NULL, 0, fmt, argv )]; vsprintf( text, fmt, argv );
74+ SendMessage( viewport, WM_SETTEXT, 0, (LPARAM)(text) );
75+ va_end( argv );
76+}
77+
78+/* $RCSfile$: end of file */