From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 2/4] Change PickView::view into an enum
Date: Wed, 24 Aug 2016 14:16:00 -0000 [thread overview]
Message-ID: <20160824141537.34836-3-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20160824141537.34836-1-jon.turney@dronecode.org.uk>
Change PickView::view from a class, into an enum
Use a C++11 scoped enum so we don't have to change all the uses of it's
values.
---
PickView.cc | 44 ++++++++++++--------------------------------
PickView.h | 41 +++++++++--------------------------------
2 files changed, 21 insertions(+), 64 deletions(-)
diff --git a/PickView.cc b/PickView.cc
index c784a2a..588cfec 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -52,15 +52,6 @@ static PickView::Header cat_headers[] = {
{0, 0, 0, false}
};
-// PickView:: views
-const PickView::views PickView::views::Unknown (0);
-const PickView::views PickView::views::PackageFull (1);
-const PickView::views PickView::views::Package (2);
-const PickView::views PickView::views::PackageKeeps (3);
-const PickView::views PickView::views::PackageSkips (4);
-const PickView::views PickView::views::PackageUserPicked (5);
-const PickView::views PickView::views::Category (6);
-
ATOM PickView::WindowClassAtom = 0;
// DoInsertItem - inserts an item into a header control.
@@ -152,7 +143,11 @@ PickView::note_width (PickView::Header *hdrs, HDC dc,
void
PickView::cycleViewMode ()
{
- setViewMode (++view_mode);
+ PickView::views _value = (PickView::views)((int)view_mode + 1);
+ if (_value > PickView::views::Category)
+ _value = PickView::views::PackageFull;
+
+ setViewMode (_value);
}
void
@@ -235,25 +230,19 @@ PickView::setViewMode (views mode)
const char *
PickView::mode_caption ()
{
- return view_mode.caption ();
-}
-
-const char *
-PickView::views::caption ()
-{
- switch (_value)
+ switch (view_mode)
{
- case 1:
+ case views::PackageFull:
return "Full";
- case 2:
+ case views::Package:
return "Pending";
- case 3:
+ case views::PackageKeeps:
return "Up To Date";
- case 4:
+ case views::PackageSkips:
return "Not Installed";
- case 5:
+ case views::PackageUserPicked:
return "Picked";
- case 6:
+ case views::Category:
return "Category";
default:
return "";
@@ -348,15 +337,6 @@ PickView::insert_category (Category *cat, bool collapsed)
delete &catline;
}
-PickView::views&
-PickView::views::operator++ ()
-{
- ++_value;
- if (_value > Category._value)
- _value = 1;
- return *this;
-}
-
int
PickView::click (int row, int x)
{
diff --git a/PickView.h b/PickView.h
index fd20dc9..054ab4a 100644
--- a/PickView.h
+++ b/PickView.h
@@ -40,7 +40,7 @@ class PickView : public Window
public:
virtual bool Create (Window * Parent = NULL, DWORD Style = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, RECT * r = NULL);
virtual bool registerWindowClass ();
- class views;
+ enum class views;
class Header;
int num_columns;
void defaultTrust (trusts trust);
@@ -96,38 +96,15 @@ public:
return listheader;
}
- class views
+ enum class views
{
- public:
- static const views Unknown;
- static const views PackageFull;
- static const views Package;
- static const views PackageKeeps;
- static const views PackageSkips;
- static const views PackageUserPicked;
- static const views Category;
- views ():_value (0)
- {
- };
- views (int aInt)
- {
- _value = aInt;
- if (_value < 0 || _value > 6)
- _value = 0;
- }
- views & operator++ ();
- bool operator == (views const &rhs)
- {
- return _value == rhs._value;
- }
- bool operator != (views const &rhs)
- {
- return _value != rhs._value;
- }
- const char *caption ();
-
- private:
- int _value;
+ Unknown,
+ PackageFull,
+ Package,
+ PackageKeeps,
+ PackageSkips,
+ PackageUserPicked,
+ Category,
};
class Header
--
2.8.3
next prev parent reply other threads:[~2016-08-24 14:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 14:16 [PATCH setup 0/4] Use a pop-up menu to select chooser view filter Jon Turney
2016-08-24 14:16 ` [PATCH setup 4/4] Use a pop-up menu to directly " Jon Turney
2016-08-24 14:16 ` Jon Turney [this message]
2016-08-24 14:16 ` [PATCH setup 3/4] Rename PickView::Package to PickView::PackagePending Jon Turney
2016-08-24 14:16 ` [PATCH setup 1/4] Build C++ code with -std=gnu++11 Jon Turney
2016-08-24 16:50 ` [PATCH setup 0/4] Use a pop-up menu to select chooser view filter Corinna Vinschen
2016-08-25 19:11 ` Jon Turney
2016-08-25 20:34 ` Yaakov Selkowitz
2016-08-26 8:07 ` Corinna Vinschen
2016-08-26 14:41 ` Jon Turney
2016-08-26 14:43 ` [PATCH setup 5/6] Simplify view mode indication Jon Turney
2016-08-26 14:43 ` [PATCH setup 6/6] Use a splitbutton to show the view choosing popup menu Jon Turney
2016-08-26 15:25 ` [PATCH setup 0/4] Use a pop-up menu to select chooser view filter Corinna Vinschen
2016-08-29 10:03 ` Jon Turney
2016-08-29 10:04 ` [PATCH setup 4/4] Use a drop-down list to directly " Jon Turney
2016-08-30 13:01 ` Corinna Vinschen
2016-08-30 23:29 ` Jon Turney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160824141537.34836-3-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).