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

pushbutton.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 _PUSHBUTTON_H
00023 #define _PUSHBUTTON_H
00024 
00025 #include <wftk/button.h>
00026 
00027 namespace wftk {
00028 
00033 class PushButton : public Button
00034 {
00035  //OBJECT
00036 
00037  public:
00039   PushButton();
00045   explicit PushButton(const std::string& text,
00046               const Font &font=Font::registry.find("button_font"));
00050   virtual ~PushButton();
00056   void setUpPic(Surface::Resource* bm);
00062   void setUpPic(const Surface& surf);
00067   void setUpPic(const std::string& name);
00073   void setDownPic(Surface::Resource* bm);
00079   void setDownPic(const Surface& surf);
00084   void setDownPic(const std::string& name);
00085 
00086  protected:
00088   virtual void draw(Surface&, const Point&, const Region&);
00089  private:
00091   Surface::Resource* upPic_;
00093   Surface::Resource* downPic_;
00095   Color light_, dark_;
00097   void handlePressed() {if(upPic_ || downPic_) setBackground(downPic_, false);}
00099   void handleReleased() {if(upPic_ || downPic_) setBackground(upPic_, false);}
00101   bool noBackground() const {return !(isPressed() ? upPic_ : downPic_);}
00103   bool anyBackground() const {return upPic_ || downPic_;}
00104 
00105 };
00106 
00107 } // namespace wftk
00108 
00109 #endif // _PUSHBUTTON_H

Generated Fri Mar 5 08:11:00 2004.
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.