From 03909a7a281058fff598a24ac68e9b7eca302b40 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 2 Aug 2008 01:06:38 +0000 Subject: [PATCH] more refinements to partion stuff --- Common/Message.cpp | 32 ++++-------------------------- Fltk/GUI_Extras.cpp | 13 ++++++------ contrib/Chaco/Makefile | 2 +- contrib/Chaco/main/Gmsh_printf.cpp | 22 ++++++++++++++++++-- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/Common/Message.cpp b/Common/Message.cpp index 8eb23cda47..0e782aa017 100644 --- a/Common/Message.cpp +++ b/Common/Message.cpp @@ -270,36 +270,12 @@ void Message::Direct(int level, const char *fmt, ...) #if defined(HAVE_FLTK) if(WID){ WID->check(); - const char *const last = str + std::max(0u, std::strlen(str) - 1); - char _buf[1029]; + std::string tmp; if(level < 3) - std::strcpy(_buf, "@C1@."); + tmp = std::string("@C1@.") + str; else - std::strcpy(_buf, "@C4@."); - char *const buf = _buf + 5; - char *p = std::strtok(str, "\n"); - if(p) { - // If more than 1 leading '\n', print a blank line - if(p - str > 1) { - buf[0] = ' '; - buf[1] = '\0'; - WID->add_message(_buf); - } - std::strcpy(buf, p); - WID->add_message(_buf); - // New line for each interior '\n' - while(p = std::strtok(NULL, "\n")) { - std::strcpy(buf, p); - WID->add_message(_buf); - } - } - // If more than 1 trailing '\n', or only "\n" in the string, print a blank - // line. - if(*last == '\n') { - buf[0] = ' '; - buf[1] = '\0'; - WID->add_message(_buf); - } + tmp = std::string("@C4@.") + str; + WID->add_message(tmp.c_str()); if(level == 1) WID->create_message_window(); } diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp index c15940b85a..7e25dae7b9 100644 --- a/Fltk/GUI_Extras.cpp +++ b/Fltk/GUI_Extras.cpp @@ -1415,11 +1415,10 @@ void partition_defaults_cb(Fl_Widget *widget, void *data) dlg->read_all_options(); partition_select_groups_cb(dlg->choicePartitioner, data); } + void partition_partition_cb(Fl_Widget *widget, void *data) { PartitionDialog *dlg = static_cast<PartitionDialog*>(data); - Fl_Window *const w = widget->window(); - w->hide(); // Write all options dlg->write_all_options(); @@ -1430,13 +1429,14 @@ void partition_partition_cb(Fl_Widget *widget, void *data) // Update the screen if(!ier) { opt_mesh_color_carousel(0, GMSH_SET | GMSH_GUI, 3.); + CTX.mesh.changed = ENT_ALL; Draw(); } - - Fl::delete_widget(widget->window()); } + void partition_cancel_cb(Fl_Widget *widget, void *data) { + widget->window()->hide(); Fl::delete_widget(widget->window()); } @@ -1581,8 +1581,8 @@ int partition_dialog() const int w = 3 * BB + IW + 3 * WB; // Window width int y = 0; - Fl_Double_Window *const window = - new Fl_Double_Window(w, h, "Partitioner Options"); + Dialog_Window *const window = new Dialog_Window(w, h, CTX.non_modal_windows, + "Partitioner Options"); window->box(GMSH_WINDOW_BOX); // Main options group [0] @@ -1882,7 +1882,6 @@ int partition_dialog() g->show(); } - window->set_modal(); window->end(); window->hotspot(window); diff --git a/contrib/Chaco/Makefile b/contrib/Chaco/Makefile index b4c7d1ed6b..d6a164806b 100644 --- a/contrib/Chaco/Makefile +++ b/contrib/Chaco/Makefile @@ -3,7 +3,7 @@ include ../../variables LIB = ../../lib/libGmshChaco${LIBEXT} -INC = ${DASH}Imain +INC = ${DASH}Imain ${DASH}I../../Common CFLAGS = ${OPTIM} ${FLAGS} ${INC} ${SYSINCLUDE} diff --git a/contrib/Chaco/main/Gmsh_printf.cpp b/contrib/Chaco/main/Gmsh_printf.cpp index 661cdb83b4..167775c5e4 100644 --- a/contrib/Chaco/main/Gmsh_printf.cpp +++ b/contrib/Chaco/main/Gmsh_printf.cpp @@ -3,7 +3,7 @@ // See the LICENSE.txt file for license information. Please report all // bugs and problems to <gmsh@geuz.org>. -#include "../../../Common/Message.h" +#include "Message.h" // Overload the printf statements in Chaco to write using Msg::Direct in gmsh @@ -14,5 +14,23 @@ extern "C" int Gmsh_printf(const char *fmt, ...) va_start(args, fmt); vsnprintf(str, sizeof(str), fmt, args); va_end(args); - Msg::Direct(3, str); + + // deal with multi-line messages + const char *const last = str + std::max(0, (int)std::strlen(str) - 1); + char buf[1024]; + char *p = std::strtok(str, "\n"); + if(p) { + // If more than 1 leading '\n', print a blank line + if(p - str > 1) Msg::Direct(" "); + std::strcpy(buf, p); + Msg::Direct(buf); + // New line for each interior '\n' + while(p = std::strtok(NULL, "\n")) { + std::strcpy(buf, p); + Msg::Direct(buf); + } + } + // If more than 1 trailing '\n', or only "\n" in the string, print a blank + // line. + if(*last == '\n') Msg::Direct(" "); } -- GitLab