home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / openloo / 3223 < prev    next >
Encoding:
Text File  |  1992-07-25  |  5.1 KB  |  201 lines

  1. Newsgroups: comp.windows.open-look
  2. Path: sparky!uunet!uunet.ca!wildcan!sq!lee
  3. From: lee@sq.sq.com (Liam R. E. Quin)
  4. Subject: Re: In Search of a Better Scrolling List
  5. Message-ID: <1992Jul25.033007.13545@sq.sq.com>
  6. Organization: SoftQuad Inc., Toronto, Canada
  7. References: <1992Jul23.184556.2701@midway.uchicago.edu>
  8. Date: Sat, 25 Jul 92 03:30:07 GMT
  9. Lines: 190
  10.  
  11. gast@midway.uchicago.edu writes:
  12. >Does anybody out the know of any Openlook widgets (in XView or OLit,
  13. >preferably XView) that can handle scrolling columns of data. 
  14.  
  15. I looked at the XView 3 source and decided it'd take me maybe a week or
  16. so to get a working, tested, documented multi-coumn list widget, with
  17. where
  18.     xv_set(MyList, 
  19.         PANEL_LIST_STRING, 23 "Col1\tCol2\tCol3"
  20.         NULL
  21.     );
  22. would do the obvious thing.  I don't have a week spare.
  23.  
  24. But I think you are looking at having columns that can be individually
  25. selected.
  26.  
  27. I can think of two fairly easy ways of doing this in XView...
  28. (1) use text fields and a scrollable panel
  29.     This might not be very OPEN LOOK-ish, beware..
  30.  
  31. (2) have several scrolling lists, and hide the scroll-bars (use
  32.     xv_get(List, PANEL_LIST_SCROLLBAR) to get a handle to the scroll bars,
  33.     and set XV_SHOW to false and PANEL_INACTIVE to true),
  34.     put your own scroll-bar on, and then create your own scroll bar to the
  35.     right of them all, and use
  36.     notify_interpose_event_func(MyScrollBar, MyScrollFunc, NOTIFY_SAFE);
  37.     as illustrated on p. 261 of the O'Reily XView 3 manual.
  38.     Your notify function will have to scroll the individual lists.
  39.     I spent a few minutes on this and didn't get very far, though - I'll
  40.     append what I did to this message & maybe someone can fix it.
  41.  
  42.     It might be easier simply to retain the right-most scroll-bar;
  43.     creaing scrollbars in XView is a black art, to say the least.
  44.  
  45. If you want to create a large number of fields (several hundred, say) you
  46. might find it easier to use olgx directly onto a canvas, or to use OLIT
  47. gadgets, since creating large numbers of objects can be slow.
  48.  
  49.  
  50. Here's a program that nearly works.  Faults:
  51. * the invisible scrol-bars still work (an XView bug?)
  52. * sometimes redrawing makes the scollbars all scroll!
  53.  
  54. Lee
  55. Liam Quin, lee@sq.com, SoftQuad, Toronto, 416 239-4801
  56. the barefoot programmer
  57.  
  58. /* cc -g -c pscroll.c
  59.  * cc -o pscroll pscroll.o -lxview -lolgx -lX11
  60.  */
  61.  
  62. #include <assert.h>
  63. #include <xview/xview.h>
  64. #include <xview/frame.h>
  65. #include <xview/panel.h>
  66. #include <xview/scrollbar.h>
  67. #include <xview/notify.h>
  68.  
  69. #define N_LISTS 6
  70.  
  71. Xv_opaque Lists[N_LISTS];
  72. Scrollbar s;
  73.  
  74. static int ValidEvent = 0;
  75.  
  76. Notify_func
  77. sc_func(client, event, sbar, type) /* p. 261 */
  78.     Notify_client client;
  79.     Event *event;
  80.     Scrollbar *sbar;
  81.     Notify_event_type type;
  82. {
  83.     if (event_id(event) == SCROLLBAR_REQUEST) {
  84.     int i;
  85.     int Where;
  86.  
  87. fprintf(stderr, "right scroll event %d\n", __LINE__);
  88.     Where = (int) xv_get(sbar, SCROLLBAR_VIEW_START);
  89.  
  90.     for (i = 0; i < N_LISTS - 1; i++) {
  91.         Scrollbar s ;
  92.         Notify_client c;
  93.  
  94.         s = (Scrollbar) xv_get(Lists[i], PANEL_LIST_SCROLLBAR);
  95.         c = (Notify_client) xv_get(s, SCROLLBAR_NOTIFY_CLIENT);
  96. fprintf(stderr, "Scroll %d %c [0x%x] to %d\n", i, c, s, Where);
  97.         ValidEvent++;
  98.         xv_set(s, SCROLLBAR_VIEW_START, Where);
  99.         ValidEvent--;
  100.     }
  101.     } else {
  102. fprintf(stderr, "not scroll event %d\n", __LINE__);
  103.     }
  104.     return notify_next_event_func(client, event, sbar, type);
  105. }
  106.  
  107. Notify_func
  108. Other_Scroll(client, event, sbar, type)
  109.     Notify_client client;
  110.     Event *event;
  111.     Scrollbar *sbar;
  112.     Notify_event_type type;
  113. {
  114.     static int InMeAlready = 0;
  115.     Notify_event n;
  116.  
  117.     if (InMeAlready > 1) {
  118.     fprintf(stderr, "OtherScroll recursion limit reached\n");
  119.     return NOTIFY_DONE;
  120.     }
  121.  
  122.     ++InMeAlready;
  123.  
  124.     if (event_id(event) != SCROLLBAR_REQUEST) {
  125. fprintf(stderr, "non-scroll event %d\n", __LINE__);
  126.     n = notify_next_event_func(client, event, sbar, type);
  127.     --InMeAlready;
  128.     return n;
  129.     } else if (ValidEvent) {
  130. fprintf(stderr, "valid scroll event %d\n", __LINE__);
  131.     n = notify_next_event_func(client, event, sbar, type);
  132.     --InMeAlready;
  133.     return n;
  134.     } else {
  135. fprintf(stderr, "INVALID scroll event %d ignored\n", __LINE__);
  136.     --InMeAlready;
  137.     return NOTIFY_DONE;
  138.     }
  139. }
  140.  
  141. main(argc, argv)
  142.     int argc;
  143.     char *argv[];
  144. {
  145.     Frame f;
  146.     Panel p ;
  147.     int i;
  148.     int x = 10;
  149.  
  150.     xv_init(XV_INIT_ARGS, argc, argv, NULL);
  151.  
  152.     f = (Frame) xv_create(NULL, FRAME, NULL);
  153.  
  154.     p = (Panel) xv_create(f, PANEL,
  155.     PANEL_LAYOUT, PANEL_HORIZONTAL,
  156.     NULL
  157.     );
  158.  
  159.     for (i = 0; i < N_LISTS; i++) {
  160.     Scrollbar tmp_s;
  161.  
  162.     Lists[i] = xv_create(p,
  163.         PANEL_LIST,
  164.         XV_X, x,
  165.         PANEL_LIST_STRINGS,
  166.         "a", "b", "c", "d", "e", "f", "g", "h", "i",
  167.         "j", "k", "l", "m", "n", "o", "p", "q",
  168.         NULL,
  169.         PANEL_LIST_DISPLAY_ROWS, 6,
  170.         NULL
  171.     );
  172.  
  173.     x += (int) xv_get(Lists[i], XV_WIDTH);
  174.  
  175.     tmp_s = (Scrollbar) xv_get(Lists[i], PANEL_LIST_SCROLLBAR);
  176.  
  177.     assert(tmp_s != 0);
  178.  
  179.     if (i + 1 < N_LISTS) {
  180.         xv_set(tmp_s,
  181.         XV_SHOW, FALSE,
  182.         NULL
  183.         );
  184.     }
  185.  
  186.     }
  187.     s = (Scrollbar) xv_get(Lists[5], PANEL_LIST_SCROLLBAR);
  188.     assert(s != 0);
  189.     notify_interpose_event_func(
  190.     /* tmp_s, */
  191.     xv_get(s, SCROLLBAR_NOTIFY_CLIENT),
  192.     sc_func,
  193.     NOTIFY_SAFE
  194.     );
  195.  
  196.     window_fit(p);
  197.     window_fit(f);
  198. fprintf(stderr, "%d\n", __LINE__);
  199.     xv_main_loop(f);
  200. }
  201.