Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » motif font/color control
motif font/color control [message #431365] Thu, 11 March 2004 19:36 Go to next message
Pete MacLiesh is currently offline Pete MacLieshFriend
Messages: 14
Registered: July 2009
Junior Member
How does one manipulate the color / weight which motif controls choose for
their "disabled" font? By which I mean the text (foreground) color / weight
of controls like Button and Text when they are setEnabled(false).

Basically the foreground colors chosen on win32 and gtk are legible; those
on motif are not - they come out (by default) as very faint grey. I'm not
sure whether it's the color or the weight controlling it - it may be the
weight because only some small percentage of the pixels appear to be
rendered.

This is on a windows 24bit color display via exceed with every font I could
find installed.

I think my question boils down to

"How do I know what X resources control the choice of fonts/colors for
eclipse motif controls in their various states (in particular Text, Button,
Combo) ?

The FAQs I have found are too trivial, and Google searching for hours also
yields just "lite" examples which don't answer this question.

TIA

PMac
Re: motif font/color control [message #431613 is a reply to message #431365] Fri, 12 March 2004 14:50 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Pete,

There isn't an X resource that controls this, it computes an "appropriate"
disabled appearance based upon the enabled appearance. The closest resource
I can find is XmNlabelInsensitivePixmap which is obviously not what's needed
here.

If this is for an app you're writing then a workaround is to change the
widget's font to bold whenever it's disabled, as this makes its disabled
appearance more readable. The snippet below demonstrates this (and this
would only be appropriate when running on motif). Beyond doing this I can't
find a way to set or override the native behaviour.

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10, 10, 300, 100);
Color red = new Color(display, 255, 0, 0);

// black, non-bold
Button b1 = new Button(shell, SWT.PUSH);
b1.setText("button 1");
b1.setEnabled(false);
b1.setBounds(10, 10, 50, 30);

// black, bold
Button b2 = new Button(shell, SWT.PUSH);
b2.setText("button 2");
b2.setEnabled(false);
b2.setBounds(70, 10, 50, 30);
FontData data[] = b2.getFont().getFontData();
for (int i = 0; i < data.length; i++) {
data[i].setStyle(data[i].getStyle() | SWT.BOLD);
}
Font newFont = new Font(display, data);
b2.setFont(newFont);

// red, non-bold
Button b3 = new Button(shell, SWT.PUSH);
b3.setText("button 3");
b3.setEnabled(false);
b3.setBounds(130, 10, 50, 30);
b3.setForeground(red);

// red, bold
Button b4 = new Button(shell, SWT.PUSH);
b4.setText("button 4");
b4.setEnabled(false);
b4.setBounds(190, 10, 50, 30);
b4.setForeground(red);
data = b4.getFont().getFontData();
for (int i = 0; i < data.length; i++) {
data[i].setStyle(data[i].getStyle() | SWT.BOLD);
}
Font newFont2 = new Font(display, data);
b4.setFont(newFont2);

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
newFont.dispose();
newFont2.dispose();
red.dispose();
display.dispose();
}

Grant

