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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXConsole.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o n s o l e   W i d g e t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2006,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 FXCONSOLE_H
00022 #define FXCONSOLE_H
00023 
00024 #ifndef FXSCROLLAREA_H
00025 #include "FXScrollArea.h"
00026 #endif
00027 
00028 #ifndef FXARRAY_H
00029 #include "FXArray.h"
00030 #endif
00031 
00032 
00034 
00035 namespace FX {
00036 
00037 
00039 enum {
00040   CONSOLE_WRAPLINES = 0x00100000        
00041   };
00042 
00043 
00044 // Strings buffer
00045 typedef FXArray<FXString>  FXStringBuffer;
00046 
00047 
00053 class FXAPI FXConsole : public FXScrollArea {
00054   FXDECLARE(FXConsole)
00055 protected:
00056   FXStringBuffer contents;      // Text data
00057   FXStringBuffer style;         // Text style
00058   FXFont        *font;          // Text font
00059   FXint          margintop;     // Margins top
00060   FXint          marginbottom;  // Margin bottom
00061   FXint          marginleft;    // Margin left
00062   FXint          marginright;   // Margin right
00063   FXint          historylines;  // History lines
00064   FXint          visiblelines;  // Visible lines
00065   FXint          topline;       // Where first line is in contents
00066   FXint          vrows;         // Default visible rows
00067   FXint          vcols;         // Default visible columns
00068   FXColor        textColor;     // Normal text color
00069   FXColor        selbackColor;  // Select background color
00070   FXColor        seltextColor;  // Select text color
00071   FXColor        cursorColor;   // Cursor color
00072   FXString       help;          // Status line help
00073   FXString       tip;           // Tooltip
00074 protected:
00075   FXConsole();
00076   FXint charWidth(FXwchar ch,FXint col) const;
00077   FXuint styleOf(FXint line,FXint index,FXint p,FXint c) const;
00078   virtual void moveContents(FXint x,FXint y);
00079   void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,const FXchar *text,FXint n,FXuint sty) const;
00080   void drawTextLine(FXDCWindow& dc,FXint line,FXint left,FXint right) const;
00081   void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
00082 protected:
00083   enum {
00084     STYLE_MASK      = 0x00FF,   // Mask color table
00085     STYLE_TEXT      = 0x0100,   // Draw some content
00086     STYLE_SELECTED  = 0x0200,   // Selected
00087     STYLE_CONTROL   = 0x0400,   // Control character
00088     STYLE_HILITE    = 0x0800,   // Highlighted
00089     STYLE_ACTIVE    = 0x1000    // Active
00090     };
00091 private:
00092   FXConsole(const FXConsole&);
00093   FXConsole &operator=(const FXConsole&);
00094 public:
00095   long onPaint(FXObject*,FXSelector,void*);
00096   long onXXX(FXObject*,FXSelector,void*);
00097 public:
00098   enum {
00099     ID_XXX=FXScrollArea::ID_LAST,
00100     ID_LAST
00101     };
00102 public:
00103 
00105   FXConsole(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2);
00106 
00108   virtual void create();
00109 
00111   virtual void detach();
00112 
00114   virtual void layout();
00115 
00117   virtual FXint getDefaultWidth();
00118 
00120   virtual FXint getDefaultHeight();
00121 
00123   virtual FXbool canFocus() const;
00124 
00126   virtual FXint getContentWidth();
00127 
00129   virtual FXint getContentHeight();
00130 
00132   void setFont(FXFont* fnt);
00133 
00135   FXFont* getFont() const { return font; }
00136 
00138   void setMarginTop(FXint pt);
00139 
00141   FXint getMarginTop() const { return margintop; }
00142 
00144   void setMarginBottom(FXint pb);
00145 
00147   FXint getMarginBottom() const { return marginbottom; }
00148 
00150   void setMarginLeft(FXint pl);
00151 
00153   FXint getMarginLeft() const { return marginleft; }
00154 
00156   void setMarginRight(FXint pr);
00157 
00159   FXint getMarginRight() const { return marginright; }
00160 
00162   void setHistoryLines(FXint hl);
00163 
00165   FXint getHistoryLines() const { return historylines; }
00166 
00168   void setVisibleRows(FXint rows);
00169 
00171   FXint getVisibleRows() const { return vrows; }
00172 
00174   void setVisibleColumns(FXint cols);
00175 
00177   FXint getVisibleColumns() const { return vcols; }
00178 
00180   void setHelpText(const FXString& text){ help=text; }
00181 
00183   FXString getHelpText() const { return help; }
00184 
00186   void setTipText(const FXString& text){ tip=text; }
00187 
00189   FXString getTipText() const { return tip; }
00190 
00192   virtual void save(FXStream& store) const;
00193 
00195   virtual void load(FXStream& store);
00196 
00198   virtual ~FXConsole();
00199   };
00200 
00201 }
00202 
00203 #endif

Copyright © 1997-2011 Jeroen van der Zijp