fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Text_Editor.H
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 // Header file for Fl_Text_Editor class.
5 //
6 // Copyright 2001-2010 by Bill Spitzak and others.
7 // Original code Copyright Mark Edel. Permission to distribute under
8 // the LGPL for the FLTK library granted by Mark Edel.
9 //
10 // This library is free software. Distribution and use rights are outlined in
11 // the file "COPYING" which should have been included with this file. If this
12 // file is missing or damaged, see the license at:
13 //
14 // http://www.fltk.org/COPYING.php
15 //
16 // Please report all bugs and problems on the following page:
17 //
18 // http://www.fltk.org/str.php
19 //
20 
21 /* \file
22  Fl_Text_Editor widget . */
23 
24 
25 #ifndef FL_TEXT_EDITOR_H
26 #define FL_TEXT_EDITOR_H
27 
28 #include "Fl_Text_Display.H"
29 
30 // key will match in any state
31 #define FL_TEXT_EDITOR_ANY_STATE (-1L)
32 
41  public:
43  typedef int (*Key_Func)(int key, Fl_Text_Editor* editor);
44 
46  struct Key_Binding {
47  int key;
48  int state;
49  Key_Func function;
51  };
52 
53  Fl_Text_Editor(int X, int Y, int W, int H, const char* l = 0);
54  ~Fl_Text_Editor() { remove_all_key_bindings(); }
55  virtual int handle(int e);
61  void insert_mode(int b) { insert_mode_ = b; }
67  int insert_mode() { return insert_mode_; }
68 
69 #if FLTK_ABI_VERSION >= 10304
70  void tab_nav(int val);
71  int tab_nav() const;
72 #endif
73 
74  void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
76  void add_key_binding(int key, int state, Key_Func f)
77  { add_key_binding(key, state, f, &key_bindings); }
78  void remove_key_binding(int key, int state, Key_Binding** list);
80  void remove_key_binding(int key, int state)
81  { remove_key_binding(key, state, &key_bindings); }
82  void remove_all_key_bindings(Key_Binding** list);
85  void add_default_key_bindings(Key_Binding** list);
86 #if FLTK_ABI_VERSION < 10304
87  // OLD: non-const
88  Key_Func bound_key_function(int key, int state, Key_Binding* list);
90  Key_Func bound_key_function(int key, int state)
91  { return bound_key_function(key, state, key_bindings); }
92 #else
93  // NEW: const (STR#3306)
94  Key_Func bound_key_function(int key, int state, Key_Binding* list) const;
96  Key_Func bound_key_function(int key, int state) const
97  { return bound_key_function(key, state, key_bindings); }
98 #endif
99 
100  void default_key_function(Key_Func f) { default_key_function_ = f; }
101 
102  // functions for the built in default bindings
103  static int kf_default(int c, Fl_Text_Editor* e);
104  static int kf_ignore(int c, Fl_Text_Editor* e);
105  static int kf_backspace(int c, Fl_Text_Editor* e);
106  static int kf_enter(int c, Fl_Text_Editor* e);
107  static int kf_move(int c, Fl_Text_Editor* e);
108  static int kf_shift_move(int c, Fl_Text_Editor* e);
109  static int kf_ctrl_move(int c, Fl_Text_Editor* e);
110  static int kf_c_s_move(int c, Fl_Text_Editor* e);
111  static int kf_meta_move(int c, Fl_Text_Editor* e);
112  static int kf_m_s_move(int c, Fl_Text_Editor* e);
113  static int kf_home(int, Fl_Text_Editor* e);
114  static int kf_end(int c, Fl_Text_Editor* e);
115  static int kf_left(int c, Fl_Text_Editor* e);
116  static int kf_up(int c, Fl_Text_Editor* e);
117  static int kf_right(int c, Fl_Text_Editor* e);
118  static int kf_down(int c, Fl_Text_Editor* e);
119  static int kf_page_up(int c, Fl_Text_Editor* e);
120  static int kf_page_down(int c, Fl_Text_Editor* e);
121  static int kf_insert(int c, Fl_Text_Editor* e);
122  static int kf_delete(int c, Fl_Text_Editor* e);
123  static int kf_copy(int c, Fl_Text_Editor* e);
124  static int kf_cut(int c, Fl_Text_Editor* e);
125  static int kf_paste(int c, Fl_Text_Editor* e);
126  static int kf_select_all(int c, Fl_Text_Editor* e);
127  static int kf_undo(int c, Fl_Text_Editor* e);
128 
129  protected:
130  int handle_key();
131  void maybe_do_callback();
132 
133 #ifndef FL_DOXYGEN
136 #endif
137 
146 
147 #ifndef FL_DOXYGEN
149 #endif
150 };
151 
152 #endif
153 
154 //
155 // End of "$Id$".
156 //
157 
Fl_Text_Editor::remove_key_binding
void remove_key_binding(int key, int state)
Definition: Fl_Text_Editor.H:80
Fl_Text_Editor::insert_mode
int insert_mode()
Definition: Fl_Text_Editor.H:67
state
int state
Definition: Fl_Text_Editor.cxx:92
Fl_Text_Editor::Key_Binding::key
int key
the key pressed
Definition: Fl_Text_Editor.H:47
H
static int H
Definition: Fl_Tooltip.cxx:76
Fl_Text_Editor::insert_mode
void insert_mode(int b)
Definition: Fl_Text_Editor.H:61
Fl_Text_Editor::insert_mode_
int insert_mode_
Definition: Fl_Text_Editor.H:134
Fl_Text_Display::handle
virtual int handle(int e)
Event handling.
Definition: Fl_Text_Display.cxx:3887
Fl_Text_Editor::global_key_bindings
static Key_Binding * global_key_bindings
Definition: Fl_Text_Editor.H:145
b
long b
Definition: jpegint.h:397
key
int key
Definition: Fl_Text_Editor.cxx:91
FL_EXPORT
#define FL_EXPORT
Definition: Fl_Export.H:35
Fl_Text_Editor::~Fl_Text_Editor
~Fl_Text_Editor()
Definition: Fl_Text_Editor.H:54
Fl_Text_Editor::Key_Binding::state
int state
the state of key modifiers
Definition: Fl_Text_Editor.H:48
Fl_Text_Editor::key_bindings
Key_Binding * key_bindings
Definition: Fl_Text_Editor.H:135
Fl_Text_Display.H
Fl_Text_Editor::bound_key_function
Key_Func bound_key_function(int key, int state)
Definition: Fl_Text_Editor.H:90
Fl_Text_Editor::default_key_function
void default_key_function(Key_Func f)
Definition: Fl_Text_Editor.H:100
Fl_Text_Editor::Key_Binding
Definition: Fl_Text_Editor.H:46
Fl_Text_Editor::remove_all_key_bindings
void remove_all_key_bindings()
Definition: Fl_Text_Editor.H:84
Fl_Text_Editor::Key_Binding::next
Key_Binding * next
next key binding in the list
Definition: Fl_Text_Editor.H:50
Fl_Text_Display
Rich text display widget.
Definition: Fl_Text_Display.H:82
f
Fl_Box_Draw_F * f
Definition: fl_boxtype.cxx:285
Y
static int Y
Definition: Fl_Tooltip.cxx:76
Fl_Text_Editor::add_key_binding
void add_key_binding(int key, int state, Key_Func f)
Definition: Fl_Text_Editor.H:76
Fl_Text_Editor::default_key_function_
Key_Func default_key_function_
Definition: Fl_Text_Editor.H:148
Fl_Text_Editor
Definition: Fl_Text_Editor.H:40