Author: matt
Date: 2012-06-25 05:39:35 -0700 (Mon, 25 Jun 2012)
New Revision: 9628
Log:
A few more changed to emu2.

Modified:
   branches/branch-3.0/include/fltk/TextDisplay.h
   branches/branch-3.0/include/fltk/TextEditor.h
   branches/branch-3.0/test2/input.cxx

Modified: branches/branch-3.0/include/fltk/TextDisplay.h
===================================================================
--- branches/branch-3.0/include/fltk/TextDisplay.h      2012-06-24 19:01:54 UTC 
(rev 9627)
+++ branches/branch-3.0/include/fltk/TextDisplay.h      2012-06-25 12:39:35 UTC 
(rev 9628)
@@ -1,4 +1,3 @@
-#error header has not been ported to 3.0 yet
 //
 // "$Id$"
 //
@@ -31,324 +30,347 @@
 #ifndef _fltk_TextDisplay_h_
 #define _fltk_TextDisplay_h_
 
+#include <fltk3/TextDisplay.h>
+
 #include "draw.h"
 #include "Group.h"
+#if 0 // FIXME: 123-2
 #include "Widget.h"
 #include "Scrollbar.h"
 #include "TextBuffer.h"
 #include "Font.h"
+#endif
 
-namespace fltk {
 
-typedef void (*UnfinishedStyleCb)(int, void *);
+FLTK2_WRAPPER_INTERFACE_BEGIN(TextDisplay, TextDisplay)
+FLTK2_WRAPPER_INTERFACE_WIDGET(TextDisplay, TextDisplay)
+FLTK2_WRAPPER_INTERFACE_END()
 
-/** TextDisplay */
-class FL_API TextDisplay: public Group {
-public:
-  enum {
-    NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR,
-    BLOCK_CURSOR, HEAVY_CURSOR
-  };
 
-  enum {
-    CURSOR_POS, CHARACTER_POS
-  };
-
-  // drag types- they match fltk::event_clicks() so that single clicking to
-  // start a collection selects by character, double clicking selects by
-  // word and triple clicking selects by line.
-  enum {
-    DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2
-  };
-
-  enum {
-    ATTR_NONE = 0,
-    ATTR_UNDERLINE = 1,
-    ATTR_HIDDEN = 2
-  };
-
-  struct StyleTableEntry {
-    Color      color;
-    Font        *font;
-    float       size;
-    unsigned   attr;
-  };
-
-  TextDisplay(int X, int Y, int W, int H, const char *l = 0);
-  ~TextDisplay();
-
-  // Emulation of Input widget:
-  int size() const { return buffer_->length(); }
-  const char* text() const { return buffer_->text(); }
-  void text( const char* v) { buffer_->text(v); }
-  void static_text( const char* v) { buffer_->text(v); }
-  char at(int i) const { return buffer_->character(i); }
-
-  virtual int handle(int e);
-  virtual void draw();
-  virtual void layout();
-
-  /** Associate 'buf' with display */
-  void buffer(TextBuffer* buf);
-  /** Associate 'buf' with display */
-  void buffer(TextBuffer& buf) { buffer(&buf); }
-
-  /** Return attached buffer */
-  TextBuffer* buffer() { return buffer_; }
-  /** Return attached buffer */
-  const TextBuffer* buffer() const { return buffer_; }
-
-  /** Append text to the end of the buffer */
-  void append(const char *text) { insert_position(buffer()->length()); 
insert(text); }
-  /** Insert text to current cursor position */
-  void insert(const char *text);
-  /** Overstrike text from current cursor position */
-  void overstrike(const char *text);
-
-  /** Set new cursor position */
-  void insert_position(int newPos);
-  /** Return current cursor position */
-  int insert_position() const { return cursor_pos_; }
-  /** Make cursor position visible in screen */
-  void show_insert_position();
-
-  /** Show cursor */
-  void show_cursor(bool b = true);
-  /** Hide cursor */
-  void hide_cursor() { show_cursor(false); }
-  /** Return cursor visibility state */
-  bool cursor_on() const { return cursor_on_; }
-  /** Set cursor style */
-  void cursor_style(int style);
-
-  /** Return cursor color */
-  Color cursor_color() const { return cursor_color_;}
-  /** Set cursor color */
-  void cursor_color(Color n) { cursor_color_ = n; }
-
-  /** Return begining of the word where 'pos' is located */
-  int word_start(int pos) { return buffer()->word_start(pos); }
-  /** Return end of the word where 'pos' is located */
-  int word_end(int pos) { return buffer()->word_end(pos); }
-  /** Go to next word */
-  void next_word(void);
-  /** Go to previous word */
-  void previous_word(void);
-
-  /** Set wrapping mode. wrap_margin is width to wrap at, zero means use w() */
-  void wrap_mode(bool wrap, int wrap_margin=0);
-
-  /** Set line number area width */
-  void linenumber_width(int width);
-  /** Return line number area width */
-  int linenumber_width() const { return linenumwidth_; }
-
-  /** Set new highlight data */
-  void highlight_data(TextBuffer *styleBuffer,
-                     StyleTableEntry *styleTable,
-                     int nStyles, char unfinishedStyle,
-                     UnfinishedStyleCb unfinishedHighlightCB,
-                     void *cbArg);
-
-  /** Move cursor right */
-  bool move_right();
-  /** Move cursor left */
-  bool move_left();
-  /** Move cursor down */
-  bool move_up();
-  /** Move cursor down */
-  bool move_down();
-
-  /** Redisplay text */
-  void redisplay_range(int start, int end);
-
-  /** Scroll to new position */
-  void scroll(int topLineNum, int horizOffset);
-
-  /** Returns true if position is inside selection */
-  bool in_selection(int x, int y);
-
-  /** Returns begining of the line where 'pos' is located */
-  int line_start(int pos);
-
-  /** Returns end of the line where 'pos' is located */
-  int line_end(int pos, bool start_pos_is_line_start = false);
-
-  /** Return number of visible lines */
-  int visible_lines() const { return visiblelines_cnt_; }
-
-  /** Return current visible topline */
-  int top_line() const { return topline_num_; }
-
-  /** Return current horizontal offset */
-  int hor_offset() const { return horiz_offset_; }
-
-  /** Find start of the next character, starting from 'pos'
-   * If 'pos' points to start of character already, it is returned.
-   * This is mainly used with UTF-8 strings
-   */
-  int find_next_char(int pos);
-
-  /** Find start of the previous character, starting from 'pos'
-   * If 'pos' points to start of character already, it is returned.
-   * This is mainly used with UTF-8 strings
-   */
-  int find_prev_char(int pos);
-
-  int xy_to_position(int X, int Y, int PosType = CHARACTER_POS);
-
-  void xy_to_rowcol(int X, int Y, int *row, int *column, int PosType = 
CHARACTER_POS);
-
-  bool position_to_xy(int pos, int *X, int *Y);
-
-  int total_lines() {return count_lines(0, buffer_->length(), true);}
-
-protected:
-  void draw_text(int X, int Y, int W, int H);
-  void draw_range(int start, int end);
-  void draw_cursor(int, int);
-
-  void draw_string(int style, int x, int y, int toX, const char *string,
-                  int nChars);
-
-  void draw_vline(int visLineNum, int leftClip, int rightClip,
-                 int leftCharIndex, int rightCharIndex);
-
-  void draw_line_numbers(bool clearAll);
-
-  void clear_rect(int style, int x, int y, int width, int height);
-  void display_insert();
-
-  int count_lines(int start, int end, bool start_pos_is_line_start);
-  int skip_lines(int startPos, int nLines, bool startPosIsLineStart);
-  int rewind_lines(int startPos, int nLines);
-  int position_style(int lineStartPos, int lineLen, int lineIndex, int 
dispIndex);
-
-  int wrapped_column(int row, int column);
-  int wrapped_row(int row);
-
-  void offset_line_starts(int newTopLineNum);
-
-  void calc_line_starts(int startLine, int endLine);
-
-  void update_line_starts(int pos, int charsInserted, int charsDeleted,
-                         int linesInserted, int linesDeleted, bool *scrolled);
-
-  void calc_last_char();
-
-  bool position_to_line(int pos, int* lineNum);
-  int string_width(const char* string, int length, int style);
-
-  static void buffer_predelete_cb(int pos, int nDeleted, void* cbArg);
-  static void buffer_modified_cb(int pos, int nInserted, int nDeleted,
-                                int nRestyled, const char* deletedText,
-                                void* cbArg);
-
-  static void h_scrollbar_cb(Scrollbar* w, TextDisplay* d);
-  static void v_scrollbar_cb( Scrollbar* w, TextDisplay* d);
-  void update_v_scrollbar();
-  void update_h_scrollbar(int longestvline = 0);
-
-  void blank_cursor_protrusions();
-  int measure_vline(int visLineNum);
-  int longest_vline();
-  int empty_vlines();
-  int vline_length(int visLineNum);
-
-  void maintain_absolute_top_line_number(bool state);
-  int get_absolute_top_line_number();
-  void absolute_top_line_number(int oldFirstChar);
-  int maintaining_absolute_top_line_number();
-  void reset_absolute_top_line_number();
-  bool position_to_linecol(int pos, int *lineNum, int *column);
-  void scroll_(int topLineNum, int horizOffset);
-
-  void extend_range_for_styles(int* start, int* end);
-
-  void find_wrap_range(const char *deletedText, int pos, int nInserted,
+namespace fltk {
+  
+  typedef void (*UnfinishedStyleCb)(int, void *);
+  
+  /** TextDisplay */
+  class FL_API TextDisplay: public Group {
+    
+  public:
+    
+    FLTK2_WIDGET_VCALLS(TextDisplay, TextDisplay)
+    
+    TextDisplay() {}
+    
+    TextDisplay(int x,int y,int w,int h, const char *l = 0) {
+      _p = new fltk3::TextDisplay_I(x, y, w, h, l);
+      _p->wrapper(this);
+    }
+    
+#if 0 // FIXME: 123-2
+    enum {
+      NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR,
+      BLOCK_CURSOR, HEAVY_CURSOR
+    };
+    
+    enum {
+      CURSOR_POS, CHARACTER_POS
+    };
+    
+    // drag types- they match fltk::event_clicks() so that single clicking to
+    // start a collection selects by character, double clicking selects by
+    // word and triple clicking selects by line.
+    enum {
+      DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2
+    };
+    
+    enum {
+      ATTR_NONE = 0,
+      ATTR_UNDERLINE = 1,
+      ATTR_HIDDEN = 2
+    };
+    
+    struct StyleTableEntry {
+      Color    color;
+      Font        *font;
+      float       size;
+      unsigned attr;
+    };
+    
+    TextDisplay(int X, int Y, int W, int H, const char *l = 0);
+    ~TextDisplay();
+    
+    // Emulation of Input widget:
+    int size() const { return buffer_->length(); }
+    const char* text() const { return buffer_->text(); }
+    void text( const char* v) { buffer_->text(v); }
+    void static_text( const char* v) { buffer_->text(v); }
+    char at(int i) const { return buffer_->character(i); }
+    
+    virtual int handle(int e);
+    virtual void draw();
+    virtual void layout();
+    
+    /** Associate 'buf' with display */
+    void buffer(TextBuffer* buf);
+    /** Associate 'buf' with display */
+    void buffer(TextBuffer& buf) { buffer(&buf); }
+    
+    /** Return attached buffer */
+    TextBuffer* buffer() { return buffer_; }
+    /** Return attached buffer */
+    const TextBuffer* buffer() const { return buffer_; }
+    
+    /** Append text to the end of the buffer */
+    void append(const char *text) { insert_position(buffer()->length()); 
insert(text); }
+    /** Insert text to current cursor position */
+    void insert(const char *text);
+    /** Overstrike text from current cursor position */
+    void overstrike(const char *text);
+    
+    /** Set new cursor position */
+    void insert_position(int newPos);
+    /** Return current cursor position */
+    int insert_position() const { return cursor_pos_; }
+    /** Make cursor position visible in screen */
+    void show_insert_position();
+    
+    /** Show cursor */
+    void show_cursor(bool b = true);
+    /** Hide cursor */
+    void hide_cursor() { show_cursor(false); }
+    /** Return cursor visibility state */
+    bool cursor_on() const { return cursor_on_; }
+    /** Set cursor style */
+    void cursor_style(int style);
+    
+    /** Return cursor color */
+    Color cursor_color() const { return cursor_color_;}
+    /** Set cursor color */
+    void cursor_color(Color n) { cursor_color_ = n; }
+    
+    /** Return begining of the word where 'pos' is located */
+    int word_start(int pos) { return buffer()->word_start(pos); }
+    /** Return end of the word where 'pos' is located */
+    int word_end(int pos) { return buffer()->word_end(pos); }
+    /** Go to next word */
+    void next_word(void);
+    /** Go to previous word */
+    void previous_word(void);
+    
+    /** Set wrapping mode. wrap_margin is width to wrap at, zero means use w() 
*/
+    void wrap_mode(bool wrap, int wrap_margin=0);
+    
+    /** Set line number area width */
+    void linenumber_width(int width);
+    /** Return line number area width */
+    int linenumber_width() const { return linenumwidth_; }
+    
+    /** Set new highlight data */
+    void highlight_data(TextBuffer *styleBuffer,
+                        StyleTableEntry *styleTable,
+                        int nStyles, char unfinishedStyle,
+                        UnfinishedStyleCb unfinishedHighlightCB,
+                        void *cbArg);
+    
+    /** Move cursor right */
+    bool move_right();
+    /** Move cursor left */
+    bool move_left();
+    /** Move cursor down */
+    bool move_up();
+    /** Move cursor down */
+    bool move_down();
+    
+    /** Redisplay text */
+    void redisplay_range(int start, int end);
+    
+    /** Scroll to new position */
+    void scroll(int topLineNum, int horizOffset);
+    
+    /** Returns true if position is inside selection */
+    bool in_selection(int x, int y);
+    
+    /** Returns begining of the line where 'pos' is located */
+    int line_start(int pos);
+    
+    /** Returns end of the line where 'pos' is located */
+    int line_end(int pos, bool start_pos_is_line_start = false);
+    
+    /** Return number of visible lines */
+    int visible_lines() const { return visiblelines_cnt_; }
+    
+    /** Return current visible topline */
+    int top_line() const { return topline_num_; }
+    
+    /** Return current horizontal offset */
+    int hor_offset() const { return horiz_offset_; }
+    
+    /** Find start of the next character, starting from 'pos'
+     * If 'pos' points to start of character already, it is returned.
+     * This is mainly used with UTF-8 strings
+     */
+    int find_next_char(int pos);
+    
+    /** Find start of the previous character, starting from 'pos'
+     * If 'pos' points to start of character already, it is returned.
+     * This is mainly used with UTF-8 strings
+     */
+    int find_prev_char(int pos);
+    
+    int xy_to_position(int X, int Y, int PosType = CHARACTER_POS);
+    
+    void xy_to_rowcol(int X, int Y, int *row, int *column, int PosType = 
CHARACTER_POS);
+    
+    bool position_to_xy(int pos, int *X, int *Y);
+    
+    int total_lines() {return count_lines(0, buffer_->length(), true);}
+    
+  protected:
+    void draw_text(int X, int Y, int W, int H);
+    void draw_range(int start, int end);
+    void draw_cursor(int, int);
+    
+    void draw_string(int style, int x, int y, int toX, const char *string,
+                     int nChars);
+    
+    void draw_vline(int visLineNum, int leftClip, int rightClip,
+                    int leftCharIndex, int rightCharIndex);
+    
+    void draw_line_numbers(bool clearAll);
+    
+    void clear_rect(int style, int x, int y, int width, int height);
+    void display_insert();
+    
+    int count_lines(int start, int end, bool start_pos_is_line_start);
+    int skip_lines(int startPos, int nLines, bool startPosIsLineStart);
+    int rewind_lines(int startPos, int nLines);
+    int position_style(int lineStartPos, int lineLen, int lineIndex, int 
dispIndex);
+    
+    int wrapped_column(int row, int column);
+    int wrapped_row(int row);
+    
+    void offset_line_starts(int newTopLineNum);
+    
+    void calc_line_starts(int startLine, int endLine);
+    
+    void update_line_starts(int pos, int charsInserted, int charsDeleted,
+                            int linesInserted, int linesDeleted, bool 
*scrolled);
+    
+    void calc_last_char();
+    
+    bool position_to_line(int pos, int* lineNum);
+    int string_width(const char* string, int length, int style);
+    
+    static void buffer_predelete_cb(int pos, int nDeleted, void* cbArg);
+    static void buffer_modified_cb(int pos, int nInserted, int nDeleted,
+                                   int nRestyled, const char* deletedText,
+                                   void* cbArg);
+    
+    static void h_scrollbar_cb(Scrollbar* w, TextDisplay* d);
+    static void v_scrollbar_cb( Scrollbar* w, TextDisplay* d);
+    void update_v_scrollbar();
+    void update_h_scrollbar(int longestvline = 0);
+    
+    void blank_cursor_protrusions();
+    int measure_vline(int visLineNum);
+    int longest_vline();
+    int empty_vlines();
+    int vline_length(int visLineNum);
+    
+    void maintain_absolute_top_line_number(bool state);
+    int get_absolute_top_line_number();
+    void absolute_top_line_number(int oldFirstChar);
+    int maintaining_absolute_top_line_number();
+    void reset_absolute_top_line_number();
+    bool position_to_linecol(int pos, int *lineNum, int *column);
+    void scroll_(int topLineNum, int horizOffset);
+    
+    void extend_range_for_styles(int* start, int* end);
+    
+    void find_wrap_range(const char *deletedText, int pos, int nInserted,
                         int nDeleted, int *modRangeStart, int *modRangeEnd,
                         int *linesInserted, int *linesDeleted);
-  void measure_deleted_lines(int pos, int nDeleted);
-  void wrapped_line_counter(TextBuffer *buf, int startPos, int maxPos,
-                            int maxLines, bool startPosIsLineStart,
-                            int styleBufOffset, int *retPos, int *retLines,
-                            int *retLineStart, int *retLineEnd,
-                            bool countLastLineMissingNewLine = true);
-  void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
+    void measure_deleted_lines(int pos, int nDeleted);
+    void wrapped_line_counter(TextBuffer *buf, int startPos, int maxPos,
+                              int maxLines, bool startPosIsLineStart,
+                              int styleBufOffset, int *retPos, int *retLines,
+                              int *retLineStart, int *retLineEnd,
+                              bool countLastLineMissingNewLine = true);
+    void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd,
                       int *nextLineStart);
-  int measure_proportional_character(TextBuffer *buf, int bufpos, int colNum, 
int pos);
-  int wrap_uses_character(int lineEndPos);
-  int range_touches_selection(TextSelection *sel, int rangeStart, int 
rangeEnd);
-  void text_drag_me(int pos);
-
-  int damage_range1_start, damage_range1_end;
-  int damage_range2_start, damage_range2_end;
-
-  int cursor_pos_;
-  bool cursor_on_;
-  int cursor_oldx_;           /* X pos. of cursor for blanking */
-  int cursor_oldy_;           /* Y pos. of cursor for blanking */
-  int cursor_hint_;           /* Tells the buffer modified callback
+    int measure_proportional_character(TextBuffer *buf, int bufpos, int 
colNum, int pos);
+    int wrap_uses_character(int lineEndPos);
+    int range_touches_selection(TextSelection *sel, int rangeStart, int 
rangeEnd);
+    void text_drag_me(int pos);
+    
+    int damage_range1_start, damage_range1_end;
+    int damage_range2_start, damage_range2_end;
+    
+    int cursor_pos_;
+    bool cursor_on_;
+    int cursor_oldx_;           /* X pos. of cursor for blanking */
+    int cursor_oldy_;           /* Y pos. of cursor for blanking */
+    int cursor_hint_;           /* Tells the buffer modified callback
                                 where to move the cursor, to reduce
                                 the number of redraw calls */
-  int cursor_style_;          /* One of enum cursorStyles above */
-  int cursor_preferred_col_;  /* Column for vert. cursor movement */
-  int visiblelines_cnt_;      /* # of visible (displayed) lines */
-  int bufferlines_cnt_;       /* # of newlines in the buffer */
-  TextBuffer *buffer_;        /* Contains text to be displayed */
-  TextBuffer *stylebuffer_;   /* Optional parallel buffer containing
+    int cursor_style_;          /* One of enum cursorStyles above */
+    int cursor_preferred_col_;  /* Column for vert. cursor movement */
+    int visiblelines_cnt_;      /* # of visible (displayed) lines */
+    int bufferlines_cnt_;       /* # of newlines in the buffer */
+    TextBuffer *buffer_;        /* Contains text to be displayed */
+    TextBuffer *stylebuffer_;   /* Optional parallel buffer containing
                                 color and font information */
-  int firstchar_, lastchar_;  /* Buffer positions of first and last
+    int firstchar_, lastchar_;  /* Buffer positions of first and last
                                 displayed character (lastChar points
                                 either to a newline or one character
                                 beyond the end of the buffer) */
-  bool own_buffer;           /* True if buffer_ created by constructor */
-  bool continuous_wrap_;      /* Wrap long lines when displaying */
-  int wrapmargin_;            /* Margin in # of char positions for
+    bool own_buffer;         /* True if buffer_ created by constructor */
+    bool continuous_wrap_;      /* Wrap long lines when displaying */
+    int wrapmargin_;            /* Margin in # of char positions for
                                 wrapping in continuousWrap mode */
-  int *linestarts_;
-  int topline_num_;           /* Line number of top displayed line
+    int *linestarts_;
+    int topline_num_;           /* Line number of top displayed line
                                 of file (first line of file is 1) */
-  int abs_topline_num_;       /* In continuous wrap mode, the line
+    int abs_topline_num_;       /* In continuous wrap mode, the line
                                 number of the top line if the text
                                 were not wrapped (note that this is
                                 only maintained as needed). */
-  bool need_abs_topline_num_; /* Externally settable flag to continue
+    bool need_abs_topline_num_; /* Externally settable flag to continue
                                 maintaining absTopLineNum even if
                                 it isn't needed for line # display */
-  int horiz_offset_;          /* Horizontal scroll pos. in pixels */
-  int numstyles_;             /* Number of entries in styleTable */
-  const StyleTableEntry *styletable_; /* Table of fonts and colors for
+    int horiz_offset_;          /* Horizontal scroll pos. in pixels */
+    int numstyles_;             /* Number of entries in styleTable */
+    const StyleTableEntry *styletable_; /* Table of fonts and colors for
                                         coloring/syntax-highlighting */
-  char unfinished_style_;     /* Style buffer entry which triggers
+    char unfinished_style_;     /* Style buffer entry which triggers
                                 on-the-fly reparsing of region */
-  UnfinishedStyleCb unfinished_highlight_cb_; /* Callback to parse 
"unfinished" */
-                                             /* regions */
-  void *highlight_cbarg_;     /* Arg to unfinishedHighlightCB */
-  int fixed_fontwidth_;       /* Font width if all current fonts are
+    UnfinishedStyleCb unfinished_highlight_cb_; /* Callback to parse 
"unfinished" */
+    /* regions */
+    void *highlight_cbarg_;     /* Arg to unfinishedHighlightCB */
+    int fixed_fontwidth_;       /* Font width if all current fonts are
                                 fixed and match in width, else -1 */
-  bool suppressresync_;       /* Suppress resynchronization of line
+    bool suppressresync_;       /* Suppress resynchronization of line
                                 starts during buffer updates */
-  int nlinesdeleted_;         /* Number of lines deleted during
+    int nlinesdeleted_;         /* Number of lines deleted during
                                 buffer modification (only used
                                 when resynchronization is suppressed) */
-
-  int stdfontwidth_;
-  int ascent_;
-  int descent_;
-  int maxsize_;
-
-  Color cursor_color_;
-
-  Scrollbar *hscrollbar;
-  Scrollbar *vscrollbar;
-
-  Rectangle text_area;
-
-  int dragpos_, dragtype_, dragging_;
-  int linenumleft_, linenumwidth_; /* Line number margin and width */
-};
-
+    
+    int stdfontwidth_;
+    int ascent_;
+    int descent_;
+    int maxsize_;
+    
+    Color cursor_color_;
+    
+    Scrollbar *hscrollbar;
+    Scrollbar *vscrollbar;
+    
+    Rectangle text_area;
+    
+    int dragpos_, dragtype_, dragging_;
+    int linenumleft_, linenumwidth_; /* Line number margin and width */
+#endif
+  };
+  
 } /* namespace fltk */
 
 #endif

Modified: branches/branch-3.0/include/fltk/TextEditor.h
===================================================================
--- branches/branch-3.0/include/fltk/TextEditor.h       2012-06-24 19:01:54 UTC 
(rev 9627)
+++ branches/branch-3.0/include/fltk/TextEditor.h       2012-06-25 12:39:35 UTC 
(rev 9628)
@@ -1,4 +1,3 @@
-#error header has not been ported to 3.0 yet
 //
 // "$Id$"
 //
@@ -28,90 +27,109 @@
 //     http://www.fltk.org/str.php
 //
 
+#ifndef FLTK2_TEXT_EDITOR_H
+#define FLTK2_TEXT_EDITOR_H
 
-#ifndef TEXT_EDITOR_H
-#define TEXT_EDITOR_H
-
+#include <fltk3/TextEditor.h>
 #include "TextDisplay.h"
 
-namespace fltk {
 
-// key will match in any state
-#define TEXT_EDITOR_ANY_STATE  (-1L)
+FLTK2_WRAPPER_INTERFACE_BEGIN(TextEditor, TextEditor)
+FLTK2_WRAPPER_INTERFACE_WIDGET(TextEditor, TextEditor)
+FLTK2_WRAPPER_INTERFACE_END()
 
-/** TextEditor */
-class FL_API TextEditor : public TextDisplay {
-public:
-  typedef int (*Key_Func)(int key, TextEditor* editor);
 
-  struct Key_Binding {
-    int          key;
-    int          state;
-    Key_Func     function;
-    Key_Binding* next;
-  };
+namespace fltk {
+  
+  // key will match in any state
+#define TEXT_EDITOR_ANY_STATE  (-1L)
+  
+  /** TextEditor */
+  class FL_API TextEditor : public TextDisplay {
+  public:
+#if 0 // FIXME: 123-2
 
-  static NamedStyle* default_style;
-
-  TextEditor(int X, int Y, int W, int H, const char* l = 0);
-  ~TextEditor();
-
-  virtual int handle(int e);
-
-  /** Set new insert mode. true=insert, false=overstrike */
-  void insert_mode(bool b) { insert_mode_ = b; }
-  /** Return current insert mode */
-  bool insert_mode() const { return insert_mode_; }
-
-  void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
-  void add_key_binding(int key, int state, Key_Func f)
+    typedef int (*Key_Func)(int key, TextEditor* editor);
+    
+    struct Key_Binding {
+      int          key;
+      int          state;
+      Key_Func     function;
+      Key_Binding* next;
+    };
+    
+    static NamedStyle* default_style;
+#endif    
+    
+    FLTK2_WIDGET_VCALLS(TextEditor, TextEditor)
+    
+    TextEditor() {}
+    
+    TextEditor(int x,int y,int w,int h, const char *l = 0) {
+      _p = new fltk3::TextEditor_I(x, y, w, h, l);
+      _p->wrapper(this);
+    }
+    
+#if 0 // FIXME: 123-2
+    ~TextEditor();
+    
+    virtual int handle(int e);
+    
+    /** Set new insert mode. true=insert, false=overstrike */
+    void insert_mode(bool b) { insert_mode_ = b; }
+    /** Return current insert mode */
+    bool insert_mode() const { return insert_mode_; }
+    
+    void add_key_binding(int key, int state, Key_Func f, Key_Binding** list);
+    void add_key_binding(int key, int state, Key_Func f)
     { add_key_binding(key, state, f, &key_bindings); }
-  void remove_key_binding(int key, int state, Key_Binding** list);
-  void remove_key_binding(int key, int state)
+    void remove_key_binding(int key, int state, Key_Binding** list);
+    void remove_key_binding(int key, int state)
     { remove_key_binding(key, state, &key_bindings); }
-  void remove_all_key_bindings(Key_Binding** list);
-  void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); }
-  void add_default_key_bindings(Key_Binding** list);
-  Key_Func bound_key_function(int key, int state, Key_Binding* list);
-  Key_Func bound_key_function(int key, int state)
+    void remove_all_key_bindings(Key_Binding** list);
+    void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); }
+    void add_default_key_bindings(Key_Binding** list);
+    Key_Func bound_key_function(int key, int state, Key_Binding* list);
+    Key_Func bound_key_function(int key, int state)
     { return bound_key_function(key, state, key_bindings); }
-  void default_key_function(Key_Func f) { default_key_function_ = f; }
-
-  // functions for the built in default bindings
-  static int kf_default(int c, TextEditor* e);
-  static int kf_ignore(int c, TextEditor* e);
-  static int kf_backspace(int c, TextEditor* e);
-  static int kf_enter(int c, TextEditor* e);
-  static int kf_move(int c, TextEditor* e);
-  static int kf_shift_move(int c, TextEditor* e);
-  static int kf_ctrl_move(int c, TextEditor* e);
-  static int kf_c_s_move(int c, TextEditor* e);
-  static int kf_home(int, TextEditor* e);
-  static int kf_end(int c, TextEditor* e);
-  static int kf_left(int c, TextEditor* e);
-  static int kf_up(int c, TextEditor* e);
-  static int kf_right(int c, TextEditor* e);
-  static int kf_down(int c, TextEditor* e);
-  static int kf_page_up(int c, TextEditor* e);
-  static int kf_page_down(int c, TextEditor* e);
-  static int kf_insert(int c, TextEditor* e);
-  static int kf_delete(int c, TextEditor* e);
-  static int kf_copy(int c, TextEditor* e);
-  static int kf_cut(int c, TextEditor* e);
-  static int kf_paste(int c, TextEditor* e);
-  static int kf_select_all(int c, TextEditor* e);
-  static int kf_undo(int c, TextEditor* e);
-
-protected:
-  int handle_key();
-  void maybe_do_callback();
-
-  bool insert_mode_;
-  Key_Binding* key_bindings;
-  static Key_Binding* global_key_bindings;
-  Key_Func default_key_function_;
-};
-
+    void default_key_function(Key_Func f) { default_key_function_ = f; }
+    
+    // functions for the built in default bindings
+    static int kf_default(int c, TextEditor* e);
+    static int kf_ignore(int c, TextEditor* e);
+    static int kf_backspace(int c, TextEditor* e);
+    static int kf_enter(int c, TextEditor* e);
+    static int kf_move(int c, TextEditor* e);
+    static int kf_shift_move(int c, TextEditor* e);
+    static int kf_ctrl_move(int c, TextEditor* e);
+    static int kf_c_s_move(int c, TextEditor* e);
+    static int kf_home(int, TextEditor* e);
+    static int kf_end(int c, TextEditor* e);
+    static int kf_left(int c, TextEditor* e);
+    static int kf_up(int c, TextEditor* e);
+    static int kf_right(int c, TextEditor* e);
+    static int kf_down(int c, TextEditor* e);
+    static int kf_page_up(int c, TextEditor* e);
+    static int kf_page_down(int c, TextEditor* e);
+    static int kf_insert(int c, TextEditor* e);
+    static int kf_delete(int c, TextEditor* e);
+    static int kf_copy(int c, TextEditor* e);
+    static int kf_cut(int c, TextEditor* e);
+    static int kf_paste(int c, TextEditor* e);
+    static int kf_select_all(int c, TextEditor* e);
+    static int kf_undo(int c, TextEditor* e);
+    
+  protected:
+    int handle_key();
+    void maybe_do_callback();
+    
+    bool insert_mode_;
+    Key_Binding* key_bindings;
+    static Key_Binding* global_key_bindings;
+    Key_Func default_key_function_;
+#endif
+  };
+  
 } /* namespace fltk */
 
 #endif

