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

FXConsole.h
1 /********************************************************************************
2 * *
3 * C o n s o l e W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2006,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXCONSOLE_H
22 #define FXCONSOLE_H
23 
24 #ifndef FXSCROLLAREA_H
25 #include "FXScrollArea.h"
26 #endif
27 
28 #ifndef FXARRAY_H
29 #include "FXArray.h"
30 #endif
31 
32 
34 
35 namespace FX {
36 
37 
39 enum {
40  CONSOLE_WRAPLINES = 0x00100000
41  };
42 
43 
44 // Strings buffer
45 typedef FXArray<FXString> FXStringBuffer;
46 
47 
53 class FXAPI FXConsole : public FXScrollArea {
54  FXDECLARE(FXConsole)
55 protected:
56  FXStringBuffer contents; // Text data
57  FXStringBuffer style; // Text style
58  FXFont *font; // Text font
59  FXint margintop; // Margins top
60  FXint marginbottom; // Margin bottom
61  FXint marginleft; // Margin left
62  FXint marginright; // Margin right
63  FXint historylines; // History lines
64  FXint visiblelines; // Visible lines
65  FXint topline; // Where first line is in contents
66  FXint vrows; // Default visible rows
67  FXint vcols; // Default visible columns
68  FXColor textColor; // Normal text color
69  FXColor selbackColor; // Select background color
70  FXColor seltextColor; // Select text color
71  FXColor cursorColor; // Cursor color
72  FXString help; // Status line help
73  FXString tip; // Tooltip
74 protected:
75  FXConsole();
76  FXint charWidth(FXwchar ch,FXint col) const;
77  FXuint styleOf(FXint line,FXint index,FXint p,FXint c) const;
78  virtual void moveContents(FXint x,FXint y);
79  void drawTextFragment(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h,const FXchar *text,FXint n,FXuint sty) const;
80  void drawTextLine(FXDCWindow& dc,FXint line,FXint left,FXint right) const;
81  void drawContents(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h) const;
82 protected:
83  enum {
84  STYLE_MASK = 0x00FF, // Mask color table
85  STYLE_TEXT = 0x0100, // Draw some content
86  STYLE_SELECTED = 0x0200, // Selected
87  STYLE_CONTROL = 0x0400, // Control character
88  STYLE_HILITE = 0x0800, // Highlighted
89  STYLE_ACTIVE = 0x1000 // Active
90  };
91 private:
92  FXConsole(const FXConsole&);
93  FXConsole &operator=(const FXConsole&);
94 public:
95  long onPaint(FXObject*,FXSelector,void*);
96  long onXXX(FXObject*,FXSelector,void*);
97 public:
98  enum {
99  ID_XXX=FXScrollArea::ID_LAST,
100  ID_LAST
101  };
102 public:
103 
105  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);
106 
108  virtual void create();
109 
111  virtual void detach();
112 
114  virtual void layout();
115 
117  virtual FXint getDefaultWidth();
118 
120  virtual FXint getDefaultHeight();
121 
123  virtual FXbool canFocus() const;
124 
126  virtual FXint getContentWidth();
127 
129  virtual FXint getContentHeight();
130 
132  void setFont(FXFont* fnt);
133 
135  FXFont* getFont() const { return font; }
136 
138  void setMarginTop(FXint pt);
139 
141  FXint getMarginTop() const { return margintop; }
142 
144  void setMarginBottom(FXint pb);
145 
147  FXint getMarginBottom() const { return marginbottom; }
148 
150  void setMarginLeft(FXint pl);
151 
153  FXint getMarginLeft() const { return marginleft; }
154 
156  void setMarginRight(FXint pr);
157 
159  FXint getMarginRight() const { return marginright; }
160 
162  void setHistoryLines(FXint hl);
163 
165  FXint getHistoryLines() const { return historylines; }
166 
168  void setVisibleRows(FXint rows);
169 
171  FXint getVisibleRows() const { return vrows; }
172 
174  void setVisibleColumns(FXint cols);
175 
177  FXint getVisibleColumns() const { return vcols; }
178 
180  void setHelpText(const FXString& text){ help=text; }
181 
183  FXString getHelpText() const { return help; }
184 
186  void setTipText(const FXString& text){ tip=text; }
187 
189  FXString getTipText() const { return tip; }
190 
192  virtual void save(FXStream& store) const;
193 
195  virtual void load(FXStream& store);
196 
198  virtual ~FXConsole();
199  };
200 
201 }
202 
203 #endif

Copyright © 1997-2016 Jeroen van der Zijp