![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Scrolling text widget * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2002 by Jereon van der Zijp. All Rights Reserved. * 00007 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00008 ********************************************************************************* 00009 * This library is free software; you can redistribute it and/or * 00010 * modify it under the terms of the GNU Lesser General Public * 00011 * License as published by the Free Software Foundation; either * 00012 * version 2.1 of the License, or (at your option) any later version. * 00013 * * 00014 * This library is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00017 * Lesser General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU Lesser General Public * 00020 * License along with this library; if not, write to the Free Software * 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00022 *********************************************************************************/ 00023 #ifndef FXTICKER 00024 #define FXTICKER 00025 00026 #ifndef FXFRAME_H 00027 #include <fox/FXFrame.h> 00028 using namespace FX; 00029 #endif 00030 namespace FXEX { 00031 00032 /** 00033 * Ticker widget; animates a running text like a kind of stock-ticker. 00034 * The displayed text, its font, and animation speed can be fully configured. 00035 */ 00036 class FXAPI FXTicker : public FXFrame { 00037 FXDECLARE(FXTicker) 00038 00039 protected: 00040 FXString label; // The text to be displayed 00041 FXFont *font; // The font in which to display 00042 FXint offset; // The current scoll offset 00043 FXint speed; // Animation speed 00044 FXint rate; // Animation rate 00045 00046 protected: 00047 FXTicker(){} 00048 00049 public: 00050 long onTimer(FXObject*,FXSelector,void*); // Handler for the timer message 00051 long onPaint(FXObject*,FXSelector,void*); // Handler for the paint message 00052 00053 public: 00054 enum{ 00055 ID_TIMER=FXFrame::ID_LAST, // Message generated by the timer 00056 ID_LAST 00057 }; 00058 00059 public: 00060 00061 /// Ticker widget; draws a text that's running sideways 00062 FXTicker(FXComposite* p,const FXString& txt,FXuint opts=FRAME_SUNKEN|FRAME_THICK,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); 00063 00064 /// Report desired width 00065 virtual FXint getDefaultWidth(); 00066 00067 /// Report desired height 00068 virtual FXint getDefaultHeight(); 00069 00070 /// Realize resources for the widget 00071 virtual void create(); 00072 00073 /// Detach resources for the widget 00074 virtual void detach(); 00075 00076 /// save resources 00077 virtual void save(FXStream& store) const; 00078 00079 /// load resources 00080 virtual void load(FXStream& store); 00081 00082 /// Change the text 00083 void setText(const FXString& txt); 00084 00085 /// Return the current text 00086 FXString getText() const { return label; } 00087 00088 /// Change drawing speed; speed of zero disables the animation 00089 void setSpeed(FXint s); 00090 00091 /// Return current speed setting 00092 FXint getSpeed() const { return speed; } 00093 00094 /// Change movement rate; -ve moves left; +ve moves right 00095 void setRate(FXint r); 00096 00097 /// Get movement rate 00098 FXint getRate() const { return rate; } 00099 00100 /// Set the text font 00101 void setFont(FXFont *fnt); 00102 00103 /// Get the text font 00104 FXFont* getFont() const { return font; } 00105 00106 /// Clean up 00107 virtual ~FXTicker(); 00108 }; 00109 00110 } // namespace FXEX 00111 #endif // FXTICKER