Modified: branches/branch-3.0/test2/input.cxx
===================================================================
--- branches/branch-3.0/test2/input.cxx 2012-06-24 19:01:54 UTC (rev 9627)
+++ branches/branch-3.0/test2/input.cxx 2012-06-25 12:39:35 UTC (rev 9628)
@@ -33,9 +33,7 @@
 #include <fltk/IntInput.h>
 #include <fltk/SecretInput.h>
 #include <fltk/WordwrapInput.h>
-#if 0 // FIXME: 123-2
 #include <fltk/TextEditor.h>
-#endif
 #include <fltk/Button.h>
 #include <fltk/ToggleButton.h>
 #if 0 // FIXME: 123-2
@@ -47,11 +45,10 @@
 
 int when = 0;
 Input *input[5];
+TextEditor* editor;
 
 #if 0 // FIXME: 123-2
 
-TextEditor* editor;
-
 void cb(Widget *ob) {
   printf("Callback for %s '%s'\n",ob->label(),((Input*)ob)->text());
 }
@@ -112,7 +109,7 @@
 }
 
 int main(int argc, char **argv) {
-  Window *window = new Window(400,350+105);
+  fltk::Window *window = new fltk::Window(400,350+105);
   //window->clear_double_buffer();
 
   window->begin();
@@ -130,14 +127,16 @@
   input[3]->tooltip("Input field for password");
   input[4] = new WordwrapInput(70,y,300,100,"Wordwrap"); y += 105;
   input[4]->tooltip("Input field for short multi-line text. Use TextEditor for 
anything more than a few lines!");
-#if 0 // FIXME: 123-2
 
   editor = new TextEditor(70,y,300,100,"TextEditor"); y += 105;
   editor->tooltip("TextEditor, designed for editing email and programs. "
                  "wrap_mode(true) has been done to this one.");
+#if 0 // FIXME: 123-2
   editor->wrap_mode(true);
+#endif
   window->resizable(editor);
 
+#if 0 // FIXME: 123-2
   for (int i = 0; i < 5; i++) {
     input[i]->when(0); input[i]->callback(cb);
   }

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to