RE: wxMac cosmetic oddities?

13 views
Skip to first unread message

Yoav Gonen

unread,
Feb 15, 2009, 7:51:01 AM2/15/09
to wx-u...@lists.wxwidgets.org
About the color picker, there's no carbon-specific implementation; on
Mac, the generic implementation is used, and is indeed ugly. We wrote
our own implementation for Carbon, I'll be happy to share it as is - I
just don't have time to go through the patch making business. It
requires a change in include/wx/clrpicker.h (#including the carbon
file), adding the src/mac/carbon/clrpicker.cpp file and NOT compiling
src/generic/clrpickerg.cpp into the library (i.e. changes in the xcode
project).

-----Original Message-----
From: wx-users...@lists.wxwidgets.org
[mailto:wx-users...@lists.wxwidgets.org] On Behalf Of Leto Atreides
Sent: Sunday, February 15, 2009 2:32 PM
To: wx-u...@lists.wxwidgets.org
Subject: wxMac cosmetic oddities?

I have noticed two things in wxMac that make my UI look ugly and was
wondering if anyone has better suggestions to work around these.

Firstly is the wxColourPicker widget. Normally on wxGTK and wxMSW,
this is a button with a rectangle on it that shows the current
selected color. In wxMac its a button, with an ugly colored rectangle
background (see picture).

Second is when I change the background color of a wxTextField it wont
change it immediately (not talking about RTF styles, just background
color), it only changes it if I give the text field focus, or if I
append text to it. The append text method (which is my current work
around), still leaves a small portion of the wxTextfield the original
color (until it gets focus)

I have attached images showing the both oddities, now in the second
case, I dont need a wxTextfield, I need more like a label with a
border that I can change the background and text color, but the label
widget from what I have seen doesnt work with the border flags, any
ideas?


*** eSafe scanned this email for malicious content ***
*** IMPORTANT: Do not open attachments from unrecognized senders ***

Stefan Csomor

unread,
Feb 15, 2009, 1:55:56 PM2/15/09
to wx-u...@lists.wxwidgets.org
Hi Leto

> I have attached images showing the both oddities, now in the second
> case, I dont need a wxTextfield, I need more like a label with a
> border that I can change the background and text color, but the label
> widget from what I have seen doesnt work with the border flags, any
> ideas?

you mean you currently call SetBackgroundColour, then you could call a
Refresh after, this should fix the missing update

and wxStaticText does not show borders for you ? on OSX only ?

Best,

Stefan

Robert Roebling

unread,
Feb 15, 2009, 2:51:22 PM2/15/09
to wx-u...@lists.wxwidgets.org

Yoav Gonen wrote:

> About the color picker, there's no carbon-specific implementation; on
> Mac, the generic implementation is used, and is indeed ugly. We wrote
> our own implementation for Carbon, I'll be happy to share it as is

Couldn't you just put the raw code as a "nearly-a-patch" on Trac?

Robert

Leto Atreides

unread,
Feb 15, 2009, 7:32:04 AM2/15/09
to wx-u...@lists.wxwidgets.org
I have noticed two things in wxMac that make my UI look ugly and was
wondering if anyone has better suggestions to work around these.

Firstly is the wxColourPicker widget. Normally on wxGTK and wxMSW,
this is a button with a rectangle on it that shows the current
selected color. In wxMac its a button, with an ugly colored rectangle
background (see picture).

Second is when I change the background color of a wxTextField it wont
change it immediately (not talking about RTF styles, just background
color), it only changes it if I give the text field focus, or if I
append text to it. The append text method (which is my current work
around), still leaves a small portion of the wxTextfield the original
color (until it gets focus)

I have attached images showing the both oddities, now in the second

wxColourPicker.png
TextBox.png

Yoav Gonen

unread,
Feb 16, 2009, 4:03:23 AM2/16/09
to wx-u...@lists.wxwidgets.org
Sorry, I couldn't even login. Last time I submitted a patch was in the
old SourceForge tracker site, and I seem to have lost my user/password.
Just now I tried to register with a different username, and I got a
"database is locked" internal error.
If anyone wants, I can send the files to someone personally.


Yoav Gonen wrote:

Robert

_______________________________________________
wx-users mailing list
wx-u...@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wx-users

Stefan Csomor

unread,
Feb 16, 2009, 3:18:10 AM2/16/09
to wx-u...@lists.wxwidgets.org
>>> you mean you currently call SetBackgroundColour, then you could call a
>>> Refresh after, this should fix the missing update
>
> I do refresh and it works on wxMSW and wxGTK but not on wxMac.

ok, reproduced, under 10.4 things work as expected (when using the system
option mac.textcontrol-use-mlte is set aas 1, as otherwise the unicode
textcontrol is used which doesn't support background colour), but under 10.5
there is a stuck refresh somewhere in the system, as event when the toplevel
window is moved it gets refreshed correctly, I'll try to find a workaround)

Thanks,

Stefan

Stefan Csomor

unread,
Feb 16, 2009, 4:30:07 AM2/16/09
to wx-u...@lists.wxwidgets.org
Hi

using a 10.4+ API with weak reference works for me, change in textctrl.cpp
the wxMacMLTEHIViewControl::SetBackground to:

void wxMacMLTEHIViewControl::SetBackground( const wxBrush &brush )
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OSX_VERSION_10_4
if (HITextViewSetBackgroundColor != NULL)
{
RGBColor col = MAC_WXCOLORREF(brush.GetColour().GetPixel()) ;

float component[4] ;
component[0] = col.red / 65536.0 ;
component[1] = col.green / 65536.0 ;
component[2] = col.blue / 65536.0 ;
component[3] = 1.0 ; // alpha

CGColorRef color = CGColorCreate( wxMacGetGenericRGBColorSpace() ,
component );
HITextViewSetBackgroundColor( m_textView , color );
}
else
#endif
{
wxMacMLTEControl::SetBackground( brush ) ;
}
}

