]> git.lyx.org Git - lyx.git/blobdiff - src/intl.C
small changes to ButtonController usage
[lyx.git] / src / intl.C
index 86d1860d07e4af160e065c55c63cc0ed821c3b9a..faaa79910bdc046a2e8f0a6453dbd9452c5424d3 100644 (file)
@@ -4,7 +4,7 @@
  *           LyX, The Document Processor
  *      
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== */
 
 #include "lyxrc.h"
 #include "trans_mgr.h"
 #include "support/lstrings.h"
+#include "language.h"
 
-extern LyXRC * lyxrc;
+using std::endl;
 
 // a wrapper around the callback static member.
 extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code);
 
 
 Intl::Intl()
-       : prim_lang(lyxrc->primary_kbmap), 
-         sec_lang(lyxrc->secondary_kbmap),
-         trans(new TransManager)
+       : prim_lang(lyxrc.primary_kbmap), 
+       sec_lang(lyxrc.secondary_kbmap),
+       trans(new TransManager)
 {
-       keymapon = lyxrc->use_kbmap;
+       keymapon = lyxrc.use_kbmap;
        chsetcode = 0;
        primarykeymap = false;
        curkeymap = 0;
@@ -48,11 +49,6 @@ Intl::Intl()
 }
 
 
-Intl::~Intl()
-{
-}
-
-
 int Intl::SetPrimary(string const & lang)
 {
        if (lyxerr.debugging(Debug::KBMAP))
@@ -71,9 +67,9 @@ int Intl::SetSecondary(string const & lang)
 
 void Intl::update()
 {
-       int off, prim, sec;
-       
-       off = prim = sec = 0;
+       int off = 0;
+       int prim = 0;
+       int sec = 0;
        
        if (!keymapon) {
                off = 1;
@@ -129,19 +125,14 @@ void Intl::ToggleKeyMap()
 
 void Intl::KeyMapPrim()
 {
-       int i;
-       string p;
-
        fl_set_button(fd_form_keymap->KeyOffBtn, 0);
        fl_set_button(fd_form_keymap->KeyOnBtn, 1);
        fl_set_button(fd_form_keymap->KeyOnBtn2, 0);
 
        /* read text from choice */
-       i = Language->get();
-       
-       if (lyxerr.debugging(Debug::KBMAP))
-               lyxerr << "Table: " << tex_babel[i-1] << endl;
+       int i = Language->get();
 
+       string p;
        if (i == otherkeymap)
                p = fl_get_input(fd_form_keymap->OtherKeymap);
        else
@@ -171,9 +162,6 @@ void Intl::KeyMapSec()
 
        /* read text from choice */
        int i = Language2->get();
-       
-       if (lyxerr.debugging(Debug::KBMAP))
-               lyxerr << "Table: " << tex_babel[i-1] << endl;
 
        string p;
        if (i == otherkeymap)
@@ -226,11 +214,13 @@ void Intl::DispatchCallback(FL_OBJECT * ob, long code)
        if (itl!= 0) itl->Keymap(code);
 }
 
+
 extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code)
 {
        Intl::DispatchCallback(ob, code);
 }
 
+
 void Intl::InitKeyMapper(bool on)
        /* initialize key mapper */
 {
@@ -277,7 +267,7 @@ void Intl::InitKeyMapper(bool on)
 
        fl_hide_object(fd_form_keymap->KeymapErr);
        fl_hide_object(fd_form_keymap->ChsetErr);
-       fl_set_input(fd_form_keymap->Charset, lyxrc->font_norm.c_str());
+       fl_set_input(fd_form_keymap->Charset, lyxrc.font_norm.c_str());
 
        // Adds two comboxes to the keyboard map
        fl_addto_form(fd_form_keymap->KeyMap);
@@ -285,20 +275,20 @@ void Intl::InitKeyMapper(bool on)
        Language2->add(120, 110, 160, 30, 300); // Secondary
        fl_end_form();
 
-       int n = 0;
+       int n = 1;
+       // Default is not in the language map
+       Language->addto("default");
+       Language2->addto("default");
+       for (Languages::const_iterator cit = languages.begin();
+            cit != languages.end(); ++cit) {
+               Language->addto((*cit).second.lang().c_str());
+               Language2->addto((*cit).second.lang().c_str());
+               ++n;
+       }
 
-       while (true)
-               if (!strlen(tex_babel[n]))
-                       break;
-               else {
-                       Language->addto(tex_babel[n]);
-                       Language2->addto(tex_babel[n]);
-                       n++;
-               }
-       
        Language->addto(_("other..."));
        Language2->addto(_("other..."));
-       otherkeymap = n+1;
+       otherkeymap = n + 1;
        if (!Language->select_text(prim_lang.c_str())) {
                Language->select(n+1);
                fl_set_input(fd_form_keymap->OtherKeymap, prim_lang.c_str());
@@ -307,7 +297,7 @@ void Intl::InitKeyMapper(bool on)
                trans->SetPrimary(prim_lang);
 
        if (!Language2->select_text(sec_lang.c_str())) {
-               Language2->select(n+1);
+               Language2->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap2, sec_lang.c_str());
        }
        else
@@ -317,7 +307,7 @@ void Intl::InitKeyMapper(bool on)
        if (keymapon)
                Keymap(23); // turn primary on
 
-       trans->setCharset(lyxrc->font_norm.c_str());
+       trans->setCharset(lyxrc.font_norm.c_str());
 }
 
 
@@ -326,6 +316,9 @@ void Intl::Keymap(long code)
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "KeyMap callback: " << code << endl;
 
+       // Did you wonder if it is possible to write spagetti code with
+       // other constructs thatn goto's? Well here we have a nice small
+       // spagetti example using a switch... (Lgb)
        switch (code) {
        case 0:
                /* cancel/hide */