]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
2001-01-07 Robert Collins <rbtcollins@hotmail.com> cygnus_cvs_20020108_pre
authorRobert Collins <rbtcollins@hotmail.com>
Sun, 6 Jan 2002 13:37:09 +0000 (13:37 +0000)
committerRobert Collins <rbtcollins@hotmail.com>
Sun, 6 Jan 2002 13:37:09 +0000 (13:37 +0000)
        * category.cc (Categorycmp): Add a const safe version.
        * category.h (Categorycmp): Add a const safe version.
        (Category): Add operator ==.
        * choose.cc (fill_missing_category): Add every package to "All".
        (pick_category_line::paint): Add support for hidden labels, and a tree depth.
        (pick_category_line::click): Ditto.
        (view::view): Pass in a top level category to use.
        (view::insert_pkg): Special case - skip category "All".
        (view::insert_category): Ditto.
        (view::clear_view): Set the contents label state.
        (create_listview): Pass in a top level category to view().
        * choose.h (topbucket): Make bucket available to derived classes.
        (pick_category_line):  Add support for hidden labels, and a tree depth.
        Remove our second copy of bucket.
        (view): Pass in a top level category to the constructor.
        Use pick_category_line to allow three level display.

ChangeLog
category.cc
category.h
choose.cc
choose.h

index 6abd6b84533a17d099d3943b174e25e6569a6a23..a59dfa7cf08c06929b55c71ffa06bd1ed493d4c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2001-01-07  Robert Collins  <rbtcollins@hotmail.com>
+
+       * category.cc (Categorycmp): Add a const safe version.
+       * category.h (Categorycmp): Add a const safe version.
+       (Category): Add operator ==.
+       * choose.cc (fill_missing_category): Add every package to "All".
+       (pick_category_line::paint): Add support for hidden labels, and a tree depth.
+       (pick_category_line::click): Ditto.
+       (view::view): Pass in a top level category to use.
+       (view::insert_pkg): Special case - skip category "All".
+       (view::insert_category): Ditto.
+       (view::clear_view): Set the contents label state.
+       (create_listview): Pass in a top level category to view().
+       * choose.h (topbucket): Make bucket available to derived classes.
+       (pick_category_line):  Add support for hidden labels, and a tree depth.
+       Remove our second copy of bucket.
+       (view): Pass in a top level category to the constructor.
+       Use pick_category_line to allow three level display.
+
 2001-01-06  Robert Collins  <rbtcollins@hotmail.com>
 
        * cygpackage.h (cygpackage): Make set_[s|l]desc virtual.
index aec9b8fd4c76031a7a967bd65235d3ef8a5d740b..fe0592ba8bf130d674a1a73d4fbb165fb97578df 100644 (file)
@@ -36,7 +36,13 @@ packages (0)
 }
 
 int
-Categorycmp (Category & a, Category & b)
+Categorycmp (Category const & a, Category const & b)
 {
   return strcasecmp (a.name, b.name);
 }
+
+int
+Categorycmp (Category & a, Category & b)
+{
+    return strcasecmp (a.name, b.name);
+}
index 542dc2c42a1f363d60779d6d47e1df3f8c5fabe0..c678e67024cea9e27dff74faa6b218b0c345217c 100644 (file)
 #ifndef _CATEGORY_H_
 #define _CATEGORY_H_
 
+class Category;
 class CategoryPackage;
 
+int Categorycmp (Category const &, Category const &);
+// Grrr template problem - couldn't get list to use int Ucmp (U const, U const),
+// and gcc wouldn't cast on the fly.
+int Categorycmp (Category &, Category &);
+
 class Category
 {
 public:
   Category ();
-  Category (const char *);
+  Category (char const *);
+  bool operator== (Category const &rhs) const {return Categorycmp (*this, rhs) ? false : true;}
 
   Category *next;              /* the next category in the list */
   const char *name;            /* the category */
@@ -32,6 +39,4 @@ public:
   CategoryPackage *packages;   /* the packages in this category */
 };
 
-int Categorycmp (Category &, Category &);
-
 #endif /* _CATEGORY_H_ */
index f443a5abd5c1ebdb14be4d7b895aeee7e23c349c..7426da7362fac8e937764b4acfd5b718e25899f1 100644 (file)
--- a/choose.cc
+++ b/choose.cc
@@ -504,6 +504,7 @@ fill_missing_category ()
       packagemeta & pkg = *db.packages[n];
       if (!pkg.Categories.number ())
        pkg.add_category (db.categories.registerbykey ("Misc"));
+      pkg.add_category (db.categories.registerbykey ("All"));
     }
 }
 
