This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[setup PATCH] Use vector instead of array to store PropertyPage pointer list.


+2003-08-02  Gary R. Van Sickle  <g.r.vansickle@worldnet.att.net>
+
+ * propsheet.cc (Copyright): Update copyright dates.
+ (PropSheet::PropSheet): Remove NumPropPages initialization.
+ (PropSheet::CreatePages): Use PropertyPages.size() instead of
+ NumPropPages.
+ (PropSheet::Create): Ditto.
+ (PropSheet::AddPage): Change to use new PropertyPages std::vector<>.
+ * propsheet.h (Copyright): Update copyright dates.
+ (File Scope): Include <vector>.
+ (PropSheet::PropertyPages): Change from array to vector<>.
+ (PropSheet::NumPropPages): Remove.

Index: propsheet.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/propsheet.cc,v
retrieving revision 2.5
diff -u -p -r2.5 propsheet.cc
--- propsheet.cc 1 Aug 2003 23:54:14 -0000 2.5
+++ propsheet.cc 2 Aug 2003 11:48:00 -0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -56,7 +56,6 @@ DLGTEMPLATEEX, *LPDLGTEMPLATEEX;

 PropSheet::PropSheet ()
 {
-  NumPropPages = 0;
 }

 PropSheet::~PropSheet ()
@@ -69,15 +68,15 @@ PropSheet::CreatePages ()
   HPROPSHEETPAGE *retarray;

   // Create the return array
-  retarray = new HPROPSHEETPAGE[NumPropPages];
+  retarray = new HPROPSHEETPAGE[PropertyPages.size()];

   // Create the pages with CreatePropertySheetPage().
   // We do it here rather than in the PropertyPages themselves
   // because, for reasons known only to Microsoft, these handles will be
   // destroyed by the property sheet before the PropertySheet() call
returns,
   // at least if it's modal (don't know about modeless).
-  int i;
-  for (i = 0; i < NumPropPages; i++)
+  unsigned int i;
+  for (i = 0; i < PropertyPages.size(); i++)
     {
       retarray[i] =
  CreatePropertySheetPage (PropertyPages[i]->GetPROPSHEETPAGEPtr ());
@@ -87,7 +86,7 @@ PropSheet::CreatePages ()
  {
    PropertyPages[i]->YouAreFirst ();
  }
-      else if (i == NumPropPages - 1)
+      else if (i == PropertyPages.size() - 1)
  {
    PropertyPages[i]->YouAreLast ();
  }
@@ -184,7 +183,7 @@ PropSheet::Create (const Window * Parent
       p.hwndParent = NULL;
     }
   p.hInstance = GetInstance ();
-  p.nPages = NumPropPages;
+  p.nPages = PropertyPages.size();
   p.pszIcon = MAKEINTRESOURCE(IDI_CYGWIN);
   p.nStartPage = 0;
   p.phpage = PageHandles;
@@ -226,8 +225,7 @@ PropSheet::AddPage (PropertyPage * p)
 {
   // Add a page to the property sheet.
   p->YouAreBeingAddedToASheet (this);
-  PropertyPages[NumPropPages] = p;
-  NumPropPages++;
+  PropertyPages.push_back(p);
 }

 bool
Index: propsheet.h
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/propsheet.h,v
retrieving revision 2.4
diff -u -p -r2.4 propsheet.h
--- propsheet.h 1 Aug 2003 10:41:36 -0000 2.4
+++ propsheet.h 2 Aug 2003 11:48:00 -0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Gary R. Van Sickle.
+ * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle.
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@
 // the Windows function of the same name.


+#include <vector>
+
 #include <windows.h>
 #include <prsht.h>

@@ -31,8 +33,8 @@ class PropertyPage;

 class PropSheet : public Window
 {
-  PropertyPage *PropertyPages[MAXPROPPAGES];
-  int NumPropPages;
+  typedef std::vector< PropertyPage* > PAGE_CONTAINER;
+  PAGE_CONTAINER PropertyPages;

   HPROPSHEETPAGE *PageHandles;
   HPROPSHEETPAGE *CreatePages ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]