00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00036
00037 namespace FX {
00038
00039
00040
00041 enum {
00042 CONSOLE_WRAPLINES = 0x00100000
00043 };
00044
00045
00046
00047 typedef FXArray<FXString> FXStringBuffer;
00048
00049
00050
00051
00052
00053
00054
00055 class FXAPI FXConsole : public FXScrollArea {
00056 FXDECLARE(FXConsole)
00057 protected:
00058 FXStringBuffer contents;
00059 FXStringBuffer style;
00060 FXFont *font;
00061 FXint margintop;
00062 FXint marginbottom;
00063 FXint marginleft;
00064 FXint marginright;
00065 FXint historylines;
00066 FXint visiblelines;
00067 FXint topline;
00068 FXint vrows;
00069 FXint vcols;
00070 FXColor textColor;
00071 FXColor selbackColor;
00072 FXColor seltextColor;
00073 FXColor cursorColor;
00074 FXString help;
00075 FXString tip;
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,
00087 STYLE_TEXT = 0x0100,
00088 STYLE_SELECTED = 0x0200,
00089 STYLE_CONTROL = 0x0400,
00090 STYLE_HILITE = 0x0800,
00091 STYLE_ACTIVE = 0x1000
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
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
00110 virtual void create();
00111
00112
00113 virtual void detach();
00114
00115
00116 virtual void layout();
00117
00118
00119 virtual FXint getDefaultWidth();
00120
00121
00122 virtual FXint getDefaultHeight();
00123
00124
00125 virtual FXbool canFocus() const;
00126
00127
00128 virtual FXint getContentWidth();
00129
00130
00131 virtual FXint getContentHeight();
00132
00133
00134 void setFont(FXFont* fnt);
00135
00136
00137 FXFont* getFont() const { return font; }
00138
00139
00140 void setMarginTop(FXint pt);
00141
00142
00143 FXint getMarginTop() const { return margintop; }
00144
00145
00146 void setMarginBottom(FXint pb);
00147
00148
00149 FXint getMarginBottom() const { return marginbottom; }
00150
00151
00152 void setMarginLeft(FXint pl);
00153
00154
00155 FXint getMarginLeft() const { return marginleft; }
00156
00157
00158 void setMarginRight(FXint pr);
00159
00160
00161 FXint getMarginRight() const { return marginright; }
00162
00163
00164 void setHistoryLines(FXint hl);
00165
00166
00167 FXint getHistoryLines() const { return historylines; }
00168
00169
00170 void setVisibleRows(FXint rows);
00171
00172
00173 FXint getVisibleRows() const { return vrows; }
00174
00175
00176 void setVisibleColumns(FXint cols);
00177
00178
00179 FXint getVisibleColumns() const { return vcols; }
00180
00181
00182 void setHelpText(const FXString& text){ help=text; }
00183
00184
00185 FXString getHelpText() const { return help; }
00186
00187
00188 void setTipText(const FXString& text){ tip=text; }
00189
00190
00191 FXString getTipText() const { return tip; }
00192
00193
00194 virtual void save(FXStream& store) const;
00195
00196
00197 virtual void load(FXStream& store);
00198
00199
00200 virtual ~FXConsole();
00201 };
00202
00203 }
00204
00205 #endif