00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00045 typedef FXArray<FXString> FXStringBuffer;
00046
00047
00053 class FXAPI FXConsole : public FXScrollArea {
00054 FXDECLARE(FXConsole)
00055 protected:
00056 FXStringBuffer contents;
00057 FXStringBuffer style;
00058 FXFont *font;
00059 FXint margintop;
00060 FXint marginbottom;
00061 FXint marginleft;
00062 FXint marginright;
00063 FXint historylines;
00064 FXint visiblelines;
00065 FXint topline;
00066 FXint vrows;
00067 FXint vcols;
00068 FXColor textColor;
00069 FXColor selbackColor;
00070 FXColor seltextColor;
00071 FXColor cursorColor;
00072 FXString help;
00073 FXString tip;
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,
00085 STYLE_TEXT = 0x0100,
00086 STYLE_SELECTED = 0x0200,
00087 STYLE_CONTROL = 0x0400,
00088 STYLE_HILITE = 0x0800,
00089 STYLE_ACTIVE = 0x1000
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