]> git.lyx.org Git - lyx.git/blobdiff - src/combox.C
small changes to ButtonController usage
[lyx.git] / src / combox.C
index ab91726cd33ddf4eddd65fda55f8b605329b01a2..400e3da44d6051e719d3e2cc95e65515358185d9 100644 (file)
@@ -4,7 +4,7 @@
  *          encapsulated to get a combobox-like object. All XForms 
  *          functions are hidden.         
  * 
- *  GNU Copyleft (C) 1996 Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ *  GNU Copyleft 1996 Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
  *                        and the LyX Team.
  * 
  *  Dependencies:  Only XForms, but created to be used with LyX.
@@ -40,6 +40,8 @@
 
 #include "debug.h"
 
+using std::endl;
+
 // These are C wrappers around static members of Combox, used as
 // callbacks for xforms.
 extern "C" void C_Combox_input_cb(FL_OBJECT *ob, long);
@@ -127,7 +129,7 @@ void Combox::addline(char const* text)
 bool Combox::select_text(char const* t)
 {
        if (!browser || !t) return false;
-       for (int i= 1; i<= fl_get_browser_maxline(browser); i++) {
+       for (int i = 1; i <= fl_get_browser_maxline(browser); ++i) {
                if (!strcmp(t, fl_get_browser_line(browser, i))) {
                        select(i);
                        return true;
@@ -368,26 +370,20 @@ int Combox::peek_event(FL_FORM * form, void * xev)
        FL_OBJECT * ob = static_cast<FL_OBJECT *>(form->u_vdata);
        Combox * combo = static_cast<Combox*>(ob->u_vdata);
        
-#if FL_REVISION < 86
-       if(((XEvent *)xev)->type == ButtonPress && !ob->belowmouse)
-#endif
-#if FL_REVISION > 85
-// I don't know why belowmouse does not work, but it doesn't. (Asger)
-               // Are we sure?
-               if (static_cast<XEvent *>(xev)->type == ButtonPress && (
-                       static_cast<XEvent *>(xev)->xbutton.x - ob->x < 0 ||
-                       static_cast<XEvent *>(xev)->xbutton.x - ob->x > ob->w ||
-                       static_cast<XEvent *>(xev)->xbutton.y - ob->y < 0 ||
-                       static_cast<XEvent *>(xev)->xbutton.y - ob->y > ob->h))
-#endif
-       {
+       // I don't know why belowmouse does not work, but it doesn't. (Asger)
+       // Are we sure? Please verify. (Lgb)
+       if (static_cast<XEvent *>(xev)->type == ButtonPress && (
+               static_cast<XEvent *>(xev)->xbutton.x - ob->x < 0 ||
+               static_cast<XEvent *>(xev)->xbutton.x - ob->x > ob->w ||
+               static_cast<XEvent *>(xev)->xbutton.y - ob->y < 0 ||
+               static_cast<XEvent *>(xev)->xbutton.y - ob->y > ob->h)) {
                combo->Hide(1); 
                return 1;
        }
                
        if (static_cast<XEvent*>(xev)->type != KeyPress) return 0;
        
-       char s_r[10];
+       char s_r[10]; s_r[9] = '\0';
        static int num_bytes;
        KeySym keysym_return;
        num_bytes = XLookupString(&static_cast<XEvent*>(xev)->xkey, s_r, 10,