Discussion:
Drawing native check-boxes of different size using wxRendererNative on GTK
(too old to reply)
kate.kulikova
2009-05-12 15:44:02 UTC
Permalink
Hello!

I was trying to draw native check-boxes of different size using
wxRendrerNative on Linux. But every time I passed different rectangles
to wxRendererGTK::DrawCheckBox() function I got the same size of check-
box picture. For small rectangles some of the parts of check-box image
were just cut out.

I looked into the code of wxWidgets and in the file
"wxWidgets-2.8.9\src\gtk\renderer.cpp" I found the following call in
wxRendererGTK::DrawCheckBox() function (line 549):

gtk_paint_check
(
button->style,
gdk_window,
state,
flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
NULL,
button,
"cellcheck",
dc.LogicalToDeviceX(rect.x)+2,
dc.LogicalToDeviceY(rect.y)+3,
13, 13
);

As I can see from this piece of code all check-boxes on GTK are forced
to have 13x13 size and their position is tuned by 2 and 3 pixels.

So, my question is the following: is there any opportunity (or is it
planned) for drawing native check-boxes with different sizes on GTK
(as similar functionality works well on Windows as far as I know)?
Vadim Zeitlin
2009-05-12 17:04:09 UTC
Permalink
On Tue, 12 May 2009 08:44:02 -0700 (PDT) "kate.kulikova" <***@gmail.com> wrote:

k> I looked into the code of wxWidgets and in the file
k> "wxWidgets-2.8.9\src\gtk\renderer.cpp" I found the following call in
k> wxRendererGTK::DrawCheckBox() function (line 549):
k>
k> gtk_paint_check
k> (
k> button->style,
k> gdk_window,
k> state,
k> flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
k> NULL,
k> button,
k> "cellcheck",
k> dc.LogicalToDeviceX(rect.x)+2,
k> dc.LogicalToDeviceY(rect.y)+3,
k> 13, 13
k> );
k>
k> As I can see from this piece of code all check-boxes on GTK are forced
k> to have 13x13 size and their position is tuned by 2 and 3 pixels.

This has changed slightly in the trunk, now the size isn't hardcoded any
more but retrieved using gtk_widget_style_get("indicator_size") and
"indicator_spacing". This is better, of course, but still doesn't really
help you as it still does draw them in a single size.

k> So, my question is the following: is there any opportunity (or is it
k> planned) for drawing native check-boxes with different sizes on GTK
k> (as similar functionality works well on Windows as far as I know)?

I don't know if gtk_paint_check() is going to work well with other sizes
but I think it should and there is no reason to not allow it. The trouble
is that we still need to ensure that it draw them in the correct size and
with correct spacing by default and this means that we need to be able to
retrieve them both from wxRenderer somehow and the existing
GetCheckBoxSize() method is not enough for this as it can return only size
but not spacing. Accordingly, we'd need to change API slightly, either by
returning wxRect from GetCheckBoxSize() or adding a GetCheckBoxMargin()
method (the latter is probably better). And we'd also need to add a margin
parameter to DrawCheckBox() itself.

But once this is done there would be no problem with using rect.width and
rect.height as the checkbox size. If you can make this work, please don't
hesitate to submit patch (http://trac.wxwidgets.org/wiki/HowToSubmitPatches)
implementing this.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
kate.kulikova
2009-05-15 12:18:52 UTC
Permalink
Hello Vadim.

Thank you very much for your detailed answer. I see that there is no
way for now to draw check-boxes of custom size using wxRendererNative
on GTK.

And you are right, gtk_paint_check() works pretty fine and is able to
draw check-box of different sizes, so I found it very useful.

I'm not sure that I've got all necessary skills to write the patch for
wxWidgets now, I think I won't be able to implement this stuff with
sufficient quality. But I've read the HowToSubmitPatches page and your
coding style and guidelines document with much interest.

Thank you again for your advice and support.

Kate.
kate.kulikova
2009-05-15 12:20:05 UTC
Permalink
Hello Vadim.

Thank you very much for your detailed answer. I see that there is no
way for now to draw check-boxes of custom size using wxRendererNative
on GTK.

And you are right, gtk_paint_check() works pretty fine and is able to
draw check-box of different sizes, so I found it very useful.

I'm not sure that I've got all necessary skills to write the patch for
wxWidgets now, I think I won't be able to implement this stuff with
sufficient quality. But I've read the HowToSubmitPatches page and your
coding style and guidelines document with much interest.

Thank you again for your advice and support.

Kate.

Loading...