X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormDocument.C;h=b144834f81f986e5e7b8d1a036d0d9f372b05045;hb=eba67bc3120dc301bf193c3f3b570f51f00a4654;hp=942270a79c30c3ae3ef0059449f443c27eab4ffc;hpb=0e86ed5583391a8a038d443c2b09d86ca8a658c6;p=lyx.git diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 942270a79c..b144834f81 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -21,7 +21,6 @@ #include "FormDocument.h" #include "form_document.h" -#include "xform_macros.h" #include "Dialogs.h" #include "layout.h" #include "combox.h" @@ -39,27 +38,15 @@ #include "CutAndPaste.h" #include "bufferview_funcs.h" -#ifdef SIGC_CXX_NAMESPACES -using SigC::slot; -#endif - #ifdef CXX_WORKING_NAMESPACES using Liason::setMinibuffer; #endif #define USE_CLASS_COMBO 1 -C_GENERICCB(FormDocument, InputCB) -C_GENERICCB(FormDocument, ChoiceClassCB) -C_GENERICCB(FormDocument, BulletPanelCB) -C_GENERICCB(FormDocument, BulletDepthCB) -C_GENERICCB(FormDocument, InputBulletLaTeXCB) -C_GENERICCB(FormDocument, ChoiceBulletSizeCB) - - FormDocument::FormDocument(LyXView * lv, Dialogs * d) - : FormBase(lv, d, BUFFER_DEPENDENT, _("Document Layout"), - new NoRepeatedApplyReadOnlyPolicy), + : FormBaseBD(lv, d, _("Document Layout"), + new NoRepeatedApplyReadOnlyPolicy), dialog_(0), paper_(0), class_(0), language_(0), options_(0), bullets_(0), current_bullet_panel(0), current_bullet_depth(0), fbullet(0), combo_language(0), combo_doc_class(0) @@ -86,7 +73,20 @@ FormDocument::~FormDocument() } -FL_FORM * const FormDocument::form() const +void FormDocument::redraw() +{ + if( form() && form()->visible ) + fl_redraw_form( form() ); + else + return; + + FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder); + if (outer_form && outer_form->visible) + fl_redraw_form( outer_form ); +} + + +FL_FORM * FormDocument::form() const { if (dialog_) return dialog_->form; return 0; @@ -100,13 +100,17 @@ void FormDocument::build() // the tabbed folder dialog_ = build_tabbed_document(); - // manage the restore, ok, apply and cancel/close buttons + // Manage the restore, ok, apply, restore and cancel/close buttons bc_.setOK(dialog_->button_ok); bc_.setApply(dialog_->button_apply); bc_.setCancel(dialog_->button_cancel); bc_.setUndoAll(dialog_->button_restore); bc_.refresh(); + // Workaround dumb xforms sizing bug + minw_ = form()->w; + minh_ = form()->h; + // the document paper form paper_ = build_doc_paper(); fl_addto_choice(paper_->choice_papersize2, @@ -117,15 +121,15 @@ void FormDocument::build() "| A4 small Margins (only portrait) " "| A4 very small Margins (only portrait) " "| A4 very wide margins (only portrait) ")); - fl_set_input_return(paper_->input_custom_width, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_custom_height, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_top_margin, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_left_margin, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_right_margin, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_head_height, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_head_sep, FL_RETURN_ALWAYS); - fl_set_input_return(paper_->input_foot_skip, FL_RETURN_ALWAYS); + fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_left_margin, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_right_margin, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED); + fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED); bc_.addReadOnly (paper_->choice_paperpackage); bc_.addReadOnly (paper_->greoup_radio_orientation); @@ -152,14 +156,15 @@ void FormDocument::build() obj = class_->choice_doc_class; fl_addto_form(class_->form); combo_doc_class = new Combox(FL_COMBOX_DROPLIST); - combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 200); + combo_doc_class->add(obj->x, obj->y, obj->w, obj->h, 400, + dialog_->tabbed_folder); combo_doc_class->shortcut("#C",1); combo_doc_class->setcallback(ComboInputCB, this); fl_end_form(); for (LyXTextClassList::const_iterator cit = textclasslist.begin(); cit != textclasslist.end(); ++cit) { - combo_doc_class->addto((*cit).description().c_str()); + combo_doc_class->addto((*cit).description()); } #else fl_clear_choice(class_->choice_doc_class); @@ -179,8 +184,9 @@ void FormDocument::build() "default|empty|plain|headings|fancy"); fl_addto_choice(class_->choice_doc_skip, _(" Smallskip | Medskip | Bigskip | Length ")); - fl_set_input_return(class_->input_doc_skip, FL_RETURN_ALWAYS); - fl_set_input_return(class_->input_doc_spacing, FL_RETURN_ALWAYS); + fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED); + fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED); + fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED); bc_.addReadOnly (class_->radio_doc_indent); bc_.addReadOnly (class_->radio_doc_skip); @@ -210,7 +216,8 @@ void FormDocument::build() obj = language_->choice_language; fl_addto_form(language_->form); combo_language = new Combox(FL_COMBOX_DROPLIST); - combo_language->add(obj->x, obj->y, obj->w, obj->h, 200); + combo_language->add(obj->x, obj->y, obj->w, obj->h, 400, + dialog_->tabbed_folder); combo_language->shortcut("#L",1); combo_language->setcallback(ComboInputCB, this); fl_end_form(); @@ -218,9 +225,9 @@ void FormDocument::build() #ifdef DO_USE_DEFAULT_LANGUAGE combo_language->addto("default"); #endif - for(Languages::iterator cit = languages.begin(); + for (Languages::const_iterator cit = languages.begin(); cit != languages.end(); ++cit) { - combo_language->addto((*cit).second.lang().c_str()); + combo_language->addto((*cit).second.lang()); } fl_addto_choice(language_->choice_quotes_language, @@ -232,6 +239,7 @@ void FormDocument::build() // the document options form options_ = build_doc_options(); + fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED); fl_set_counter_bounds(options_->slider_secnumdepth,-2,5); fl_set_counter_bounds(options_->slider_tocdepth,-1,5); fl_set_counter_step(options_->slider_secnumdepth,1,1); @@ -300,6 +308,94 @@ void FormDocument::apply() } +void FormDocument::cancel() +{ + // this avoids confusion when reopening + BufferParams & param = lv_->buffer()->params; + param.temp_bullets[0] = param.user_defined_bullets[0]; + param.temp_bullets[1] = param.user_defined_bullets[1]; + param.temp_bullets[2] = param.user_defined_bullets[2]; + param.temp_bullets[3] = param.user_defined_bullets[3]; + hide(); +} + + +void FormDocument::update() +{ + if (!dialog_) + return; + + checkReadOnly(); + + BufferParams const & params = lv_->buffer()->params; + + class_update(params); + paper_update(params); + language_update(params); + options_update(params); + bullets_update(params); +} + + +bool FormDocument::input( FL_OBJECT * ob, long data ) +{ + State cb = static_cast( data ); + + switch (cb) { + case CHECKCHOICECLASS: + CheckChoiceClass(ob, 0); + break; + case CHOICEBULLETSIZE: + ChoiceBulletSize(ob, 0); + break; + case INPUTBULLETLATEX: + InputBulletLaTeX(ob, 0); + break; + case BULLETDEPTH1: + case BULLETDEPTH2: + case BULLETDEPTH3: + case BULLETDEPTH4: + BulletDepth(ob, cb); + break; + case BULLETPANEL1: + case BULLETPANEL2: + case BULLETPANEL3: + case BULLETPANEL4: + case BULLETPANEL5: + case BULLETPANEL6: + BulletPanel(ob, cb); + break; + case BULLETBMTABLE: + BulletBMTable(ob, 0); + break; + default: + break; + } + + switch (data) { + case INPUT: + case CHECKCHOICECLASS: + case CHOICEBULLETSIZE: + case INPUTBULLETLATEX: + case BULLETBMTABLE: + return CheckDocumentInput(ob, 0); + default: + break; + } + + return true; +} + + +void FormDocument::ComboInputCB(int, void * v, Combox * combox) +{ + FormDocument * pre = static_cast(v); + if (combox == pre->combo_doc_class) + pre->CheckChoiceClass(0, 0); + pre->bc_.valid(pre->CheckDocumentInput(0,0)); +} + + bool FormDocument::class_apply() { bool redo = false; @@ -316,9 +412,9 @@ bool FormDocument::class_apply() params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle); #ifdef USE_CLASS_COMBO - unsigned int new_class = combo_doc_class->get() - 1; + unsigned int const new_class = combo_doc_class->get() - 1; #else - unsigned int new_class = fl_get_choice(class_->choice_doc_class) - 1; + unsigned int const new_class = fl_get_choice(class_->choice_doc_class) - 1; #endif if (params.textclass != new_class) { // try to load new_class @@ -349,14 +445,14 @@ bool FormDocument::class_apply() _("Errors loading new document class."), _("Reverting to original document class.")); #ifdef USE_CLASS_COMBO - combo_doc_class->select(params.textclass + 1); + combo_doc_class->select(int(params.textclass) + 1); #else fl_set_choice(class_->choice_doc_class, params.textclass + 1); #endif } } - char tmpsep = params.paragraph_separation; + BufferParams::PARSEP tmpsep = params.paragraph_separation; if (fl_get_button(class_->radio_doc_indent)) params.paragraph_separation = BufferParams::PARSEP_INDENT; else @@ -397,7 +493,7 @@ bool FormDocument::class_apply() params.sides = LyXTextClass::OneSide; Spacing tmpSpacing = params.spacing; - switch(fl_get_choice(class_->choice_doc_spacing)) { + switch (fl_get_choice(class_->choice_doc_spacing)) { case 1: lyxerr[Debug::INFO] << "Spacing: SINGLE\n"; params.spacing.set(Spacing::Single); @@ -429,8 +525,10 @@ void FormDocument::paper_apply() { BufferParams & params = lv_->buffer()->params; - params.papersize2 = fl_get_choice(paper_->choice_papersize2)-1; - params.paperpackage = fl_get_choice(paper_->choice_paperpackage)-1; + params.papersize2 = + static_cast(fl_get_choice(paper_->choice_papersize2)-1); + params.paperpackage = + static_cast(fl_get_choice(paper_->choice_paperpackage)-1); params.use_geometry = fl_get_button(paper_->push_use_geometry); if (fl_get_button(paper_->radio_landscape)) params.orientation = BufferParams::ORIENTATION_LANDSCAPE; @@ -455,7 +553,7 @@ bool FormDocument::language_apply() InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; bool redo = false; - switch(fl_get_choice(language_->choice_quotes_language) - 1) { + switch (fl_get_choice(language_->choice_quotes_language) - 1) { case 0: lga = InsetQuotes::EnglishQ; break; @@ -481,14 +579,10 @@ bool FormDocument::language_apply() else params.quotes_times = InsetQuotes::DoubleQ; - Language const * old_language = params.language_info; - params.language = combo_language->getline(); - Languages::iterator lit = languages.find(params.language); - - Language const * new_language; - if (lit != languages.end()) - new_language = &(*lit).second; - else + Language const * old_language = params.language; + Language const * new_language = + languages.getLanguage(combo_language->getline()); + if (!new_language) new_language = default_language; if (old_language != new_language @@ -498,7 +592,7 @@ bool FormDocument::language_apply() if (old_language != new_language) { redo = true; } - params.language_info = new_language; + params.language = new_language; params.inputenc = fl_get_choice_text(language_->choice_inputenc); return redo; @@ -541,35 +635,6 @@ void FormDocument::bullets_apply() } -void FormDocument::cancel() -{ - // this avoids confusion when reopening - BufferParams & param = lv_->buffer()->params; - param.temp_bullets[0] = param.user_defined_bullets[0]; - param.temp_bullets[1] = param.user_defined_bullets[1]; - param.temp_bullets[2] = param.user_defined_bullets[2]; - param.temp_bullets[3] = param.user_defined_bullets[3]; - hide(); -} - - -void FormDocument::update() -{ - if (!dialog_) - return; - - checkReadOnly(); - - BufferParams const & params = lv_->buffer()->params; - - class_update(params); - paper_update(params); - language_update(params); - options_update(params); - bullets_update(params); -} - - void FormDocument::class_update(BufferParams const & params) { if (!class_) @@ -579,7 +644,7 @@ void FormDocument::class_update(BufferParams const & params) #ifdef USE_CLASS_COMBO combo_doc_class->select_text( - textclasslist.DescOfClass(params.textclass).c_str()); + textclasslist.DescOfClass(params.textclass)); #else fl_set_choice_text(class_->choice_doc_class, textclasslist.DescOfClass(params.textclass).c_str()); @@ -624,7 +689,7 @@ void FormDocument::class_update(BufferParams const & params) } fl_set_button(class_->radio_doc_sides_one, 0); fl_set_button(class_->radio_doc_sides_two, 0); - if (params.sides == 2) + if (params.sides == LyXTextClass::TwoSides) fl_set_button(class_->radio_doc_sides_two, 1); else fl_set_button(class_->radio_doc_sides_one, 1); @@ -670,7 +735,7 @@ void FormDocument::language_update(BufferParams const & params) if (!language_) return; - combo_language->select_text(params.language.c_str()); + combo_language->select_text(params.language->lang()); fl_set_choice_text(language_->choice_inputenc, params.inputenc.c_str()); fl_set_choice(language_->choice_quotes_language, params.quotes_language + 1); fl_set_button(language_->radio_single, 0); @@ -749,30 +814,6 @@ void FormDocument::bullets_update(BufferParams const & params) } -void FormDocument::InputCB(FL_OBJECT * ob, long) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->bc_.valid(pre->CheckDocumentInput(ob,0)); -} - - -void FormDocument::ComboInputCB(int, void * v, Combox * combox) -{ - FormDocument * pre = static_cast(v); - if (combox == pre->combo_doc_class) - pre->CheckChoiceClass(0, 0); - pre->bc_.valid(pre->CheckDocumentInput(0,0)); -} - - -void FormDocument::ChoiceClassCB(FL_OBJECT * ob, long) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->CheckChoiceClass(ob,0); - pre->bc_.valid(pre->CheckDocumentInput(ob,0)); -} - - void FormDocument::checkReadOnly() { if (bc_.readOnly(lv_->buffer()->isReadonly())) { @@ -792,6 +833,7 @@ void FormDocument::checkReadOnly() void FormDocument::checkMarginValues() { +#if 0 int const allEmpty = (!strlen(fl_get_input(paper_->input_top_margin)) && !strlen(fl_get_input(paper_->input_bottom_margin)) && !strlen(fl_get_input(paper_->input_left_margin)) && @@ -803,12 +845,14 @@ void FormDocument::checkMarginValues() !strlen(fl_get_input(paper_->input_custom_height))); if (!allEmpty) fl_set_button(paper_->push_use_geometry, 1); +#endif } + bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long) { string str; - char val; + int val; bool ok = true; char const * input; @@ -895,14 +939,6 @@ bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long) } -void FormDocument::ChoiceBulletSizeCB(FL_OBJECT * ob, long) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->ChoiceBulletSize(ob,0); - pre->bc_.valid(pre->CheckDocumentInput(ob,0)); -} - - void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ ) { BufferParams & param = lv_->buffer()->params; @@ -914,14 +950,6 @@ void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ ) } -void FormDocument::InputBulletLaTeXCB(FL_OBJECT * ob, long) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->InputBulletLaTeX(ob,0); - pre->bc_.valid(pre->CheckDocumentInput(ob,0)); -} - - void FormDocument::InputBulletLaTeX(FL_OBJECT *, long) { BufferParams & param = lv_->buffer()->params; @@ -931,14 +959,7 @@ void FormDocument::InputBulletLaTeX(FL_OBJECT *, long) } -void FormDocument::BulletDepthCB(FL_OBJECT * ob, long data) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->BulletDepth(ob, data); -} - - -void FormDocument::BulletDepth(FL_OBJECT * ob, long data) +void FormDocument::BulletDepth(FL_OBJECT * ob, State cb) { /* Should I do the following: */ /* 1. change to the panel that the current bullet belongs in */ @@ -950,9 +971,19 @@ void FormDocument::BulletDepth(FL_OBJECT * ob, long data) /* maybe try to support the others later */ BufferParams & param = lv_->buffer()->params; + int data = 0; + if (cb == BULLETDEPTH1 ) + data = 0; + else if (cb == BULLETDEPTH2 ) + data = 1; + else if (cb == BULLETDEPTH3 ) + data = 2; + else if (cb == BULLETDEPTH4 ) + data = 3; + switch (fl_get_button_numb(ob)) { case 3: - // right mouse button resets to default + // right mouse button resets to default param.temp_bullets[data] = ITEMIZE_DEFAULTS[data]; default: current_bullet_depth = data; @@ -964,18 +995,25 @@ void FormDocument::BulletDepth(FL_OBJECT * ob, long data) } -void FormDocument::BulletPanelCB(FL_OBJECT * ob, long data) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->BulletPanel(ob,data); -} - - -void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, long data) +void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb) { /* Here we have to change the background pixmap to that selected */ /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */ + int data = 0; + if (cb == BULLETPANEL1 ) + data = 0; + else if (cb == BULLETPANEL2 ) + data = 1; + else if (cb == BULLETPANEL3 ) + data = 2; + else if (cb == BULLETPANEL4 ) + data = 3; + else if (cb == BULLETPANEL5 ) + data = 4; + else if (cb == BULLETPANEL6 ) + data = 5; + if (data != current_bullet_panel) { fl_freeze_form(bullets_->form); current_bullet_panel = data; @@ -983,24 +1021,24 @@ void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, long data) /* free the current pixmap */ fl_free_bmtable_pixmap(bullets_->bmtable_bullet_panel); string new_panel; - switch (data) { + switch (cb) { /* display the new one */ - case 0 : + case BULLETPANEL1 : new_panel = "standard"; break; - case 1 : + case BULLETPANEL2 : new_panel = "amssymb"; break; - case 2 : + case BULLETPANEL3 : new_panel = "psnfss1"; break; - case 3 : + case BULLETPANEL4 : new_panel = "psnfss2"; break; - case 4 : + case BULLETPANEL5 : new_panel = "psnfss3"; break; - case 5 : + case BULLETPANEL6 : new_panel = "psnfss4"; break; default : @@ -1012,21 +1050,13 @@ void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, long data) } new_panel += ".xpm"; fl_set_bmtable_pixmap_file(bullets_->bmtable_bullet_panel, 6, 6, - LibFileSearch("images", new_panel.c_str()).c_str()); + LibFileSearch("images", new_panel).c_str()); fl_redraw_object(bullets_->bmtable_bullet_panel); fl_unfreeze_form(bullets_->form); } } -void FormDocument::BulletBMTableCB(FL_OBJECT * ob, long) -{ - FormDocument * pre = static_cast(ob->form->u_vdata); - pre->BulletBMTable(ob,0); - pre->bc_.valid(pre->CheckDocumentInput(ob,0)); -} - - void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/ ) { /* handle the user input by setting the current bullet depth's pixmap */ @@ -1051,15 +1081,13 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) ob = class_->choice_doc_class; ProhibitInput(lv_->view()); - int tc; - string tct; #ifdef USE_CLASS_COMBO - tc = combo_doc_class->get() - 1; - tct = combo_doc_class->getline(); + int tc = combo_doc_class->get() - 1; + string tct = combo_doc_class->getline(); #else - tc = fl_get_choice(ob) - 1; - tct = fl_get_choice_text(ob); + int tc = fl_get_choice(ob) - 1; + string tct = fl_get_choice_text(ob); #endif if (textclasslist.Load(tc)) { if (AskQuestion(_("Should I set some parameters to"), tct, @@ -1076,7 +1104,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) _("Unable to switch to new document class."), _("Reverting to original document class.")); #ifdef USE_CLASS_COMBO - combo_doc_class->select(lv_->buffer()->params.textclass + 1); + combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1); #else fl_set_choice(class_->choice_doc_class, lv_->buffer()->params.textclass + 1);