* 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-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.
}
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);
+}
#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 */
CategoryPackage *packages; /* the packages in this category */
};
-int Categorycmp (Category &, Category &);
-
#endif /* _CATEGORY_H_ */
packagemeta & pkg = *db.packages[n];
if (!pkg.Categories.number ())
pkg.add_category (db.categories.registerbykey ("Misc"));
+ pkg.add_category (db.categories.registerbykey ("All"));
}
}
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);
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;
}
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)
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);
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);
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)
{
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
(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];
protected:
topbucket (topbucket const &);
topbucket & operator= (topbucket const &);
-private:
list < pick_line, char const *, strcasecmp > bucket;
};
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);
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
{