Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!pictel!harling From: harling@pictel.uucp (Dan Harling) Newsgroups: comp.windows.open-look Subject: Re: Help modifying textsw scrollbar Message-ID: <1991Jun24.222255.2677@pictel.uucp> Date: 24 Jun 91 22:22:55 GMT References: <1991Jun20.210038.5036@pictel.uucp> <1991Jun24.170403.1381@pictel.uucp> Sender: Dan Harling Organization: PictureTel Corporation Lines: 94 For those of you who are interested, I have succeeded in using two scrollbars on a text subwindow for displaying an array subrange, despite discouragement from official and unofficial channels. Problem Description: -The display function prints one screenful of data to the text subwindow, starting with the current origin coordinates. -Clicking on the vertical scrollbar changes the Y origin and calls the display function with the new coordinates. -Clicking on the horizontal scrollbar changes the X origin and calls the display function with the new coordinates. Unfortunately, the vertical scrollbar that comes as part of the TEXTSW package seems to be internally dependent on the text display, so that the elevator proportions depend on the window contents rather than on my code. Solution: After creating the window (array_frame) and text subwindow (array_text), Scrollbar horiz_scroll, vert_scroll, old_scroll; /* existing vertical scrollbar */ Xv_window view; Rect *rect; /* * View 0 owns the vertical scrollbar. Find it and hide it. */ view = (Xv_window)xv_get(array_text, OPENWIN_NTH_VIEW, 0); old_scroll = (Scrollbar)xv_get(view, WIN_VERTICAL_SCROLLBAR); xv_set(old_scroll, XV_SHOW, FALSE, NULL); /* * Get scrollbar rectangle. The location and dimensions * will be used to position the new scrollbar in the same place. */ rect = (Rect *)xv_get(old_scroll, XV_RECT); /* * Create a new vertical scrollbar, owned by the text pane, * using location and size of old_scroll. The handle is stored * in the frame for later access. */ vert_scroll = (Scrollbar)xv_create(array_text, SCROLLBAR, SCROLLBAR_DIRECTION, SCROLLBAR_VERTICAL, SCROLLBAR_COMPUTE_SCROLL_PROC, array_compute_scroll, XV_X, rect->r_left, XV_Y, rect->r_top, XV_WIDTH, rect->r_width, XV_HEIGHT, rect->r_height, NULL); xv_set(array_frame, XV_KEY_DATA, VERT_SCROLL_KEY, vert_scroll, NULL); /* * Create a horizontal scrollbar, owned by the text pane. * the handle is stored in the frame for later access. */ horiz_scroll = (Scrollbar)xv_create(array_text, SCROLLBAR, SCROLLBAR_DIRECTION, SCROLLBAR_HORIZONTAL, SCROLLBAR_COMPUTE_SCROLL_PROC, array_compute_scroll, XV_SHOW, TRUE, NULL); xv_set(array_frame, XV_KEY_DATA, HORIZ_SCROLL_KEY, horiz_scroll, NULL); Summary: The vertical scrollbar that was created with the text subwindow is located and made invisible. Its coordinates are used to create a new vertical scrollbar in the same position. A horizontal scrollbar is also created. The scrollbars call a SCROLLBAR_COMPUTE_SCROLL_PROC (array_compute_scroll) that determines which scrollbar was pressed, determines the new origin coordinates, and prints a new subrange of the array. Conclusion: The XView toolkit makes many things easy to do; however, there have been a number of things (such as this problem) which apparently go beyond the anticipation of the designers, and require quite a lot of effort to accomplish. This is, of course, in keeping with the "90-10" rule for when using toolkits: A good toolkit allows you to do 90% of your work in 10% of the time; it will also require you to use the remaining 90% of your time to bypass "features" in order to accomplish the remaining 10% of your work. ______________________________________________________________________ Daniel A. Harling uunet!pictel!harling PictureTel, Inc. Rockport, MA Peabody, MA Opinions expressed herein are not necessarily those of PictureTel, Inc.; they are MINE, ALL MINE! (So there.) ---- === ====