Author: baby-guest
Date: 2007-06-20 20:16:39 +0000 (Wed, 20 Jun 2007)
New Revision: 3037

Modified:
   software/ui/src/pkgbrowser.cpp
   software/ui/src/pkgbrowser.h
Log:
Improved browser



Modified: software/ui/src/pkgbrowser.cpp
===================================================================
--- software/ui/src/pkgbrowser.cpp      2007-06-20 19:42:11 UTC (rev 3036)
+++ software/ui/src/pkgbrowser.cpp      2007-06-20 20:16:39 UTC (rev 3037)
@@ -90,3 +90,50 @@
        }
        return ret;
 }
+
+PackageViewer::PackageViewer(int X, int Y, int W, int H, const char *L)
+       : Fl_Scroll(X,Y,W,H,L), nchild(0)
+{
+       for ( int t=0; t<4; t++ ) { Add(); }
+}
+
+PackageViewer::Item::Item(int X, int Y, int W, int H, int FW, int DH, const 
char *L)
+       : Fl_Group(X, Y, W, H, L)
+{
+       // Green fixed width box
+       FixedBox = new Fl_Box(X, Y, FW, DH, "Fixed");
+       FixedBox->box(FL_UP_BOX);
+       FixedBox->color(FL_GREEN);
+       // Red stretchy box
+       StretchBox = new Fl_Box(X+FW, Y, W-FW, DH, "Stretch");
+       StretchBox->color(FL_BLUE);
+       StretchBox->box(FL_UP_BOX);
+       resizable(StretchBox);
+       end();
+}
+
+void PackageViewer::resize(int X, int Y, int W, int H)
+{
+       // Tell children to resize to our new width
+       for ( int t=0; t<children()-2; t++ )
+       { // -2: skip scrollbars
+               Fl_Widget *w = child(t);
+               w->resize(w->x(), w->y(), W-20, w->h()); // W-20: leave room 
for scrollbar
+       }
+       // Tell scroll children changed in size
+       init_sizes();
+       Fl_Scroll::resize(X,Y,W,H);
+}
+
+void PackageViewer::Add()
+{
+       // Append new scrollitem to bottom
+       // Note: An Fl_Pack would be a good way to do this, too
+       int ix = x() + 1;
+       int iy = y() - yposition() + (nchild*25)+1;
+       int iw = w() - 20; // -20: compensate for vscroll bar
+       int ih = 25;
+       add(new Item(ix, iy, iw, ih, 50, 25));
+       redraw();
+       nchild++;
+}

Modified: software/ui/src/pkgbrowser.h
===================================================================
--- software/ui/src/pkgbrowser.h        2007-06-20 19:42:11 UTC (rev 3036)
+++ software/ui/src/pkgbrowser.h        2007-06-20 20:16:39 UTC (rev 3037)
@@ -34,4 +34,30 @@
        virtual int handle(int e);
 };
 
+#include <FL/Fl.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Scroll.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Box.H>
+
+class PackageViewer : public Fl_Scroll {
+public:
+       class Item : public Fl_Group
+       {
+               private:
+                       Fl_Box* FixedBox;
+                       Fl_Box* StretchBox;
+               public:
+                       Item(int X, int Y, int W, int H, int FW, int DH, const 
char* L = NULL);
+       };
+
+       PackageViewer(int X, int Y, int W, int H, const char* L = NULL);
+       void resize(int X, int Y, int W, int H);
+       void Add();
+
+private:
+       int nchild;
+};
+
 #endif


_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-games-commits

Reply via email to