Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

slider.h

00001 /*
00002   libwftk - Worldforge Toolkit - a widget library
00003   Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org>
00004   Based on code copyright  (C) 1999-2002  Karsten Laux
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either
00009   version 2.1 of the License, or (at your option) any later version.
00010   
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015   
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library; if not, write to the
00018   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019   Boston, MA  02111-1307, SA.
00020 */
00021 
00022 #ifndef _SLIDER_H
00023 #define _SLIDER_H
00024 
00025 #include <wftk/widget.h>
00026 
00027 namespace wftk {
00028     
00031 class Slider : public Widget
00032 {
00033  public:
00035   enum Orientation { VERTICAL, HORIZONTAL };
00037   explicit Slider(Orientation orient, unsigned thickness = 25);
00039   virtual ~Slider();
00040   
00042   void setButtonColor(const Color&);
00044   void setButtonSurface(const Surface&);
00046   void setButtonSurface(Surface::Resource*);
00048   void setButtonSurface(const std::string&);
00049 
00051   void setRange(int min, int max);
00053   void setDelta(int delta);
00054   
00056   virtual void increase();
00058   virtual void decrease();
00059   
00061   void setValue(int);
00063   int value() const { return (int)(value_+0.45); };
00064   
00066   SigC::Signal1<void, int> valueChanged;
00067 
00069   virtual bool mouseEvent(const Point& pos, const Point& rel, Mouse::Button mask);
00071   virtual bool buttonEvent(Mouse::Button, bool pressed, const Point&);
00073   //virtual void lostMouse() {moving_ = false;}
00074  protected: 
00076   virtual void draw(Surface&, const Point&, const Region&);
00078   virtual void handleResize(Uint16 w, Uint16 h);
00080   virtual void setPackingInfo();
00081  private:
00083   Surface::Resource* buttonSurface_;
00085   void setScaledButtonSurface();
00087   Surface scaledSurface_;
00089   Color buttonColor_;
00091   Rect button_;
00093   Orientation orientation_;
00095   unsigned thickness_;
00097   float value_;
00099   int delta_;
00101   int min_;
00103   int max_;
00105   Point position_;
00107   bool moving_;
00109   float delta_per_pixel_;
00110 };
00111 
00112 } // namespace wftk
00113 
00114 #endif // _SLIDER_H

Generated Tue Aug 9 18:40:26 2005.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.