Hello all
I would like to use your collective wisdom to try to improve an aspect of a program which is bugging me. The object is to present a summary of a lot of detail from elsewhere in the app, and a convenient layout is a grid like a spreadsheet - each column is a case, each row is an aspect of the cases. Grid lines are not essential, and I can assume that all cell entries are left justified. In some cases the cell entry is a summary, e.g. the number of errors of a certain kind, and it would be handy to be able to hover or click on the cell and get more detail. So far I have a (more or less) working summary display, by using a RichTextEdit and using tab stops to separate the columns. The problems are that the entries are occasionally too long for a column width, so the next column starts at the wrong tab, and I can't get the extra detail. I have thought of three ways of improving the effect: a. Draw the text of the entries directly on the display using Canvas>>text:at:, which will ensure correct positioning but not give the extra detail. The calculation of the cell locations looks unSmalltalkish (like going back to my early days programming in Fortran), but it should work. b. Populate the pane with a grid of TextEdit subpanes, and enter the contents of a cell in each subpane. I should be able to attach a tool tip text to any subpane for the extra detail. It would be necessary to locate and size the subpanes programmatically, and I am not sure how to do this. c. Embed an Excel spreadsheet using ActiveX, and use cell comments for the extra detail. I have never tried this, and I can't get the sample ActiveX use of Excel in AXTypeLibraryAnalyzer class>>example3 to work, so I am a bit apprehensive. I would be grateful for any comments from the gurus in this group. If it's documented somewhere that I haven't found, just give me pointers. Thanks in advance Peter Kenny |
Peter,
> b. Populate the pane with a grid of TextEdit subpanes, and enter the > contents of a cell in each subpane. I should be able to attach a tool tip > text to any subpane for the extra detail. It would be necessary to locate > and size the subpanes programmatically, and I am not sure how to do this. If I understand you correctly there's a LayoutManager that will do most of that for you. As in s := Shell show. s view layoutManager: GridLayout new. s view layoutManager rows: 5; columns: 3. 1 to: 5 do: [:r | 1 to: 3 do: [:c | s view addSubView: (t := TextEdit new). t name: 'c' , c printString , 'r' , r printString]]. "later" (s view viewNamed: 'c2r3') text: 'hello' -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
In reply to this post by Peter Kenny-2
Peter,
> I would be grateful for any comments from the gurus in this group. If it's > documented somewhere that I haven't found, just give me pointers. I was wondering if a ListView might not also be a possible solution to this. You couldn't use tool tip (they are broken in ListViews because of a Windows bug) but perhaps, when the user selected a cell, you could display the extra info in another text edit or on the StatusBar. The only caveat might be that I can't recall how easy it is to get info on which column is "selected" when the mouse is clicked. Anyone? -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
Ian
Many thanks for both ideas. i have been playing with the GridLayout approach, and with a few tweaks I think I will get close to what I want. i can see the idea of a multi-column ListView is attractive, and I may pursue it later, but for the sake of getting something working quickly I shall probably stick to GridLayout for now. Looking again a the title of the post, I wonder why I ddn't think of searching and finding it withoiut troubling the group. I suppose it's just experience tells one how to search! Thanks again Peter |
In reply to this post by Ian Bartholomew-19
Ian, Peter,
> I was wondering if a ListView might not also be a possible solution to > this. Personally, I would try very hard to use this option in preference to drawing my own graphics. At least if there weren't too many columns. It seems to be feasible to use several tens of columns, e.g. p := ListPresenter show: 'Enhanced list view' on: (ListModel on: (1 to: 100)). 99 timesRepeat: [p view addColumn]. > The only caveat might be that I can't recall how easy it is to get info on > which column is "selected" when the mouse is clicked. Anyone? I don't know of any easy way myself. I note that the EditableListView does this, and goes via the mouse position and a Window's hit-test (in #fullItemFromPoint:, one of the loose methods it adds to ListView). -- chris |
"Chris Uppal" <[hidden email]> wrote in message
news:421b4cbf$1$38041$[hidden email]... > Ian, Peter, > > > I was wondering if a ListView might not also be a possible solution to > > this. > > Personally, I would try very hard to use this option in preference to drawing > my own graphics. At least if there weren't too many columns. Chris Thanks. In fact, after playing with a GridLayout of TextEdits for a while, I have switched to the ListView approach, which seems to be working out. It was a struggle to get the ListViewColumn>>getContentsBlock: method to produce the effect I wanted - every column had the intended contents of the last column. In the end I made the argument the result of applying Compiler class>>evaluate: to the text of the block, but there must be an easier way. However, I now have a way of making it work in a workspace, and today I shall try to turn it into a method in my app. There will generally not be more than a dozen or so columns, so it works OK from the space point of view. > > > The only caveat might be that I can't recall how easy it is to get info on > > which column is "selected" when the mouse is clicked. Anyone? > > I don't know of any easy way myself. I note that the EditableListView does > this, and goes via the mouse position and a Window's hit-test (in > #fullItemFromPoint:, one of the loose methods it adds to ListView). > > -- chris > I have been using the standard ListView so far, but I shall look at EditableListView to see if I can make my method work more smoothly. Peter |
Peter>
> It was a struggle to get the > ListViewColumn>>getContentsBlock: method to produce the effect I wanted - > every column had the intended contents of the last column. That sounds as if you are doing something roughly like: 1 to: columns size do: [:i || block | block := [:row | row columnAt: i]. (columns at: i) getContentsBlock: block]. which will have that effect. It /should/ work, but doesn't (at least until D6 is released). That's because the way the block [:row | row columnAt: i] is implemented -- it shares the 'i' variable with the containing method invocation, rather than having its own private variable. So as the loop proceeds the value of 'i' is updated, but all the created blocks share access to the /same/ 'i' variable. The best (and cleanest) way to avoid the problem is to create the block in a separate method: 1 to: columns size do: [:i || block | block := self makeGetContentBlockForColumn: i. (columns at: i) getContentsBlock: block]. where: makeGetContentsBlockForColumn: anInteger ^ [:row | row columnAt: i] This problem normally only occurs when you create several blocks in a loop (or in some threading situations). -- chris |
Chris
Thanks - it's good to know I am not a complete idiot. Your method may be a cleaner fudge than mine, but it still looks like a fudge! I have a working method now in my app, so all is well - and the suggestion of the ListView was just right, so thanks again to you and Ian. Peter |
Free forum by Nabble | Edit this page |