Re: [AD] GUI changes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Finally I got an idea how to handle this problem. My solution is to
add one parameter to the function _handle_scrollable_scroll_click - the
height parameter. So the function doesn't calculate the height alone, but
takes it directly from the GUI object - and everything is all right. In the
attachment there is a diff for guiproc.c, aintern.h (declaration of the
function) and grabber.c (removes my previous patch of d_helptext_proc).
I tested it and it works fine...

And please, remove the section about the modifications of objects derived
from d_textbox_proc from the docs... thank you.
-- 
------------------------------------------------------------------------------
Mail: pavlovic@xxxxxxxxxx
WEB : http://redbull.dcs.fmph.uniba.sk/~pavlovic
------------------------------------------------------------------------------
diff -r -U 3 -N allegro.old/include/allegro/aintern.h allegro/include/allegro/aintern.h
--- allegro.old/include/allegro/aintern.h	Tue Aug 22 20:46:14 2000
+++ allegro/include/allegro/aintern.h	Tue Sep  5 15:35:18 2000
@@ -172,7 +172,7 @@
 
 
 /* some GUI innards that other people need to use */
-AL_FUNC(void, _handle_scrollable_scroll_click, (DIALOG *d, int listsize, int *offset));
+AL_FUNC(void, _handle_scrollable_scroll_click, (DIALOG *d, int listsize, int *offset, int height));
 AL_FUNC(void, _handle_scrollable_scroll, (DIALOG *d, int listsize, int *index, int *offset));
 AL_FUNC(void, _handle_listbox_click, (DIALOG *d););
 AL_FUNC(void, _draw_scrollable_frame, (DIALOG *d, int listsize, int offset, int height, int fg_color, int bg));
diff -r -U 3 -N allegro.old/src/guiproc.c allegro/src/guiproc.c
--- allegro.old/src/guiproc.c	Tue Sep  5 13:49:04 2000
+++ allegro/src/guiproc.c	Tue Sep  5 15:32:30 2000
@@ -773,17 +773,11 @@
 /* _handle_scrollable_click:
  *  Helper to process a click on a scrollable object.
  */
-void _handle_scrollable_scroll_click(DIALOG *d, int listsize, int *offset)
+void _handle_scrollable_scroll_click(DIALOG *d, int listsize, int *offset, int height)
 {
    int xx, yy;
-   int height;
    int hh = d->h - 5;
 
-   if (d->proc == d_textbox_proc)
-      height = (d->h-8) / text_height(font);
-   else 
-      height = (d->h-4) / text_height(font);
-
    while (gui_mouse_b()) {
       int i = (hh * height + listsize/2) / listsize;
       int len = (hh * (*offset) + listsize/2) / listsize + 2;
@@ -1127,9 +1121,9 @@
 	       _handle_listbox_click(d);
 	       d->flags &= ~D_INTERNAL;
 	    }
-	 }
+         }
 	 else {
-	    _handle_scrollable_scroll_click(d, listsize, &d->d2);
+	    _handle_scrollable_scroll_click(d, listsize, &d->d2, height);
 	 }
 	 break;
 
@@ -1577,7 +1571,7 @@
 	 }
 	 else {
 	    /* clicked on the scroll area */
-	    _handle_scrollable_scroll_click(d, d->d1, &d->d2);
+	    _handle_scrollable_scroll_click(d, d->d1, &d->d2, height);
 	 }
 	 break;
 
diff -r -U 3 -N allegro.old/tools/grabber.c allegro/tools/grabber.c
--- allegro.old/tools/grabber.c	Sun Aug 27 17:37:52 2000
+++ allegro/tools/grabber.c	Tue Sep  5 15:42:10 2000
@@ -2348,9 +2348,6 @@
 
 static int d_helptext_proc(int msg, DIALOG *d, int c)
 {
-   int (*proc)(int, DIALOG *, int);
-   int ret;
-
    if (d->dp == NULL)
       d->dp = grabber_help_text;
 
@@ -2367,13 +2364,8 @@
 
       return D_O_K;
    }
-   else {
-      proc = d->proc;
-      d->proc = d_textbox_proc;
-      ret = d_textbox_proc(msg, d, c);
-      d->proc = proc;
-      return ret;
-   }
+   else
+      return d_textbox_proc(msg, d, c);
 };
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/