From 7f6bacf2374d8e82a31cdbfd8fcf5ff18e97a55b Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 4 Nov 2005 15:16:24 +0000 Subject: FLUID1: The comment entry in the Browser now reveals some more information by showing multiple lines up to 50 characters. Also, a change just to make sure our Code View won't harm. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4638 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/Fl_Function_Type.cxx | 23 +++++++++++++++++++++++ fluid/Fl_Type.h | 2 ++ fluid/fluid.cxx | 13 +++++++++++-- fluid/function_panel.fl | 10 +++++----- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index d5627b2a8..77391abc1 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -681,6 +681,7 @@ Fl_Type *Fl_Comment_Type::make() { o->name("my comment"); o->add(p); o->factory = this; + o->title_buf[0] = 0; return o; } @@ -835,9 +836,31 @@ void Fl_Comment_Type::open() { break; } BREAK2: + title_buf[0] = 0; comment_panel->hide(); } +const char *Fl_Comment_Type::title() { + const char* n = name(); + if (!n || !*n) return type_name(); + if (title_buf[0]==0) { + const char *s = n; + char *d = title_buf; + int i = 50; + while (--i > 0) { + char n = *s++; + if (n==0) break; + if (n=='\r') { *d++ = '\\'; *d++ = 'r'; i--; } + else if (n=='\n') { *d++ = '\\'; *d++ = 'n'; i--; } + else if (n<32) { *d++ = '^'; *d++ = 'A'+n; i--; } + else *d++ = n; + } + if (i<=0) { *d++ = '.'; *d++ = '.'; *d++ = '.'; } + *d++ = 0; + } + return title_buf; +} + Fl_Comment_Type Fl_Comment_type; void Fl_Comment_Type::write_code1() { diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 18f6f5303..fe9d65351 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -230,12 +230,14 @@ public: class Fl_Comment_Type : public Fl_Type { char in_c_, in_h_, style_; + char title_buf[64]; public: Fl_Type *make(); void write_code1(); void write_code2(); void open(); virtual const char *type_name() {return "comment";} + virtual const char *title(); // string for browser void write_properties(); void read_property(const char *); virtual int is_public() const { return 1; } diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index f0f608dce..677e80dad 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -2048,8 +2048,14 @@ void update_sourceview_cb(Fl_Button*, void*) fluid_prefs.getUserdataPath(sv_header_filename, FL_PATH_MAX); strlcat(sv_header_filename, "source_view_tmp.h", FL_PATH_MAX); } - if (!header_file_name || !*header_file_name) - header_file_name = sv_header_filename; + + strlcpy(i18n_program, fl_filename_name(sv_source_filename), sizeof(i18n_program)); + fl_filename_setext(i18n_program, sizeof(i18n_program), ""); + const char *code_file_name_bak = code_file_name; + code_file_name = sv_source_filename; + const char *header_file_name_bak = header_file_name; + header_file_name = sv_header_filename; + // generate the code and load the files write_sourceview = 1; // generate files @@ -2067,6 +2073,9 @@ void update_sourceview_cb(Fl_Button*, void*) update_sourceview_position(); } write_sourceview = 0; + + code_file_name = code_file_name_bak; + header_file_name = header_file_name_bak; } void update_sourceview_timer(void*) diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl index 655ead0ce..f6900bad5 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 + callback type_make_cb selected tooltip {Declaration Block} xywh {30 55 25 25} box THIN_UP_BOX code0 {o->image(pixmap[11]);} } @@ -688,11 +688,11 @@ Function {make_sourceview()} {open } { Fl_Window sourceview_panel { label {Code View} - callback toggle_sourceview_cb open + callback toggle_sourceview_cb xywh {533 374 520 490} type Double resizable size_range {384 120 0 0} visible } { Fl_Tabs sv_tab { - callback update_sourceview_position_cb open + callback update_sourceview_position_cb xywh {10 10 500 440} selection_color 4 labelcolor 7 resizable } { Fl_Group {} { @@ -709,14 +709,14 @@ Function {make_sourceview()} {open label Header open xywh {10 35 500 415} labelsize 13 } { - Fl_Text_Editor sv_header {selected + Fl_Text_Editor sv_header { xywh {20 50 480 390} textfont 4 textsize 11 resizable code0 {\#include "CodeEditor.h"} class CodeEditor } } } - Fl_Group {} {open + Fl_Group {} { xywh {10 460 500 20} } { Fl_Button {} { -- cgit v1.2.3