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

FXConsole.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o n s o l e   W i d g e t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2006,2009 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 * $Id: FXConsole.h,v 1.19 2009/01/06 13:07:22 fox Exp $                         *
00022 ********************************************************************************/
00023 #ifndef FXCONSOLE_H
00024 #define FXCONSOLE_H
00025 
00026 #ifndef FXSCROLLAREA_H
00027 #include "FXScrollArea.h"
00028 #endif
00029 
00030 #ifndef FXARRAY_H
00031 #include "FXArray.h"
00032 #endif
00033 
00034 
00035 //////////////////////////////  UNDER DEVELOPMENT  //////////////////////////////
00036 
00037 namespace FX {
00038 
00039 
00040 /// Scrollbar options
00041 enum {
00042   CONSOLE_WRAPLINES = 0x00100000        /// Wrap lines
00043   };
00044 
00045 
00046 // Strings buffer
00047 typedef FXArray<FXString>  FXStringBuffer;
00048 
00049 
00050 /**
00051 * The console widget is a scrolling text widget used primarily
00052 * for logging purposes and "terminals"  It is high-performance
00053 * and features bounded but arbitrary scroll-back capability.
00054 */
00055 class FXAPI FXConsole : public FXScrollArea {
00056   FXDECLARE(FXConsole)
00057 protected:
00058   FXStringBuffer contents;      // Text data
00059   FXStringBuffer style;         // Text style
00060   FXFont        *font;          // Text font
00061   FXint          margintop;     // Margins top
00062   FXint          marginbottom;  // Margin bottom
00063   FXint          marginleft;    // Margin left
00064   FXint          marginright;   // Margin right
00065   FXint          historylines;  // History lines
00066   FXint          visiblelines;  // Visible lines
00067   FXint          topline;       // Where first line is in contents
00068   FXint          vrows;         // Default visible rows
00069   FXint          vcols;         // Default visible columns
00070   FXColor        textColor;     // Normal text color
00071   FXColor        selbackColor;  // Select background color
00072   FXColor        seltextColor;  // Select text color
00073   FXColor        cursorColor;   // Cursor color
00074   FXString       help;          // Status line help
00075   FXString       tip;           // Tooltip
00076 protected:
00077   FXConsole();
00078   FXint charWidth(FXwchar ch,FXint col) const;
00079   FXuint styleOf(FXint line,FXint index,FXint p,FXint c) const;
00080   virtual void moveContents(FXint x,FXint y);
00081   void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,const FXchar *text,FXint n,FXuint style) const;
00082   void drawTextLine(FXDCWindow& dc,FXint line,FXint left,FXint right) const;
00083   void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
00084 protected:
00085   enum {
00086     STYLE_MASK      = 0x00FF,   // Mask color table
00087     STYLE_TEXT      = 0x0100,   // Draw some content
00088     STYLE_SELECTED  = 0x0200,   // Selected
00089     STYLE_CONTROL   = 0x0400,   // Control character
00090     STYLE_HILITE    = 0x0800,   // Highlighted
00091     STYLE_ACTIVE    = 0x1000    // Active
00092     };
00093 private:
00094   FXConsole(const FXConsole&);
00095   FXConsole &operator=(const FXConsole&);
00096 public:
00097   long onPaint(FXObject*,FXSelector,void*);
00098   long onXXX(FXObject*,FXSelector,void*);
00099 public:
00100   enum {
00101     ID_XXX=FXScrollArea::ID_LAST,
00102     ID_LAST
00103     };
00104 public:
00105 
00106   /// Construct console window
00107   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);
00108 
00109   /// Create server-side resources
00110   virtual void create();
00111 
00112   /// Detach server-side resources
00113   virtual void detach();
00114 
00115   /// Perform layout
00116   virtual void layout();
00117 
00118   /// Return default width
00119   virtual FXint getDefaultWidth();
00120 
00121   /// Return default height
00122   virtual FXint getDefaultHeight();
00123 
00124   /// Returns true because a text widget can receive focus
00125   virtual FXbool canFocus() const;
00126 
00127   /// Return content width
00128   virtual FXint getContentWidth();
00129 
00130   /// Return content height
00131   virtual FXint getContentHeight();
00132 
00133   /// Change text font
00134   void setFont(FXFont* fnt);
00135 
00136   /// Return text font
00137   FXFont* getFont() const { return font; }
00138 
00139   /// Change top margin
00140   void setMarginTop(FXint pt);
00141 
00142   /// Return top margin
00143   FXint getMarginTop() const { return margintop; }
00144 
00145   /// Change bottom margin
00146   void setMarginBottom(FXint pb);
00147 
00148   /// Return bottom margin
00149   FXint getMarginBottom() const { return marginbottom; }
00150 
00151   /// Change left margin
00152   void setMarginLeft(FXint pl);
00153 
00154   /// Return left margin
00155   FXint getMarginLeft() const { return marginleft; }
00156 
00157   /// Change right margin
00158   void setMarginRight(FXint pr);
00159 
00160   /// Return right margin
00161   FXint getMarginRight() const { return marginright; }
00162 
00163   /// Change history lines
00164   void setHistoryLines(FXint hl);
00165 
00166   /// Return history lines
00167   FXint getHistoryLines() const { return historylines; }
00168 
00169   /// Change number of visible rows
00170   void setVisibleRows(FXint rows);
00171 
00172   /// Return number of visible rows
00173   FXint getVisibleRows() const { return vrows; }
00174 
00175   /// Change number of visible columns
00176   void setVisibleColumns(FXint cols);
00177 
00178   /// Return number of visible columns
00179   FXint getVisibleColumns() const { return vcols; }
00180 
00181   /// Set help text
00182   void setHelpText(const FXString& text){ help=text; }
00183 
00184   /// Return help text
00185   FXString getHelpText() const { return help; }
00186 
00187   /// Set the tool tip message for this widget
00188   void setTipText(const FXString& text){ tip=text; }
00189 
00190   /// Get the tool tip message for this widget
00191   FXString getTipText() const { return tip; }
00192 
00193   /// Save to a stream
00194   virtual void save(FXStream& store) const;
00195 
00196   /// Load from a stream
00197   virtual void load(FXStream& store);
00198 
00199   /// Destructor
00200   virtual ~FXConsole();
00201   };
00202 
00203 }
00204 
00205 #endif

Copyright © 1997-2009 Jeroen van der Zijp