Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Printing a Table
|
Re: Printing a Table [message #466167 is a reply to message #466102] |
Wed, 04 January 2006 07:49 |
Sebastian Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Hello. I have a method to print the current view of a table, but is it
somehow possible to print the whole table and not only a cut-out of it?
Here is my code to print the current cut-out of the table I see on the
screen:
print.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
Point tableSize = table.getSize();
final Image tableImage =
new Image(Display.getCurrent(), 750, tableSize.y);
GC tableGC = new GC(table);
tableGC.copyArea(tableImage, 0, 0);
Shell shell = new Shell();
PrintDialog dialog = new PrintDialog(shell);
PrinterData data = dialog.open();
Printer printer = new Printer(data);
ImageData tableImageData = tableImage.getImageData();
tableImageData.transparentPixel = -1;
int scaleFactor = 5;
Rectangle trim = printer.computeTrim(-500, -500, 0, 0);
if (printer.startJob("DeployHistory-Print")) {
GC gc = new GC(printer);
if (printer.startPage()) {
gc.drawImage(
tableImage,
0,
0,
tableImageData.width,
tableImageData.height,
-trim.x,
-trim.y,
scaleFactor * tableImageData.width,
scaleFactor * tableImageData.height);
printer.endPage();
}
printer.endJob();
}
printer.dispose();
tableGC.dispose();
}
});
|
|
| | | |
Re: Printing a Table [message #466273 is a reply to message #466242] |
Thu, 05 January 2006 17:54 |
Joe Mihalich Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hey,
I would otherwise be happy to post the code, but
I have a rather large printing infrastructure that this code
works off of, and it's not something where I can just post
the contents of a method.
Regarding your question though, there are two solutions:
1) Pre-calculate the max column width (using text extents)
for each row of a page. Then make column 2 (for instance)
start at the same location for each row where the "x" of
column 2 is greater than the max width of column 1.
2) Instead of drawing row 1, then row 2, then row 3, reverse your
loop, and draw by columns. that way you don't have to
pre-calculate
the max width of every column...you draw column 1 first keeping
the maximum width of all column 1 for a given page as you draw
each cell. Then when you get to column 2, you know the the
max "x", so just continue your look, setting your column 2
starting
"x" to be greater than that max value.
I actually chose number 2 in my implementation.
Hope that helps.
Joe
"Sebastian" <s-bayerlein@gmx.de> wrote in message
news:4cd4aac847387d6a193e454258890d9a$1@www.eclipse.org...
> Hello.
>
> Thank you for your answers. I thought so, that it won't become easy to
> implement it, because I found nothing about this problem. Does soembody
> know, if it will be included in later versions of Eclipse and SWT?
> @Joe
> Can you please post me your code, that I can have a look on it? I also
> tried to do this, but I never had such a structure like in the table.
> f.e.:
> 1st_column 2nd_column 3rd_column
> test1 test2 test3
> test234 a_much_to_long_text a_new_text abc def
> ghi
> What can I do, that all entries of a column are among each other and not
> shifted?
>
|
|
|
Re: Printing a Table [message #466543 is a reply to message #466102] |
Wed, 11 January 2006 10:07 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Hi,
sorry for the late answer. You could try KPrint
see http://www.kupzog.de/fkmk_uk/Programming/Downloads/downloads .html
This is a SWT formatted printing utility that also supports printing SWT
tables (and KTables).
Regards,
Friederich
Sebastian wrote:
> Hi all.
>
> Does somebody know how to print a table in SWT? I don't want to print
> only the content, I need to print the whole table.
> Thanks SB
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel +49 241 9979356
Fax +49 221 726670
www.kupzog.de/fkmk
|
|
|
Goto Forum:
Current Time: Fri Dec 27 00:38:11 GMT 2024
Powered by FUDForum. Page generated in 0.03573 seconds
|