CodeView  Version0.4
 All Classes Functions Variables
codeview.h
1 /* libcodeview.so - A programmers editor widget for Atheos
2  Copyright (c) 2001 Andreas Engh-Halstvedt
3  Copyright (c) 2003 Henrik Isaksson
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18  MA 02111-1307, USA
19 */
20 
21 #ifndef F_CODEVIEW_CODEVIEW_H
22 #define F_CODEVIEW_CODEVIEW_H
23 
24 #include <gui/control.h>
25 #include <gui/menu.h>
26 
27 namespace cv
28 {
29 
30 class InnerEdit;
31 class Format;
32 class os::ScrollBar;
33 
54 class CodeView : public os::Control{
55 public:
56  enum {
57  EI_CONTENT_CHANGED = 0x0001,
58  EI_ENTER_PRESSED = 0x0002,
59  EI_ESC_PRESSED = 0x0004,
60  EI_FOCUS_LOST = 0x0008,
61  EI_CURSOR_MOVED = 0x0010,
62  EI_SELECTION_CHANGED = 0x0020
63  };
64 
65 public:
66  CodeView( const os::Rect&, const os::String& name, const os::String& buffer,
67  uint32 resizeMask=os::CF_FOLLOW_LEFT||os::CF_FOLLOW_TOP,
68  uint32 flags=os::WID_WILL_DRAW || os::WID_FULL_UPDATE_ON_RESIZE );
69 
70  void Paint( const os::Rect& );
71 
72  //******************************
73  // TextView emulation methods
74  //******************************
75  void EnableStatusChanged(bool enable);
76  void FontChanged(os::Font *f);
77 
78  virtual void MakeFocus(bool =true);
79  virtual bool HasFocus();
80 
81  bool Invoked(os::Message*);
82 
83  void SetReadOnly(bool flag=true);
84  bool GetReadOnly() const;
85 
86  int GetMaxUndoSize() const;
87  void SetMaxUndoSize(int size);
88 
89  uint32 GetEventMask() const;
90  void SetEventMask(uint32 mask);
91 
92  void GetRegion(os::String *buffer);
93 
94  void MakeCsrVisible();
95  void Clear(bool sendNotify=true);
96  void Set(const char *text, bool sendNotify=true);
97  void Insert(const char *text, bool sendNotify=true);
98  void Insert(const os::IPoint &pos, const char *text, bool sendNotify=true);
99 
100  void Select(const os::IPoint &start, const os::IPoint &end, bool sendNotify=true);
101  void SelectAll(bool sendNotify=true);
102  void ClearSelection(bool sendNotify=true);
103 
104  void SetCursor(int x, int y, bool select=false, bool sendNotify=true);
105  void SetCursor(const os::IPoint &pos, bool select=false, bool sendNotify=true);
106  os::IPoint GetCursor() const;
107 
108  size_t GetCurrentLength() const;
109 
110  void Cut(bool sendNotify=true);
111  void Copy();
112  void Paste(bool sendNotify=true);
113  void Delete(bool sendNotify=true);
114  void Delete(const os::IPoint &start, const os::IPoint &end, bool sendNotify=true);
115 
116  void SetTabOrder(int order);
117 
118  //******************************
119  // CodeView specific methods
120  //******************************
121  void SetFormat(Format* f);
122  Format* GetFormat();
123 
124  void SetTextColor(os::Color32_s);
125  os::Color32_s GetTextColor();
126  void SetBackground(os::Color32_s);
127  os::Color32_s GetBackground();
128 
129  void SetShowLineNumbers( bool bShowLN );
130  bool GetShowLineNumbers();
131 
132  uint GetLineCount() const;
133  const os::String& GetLine(uint i) const;
134  void SetLine(const os::String &text, uint i);
135 
136  bool Undo(bool sendNotify=true);
137  bool Redo(bool sendNotify=true);
138  bool UndoAvailable() const;
139  bool RedoAvailable() const;
140 
141  void SetTabSize(uint size);
142  uint GetTabSize();
143  void SetUseTab(bool);
144  bool GetUseTab();
145 
146  void ClearEvents();
147 
148  void SetHighlightColor(os::Color32_s);
149  os::Color32_s GetHighlightColor();
150 
151  void SetLineNumberFgColor(os::Color32_s);
152  os::Color32_s GetLineNumberFgColor();
153 
154  void SetLineNumberBgColor(os::Color32_s);
155  os::Color32_s GetLineNumberBgColor();
156 
157  void SetLineBackColor(os::Color32_s);
158  os::Color32_s GetLineBackColor();
159 
160  os::Font* GetEditorFont() const;
161  void SetContextMenu( os::Menu * pcMenu );
162 
163  void FoldAll();
164 
165  virtual void MouseUp(const os::Point&, uint32, os::Message*);
166 
167 private:
168  InnerEdit* edit;
169  os::ScrollBar *vScroll, *hScroll;
170 };
171 
172 } /* namespace cv */
173 
174 #endif /* F_CODEVIEW_CODEVIEW_H */
175 
176 
177