From d90102f9d22f7da2a21c42e6f7e953ca479c6671 Mon Sep 17 00:00:00 2001 From: Matthias Melcher <fltk@matthiasm.com> Date: Fri, 28 Apr 2006 01:00:41 +0000 Subject: [PATCH] Fluid Code Viewer is now truly a viewer, not an editor. I would love to allow text editing in the Code Viewer and re-enter the code into the UI, but that is currently close to impossible to implement git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5039 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ fluid/CodeEditor.cxx | 8 ++++++++ fluid/CodeEditor.h | 11 +++++++++++ fluid/function_panel.cxx | 8 ++++---- fluid/function_panel.fl | 8 ++++---- fluid/function_panel.h | 4 ++-- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 9a96a1a56..3beb0fbcb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ CHANGES IN FLTK 1.1.8 + - Fluid Code Viewer is now truly a viewer, not a text + editor because edited text can not be saved. - Fl_Spinner is now fully supported by Fluid (STR #1158) - Fixed usage of deleted object after menu pulldown (STR #1162) diff --git a/fluid/CodeEditor.cxx b/fluid/CodeEditor.cxx index af1e0c8ac..a2df6ec07 100644 --- a/fluid/CodeEditor.cxx +++ b/fluid/CodeEditor.cxx @@ -406,6 +406,14 @@ CodeEditor::~CodeEditor() { } +CodeViewer::CodeViewer(int X, int Y, int W, int H, const char *L) +: CodeEditor(X, Y, W, H, L) +{ + default_key_function(kf_ignore); + remove_all_key_bindings(&key_bindings); + cursor_style(CARET_CURSOR); +} + // // End of "$Id$". // diff --git a/fluid/CodeEditor.h b/fluid/CodeEditor.h index 04c51bd09..a13c8ddd4 100644 --- a/fluid/CodeEditor.h +++ b/fluid/CodeEditor.h @@ -70,6 +70,17 @@ class CodeEditor : public Fl_Text_Editor { int top_line() { return get_absolute_top_line_number(); } }; +class CodeViewer : public CodeEditor { + + public: + + CodeViewer(int X, int Y, int W, int H, const char *L=0); + + protected: + + int handle(int ev) { return Fl_Text_Display::handle(ev); } +}; + #endif // !CodeEditor_h // diff --git a/fluid/function_panel.cxx b/fluid/function_panel.cxx index 43c6ccf88..64ba8b58e 100644 --- a/fluid/function_panel.cxx +++ b/fluid/function_panel.cxx @@ -843,9 +843,9 @@ Fl_Double_Window *sourceview_panel=(Fl_Double_Window *)0; Fl_Tabs *sv_tab=(Fl_Tabs *)0; -CodeEditor *sv_source=(CodeEditor *)0; +CodeViewer *sv_source=(CodeViewer *)0; -CodeEditor *sv_header=(CodeEditor *)0; +CodeViewer *sv_header=(CodeViewer *)0; Fl_Light_Button *sv_autorefresh=(Fl_Light_Button *)0; @@ -863,7 +863,7 @@ Fl_Double_Window* make_sourceview() { { Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Source"); o->labelsize(13); o->hide(); - { CodeEditor* o = sv_source = new CodeEditor(20, 50, 480, 390); + { CodeViewer* o = sv_source = new CodeViewer(20, 50, 480, 390); o->box(FL_DOWN_FRAME); o->color(FL_BACKGROUND2_COLOR); o->selection_color(FL_SELECTION_COLOR); @@ -882,7 +882,7 @@ Fl_Double_Window* make_sourceview() { } { Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Header"); o->labelsize(13); - { CodeEditor* o = sv_header = new CodeEditor(20, 50, 480, 390); + { CodeViewer* o = sv_header = new CodeViewer(20, 50, 480, 390); o->box(FL_DOWN_FRAME); o->color(FL_BACKGROUND2_COLOR); o->selection_color(FL_SELECTION_COLOR); diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl index f6900bad5..ae8b9fff2 100644 --- a/fluid/function_panel.fl +++ b/fluid/function_panel.fl @@ -402,7 +402,7 @@ Function {make_widgetbin()} {open } Fl_Button {} { user_data {"declblock"} - callback type_make_cb selected + callback type_make_cb tooltip {Declaration Block} xywh {30 55 25 25} box THIN_UP_BOX code0 {o->image(pixmap[11]);} } @@ -702,17 +702,17 @@ Function {make_sourceview()} {open Fl_Text_Editor sv_source { xywh {20 50 480 390} textfont 4 textsize 11 resizable code0 {\#include "CodeEditor.h"} - class CodeEditor + class CodeViewer } } Fl_Group {} { - label Header open + label Header open selected xywh {10 35 500 415} labelsize 13 } { Fl_Text_Editor sv_header { xywh {20 50 480 390} textfont 4 textsize 11 resizable code0 {\#include "CodeEditor.h"} - class CodeEditor + class CodeViewer } } } diff --git a/fluid/function_panel.h b/fluid/function_panel.h index cd8c5254c..cd87a096b 100644 --- a/fluid/function_panel.h +++ b/fluid/function_panel.h @@ -97,8 +97,8 @@ extern Fl_Double_Window *sourceview_panel; #include <FL/Fl_Tabs.H> extern void update_sourceview_position_cb(Fl_Tabs*, void*); extern Fl_Tabs *sv_tab; -extern CodeEditor *sv_source; -extern CodeEditor *sv_header; +extern CodeViewer *sv_source; +extern CodeViewer *sv_header; extern void update_sourceview_cb(Fl_Button*, void*); extern Fl_Light_Button *sv_autorefresh; extern Fl_Light_Button *sv_autoposition;