]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetinfo.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / insets / insetinfo.C
index 1fc4387e9ff439b7cfd292167bc7ce5c34c5ef05..52e8935c176af5ccba552526383d6b99d3a83764 100644 (file)
@@ -3,13 +3,14 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1998 The LyX Team.
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ======================================================*/
 
 #include <config.h>
-#include <ctype.h>
+
+#include <cctype>
 
 #ifdef __GNUG__
 #pragma implementation
 
 #include "insetinfo.h"
 #include "lyxparagraph.h"
-#include "error.h"
+#include "debug.h"
 #include "lyxdraw.h"
 #include "gettext.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 #include "buffer.h"
-
-//     $Id: insetinfo.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $ 
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: insetinfo.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $";
-#endif /* lint */
-
-extern BufferView *current_view;
+#include "support/lstrings.h"
 
 /* Info, used for the Info boxes */
 
+extern BufferView * current_view;
+
 InsetInfo::InsetInfo()
 {
-       form = NULL;
+       form = 0;
 }
 
 
-InsetInfo::InsetInfo(LString const & string)
+InsetInfo::InsetInfo(string const & string)
        : contents(string)
 {
-       form = NULL;
+       form = 0;
 }
 
 
@@ -51,7 +47,7 @@ InsetInfo::~InsetInfo()
        if (form){
                fl_hide_form(form);
                fl_free_form(form);
-               form = NULL;
+               form = 0;
        }
 }
 
@@ -102,10 +98,10 @@ void InsetInfo::Write(FILE *file)
 
 void InsetInfo::Read(LyXLex &lex)
 {
-       LString tmp = lex.GetString(); // should be "Info"
+       string tmp = lex.GetString(); // should be "Info"
        if (tmp != "Info")
-               lyxerr.print("ERROR (InsetInfo::Read): "
-                             "consistency check 1 failed.");
+               lyxerr << "ERROR (InsetInfo::Read): "
+                       "consistency check 1 failed." << endl;
 
        while (lex.IsOK()) {
                if (!lex.EatLine())
@@ -113,8 +109,8 @@ void InsetInfo::Read(LyXLex &lex)
                        // should we skip blank lines?
                        continue;
 
-               LString const token = lex.GetString().strip();
-               lyxerr.debug("Note: " + token, Error::LEX_PARSER);
+               string const token = strip(lex.GetString());
+               lyxerr[Debug::PARSER] << "Note: " << token << endl;
                
                if (token != "\\end_inset") {
                        contents += token + '\n';
@@ -123,7 +119,7 @@ void InsetInfo::Read(LyXLex &lex)
                        break;
        }
        // now remove the last '\n's
-       contents.strip('\n');
+       contents = strip(contents, '\n');
 }
       
 
@@ -133,19 +129,19 @@ int InsetInfo::Latex(FILE *, signed char /*fragile*/)
 }
 
 
-int InsetInfo::Latex(LString &, signed char /*fragile*/)
+int InsetInfo::Latex(string &, signed char /*fragile*/)
 {
        return 0;
 }
 
 
-int InsetInfo::Linuxdoc(LString &)
+int InsetInfo::Linuxdoc(string &)
 {
        return 0;
 }
 
 
-int InsetInfo::DocBook(LString &)
+int InsetInfo::DocBook(string &)
 {
        return 0;
 }
@@ -161,7 +157,7 @@ void InsetInfo::CloseInfoCB(FL_OBJECT *, long data)
 {
        InsetInfo *inset = (InsetInfo*) data;
 //     inset->contents = fl_get_input(inset->strobj);
-       LString tmp = fl_get_input(inset->strobj);
+       string tmp = fl_get_input(inset->strobj);
        Buffer *buffer = current_view->currentBuffer();
        if(tmp != inset->contents && !(buffer->isReadonly()) ) {
                buffer->markDirty();
@@ -170,13 +166,20 @@ void InsetInfo::CloseInfoCB(FL_OBJECT *, long data)
        if (inset->form) {
                fl_hide_form(inset->form);
                fl_free_form(inset->form);
-               inset->form = NULL;
+               inset->form = 0;
        }
 }
 
+// This is just a wrapper.
+extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT *, long data) 
+{
+       InsetInfo::CloseInfoCB(0, data);
+}
 
 void InsetInfo::Edit(int, int)
 {
+       static int ow = -1, oh;
+
        if(current_view->currentBuffer()->isReadonly())
                WarnReadonly();
        
@@ -189,18 +192,23 @@ void InsetInfo::Edit(int, int)
                fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity);
                obj = fl_add_button(FL_NORMAL_BUTTON,130,140,120,30,idex(_("Close|#C^[")));
                fl_set_object_resize(obj, FL_RESIZE_NONE);
-               fl_set_object_gravity(obj, SouthWestGravity, SouthEastGravity);
-               fl_set_object_callback(obj, CloseInfoCB, (long)this);
+               fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity);
+               fl_set_object_callback(obj, C_InsetInfo_CloseInfoCB, (long)this);
                fl_set_object_shortcut(obj, scex(_("Close|#C^[")), (long)this);
                fl_end_form();
-               fl_set_form_atclose(form, CancelCloseBoxCB, NULL);
+               fl_set_form_atclose(form, CancelCloseBoxCB, 0);
        }
        fl_set_input(strobj, contents.c_str());
        if (form->visible) {
                fl_raise_form(form);
        } else {
-               fl_show_form(form,FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, 
+               fl_show_form(form,FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER, 
                             _("Note"));
+               if (ow < 0) {
+                       ow = form->w;
+                       oh = form->h;
+               }
+               fl_set_form_minsize(form, ow, oh);
        }
 }