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,2024 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=nullptr,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
FXint getHistoryLines() const
Return history lines.
Definition: FXConsole.h:165
FXint getMarginTop() const
Return top margin.
Definition: FXConsole.h:141
Base composite.
Definition: FXComposite.h:32
FXString getHelpText() const
Return help text.
Definition: FXConsole.h:183
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXint getMarginRight() const
Return right margin.
Definition: FXConsole.h:159
Definition: FX4Splitter.h:28
FXint getVisibleColumns() const
Return number of visible columns.
Definition: FXConsole.h:177
FXint getVisibleRows() const
Return number of visible rows.
Definition: FXConsole.h:171
The scroll area widget manages a content area and a viewport area through which the content is viewed...
Definition: FXScrollArea.h:69
FXint getMarginLeft() const
Return left margin.
Definition: FXConsole.h:153
FXint getMarginBottom() const
Return bottom margin.
Definition: FXConsole.h:147
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
Window Device Context.
Definition: FXDCWindow.h:48
void setTipText(const FXString &text)
Set the tool tip message for this widget.
Definition: FXConsole.h:186
void setHelpText(const FXString &text)
Set help text.
Definition: FXConsole.h:180
The console widget is a scrolling text widget used primarily for logging purposes and "terminals" It ...
Definition: FXConsole.h:53
FXFont * getFont() const
Return text font.
Definition: FXConsole.h:135
FXString getTipText() const
Get the tool tip message for this widget.
Definition: FXConsole.h:189
Font class.
Definition: FXFont.h:137
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp