Back to index

extremetuxracer  0.5beta
textarea.h
Go to the documentation of this file.
00001 /* 
00002  * PPRacer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  *
00005  * Copyright (C) 1999-2001 Jasmin F. Patry
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 
00022 #ifndef TEXTAREA_H
00023 #define TEXTAREA_H
00024 
00025 #include "widget.h"
00026 #include "button.h"
00027 #include "ui_theme.h"
00028 #include "font.h"
00029 
00030 #include <list>
00031 
00032 namespace pp {
00033        
00034        
00035 class Textarea : public Widget {
00036 
00037        double m_arrowWidth;
00038        double m_borderWidth;
00039        double m_textPad;
00040        double m_textRegionHeight;
00041     double m_textRegionWidth;
00042        
00043     pp::Font *mp_font;
00044        
00045     pp::Color m_borderColor;
00046     pp::Color m_backgroundColor;
00047     pp::Button *mp_upButton;
00048     pp::Button *mp_downButton;
00049     char *mp_textOrig;
00050     char *mp_textLines;
00051        std::list<char*> m_lines;
00052        std::list<char*>::iterator mi_topLine;
00053        
00054        void calcTextRegionDims();
00055        void updateButtonPositions();
00056        void createLines();
00057        void updateButtonEnabledStates();
00058        void drawTextLines();
00059        
00060 public:
00061        Textarea( pp::Vec2d pos, pp::Vec2d size,
00062                           const char *binding, const char *text );
00063        ~Textarea();
00064 
00065        void setText( const char *text );
00066        void setPosition(pp::Vec2d pos);
00067 
00068        void upButtonClick();
00069        void downButtonClick();
00070 
00071        void draw();
00072 };
00073        
00074 } //namespace pp
00075 
00076 #endif // TEXTAREA_H