"Pete MacLiesh" <pmac@nospam.tensilica.nospam.com> wrote in message
news:c2qerf$tjd$1@eclipse.org...
>
> How does one manipulate the color / weight which motif controls choose for
> their "disabled" font? By which I mean the text (foreground) color /
weight
> of controls like Button and Text when they are setEnabled(false).
>
> Basically the foreground colors chosen on win32 and gtk are legible; those
> on motif are not - they come out (by default) as very faint grey. I'm not
> sure whether it's the color or the weight controlling it - it may be the
> weight because only some small percentage of the pixels appear to be
> rendered.
>
> This is on a windows 24bit color display via exceed with every font I
could
> find installed.
>
> I think my question boils down to
>
> "How do I know what X resources control the choice of fonts/colors for
> eclipse motif controls in their various states (in particular Text,
Button,
> Combo) ?
>
> The FAQs I have found are too trivial, and Google searching for hours also
> yields just "lite" examples which don't answer this question.
>
> TIA
>
> PMac
>
>
Re: motif font/color control [message #431980 is a reply to message #431613] Fri, 12 March 2004 17:09 Go to previous message
Pete MacLiesh is currently offline Pete MacLieshFriend
Messages: 14
Registered: July 2009
Junior Member
Thanks Grant.

Guess I'll sublcass those controls which are in my parts of the app and try
what you suggest.

Of course all the rest of the platform will remain as is ... but that's what
you get for using Motif.

PMac


"Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
news:c2sig4$a2a$1@eclipse.org...
> Pete,
>
> There isn't an X resource that controls this, it computes an "appropriate"
> disabled appearance based upon the enabled appearance. The closest
resource
> I can find is XmNlabelInsensitivePixmap which is obviously not what's
needed
> here.
>
> If this is for an app you're writing then a workaround is to change the
> widget's font to bold whenever it's disabled, as this makes its disabled
> appearance more readable. The snippet below demonstrates this (and this
> would only be appropriate when running on motif). Beyond doing this I
can't
> find a way to set or override the native behaviour.
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setBounds(10, 10, 300, 100);
> Color red = new Color(display, 255, 0, 0);
>
> // black, non-bold
> Button b1 = new Button(shell, SWT.PUSH);
> b1.setText("button 1");
> b1.setEnabled(false);
> b1.setBounds(10, 10, 50, 30);
>
> // black, bold
> Button b2 = new Button(shell, SWT.PUSH);
> b2.setText("button 2");
> b2.setEnabled(false);
> b2.setBounds(70, 10, 50, 30);
> FontData data[] = b2.getFont().getFontData();
> for (int i = 0; i < data.length; i++) {
> data[i].setStyle(data[i].getStyle() | SWT.BOLD);
> }
> Font newFont = new Font(display, data);
> b2.setFont(newFont);
>
> // red, non-bold
> Button b3 = new Button(shell, SWT.PUSH);
> b3.setText("button 3");
> b3.setEnabled(false);
> b3.setBounds(130, 10, 50, 30);
> b3.setForeground(red);
>
> // red, bold
> Button b4 = new Button(shell, SWT.PUSH);
> b4.setText("button 4");
> b4.setEnabled(false);
> b4.setBounds(190, 10, 50, 30);
> b4.setForeground(red);
> data = b4.getFont().getFontData();
> for (int i = 0; i < data.length; i++) {
> data[i].setStyle(data[i].getStyle() | SWT.BOLD);
> }
> Font newFont2 = new Font(display, data);
> b4.setFont(newFont2);
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> newFont.dispose();
> newFont2.dispose();
> red.dispose();
> display.dispose();
> }
>
> Grant
>
> "Pete MacLiesh" <pmac@nospam.tensilica.nospam.com> wrote in message
> news:c2qerf$tjd$1@eclipse.org...
> >
> > How does one manipulate the color / weight which motif controls choose
for
> > their "disabled" font? By which I mean the text (foreground) color /
> weight
> > of controls like Button and Text when they are setEnabled(false).
> >
> > Basically the foreground colors chosen on win32 and gtk are legible;
those
> > on motif are not - they come out (by default) as very faint grey. I'm
not
> > sure whether it's the color or the weight controlling it - it may be the
> > weight because only some small percentage of the pixels appear to be
> > rendered.
> >
> > This is on a windows 24bit color display via exceed with every font I
> could
> > find installed.
> >
> > I think my question boils down to
> >
> > "How do I know what X resources control the choice of fonts/colors for
> > eclipse motif controls in their various states (in particular Text,
> Button,
> > Combo) ?
> >
> > The FAQs I have found are too trivial, and Google searching for hours
also
> > yields just "lite" examples which don't answer this question.
> >
> > TIA
> >
> > PMac
> >
> >
>
>
Previous Topic:TreeViewer lazy initialization (fill on expand)
Next Topic:Multiple composites in a ScrolledComposite with Grid layout?
Goto Forum:
  


Current Time: Sat Dec 20 07:29:20 GMT 2014

Powered by FUDForum. Page generated in 0.12843 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software