scrollbar.h

00001 // scrollbar.h                         -*-c++-*-
00002 //
00003 //   Copyright (C) 2004-2006 Daniel Burrows
00004 //
00005 //   This program is free software; you can redistribute it and/or
00006 //   modify it under the terms of the GNU General Public License as
00007 //   published by the Free Software Foundation; either version 2 of
00008 //   the License, or (at your option) any later version.
00009 //
00010 //   This program is distributed in the hope that it will be useful,
00011 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 //   General Public License for more details.
00014 //
00015 //   You should have received a copy of the GNU General Public License
00016 //   along with this program; see the file COPYING.  If not, write to
00017 //   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018 //   Boston, MA 02111-1307, USA.
00019 
00020 
00021 #ifndef SCROLLBAR_H
00022 #define SCROLLBAR_H
00023 
00024 #include "widget.h"
00025 
00026 namespace cwidget
00027 {
00028   namespace widgets
00029   {
00030     class scrollbar : public widget
00031     {
00032     public:
00033       enum direction {HORIZONTAL, VERTICAL};
00034 
00035     private:
00036       direction dir;
00037 
00038       int max, val;
00039       // The current slider maximum and value (FIXME: use floats?)
00040 
00045       int get_slider();
00046     protected:
00047       scrollbar(direction _dir, int _val, int _max)
00048         :dir(_dir), max(_max), val(_val) {}
00049 
00050       scrollbar(direction _dir)
00051         :dir(_dir), max(0), val(0) {}
00052     public:
00053       static
00054       util::ref_ptr<scrollbar> create(direction dir, int val, int max)
00055       {
00056         util::ref_ptr<scrollbar> rval(new scrollbar(dir, val, max));
00057         rval->decref();
00058         return rval;
00059       }
00060 
00061       static
00062       util::ref_ptr<scrollbar> create(direction dir)
00063       {
00064         util::ref_ptr<scrollbar> rval(new scrollbar(dir));
00065         rval->decref();
00066         return rval;
00067       }
00068 
00069       void paint(const style &st);
00070 
00071       int width_request();
00072       int height_request(int w);
00073 
00074       bool get_cursorvisible();
00075       point get_cursorloc();
00076       void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate);
00077 
00078       void set_slider(int newval, int newmax);
00079 
00084       sigc::signal1<void, bool> scrollbar_interaction;
00085     };
00086 
00087     typedef util::ref_ptr<scrollbar> scrollbar_ref;
00088   }
00089 }
00090 
00091 #endif

Generated on Mon Jul 7 11:11:55 2008 for cwidget by  doxygen 1.5.6