]> git.lyx.org Git - features.git/blobdiff - src/frontends/xforms/FormDocument.C
Dekel language/encoding patch + a few fixes
[features.git] / src / frontends / xforms / FormDocument.C
index 268c27abbab93228793f6f3c3765d29e9aa6cba3..c7e32b1ae68f361aabe5ace68b05ecb42c04a24b 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "FormDocument.h"
 #include "form_document.h"
-#include "xform_macros.h"
 #include "Dialogs.h"
 #include "layout.h"
 #include "combox.h"
 #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"),
+       : FormBase(lv, d, _("Document Layout"), BUFFER_DEPENDENT, UPDATE,
                   new NoRepeatedApplyReadOnlyPolicy),
          dialog_(0), paper_(0), class_(0), language_(0), options_(0),
-         bullets_(0)
+         bullets_(0), current_bullet_panel(0), current_bullet_depth(0),
+         fbullet(0), combo_language(0), combo_doc_class(0)
 {
     // let the popup be shown
     // This is a permanent connection so we won't bother
     // storing a copy because we won't be disconnecting.
     d->showLayoutDocument.connect(slot(this, &FormDocument::show));
-    current_bullet_depth = 0;
-    current_bullet_panel = 0;
 }
 
 
@@ -87,7 +73,7 @@ FormDocument::~FormDocument()
 }
 
 
-FL_FORM * const FormDocument::form() const
+FL_FORM * FormDocument::form() const
 {
     if (dialog_) return dialog_->form;
     return 0;
@@ -153,7 +139,7 @@ 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);
     combo_doc_class->shortcut("#C",1);
     combo_doc_class->setcallback(ComboInputCB, this);
     fl_end_form();
@@ -211,7 +197,7 @@ 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);
     combo_language->shortcut("#L",1);
     combo_language->setcallback(ComboInputCB, this);
     fl_end_form();
@@ -219,7 +205,7 @@ 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());
     }
@@ -301,6 +287,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<State>( 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<FormDocument*>(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;
@@ -482,14 +556,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
@@ -499,7 +569,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;
@@ -542,35 +612,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_)
@@ -671,7 +712,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().c_str());
     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);
@@ -750,30 +791,6 @@ void FormDocument::bullets_update(BufferParams const & params)
 }
 
 
-void FormDocument::InputCB(FL_OBJECT * ob, long)
-{
-    FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
-    pre->bc_.valid(pre->CheckDocumentInput(ob,0));
-}
-
-
-void FormDocument::ComboInputCB(int, void * v, Combox * combox)
-{
-    FormDocument * pre = static_cast<FormDocument*>(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<FormDocument*>(ob->form->u_vdata);
-    pre->CheckChoiceClass(ob,0);
-    pre->bc_.valid(pre->CheckDocumentInput(ob,0));
-}
-
-
 void FormDocument::checkReadOnly()
 {
     if (bc_.readOnly(lv_->buffer()->isReadonly())) {
@@ -896,14 +913,6 @@ bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
 }
 
 
-void FormDocument::ChoiceBulletSizeCB(FL_OBJECT * ob, long)
-{
-    FormDocument * pre = static_cast<FormDocument*>(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;
@@ -915,14 +924,6 @@ void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ )
 }
 
 
-void FormDocument::InputBulletLaTeXCB(FL_OBJECT * ob, long)
-{
-    FormDocument * pre = static_cast<FormDocument*>(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;
@@ -932,14 +933,7 @@ void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
 }
 
 
-void FormDocument::BulletDepthCB(FL_OBJECT * ob, long data)
-{
-    FormDocument * pre = static_cast<FormDocument*>(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 */
@@ -951,9 +945,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;
@@ -965,18 +969,25 @@ void FormDocument::BulletDepth(FL_OBJECT * ob, long data)
 }
 
 
-void FormDocument::BulletPanelCB(FL_OBJECT * ob, long data)
-{
-    FormDocument * pre = static_cast<FormDocument*>(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;
@@ -984,24 +995,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 :
@@ -1020,14 +1031,6 @@ void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, long data)
 }
 
 
-void FormDocument::BulletBMTableCB(FL_OBJECT * ob, long)
-{
-    FormDocument * pre = static_cast<FormDocument*>(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 */