Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

/home/jeroen/FOX/fox/fox-1.7.33/include/FXHeader.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                          H e a d e r   W i d g e t                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXHEADER_H
00022 #define FXHEADER_H
00023 
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 class FXIcon;
00031 class FXFont;
00032 class FXHeader;
00033 
00034 
00036 enum {
00037   HEADER_BUTTON     = 0x00008000,     
00038   HEADER_HORIZONTAL = 0,              
00039   HEADER_VERTICAL   = 0x00010000,     
00040   HEADER_TRACKING   = 0x00020000,     
00041   HEADER_RESIZE     = 0x00040000,     
00042   HEADER_NORMAL     = HEADER_HORIZONTAL|FRAME_NORMAL
00043   };
00044 
00045 
00047 class FXAPI FXHeaderItem : public FXObject {
00048   FXDECLARE(FXHeaderItem)
00049   friend class FXHeader;
00050 protected:
00051   FXString  label;      // Text of item
00052   FXString  tip;        // Tooltip of item
00053   FXIcon   *icon;       // Icon of item
00054   void     *data;       // User data pointer
00055   FXint     size;       // Item size
00056   FXint     pos;        // Item position
00057   FXuint    state;      // State flags
00058 private:
00059   FXHeaderItem(const FXHeaderItem&);
00060   FXHeaderItem& operator=(const FXHeaderItem&);
00061 protected:
00062   FXHeaderItem(){}
00063   virtual void draw(const FXHeader* header,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00064 public:
00065   enum{
00066     ARROW_NONE = 0,             
00067     ARROW_UP   = 0x00000001,    
00068     ARROW_DOWN = 0x00000002,    
00069     PRESSED    = 0x00000004,    
00070     ICONOWNED  = 0x00000008,    
00071     RIGHT      = 0x00000010,    
00072     LEFT       = 0x00000020,    
00073     CENTER_X   = 0,             
00074     TOP        = 0x00000040,    
00075     BOTTOM     = 0x00000080,    
00076     CENTER_Y   = 0,             
00077     BEFORE     = 0x00000100,    
00078     AFTER      = 0x00000200,    
00079     ABOVE      = 0x00000400,    
00080     BELOW      = 0x00000800     
00081     };
00082 public:
00083 
00085   FXHeaderItem(const FXString& text,FXIcon* ic=NULL,FXint s=0,void* ptr=NULL);
00086 
00088   virtual void setText(const FXString& txt);
00089 
00091   const FXString& getText() const { return label; }
00092 
00094   void setTipText(const FXString& text){ tip=text; }
00095 
00097   const FXString& getTipText() const { return tip; }
00098 
00100   virtual void setIcon(FXIcon* icn,FXbool owned=false);
00101 
00103   FXIcon* getIcon() const { return icon; }
00104 
00106   void setData(void* ptr){ data=ptr; }
00107 
00109   void* getData() const { return data; }
00110 
00112   void setSize(FXint s){ size=s; }
00113 
00115   FXint getSize() const { return size; }
00116 
00118   void setPos(FXint p){ pos=p; }
00119 
00121   FXint getPos() const { return pos; }
00122 
00124   void setArrowDir(FXuint dir=ARROW_NONE);
00125 
00127   FXuint getArrowDir() const;
00128 
00130   void setJustify(FXuint justify=LEFT|CENTER_Y);
00131 
00133   FXuint getJustify() const;
00134 
00136   void setIconPosition(FXuint mode=BEFORE);
00137 
00139   FXuint getIconPosition() const;
00140 
00142   void setPressed(FXbool pressed);
00143 
00145   FXbool isPressed() const;
00146 
00148   virtual FXint getWidth(const FXHeader* header) const;
00149 
00151   virtual FXint getHeight(const FXHeader* header) const;
00152 
00154   virtual void create();
00155 
00157   virtual void detach();
00158 
00160   virtual void destroy();
00161 
00163   virtual void save(FXStream& store) const;
00164   virtual void load(FXStream& store);
00165 
00167   virtual ~FXHeaderItem();
00168   };
00169 
00170 
00172 typedef FXObjectListOf<FXHeaderItem> FXHeaderItemList;
00173 
00174 
00194 class FXAPI FXHeader : public FXFrame {
00195   FXDECLARE(FXHeader)
00196 protected:
00197   FXHeaderItemList items; // Item list
00198   FXColor          textColor; // Text color
00199   FXFont          *font;  // Text font
00200   FXString         help;  // Help text
00201   FXint            pos;   // Scroll position
00202   FXint            active;  // Active button
00203   FXint            activepos; // Position of active item
00204   FXint            activesize;  // Size of active item
00205   FXint            offset;  // Offset where split grabbed
00206 protected:
00207   FXHeader();
00208   void drawSplit(FXint pos);
00209   virtual FXHeaderItem *createItem(const FXString& text,FXIcon* icon,FXint size,void* ptr);
00210 private:
00211   FXHeader(const FXHeader&);
00212   FXHeader &operator=(const FXHeader&);
00213 public:
00214   long onPaint(FXObject*,FXSelector,void*);
00215   long onLeftBtnPress(FXObject*,FXSelector,void*);
00216   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00217   long onUngrabbed(FXObject*,FXSelector,void*);
00218   long onMotion(FXObject*,FXSelector,void*);
00219   long onTipTimer(FXObject*,FXSelector,void*);
00220   long onQueryTip(FXObject*,FXSelector,void*);
00221   long onQueryHelp(FXObject*,FXSelector,void*);
00222 public:
00223 
00225   FXHeader(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=HEADER_NORMAL,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);
00226 
00228   virtual void create();
00229 
00231   virtual void detach();
00232 
00234   virtual void layout();
00235 
00237   FXint getNumItems() const { return items.no(); }
00238 
00240   FXint getTotalSize() const;
00241 
00243   virtual FXint getDefaultWidth();
00244 
00246   virtual FXint getDefaultHeight();
00247 
00249   void setPosition(FXint pos);
00250 
00252   FXint getPosition() const { return pos; }
00253 
00259   FXint getItemAt(FXint coord) const;
00260 
00262   FXHeaderItem *getItem(FXint index) const;
00263 
00265   FXint setItem(FXint index,FXHeaderItem* item,FXbool notify=false);
00266 
00268   FXint setItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
00269 
00271   FXint fillItems(const FXchar** strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
00272 
00274   FXint fillItems(const FXString& strings,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
00275 
00277   FXint insertItem(FXint index,FXHeaderItem* item,FXbool notify=false);
00278 
00280   FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
00281 
00283   FXint appendItem(FXHeaderItem* item,FXbool notify=false);
00284 
00286   FXint appendItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
00287 
00289   FXint prependItem(FXHeaderItem* item,FXbool notify=false);
00290 
00292   FXint prependItem(const FXString& text,FXIcon *icon=NULL,FXint size=0,void* ptr=NULL,FXbool notify=false);
00293 
00295   FXHeaderItem* extractItem(FXint index,FXbool notify=false);
00296 
00298   void removeItem(FXint index,FXbool notify=false);
00299 
00301   void clearItems(FXbool notify=false);
00302 
00304   void setItemText(FXint index,const FXString& text);
00305 
00307   FXString getItemText(FXint index) const;
00308 
00310   void setItemTipText(FXint index,const FXString& text);
00311 
00313   FXString getItemTipText(FXint index) const;
00314 
00316   void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false);
00317 
00319   FXIcon* getItemIcon(FXint index) const;
00320 
00322   void setItemSize(FXint index,FXint size);
00323 
00325   FXint getItemSize(FXint index) const;
00326 
00328   FXint getItemOffset(FXint index) const;
00329 
00331   void setItemData(FXint index,void* ptr);
00332 
00334   void* getItemData(FXint index) const;
00335 
00337   void setArrowDir(FXint index,FXuint dir=FXHeaderItem::ARROW_NONE);
00338 
00340   FXuint getArrowDir(FXint index) const;
00341 
00349   void setItemJustify(FXint index,FXuint justify);
00350 
00352   FXuint getItemJustify(FXint index) const;
00353 
00361   void setItemIconPosition(FXint index,FXuint mode);
00362 
00364   FXuint getItemIconPosition(FXint index) const;
00365 
00367   void setItemPressed(FXint index,FXbool pressed=true);
00368 
00370   FXbool isItemPressed(FXint index) const;
00371 
00373   void makeItemVisible(FXint index);
00374 
00376   void updateItem(FXint index) const;
00377 
00379   void setFont(FXFont* fnt);
00380 
00382   FXFont* getFont() const { return font; }
00383 
00385   FXColor getTextColor() const { return textColor; }
00386 
00388   void setTextColor(FXColor clr);
00389 
00391   void setHeaderStyle(FXuint style);
00392 
00394   FXuint getHeaderStyle() const;
00395 
00397   void setHelpText(const FXString& text){ help=text; }
00398 
00400   const FXString& getHelpText() const { return help; }
00401 
00403   virtual void save(FXStream& store) const;
00404 
00406   virtual void load(FXStream& store);
00407 
00409   virtual ~FXHeader();
00410   };
00411 
00412 }
00413 
00414 #endif

Copyright © 1997-2011 Jeroen van der Zijp