#14294: wxGrid Render to wxDC method

17 views
Skip to first unread message

wxTrac

unread,
May 11, 2012, 7:20:22 AM5/11/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.4
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby:
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------
Attached patch adds drawing a wxGrid cell selection to a wxDC for print or
display purposes.

#13834 causes problems with overflow from the bounding rectangle as can be
seen in the grid sample.

Also there is a problem with OSX-Cocoa clipping region and cell lines and
it is untested with GTK.

This is the first public cut. I have added a very minimal example to the
wxGrid sample. No doubt there will be some changes required.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294>

wxTrac

unread,
May 14, 2012, 12:34:08 AM5/14/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:1>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.4
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby:
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------

Comment(by johnr):

Don't know what went wrong there. Anyway if there is any interest in this
I will tidy up the sample demo with output options, a persistent display
output, look at a couple of glitches in the code and upload an updated
patch.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:1>

Alec Ross

unread,
May 14, 2012, 4:06:05 AM5/14/12
to wx-...@googlegroups.com
Hi John,

I, for one, am interested. BR, Alec

In message <052.177080452a1831...@wxsite.net>, wxTrac
<nor...@wxsite.net> writes
--
Alec Ross

wxTrac

unread,
May 14, 2012, 7:26:39 AM5/14/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:2>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby:
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------
Changes (by vadz):

* milestone: 2.9.4 =>


Comment:

Yes, there is definitely interest. Just no time to look at it just yet
(and perhaps not before 2.9.4, but this depends on the patch complexity),
please do upload the real patch. Thanks!


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:2>

wxTrac

unread,
May 15, 2012, 5:59:35 AM5/15/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:3>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby:
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------

Comment(by johnr):

Good, I was reluctant to spend valuable time finishing docs, demo routines
etc if there was no interest. At present it works on MSW but the OSX
clipping region for DrawAllGridLines seems to not like having a user scale
!= 1. Probably something I have done.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:3>

wxTrac

unread,
May 26, 2012, 8:19:22 PM5/26/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:7>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby: 14319, 14319, 14319
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------

Comment(by johnr):

Added patch for grid interface docs and sample code changes.

Patch to grid.h/cpp to follow. Works perfectly on MSW but still have a
problem with OSX-Cocoa clipping region.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:7>

wxTrac

unread,
May 27, 2012, 7:27:52 AM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:8>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby: 14319, 14319, 14319
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------

Comment(by johnr):

Attached the patch grid.h/cpp.

Tested on Win7 32/64, XP32 100%
OSX-Cocoa 10.7.x see notes below. I do not have a linux platform.

In addition to #13834 on all platforms I have tested there is a problem
with the ClippingRegion for OSX. Any scale != 1 results in the clipping
region being applied with a wrong scaling factor. It can be seen when
using sample menu item "Render setup/Zoom 125%" +/- with "Logical 50 unit
margin" +/- "Render G5:P30".

In the demo I scale to 1.25 but the figures that work for the
ClippingRegion need *1.2 not 1.25. Perhaps a rounding error somewhere but
I haven't found it so far and probably will not be able to look at it
again for 2-3 weeks.

I have left some rectangle draw code in DrawAllGridLines() that can be
used for testing that the passed dimensions are ok and for testing whether
the clipping region is ok. Also a workaround that I use in my own code to
avoid applying the clipregion if userscale != 1. Most of this code is
commented.

More problems with SVN which didn't add one of the functions in grid.h so
I added it manually. Don't know what is going on there either but maybe I
need to move to git.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:8>

wxTrac

unread,
May 27, 2012, 8:27:57 AM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:9>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby: 14319
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------
Changes (by vadz):

* blockedby: 14319, 14319, 14319 => 14319


Comment:

Thanks for the update, the patch was indeed corrupted but I applied it
manually and now am in process of polishing it a bit, notably I want to
change the `DrawAllGridLines()` to split it in two functions as it's not
really doing drawing "all" the grid lines any longer and both the name and
the function logic are confusing. I won't dare to touch `Render()` but I
think it would be really nice to refactor it to be less intimidating too,
no function should be 200+ lines long.

But anyhow, let me commit the changes to `DrawAllGridLines()` first.

Thanks again!


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:9>

wxTrac

unread,
May 27, 2012, 9:00:11 AM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:10>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby: 14319
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------

Comment(by VZ):

(In [71575]) No changes, just refactor wxGrid::DrawAllGridLines().

Extract the actual drawing of the lines into a new DoDrawGridLines()
method.

This will be used by the upcoming commits for drawing grid lines for a
part of
the grid only, see #14294.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:10>

wxTrac

unread,
May 27, 2012, 9:00:15 AM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:11>

#14294: wxGrid Render to wxDC method
--------------------------------------+-------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Keywords: wxGrid Render Print wxDC | Blockedby: 14319
Patch: 1 | Blocking:
--------------------------------------+-------------------------------------

Comment(by VZ):

(In [71576]) Add wxGrid::DrawRangeGridLines().

This method draws only the grid lines for the cells in the specified range
and
not for all of them.

It is not used yet but will be by the upcoming wxGrid::Render(), see
#14294.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:11>

wxTrac

unread,
May 27, 2012, 9:00:20 AM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:12>

#14294: wxGrid Render to wxDC method
--------------------------+-------------------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Resolution: fixed | Keywords: wxGrid Render Print wxDC
Blockedby: 14319 | Patch: 1
Blocking: |
--------------------------+-------------------------------------------------
Changes (by VZ):

* status: new => closed
* resolution: => fixed


Comment:

(In [71577]) Add wxGrid::Render() for drawing the grid to any wxDC.

In particular, this allows to print the grid contents easily.

Closes #14294.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:12>

wxTrac

unread,
May 27, 2012, 7:21:44 PM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:13>

#14294: wxGrid Render to wxDC method
--------------------------+-------------------------------------------------
Reporter: johnr | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: GUI-generic | Version: 2.9-svn
Resolution: fixed | Keywords: wxGrid Render Print wxDC
Blockedby: 14319 | Patch: 1
Blocking: |
--------------------------+-------------------------------------------------

Comment(by johnr):

Replying to [comment:9 vadz]:
> I think it would be really nice to refactor it to be less intimidating
too, no function should be 200+ lines long.

Agreed. It is a little complex and one change can wreak havoc so I have
found. I will hive off some of Render()'s components in another ticket.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14294#comment:13>
Reply all
Reply to author
Forward
0 new messages