Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

scrollinglabel.h

00001 /***************************************************************************
00002                           scrollinglabel.h  -  description
00003                              -------------------
00004     begin                : Thu Aug 28 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef SCROLLING_LABEL_H
00019 #define SCROLLING_LABEL_H
00020 
00021 #include "../constants.h"
00022 #include "widget.h"
00023 #include "button.h"
00024 #include "window.h"
00025 #include "draganddrop.h"
00026 #include <vector>
00027 
00028 using namespace std;
00029 
00035 class WordClickedHandler {
00036 public:
00037         WordClickedHandler() {
00038   }
00039 
00040         virtual ~WordClickedHandler() {
00041   }
00042 
00043   virtual void wordClicked( char *word ) = 0;
00044   virtual void showingWord( char *word ) = 0;
00045 };
00046 
00047 class ScrollingLabel : public Widget {
00048  protected:
00049   char text[3000];
00050   int lineWidth;
00051   vector<string> lines;
00052 
00053   //  int count;
00054   //  const char **list;
00055   //  const Color *colors;
00056   //  const GLuint *icons;
00057   int value;
00058   int scrollerWidth, scrollerHeight;
00059   int listHeight;
00060   bool willSetScrollerHeight;
00061   float alpha, alphaInc;
00062   GLint lastTick;
00063   bool inside;
00064   int scrollerY;
00065   bool dragging;
00066   int dragX, dragY;
00067   int selectedLine;
00068   //  DragAndDropHandler *dragAndDropHandler;
00069   bool innerDrag;
00070   int innerDragX, innerDragY;
00071   //  bool highlightBorders;
00072   // GLuint highlight;
00073   bool canGetFocusVar;
00074 
00075   map<char, Color> coloring;
00076 
00077   typedef struct _WordPos {
00078     int x, y, w, h;
00079     char word[255];
00080   } WordPos;
00081   WordPos wordPos[1000];
00082   int wordPosCount;
00083   WordClickedHandler *handler;
00084 
00085  public: 
00086 
00087    bool debug;
00088 
00089    ScrollingLabel(int x, int y, int w, int h, char *text );
00090    virtual ~ScrollingLabel();
00091 
00092    inline void setWordClickedHandler( WordClickedHandler *handler ) { this->handler = handler; }
00093 
00094    inline void addColoring( char c, Color color ) { coloring[c]=color; }
00095 
00096    inline char *getText() { return text; }
00097    void setText(char *s);
00098 
00099    //  inline int getLineCount() { return count; }
00100    //  void setLines(int count, const char *s[], const Color *colors=NULL, const GLuint *icon=NULL);
00101    //  inline const char *getLine(int index) { return list[index]; }
00102 
00103    //  inline int getSelectedLine() { return selectedLine; }
00104    //  void setSelectedLine(int n);
00105 
00106   void drawWidget(Widget *parent);
00107 
00113   bool handleEvent(Widget *parent, SDL_Event *event, int x, int y);
00114 
00115   void removeEffects(Widget *parent);
00116 
00117   // don't play sound when the value changes
00118   virtual inline bool hasSound() { return false; }
00119 
00120   inline bool canGetFocus() { return canGetFocusVar; }
00121   inline void setCanGetFocus(bool b) { this->canGetFocusVar = b; }
00122 
00123  private:
00124    char *printLine( Widget *parent, int x, int y, char *s );
00125    int getWordPos( int x, int y );
00126   //  void selectLine(int x, int y);
00127   //  void drawIcon( int x, int y, GLuint icon );
00128 };
00129 
00130 #endif
00131 

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0