Thanks,

Stefan

Stefan Csomor

unread,
Feb 16, 2009, 6:03:28 AM2/16/09
to wx-u...@lists.wxwidgets.org
Hi

> CGColorRef color = CGColorCreate( wxMacGetGenericRGBColorSpace() ,
> component );
> HITextViewSetBackgroundColor( m_textView , color );

add a

CGColorRelease(color);

please, HITextViewSetBackgroundColor retains the color

Thanks,

Stefan

The Devils Jester

unread,
Feb 15, 2009, 7:48:44 PM2/15/09
to wx-u...@lists.wxwidgets.org
>> you mean you currently call SetBackgroundColour, then you could call a
>> Refresh after, this should fix the missing update

I do refresh and it works on wxMSW and wxGTK but not on wxMac.

>> and wxStaticText does not show borders for you ? on OSX only ?

They dont on wxGTK for me, I havent tried on wxMac, since I need a
fairly universal solution.

On Sun, Feb 15, 2009 at 12:55 PM, Stefan Csomor
<cso...@advancedconcepts.ch> wrote:
> Hi Leto
>
>> I have attached images showing the both oddities, now in the second
>> case, I dont need a wxTextfield, I need more like a label with a
>> border that I can change the background and text color, but the label
>> widget from what I have seen doesnt work with the border flags, any
>> ideas?
>

>


> and wxStaticText does not show borders for you ? on OSX only ?
>
> Best,
>
> Stefan
>
>
>

> _______________________________________________
> wx-users mailing list
> wx-u...@lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>

--
If you make something that any idiot can use, only idiots will use it.

Leto Atreides

unread,
Feb 16, 2009, 3:43:40 AM2/16/09
to wx-u...@lists.wxwidgets.org
I appreciate the time and effort.

Leto Atreides

unread,
Feb 16, 2009, 1:34:42 PM2/16/09
to wx-u...@lists.wxwidgets.org
Thank you that works perfectly, though you had a typo in the posted
code, you said
MAC_OSX_VERSION_10_4

When it should have been
MAC_OS_X_VERSION_10_4

Other than that, it works great.


Is there anyway you can get the color picker code from Yoav Gonen and
integrate it into wxMac?

Stefan Csomor

unread,
Feb 17, 2009, 2:52:23 AM2/17/09
to wx-u...@lists.wxwidgets.org
Hi Leto

On 16.02.09 19:34, "Leto Atreides" <thedevi...@gmail.com> wrote:

> Thank you that works perfectly, though you had a typo in the posted
> code, you said
> MAC_OSX_VERSION_10_4
>
> When it should have been
> MAC_OS_X_VERSION_10_4

oops, sorry and thanks for spotting it ...

> Is there anyway you can get the color picker code from Yoav Gonen and
> integrate it into wxMac?

as I assume other platforms might get into similar problems (native controls
not allowing background change), I'll try to add an option to the generic
control picker, this option would derive from a bitmap button instead of a
button and carries the colour + label as a bitmap

Best,

Stefan


Leto Atreides

unread,
Feb 17, 2009, 3:39:47 AM2/17/09
to wx-u...@lists.wxwidgets.org
> oops, sorry and thanks for spotting it ...

As it wouldnt compile with that typo, I am sure you already noticed
it, otherwise you wouldnt have known the fix worked, I just wanted
anyone searching the lists to be aware of that small typo so they can
get it to work too.

> as I assume other platforms might get into similar problems (native
> controls
> not allowing background change), I'll try to add an option to the
> generic
> control picker, this option would derive from a bitmap button
> instead of a
> button and carries the colour + label as a bitmap

That would be the ideal solution, thanks. If you manage it without
too many modifications to the existing code, if you would post the
changes here so that I can retro fit 2.8.9, as you have done with your
other fixes, that would be appreciated. If it becomes too complex,
then I can just wait for the 2.8.10 release, since its not a critical
need.

Stefan Csomor

unread,
Feb 17, 2009, 8:34:28 AM2/17/09
to wx-u...@lists.wxwidgets.org
Hi

>> Is there anyway you can get the color picker code from Yoav Gonen and
>> integrate it into wxMac?
>
> as I assume other platforms might get into similar problems (native controls
> not allowing background change), I'll try to add an option to the generic
> control picker, this option would derive from a bitmap button instead of a
> button and carries the colour + label as a bitmap

I've committed a variant to clrpickerg.cpp and .h, as r58967 to use a bitmap
button set

wxCLRBTN_USES_BMP_BUTTON to 1 when building

Best,

Stefan

Stefan Csomor

unread,
Feb 18, 2009, 2:19:41 AM2/18/09
to wx-u...@lists.wxwidgets.org
Hi

On 17.02.09 09:39, "Leto Atreides" <thedevi...@gmail.com> wrote:

>> oops, sorry and thanks for spotting it ...
>
> As it wouldnt compile with that typo, I am sure you already noticed
> it, otherwise you wouldnt have known the fix worked, I just wanted
> anyone searching the lists to be aware of that small typo so they can
> get it to work too.

it just compiled fine using xcode for me, resolved to empty, and thus the
condition still triggered, only when building against 10.3 SDK (where it
still would trigger) it would have lead to a compile error, as there the
function wouldn't be known.. it isn't the first time such a preproc problem
has happened to me, but last time it took me a long time staring at the code
until I realized what was really happening

Best,

Stefan

Reply all
Reply to author
Forward
0 new messages