[wx-dev] wxMSW: Themed borders?

Robin Dunn robin at alldunn.com
Mon Jan 29 16:26:14 PST 2007


Vadim Zeitlin wrote:
> On Fri, 26 Jan 2007 12:05:23 -0800 Robin Dunn <robin at alldunn.com> wrote:
> 
> RD> Currently the generic wxSearchCtrl is using wxBORDER_SIMPLE to have a 
> RD> single pixel border on wxMSW, but it is the default black one and 
> RD> doesn't match what is typically drawn by the themed wxTextCtrl on XP so 
> RD> it ends up looking out of place.  Is it possible, and would it make 
> RD> sense, to have a border style that emulates the default textctrl border 
> RD> on each platform?
> 
>  Probably yes but I wonder if one of the existing border styles doesn't
> already correspond to wxTextCtrl border?

Nope.  See the following images.  The right column are real wxTextCtrls 
with default style, and the center column is plain wxControl with a 
white background and the labeled border style.  For the unthemed version 
the wx.BORDER_DEFAULT and wx.BORDER_SUNKEN matches the text ctrl, but 
for the themed version nothing matches.

http://alldunn.com/temp/borders-XP-themed.png
http://alldunn.com/temp/borders-XP-unthemed.png

Just for kicks I ran the sample on the other platforms too, and found 
that wx.BORDER_DEFAULT doesn't match the wxTextCtrl border, but 
wx.BORDER_SUNKEN does...

http://alldunn.com/temp/borders-GTK.png
http://alldunn.com/temp/borders-OSX.png


> 
> RD> Other controls tend to have this same border too so maybe the style
> RD> should be something like wxBORDER_DEFAULT_CONTROL.
> 
>  We already have wxBORDER_DEFAULT so this would IMO be confusing. We could
> make GetDefaultBorder() return this new wxBORDER_TEXT border style however.
> OTOH it might not make sense for all controls and the current default of
> wxBORDER_NONE could be more sane.
> 
> RD> Or would it make more sense to put themed border styles in the native 
> RD> renderers and require the custom controls to draw the border themselves?
> 
>  Not if we can avoid it.

I've done a bit of googling today and it looks like the way this has 
been solved by others so far is to handle WM_NCPAINT and draw the border 
there.

http://www.codeproject.com/cs/miscctrl/RichTextBoxEx.asp
http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c8729__1/
http://www.shorterpath.com/develop/zonearticles/ThemedCustomControl.asp



-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wx-dev mailing list