cwidget  0.5.17
scrollbar.h
1 // scrollbar.h -*-c++-*-
2 //
3 // Copyright (C) 2004-2006 Daniel Burrows
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; see the file COPYING. If not, write to
17 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 // Boston, MA 02111-1307, USA.
19 
20 
21 #ifndef SCROLLBAR_H
22 #define SCROLLBAR_H
23 
24 #include "widget.h"
25 
26 namespace cwidget
27 {
28  namespace widgets
29  {
30  class scrollbar : public widget
31  {
32  public:
33  enum direction {HORIZONTAL, VERTICAL};
34 
35  private:
36  direction dir;
37 
38  int max, val;
39  // The current slider maximum and value (FIXME: use floats?)
40 
45  int get_slider();
46  protected:
47  scrollbar(direction _dir, int _val, int _max)
48  :dir(_dir), max(_max), val(_val) {}
49 
50  scrollbar(direction _dir)
51  :dir(_dir), max(0), val(0) {}
52  public:
53  static
54  util::ref_ptr<scrollbar> create(direction dir, int val, int max)
55  {
56  util::ref_ptr<scrollbar> rval(new scrollbar(dir, val, max));
57  rval->decref();
58  return rval;
59  }
60 
61  static
62  util::ref_ptr<scrollbar> create(direction dir)
63  {
64  util::ref_ptr<scrollbar> rval(new scrollbar(dir));
65  rval->decref();
66  return rval;
67  }
68 
69  void paint(const style &st);
70 
71  int width_request();
72  int height_request(int w);
73 
74  bool get_cursorvisible();
75  point get_cursorloc();
76  void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate);
77 
78  void set_slider(int newval, int newmax);
79 
84  sigc::signal1<void, bool> scrollbar_interaction;
85  };
86 
88  }
89 }
90 
91 #endif
A "style" is a setting to be applied to a display element (widget, text, etc).
Definition: style.h:51
int height_request(int w)
Calculate the desired height of the widget, given its width.
Definition: scrollbar.cc:70
Definition: widget.h:89
Definition: ref_ptr.h:19
The namespace containing everything defined by cwidget.
Definition: columnify.cc:26
Definition: scrollbar.h:30
void paint(const style &st)
Display this widget.
Definition: scrollbar.cc:37
The basic widget interface.
Definition: widget.h:107
sigc::signal1< void, bool > scrollbar_interaction
This signal is emitted if the user "pages up" or "pages down" via the scrollbar.
Definition: scrollbar.h:84
int width_request()
Definition: scrollbar.cc:65