]> git.lyx.org Git - lyx.git/blobdiff - src/intl.C
use the new bufferstorage (this change only deletes all references to the old one
[lyx.git] / src / intl.C
index fc6266c558be06f567f88efe099d6bd9620fa659..86d1860d07e4af160e065c55c63cc0ed821c3b9a 100644 (file)
@@ -1,12 +1,12 @@
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1995 Matthias Ettrich
-*           Copyright (C) 1995-1998 The LyX Team.
-*
-*======================================================*/
+ * ====================================================== 
+ 
+ *           LyX, The Document Processor
+ *      
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
+ *
+ * ====================================================== */
 
 /*
  *     International support for LyX
 #include "tex-strings.h"
 #include "combox.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
-#include "error.h"
+#include "debug.h"
 #include "lyxrc.h"
 #include "trans_mgr.h"
+#include "support/lstrings.h"
 
+extern LyXRC * lyxrc;
 
-//     $Id: intl.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $      
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: intl.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $";
-#endif /* lint */
-
-// lyx rc 
-extern LyXRC* lyxrc;
+// a wrapper around the callback static member.
+extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code);
 
 
 Intl::Intl()
@@ -45,7 +41,7 @@ Intl::Intl()
          trans(new TransManager)
 {
        keymapon = lyxrc->use_kbmap;
-       chsetcode = NULL;
+       chsetcode = 0;
        primarykeymap = false;
        curkeymap = 0;
        otherkeymap = 0;
@@ -57,41 +53,41 @@ Intl::~Intl()
 }
 
 
-int Intl::SetPrimary(LString const & lang)
+int Intl::SetPrimary(string const & lang)
 {
-       if (lyxerr.debugging(Error::KBMAP))
-               lyxerr.print("Primary: `" + lang + "'");
+       if (lyxerr.debugging(Debug::KBMAP))
+               lyxerr << "Primary: `" << lang << "'" << endl;
        return trans->SetPrimary(lang);
 }
 
 
-int Intl::SetSecondary(LString const & lang)
+int Intl::SetSecondary(string const & lang)
 {
-       if (lyxerr.debugging(Error::KBMAP))
-               lyxerr.print("Secondary: `" + lang + "'");
+       if (lyxerr.debugging(Debug::KBMAP))
+               lyxerr << "Secondary: `" << lang << "'" << endl;
        return trans->SetSecondary(lang);
 }
 
 
 void Intl::update()
 {
-       int off,prim,sec;
+       int off, prim, sec;
        
-       off=prim=sec=0;
+       off = prim = sec = 0;
        
        if (!keymapon) {
-               off=1;
+               off = 1;
        } else {
                if (primarykeymap) {
-                       prim=1;
+                       prim = 1;
                } else {
-                       sec=1;
+                       sec = 1;
                }
        }
        
-       fl_set_button(fd_form_keymap->KeyOffBtn,off);
-       fl_set_button(fd_form_keymap->KeyOnBtn,prim);
-       fl_set_button(fd_form_keymap->KeyOnBtn2,sec);
+       fl_set_button(fd_form_keymap->KeyOffBtn, off);
+       fl_set_button(fd_form_keymap->KeyOnBtn, prim);
+       fl_set_button(fd_form_keymap->KeyOnBtn2, sec);
 }
 
 
