Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!gatech!emory!stiatl!meo From: meo@stiatl.UUCP (Miles O'Neal) Newsgroups: comp.windows.x Subject: Re: Scrolling a spreadsheet inside a Viewport Message-ID: <6651@stiatl.UUCP> Date: 25 Aug 89 15:39:54 GMT References: <15318@umn-cs.CS.UMN.EDU> Reply-To: meo@stiatl.UUCP (Miles O'Neal) Distribution: usa Organization: Sales Technologies Inc., "The Procedure IS the product" Lines: 75 In article <15318@umn-cs.CS.UMN.EDU> kulkarni@umn-cs.CS.UMN.EDU (Srinivas R. Kulkarni) writes: | | I am developing a small spreadsheet sort of application using |Xaw. I am using X11R3. | | Since I want the spreadsheet to scroll both horizontally and |vertically, I have implemented the spreadsheet canvas as the child of a |viewport widget. | |concise problem description: |^^^^^^^^^^^^^^^^^^^^^^^^^^ | I want Column titles on the top row and Row titles in the |leftmost column of my spreadsheet. The Column titles scroll ONLY |horizontally and similarly the Row titles scroll ONLY vertically. | That is the problem. I am not quite sure if (and how) I can |achieve such 'partial' scrolling. | |a few things I tried: |^^^^^^^^^^^^^^^^^^^^^ |I thought of using label widgets for the Column titles and making |them the children of the Viewport's horizontall scroll bar using |XtNameToWidget(viewport, "horizontal") but that's out of question |since a scrollbar/viewport widget can have only child. So I created |a form widget as the child of my viewport widget and made the |canvas and the column/row label widgets the child of my form widget. In addition to the suggestions someone else made, there is another solution. It involves a bit more work, but has some advantages. Don't use a viwport widget. Use a form widget with something like the following layout. +----------------------------------------------------------------------+ | sub-form widget containing labels containing column titles | +----------------------------------------------------------------------+ | sub-form | | | widget | | | containing | | | labels | | | containing | This are contains the cell widgets (label, | | row titles | or whatever) | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +----------------------------------------------------------------------+ Only create enough cell widgets to fill your screen. I didn't draw the scrollbars above, but attach them wherever you want them. The scrollbar action routines would change internal spreadsheet cell pointers to point to the "active" cells. These would then be mapped into the cell widgets on the screen. For large spreadsheets, this is MUCH less memory-intensive than having lots and lots of widgets. For any size spreadsheet, this should give you much faster scrolling than having the viewport tell a whole bunch of widgets to move/unmap/map themselves. We did a srcolling menu based on this. We originally tried the classic approaches, and discarded them one by one for memory and/or speed reasons. This was not an academic excersize; this was a real-world solution to real- world problems. It works VERY well. -Miles (if I disappear from the net, it is because I was shot for giving away trade secrets...)