FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Text_Editor.H

    00001 //
    00002 // "$Id: Fl_Text_Editor.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
    00003 //
    00004 // Header file for Fl_Text_Editor class.
    00005 //
    00006 // Copyright 2001-2010 by Bill Spitzak and others.
    00007 // Original code Copyright Mark Edel.  Permission to distribute under
    00008 // the LGPL for the FLTK library granted by Mark Edel.
    00009 //
    00010 // This library is free software. Distribution and use rights are outlined in
    00011 // the file "COPYING" which should have been included with this file.  If this
    00012 // file is missing or damaged, see the license at:
    00013 //
    00014 //     http://www.fltk.org/COPYING.php
    00015 //
    00016 // Please report all bugs and problems on the following page:
    00017 //
    00018 //     http://www.fltk.org/str.php
    00019 //
    00020
    00021 /* \file
    00022    Fl_Text_Editor widget . */
    00023
    00024
    00025 #ifndef FL_TEXT_EDITOR_H
    00026 #define FL_TEXT_EDITOR_H
    00027
    00028 #include "Fl_Text_Display.H"
    00029
    00030 // key will match in any state
    00031 #define FL_TEXT_EDITOR_ANY_STATE  (-1L)
    00032
    00040 class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display {
    00041   public:
    00043     typedef int (*Key_Func)(int key, Fl_Text_Editor* editor);
    00044
    00046     struct Key_Binding {
    00047       int          key;
    00048       int          state;
    00049       Key_Func     function;
    00050       Key_Binding* next;
    00051     };
    00052
    00053     Fl_Text_Editor(int X, int Y, int W, int H, const char* l = 0);
    00054     ~Fl_Text_Editor() { remove_all_key_bindings(); }
    00055     virtual int handle(int e);
    00061     void insert_mode(int b) { insert_mode_ = b; }
    00067     int insert_mode() { return insert_mode_; }
    00068
    00069     void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
    00071     void add_key_binding(int key, int state, Key_Func f)
    00072       { add_key_binding(key, state, f, &key_bindings); }
    00073     void remove_key_binding(int key, int state, Key_Binding** list);
    00075     void remove_key_binding(int key, int state)
    00076       { remove_key_binding(key, state, &key_bindings); }
    00077     void remove_all_key_bindings(Key_Binding** list);
    00079     void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); }
    00080     void add_default_key_bindings(Key_Binding** list);
    00081     Key_Func bound_key_function(int key, int state, Key_Binding* list);
    00083     Key_Func bound_key_function(int key, int state)
    00084       { return bound_key_function(key, state, key_bindings); }
    00086     void default_key_function(Key_Func f) { default_key_function_ = f; }
    00087
    00088     // functions for the built in default bindings
    00089     static int kf_default(int c, Fl_Text_Editor* e);
    00090     static int kf_ignore(int c, Fl_Text_Editor* e);
    00091     static int kf_backspace(int c, Fl_Text_Editor* e);
    00092     static int kf_enter(int c, Fl_Text_Editor* e);
    00093     static int kf_move(int c, Fl_Text_Editor* e);
    00094     static int kf_shift_move(int c, Fl_Text_Editor* e);
    00095     static int kf_ctrl_move(int c, Fl_Text_Editor* e);
    00096     static int kf_c_s_move(int c, Fl_Text_Editor* e);
    00097     static int kf_meta_move(int c, Fl_Text_Editor* e);
    00098     static int kf_m_s_move(int c, Fl_Text_Editor* e);
    00099     static int kf_home(int, Fl_Text_Editor* e);
    00100     static int kf_end(int c, Fl_Text_Editor* e);
    00101     static int kf_left(int c, Fl_Text_Editor* e);
    00102     static int kf_up(int c, Fl_Text_Editor* e);
    00103     static int kf_right(int c, Fl_Text_Editor* e);
    00104     static int kf_down(int c, Fl_Text_Editor* e);
    00105     static int kf_page_up(int c, Fl_Text_Editor* e);
    00106     static int kf_page_down(int c, Fl_Text_Editor* e);
    00107     static int kf_insert(int c, Fl_Text_Editor* e);
    00108     static int kf_delete(int c, Fl_Text_Editor* e);
    00109     static int kf_copy(int c, Fl_Text_Editor* e);
    00110     static int kf_cut(int c, Fl_Text_Editor* e);
    00111     static int kf_paste(int c, Fl_Text_Editor* e);
    00112     static int kf_select_all(int c, Fl_Text_Editor* e);
    00113     static int kf_undo(int c, Fl_Text_Editor* e);
    00114
    00115   protected:
    00116     int handle_key();
    00117     void maybe_do_callback();
    00118
    00119 #ifndef FL_DOXYGEN
    00120     int insert_mode_;
    00121     Key_Binding* key_bindings;
    00122     static Key_Binding* global_key_bindings;
    00123     Key_Func default_key_function_;
    00124 #endif
    00125 };
    00126
    00127 #endif
    00128
    00129 //
    00130 // End of "$Id: Fl_Text_Editor.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
    00131 //
    00132