@@ -134,7 +130,7 @@ void Intl::ToggleKeyMap()
 void Intl::KeyMapPrim()
 {
        int i;
-       LString p;
+       string p;
 
        fl_set_button(fd_form_keymap->KeyOffBtn, 0);
        fl_set_button(fd_form_keymap->KeyOnBtn, 1);
@@ -143,8 +139,8 @@ void Intl::KeyMapPrim()
        /* read text from choice */
        i = Language->get();
        
-       if (lyxerr.debugging(Error::KBMAP))
-               lyxerr.print(LString("Table: ") + tex_babel[i-1]);
+       if (lyxerr.debugging(Debug::KBMAP))
+               lyxerr << "Table: " << tex_babel[i-1] << endl;
 
        if (i == otherkeymap)
                p = fl_get_input(fd_form_keymap->OtherKeymap);
@@ -169,19 +165,17 @@ void Intl::KeyMapPrim()
 
 void Intl::KeyMapSec()
 {
-       int i;
-       LString p;
-
        fl_set_button(fd_form_keymap->KeyOffBtn, 0);
        fl_set_button(fd_form_keymap->KeyOnBtn, 0);
        fl_set_button(fd_form_keymap->KeyOnBtn2, 1);
 
        /* read text from choice */
-       i = Language2->get();
+       int i = Language2->get();
        
-       if (lyxerr.debugging(Error::KBMAP))
-               lyxerr.print(LString("Table: ") + tex_babel[i-1]);
+       if (lyxerr.debugging(Debug::KBMAP))
+               lyxerr << "Table: " << tex_babel[i-1] << endl;
 
+       string p;
        if (i == otherkeymap)
                p = fl_get_input(fd_form_keymap->OtherKeymap2);
        else
@@ -202,23 +196,23 @@ void Intl::KeyMapSec()
 }
 
 
-void Intl::LCombo(int, void *v)
+void Intl::LCombo(int, void * v)
 {
-       Intl *itl = (Intl*) v;
+       Intl * itl = static_cast<Intl*>(v);
        itl->Keymap(23);
        return;
 }
 
 
-void Intl::LCombo2(int, void *v)
+void Intl::LCombo2(int, void * v)
 {
-       Intl *itl = (Intl*) v;
+       Intl * itl = static_cast<Intl*>(v);
        itl->Keymap(43);
        return;
 }
 
 
-void Intl::DispatchCallback(FL_OBJECT *ob,long code)
+void Intl::DispatchCallback(FL_OBJECT * ob, long code)
 {
        if (ob && (code == 0)) {
                fl_hide_form(ob->form);
@@ -227,16 +221,20 @@ void Intl::DispatchCallback(FL_OBJECT *ob,long code)
        if (!ob || !(ob->u_vdata))
                return;
        
-       Intl *itl=(Intl *)ob->u_vdata;
+       Intl * itl = static_cast<Intl *>(ob->u_vdata);
 
-       if (itl!=NULL) itl->Keymap(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 */
 {
-       lyxerr.debug("Initializing key mappings...", Error::KBMAP);
+       lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
 
        if (prim_lang.empty() && sec_lang.empty())
                keymapon = false; 
@@ -245,31 +243,37 @@ void Intl::InitKeyMapper(bool on)
 
        Language = new Combox(FL_COMBOX_DROPLIST);
        Language2 = new Combox(FL_COMBOX_DROPLIST);
-       Language->setcallback(LCombo,this);
-       Language2->setcallback(LCombo2,this);
+       Language->setcallback(LCombo, this);
+       Language2->setcallback(LCombo2, this);
 
        fd_form_keymap = create_form_KeyMap();
 
        // Add the Intl* pointer
-       fd_form_keymap->AcceptChset->u_vdata=
-               fd_form_keymap->Charset->u_vdata=
-               fd_form_keymap->Accept->u_vdata=
-               fd_form_keymap->OtherKeymap->u_vdata=
-               fd_form_keymap->KeyOnBtn->u_vdata=
-               fd_form_keymap->KeyOffBtn->u_vdata=
-               fd_form_keymap->KeyOnBtn2->u_vdata=(void *)this;
+       fd_form_keymap->AcceptChset->u_vdata =
+               fd_form_keymap->Charset->u_vdata =
+               fd_form_keymap->Accept->u_vdata =
+               fd_form_keymap->OtherKeymap->u_vdata =
+               fd_form_keymap->KeyOnBtn->u_vdata =
+               fd_form_keymap->KeyOffBtn->u_vdata =
+               fd_form_keymap->KeyOnBtn2->u_vdata = this;
 
        // add the callbacks.
-       fl_set_object_callback(fd_form_keymap->AcceptChset,DispatchCallback,27);
-       fl_set_object_callback(fd_form_keymap->Charset,DispatchCallback,26);
-       fl_set_object_callback(fd_form_keymap->Accept,DispatchCallback,0);
-
-       fl_set_object_callback(fd_form_keymap->KeyOnBtn,DispatchCallback,23);
-       fl_set_object_callback(fd_form_keymap->KeyOffBtn,DispatchCallback,3);
-       fl_set_object_callback(fd_form_keymap->KeyOnBtn2,DispatchCallback,43);
+       fl_set_object_callback(fd_form_keymap->AcceptChset,
+                              C_Intl_DispatchCallback, 27);
+       fl_set_object_callback(fd_form_keymap->Charset,
+                              C_Intl_DispatchCallback, 26);
+       fl_set_object_callback(fd_form_keymap->Accept,
+                              C_Intl_DispatchCallback, 0);
+
+       fl_set_object_callback(fd_form_keymap->KeyOnBtn,
+                              C_Intl_DispatchCallback, 23);
+       fl_set_object_callback(fd_form_keymap->KeyOffBtn,
+                              C_Intl_DispatchCallback, 3);
+       fl_set_object_callback(fd_form_keymap->KeyOnBtn2,
+                              C_Intl_DispatchCallback, 43);
        
        // Make sure pressing the close box does not kill LyX. (RvdK)
-       fl_set_form_atclose(fd_form_keymap->KeyMap, CancelCloseBoxCB, NULL);
+       fl_set_form_atclose(fd_form_keymap->KeyMap, CancelCloseBoxCB, 0);
 
        fl_hide_object(fd_form_keymap->KeymapErr);
        fl_hide_object(fd_form_keymap->ChsetErr);
@@ -277,11 +281,11 @@ void Intl::InitKeyMapper(bool on)
 
        // Adds two comboxes to the keyboard map
        fl_addto_form(fd_form_keymap->KeyMap);
-       Language->add(120,30,160,30,300);       // Primary
-       Language2->add(120,110,160,30,300);     // Secondary
+       Language->add(120, 30, 160, 30, 300);   // Primary
+       Language2->add(120, 110, 160, 30, 300); // Secondary
        fl_end_form();
 
-       int n=0;
+       int n = 0;
 
        while (true)
                if (!strlen(tex_babel[n]))
@@ -319,10 +323,8 @@ void Intl::InitKeyMapper(bool on)
 
 void Intl::Keymap(long code)
 {
-       char const *p;
-
-       if (lyxerr.debugging(Error::KBMAP))
-               lyxerr.print(LString("KeyMap callback: ") + code);
+       if (lyxerr.debugging(Debug::KBMAP))
+               lyxerr << "KeyMap callback: " << code << endl;
 
        switch (code) {
        case 0:
@@ -332,22 +334,22 @@ void Intl::Keymap(long code)
        case 3:
        case 23:
        case 43:
-               if (code==3) {
+               if (code == 3) {
                        KeyMapOn(false);
                        return;
                }
                code -= 19;     // change to language change type code
                
        case 4: // 4 and 24 will never be called directly, they will only be
-       case 24: // called through 3,23,43 (lgb)
-               if (code==4) {
+       case 24: // called through 3, 23, 43 (lgb)
+               if (code == 4) {
                        KeyMapPrim();
                } else {
                        KeyMapSec();
                }
                break;
        case 27:        /* set new font norm */
-               p = fl_get_input(fd_form_keymap->Charset);
+               char const * p = fl_get_input(fd_form_keymap->Charset);
                if (trans->setCharset(p))
                        fl_show_object(fd_form_keymap->ChsetErr);
                else