Hi all,
I want to make #print method in ListView class. (to print ListView's contents) Does anyone tried this ? Any suggestions ? Regards Bruno |
Bruno,
> I want to make #print method in ListView class. > (to print ListView's contents) > > Does anyone tried this ? > Any suggestions ? Do you mean "print" as in #printOn: (text for developers - aListView contents printOn: should do the trick) or do you want a hardcopy on paper? I suspect (even fear<g>) the latter, which is not a simple task in general. First, there is no way to access the control's drawing code (so you will need to write your own), and even if there were a way to get to it, there is no guarantee that it would work at typical printer resolutions. Pagination is also an issue on paper. Ian has a printing goodie that might be a good starting point if paper is your objective. Does that help? Bill -- Wilhelm K. Schwab, Ph.D. [hidden email] |
"Bill Schwab" <[hidden email]> escribió en el mensaje
news:aph81h$bhb$[hidden email]... > Bruno, > > > I want to make #print method in ListView class. > > (to print ListView's contents) > > > > Does anyone tried this ? > > Any suggestions ? > > Do you mean "print" as in #printOn: (text for developers - aListView > contents printOn: should do the trick) or do you want a hardcopy on paper? > I suspect (even fear<g>) the latter, which is not a simple task in > First, there is no way to access the control's drawing code (so you will > need to write your own), and even if there were a way to get to it, there is > no guarantee that it would work at typical printer resolutions. Pagination > is also an issue on paper. Ian has a printing goodie that might be a good > starting point if paper is your objective. > > Does that help? Yes, I mean a Hard copy on paper. Thanks you. Well, I'll be working. Regards Bruno |
Bruno,
If you can use my Printer extensions (Windows NT, 2000 and XP) and if you just want a straight printout then it's not too difficult. The Printer extensions handle all the paging for you, all you have to do is get the list contents into a RichTextEdit. As a demo. This first bit just creates a ListPresenter on an enhanced ListView that we can test with. l := ListPresenter show: 'Enhanced list view'. l view primaryColumn text: 'Column One'; getTextBlock: [:o | o at: 1]; width: 120. l view addColumn: (ListViewColumn new text: 'Column Two'; getTextBlock: [:o | o at: 2]). (l view columnAtIndex: 2) width: 120. l view addColumn: (ListViewColumn new text: 'Column Three'; getTextBlock: [:o | o at: 3]). (l view columnAtIndex: 3) width: 120. l list: ((1 to: 100) collect: [:index | Array with: 'A-' , index printString with: 'B-' , index printString with: 'C-' , index printString]). Evaluate all that in a workspace and you should create and display a test list with 3 columns and 100 entries. The next step is to create a RichTextEdit and copy the contents of the list into it. This is where you can adjust the formatting, add headers etc. With the latest RichTextEdit I think you could have a proper table with lines around but I haven't looked into that. rte := RichTextEdit new asPrintingRichTextEdit. l list do: [:each | (l view columns addFirst: l view primaryColumn; yourself) do: [:col | rte appendPlainText: ('%30s' sprintfWith: (col textFromRow: each))]. rte appendPlainText: String lineDelimiter]. Finally you just print the contents of the RichTextEdit using the default IdePrinter (or one that you have set up manually). IdePrinter default print: rte Regards Ian |
Thanks very much Ian !
Regards Bruno "Ian Bartholomew" <[hidden email]> escribió en el mensaje news:J9bv9.17$XN5.4460@wards... > Bruno, > > If you can use my Printer extensions (Windows NT, 2000 and XP) and if you > just want a straight printout then it's not too difficult. The Printer > extensions handle all the paging for you, all you have to do is get the list > contents into a RichTextEdit. > > As a demo. This first bit just creates a ListPresenter on an enhanced > ListView that we can test with. > > l := ListPresenter show: 'Enhanced list view'. > l view primaryColumn > text: 'Column One'; > getTextBlock: [:o | o at: 1]; > width: 120. > l view addColumn: (ListViewColumn new > text: 'Column Two'; > getTextBlock: [:o | o at: 2]). > (l view columnAtIndex: 2) width: 120. > l view addColumn: (ListViewColumn new > text: 'Column Three'; > getTextBlock: [:o | o at: 3]). > (l view columnAtIndex: 3) width: 120. > l list: ((1 to: 100) collect: [:index | > Array > with: 'A-' , index printString > with: 'B-' , index printString > with: 'C-' , index printString]). > > Evaluate all that in a workspace and you should create and display a test > list with 3 columns and 100 entries. The next step is to create a > RichTextEdit and copy the contents of the list into it. This is where you > can adjust the formatting, add headers etc. With the latest RichTextEdit > think you could have a proper table with lines around but I haven't looked > into that. > > rte := RichTextEdit new asPrintingRichTextEdit. > l list do: [:each | > (l view columns addFirst: l view primaryColumn; yourself) do: [:col | > rte appendPlainText: ('%30s' sprintfWith: (col textFromRow: each))]. > rte appendPlainText: String lineDelimiter]. > > Finally you just print the contents of the RichTextEdit using the default > IdePrinter (or one that you have set up manually). > > IdePrinter default print: rte > > Regards > Ian > > > |
Free forum by Nabble | Edit this page |