@@ -664,11 +665,12 @@ void
 pick_category_line::paint (HDC hdc, int x, int y, int row, int show_cat)
 {
   int r = y + row * row_height;
-  TextOut (hdc, x + chooser->headers[chooser->cat_col].x + HMARGIN / 2, r,
+  if (show_label)
+    TextOut (hdc, x + chooser->headers[chooser->cat_col].x + HMARGIN / 2 + depth * 8, r,
           cat.name, strlen (cat.name));
   if (collapsed)
     return;
-  int accum_row = row + 1;
+  int accum_row = row + (show_label ? 1 : 0);
   for (size_t n = 1; n <= bucket.number (); n++)
     {
       bucket[n]->paint (hdc, x, y, accum_row, show_cat);
@@ -698,7 +700,7 @@ pick_pkg_line::click (int const myrow, int const ClickedRow, int const x)
 int
 pick_category_line::click (int const myrow, int const ClickedRow, int const x)
 {
-  if (myrow == ClickedRow)
+  if (myrow == ClickedRow && show_label)
     {
       collapsed = !collapsed;
       int accum_row = 0;
@@ -708,7 +710,7 @@ pick_category_line::click (int const myrow, int const ClickedRow, int const x)
     }
   else
     {
-      int accum_row = myrow + 1;
+      int accum_row = myrow + (show_label ? 1 : 0);
       for (size_t n = 1; n <= bucket.number (); n++)
        {
          if (accum_row + bucket[n]->itemcount () > ClickedRow)
@@ -721,7 +723,8 @@ pick_category_line::click (int const myrow, int const ClickedRow, int const x)
 
 HWND DoCreateHeader (HWND hwndParent);
 
-view::view (views _mode, HWND lv):listview (lv)
+view::view (views _mode, HWND lv, Category &cat) : 
+contents (cat, 0, false, true), listview (lv)
 {
 
   HDC dc = GetDC (listview);
@@ -924,7 +927,10 @@ view::insert_pkg (packagemeta & pkg)
       for (size_t x = 1; x <= pkg.Categories.number (); x++)
        {
          Category & cat = pkg.Categories[x]->key;
-         pick_category_line & catline = *new pick_category_line (cat);
+         // Special case - yuck
+         if (cat == Category ("All"))
+           continue;
+         pick_category_line & catline = *new pick_category_line (cat, 1);
          pick_pkg_line & line = *new pick_pkg_line (pkg);
          catline.insert (line);
          contents.insert (catline);
@@ -935,8 +941,9 @@ view::insert_pkg (packagemeta & pkg)
 void
 view::insert_category (Category * cat, bool collapsed)
 {
-
-  pick_category_line & catline = *new pick_category_line (*cat, collapsed);
+  if (*cat == Category ("All"))
+    return;
+  pick_category_line & catline = *new pick_category_line (*cat, 1, collapsed);
   for (CategoryPackage * catpkg = cat->packages; catpkg;
        catpkg = catpkg->next)
     {
@@ -951,6 +958,20 @@ void
 view::clear_view (void)
 {
   contents.empty ();
+  switch (view_mode)
+  {
+  case VIEW_UNKNOWN:
+    break;
+  case VIEW_PACKAGE_FULL:
+  case VIEW_PACKAGE:
+    contents.ShowLabel (false);
+    break;
+  case VIEW_CATEGORY:
+    contents.ShowLabel ();
+    break;
+  default:
+    return;
+  }
 }
 
 static views
@@ -1074,14 +1095,14 @@ create_listview (HWND dlg, RECT * r)
                       (HMENU) MAKEINTRESOURCE (IDC_CHOOSE_LIST),
                       hinstance, 0);
   ShowWindow (lv, SW_SHOW);
-  chooser = new view (VIEW_CATEGORY, lv);
+  packagedb db;
+  chooser = new view (VIEW_CATEGORY, lv, db.categories.registerbykey("All"));
 
   default_trust (lv, TRUST_CURR);
   set_view_mode (lv, VIEW_CATEGORY);
   if (!SetDlgItemText (dlg, IDC_CHOOSE_VIEWCAPTION, chooser->mode_caption ()))
     log (LOG_BABBLE, "Failed to set View button caption %ld",
         GetLastError ());
-  packagedb db;
   for (size_t n = 1; n <= db.packages.number (); n++)
     {
       packagemeta & pkg = *db.packages[n];
index ac67bb624bb528e51ee389704c2ab6d894d26dc3..c1c37906f550f0e30ffe525042f0b9aafc553930 100644 (file)
--- a/choose.h
+++ b/choose.h
@@ -150,7 +150,6 @@ public:
 protected:
   topbucket (topbucket const &);
   topbucket & operator= (topbucket const &);
-private:
   list < pick_line, char const *, strcasecmp > bucket;
 };
 
@@ -158,43 +157,52 @@ private:
 class pick_category_line:public topbucket
 {
 public:
-  pick_category_line (Category & _cat, bool aBool =
-                     true):cat (_cat), collapsed (aBool)
-  {
+  pick_category_line (Category & _cat, size_t thedepth = 0, bool aBool =
+                     true, bool aBool2 = true):cat (_cat), depth(thedepth)
+  {
+    if (aBool)
+      {
+        collapsed = true;
+       show_label = true;
+      }
+    else
+      {
+       collapsed = false;
+       show_label = aBool2;
+      }
+    
     key = _cat.key;
   };
+  void ShowLabel(bool aBool = true) {show_label = aBool; if (!show_label) collapsed = false;}
   virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
   virtual int click (int const myrow, int const ClickedRow, int const x);
   virtual int itemcount () const
   {
     if (collapsed)
       return 1;
-    int t = 1;
+    int t = show_label ? 1 : 0;
     for (size_t n = 1; n <= bucket.number (); n++)
         t += bucket[n]->itemcount ();
       return t;
   };
-  virtual void insert (pick_line & aLine)
-  {
-    bucket.registerbyobject (aLine);
-  }
 private:
   Category & cat;
-  list < pick_line, char const *, strcasecmp > bucket;
   bool collapsed;
+  bool show_label;
+  size_t depth;
 };
 
 class view
 {
 public:
   int num_columns;
-  views get_view_mode ()
+  views get_view_mode () 
   {
     return view_mode;
   };
   void set_view_mode (views _mode);
   struct _header *headers;
-  view (views mode, HWND listview);
+  view (views mode, HWND listview, Category &cat);
   const char *mode_caption ();
   void insert_pkg (packagemeta &);
   void insert_category (Category *, bool);
@@ -206,9 +214,7 @@ public:
   int cat_col;
   int pkg_col;
   int last_col;
-//  pick_line *lines;
-//  int nlines;
-  topbucket contents;
+  pick_category_line contents;
   void scroll (HWND hwnd, int which, int *var, int code);
   HWND ListHeader (void) const
   {
This page took 0.048228 seconds and 5 git commands to generate.