GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Nov 24, 2014 4:15 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Changing the 3d effect in GtkLabel
PostPosted: Mon Feb 27, 2012 2:56 pm 
Offline
Familiar Face

Joined: Sat Nov 19, 2011 10:28 am
Posts: 7
Hi,
I have created a button and have added label into the button container, when i disable the button the label text is having a 3d effect, It has a white shade on the text. Kindly help in removing this grayed out effect.
Code:
   GtkWidget* pButton;
    GtkWidget* pLabel;
    GdkColor ButtonColour;

    // Create Button
    pButton = gtk_button_new();

    // Fix it on the background
    gtk_fixed_put(GTK_FIXED(pBackground), pButton, CHANGEX(nFixedX,nwidth),
    CHANGEY(nFixedY,nheight));
    gtk_widget_set_size_request(pButton, CHANGEX(nSizeX,nwidth), CHANGEY(nSizeY,nheight));

    // Create label to fix
    pLabel = gtk_label_new((gchar*) csButtonText.c_str());
    gtk_widget_show(pLabel);

    // Modify font
    gtk_widget_modify_font(pLabel, pFont);

    // Set size for the label
    gtk_widget_set_size_request(pLabel, CHANGEX((nSizeX/2),nwidth), CHANGEY((nSizeY/2),nheight));
    // Justify to center
    gtk_label_set_justify(GTK_LABEL(pLabel), GTK_JUSTIFY_CENTER);
    // Set line wrap for the Label
    gtk_label_set_line_wrap(GTK_LABEL(pLabel), TRUE);

    //Add  label to Button
    gtk_container_add(GTK_CONTAINER(pButton), pLabel);

    // Modify BackGround
    gtk_widget_modify_bg(pButton, GTK_STATE_NORMAL, &m_Color);
    gtk_widget_modify_bg(pButton, GTK_STATE_INSENSITIVE, &m_Black);
    gtk_widget_modify_bg(pButton, GTK_STATE_PRELIGHT, &m_Color);

    // Modify Foreground
    ButtonColour.red = 65535;
    ButtonColour.blue= 65535;
    ButtonColour.green = 65535;

    gtk_widget_modify_fg(pLabel, GTK_STATE_NORMAL, &ButtonColour);
    gtk_widget_modify_fg(pLabel, GTK_STATE_PRELIGHT, &ButtonColour);
    gtk_widget_modify_fg(pLabel, GTK_STATE_SELECTED, &ButtonColour);
    gtk_widget_modify_fg(pLabel, GTK_STATE_ACTIVE, &ButtonColour);

    // Change the color of button label in insensitive state
    ButtonColour.red = 65535/2;
    ButtonColour.blue= 65535/2;
    ButtonColour.green = 65535/2;
    gtk_widget_modify_fg(pLabel, GTK_STATE_INSENSITIVE, &ButtonColour);


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Mon Feb 27, 2012 7:09 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 778
Location: UK
Hi,

The greying out of an object that has been made insensitive to user action is normal and is an indicator to the user that you can not interact with that object. For example a greyed out button (one that has been made insensitive) can not be clicked on. Note that GTK does not give a 3D look to buttons as you are looking directly on top of the button and not from an angle.

If you can explain more about what you really want then I could give better details of what you should be doing. But at the moment it seams that what you are trying to do is poor user interface design.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Mon Feb 27, 2012 10:26 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
If you want to ensure that it looks the same, instead of disabling the button you should disconnect the signal handler to the button.
However, I also agree strongly with Errol. Grayed out buttons visually let a user know that they are disabled and removing this visual cue will just confuse users as well as stuff up your accessibility compliance.
If there's something visually out of place (you mention something about a white shadow) could you please attach a screenshot?


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Tue Feb 28, 2012 6:11 am 
Offline
Familiar Face

Joined: Sat Nov 19, 2011 10:28 am
Posts: 7
Hi Errol and paul,
Thank u for ur reponse. I understand the motive behind the greying out but as per our requirements the button disabled should have label text only in grey color without having a white shade. I have attached a screen shot(sample) to show the shading effect. I had some work around with the themes too, when i use crux theme the button looks in the way i want it but with the default theme this effect occurs. How do i change this using code.

Thanks,
Kowsalya


Attachments:
File comment: Shadow effect in button with white shade
Shadow.png
Shadow.png [ 53.32 KiB | Viewed 1093 times ]
Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Tue Feb 28, 2012 7:44 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 778
Location: UK
Kowsalya,

Please do not use mobile / cell phone SMS/text short hand. We do have an international audience whose first language is not English and it can be hard to read. Also it does make you appear childish and willing only to take short cuts.

You have still not explained the background as to why you want to change the default behaviour of the button.

Looking at the screen shot, the theme engine has probably done more than change the colour. It may have set the font to outline. So for your application you will need to think of every possible action that a theme engine can do and act on it or write your own theme for your application. Both are not small jobs.

As Paul said, you really need to think about accessibility so that users that are disabled can still use your application and other can find buttons and other actions with ease. Note accessibility is not just how things look but also actions. Some one here wrote a bit of code that had a strobe effect on the screen. This affects me as my disability is epilepsy and this could have caused a seizure.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Tue Feb 28, 2012 11:01 am 
Offline
Familiar Face

Joined: Sat Nov 19, 2011 10:28 am
Posts: 7
Errol,
I am sorry for using SMS text language.

The background behind why I want to change the default appearance is, I am reproducing a screen which is already available in windows OS developed using vc++, there the disabled button has a grey text without the white shade. So I wanted to give similar look to the screen developed in linux using gtk+, hence i have modified the label text color when disabled to grey.
I understand why I am not able to change this effect as you have explained about the accessibility problems. Thanks for your response.

I tried using the Crux theme and I am able to get the desired look on my application (without white shade). I have set this crux theme using gtk_settings_set_string_property(pSettings, "gtk-theme-name", "Crux", NULL); in my application. Now I wanted to know whether i can achieve this through some gtk APIs itself so that i can bring this same effect on all flavours where Crux engine is actually absent.

Thanks,
Kowsalya


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Thu Mar 01, 2012 5:56 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 778
Location: UK
Do you know which version of GTK you are compiling with? The answer will depend on if you are using v2.xx or v3.xx as the API has changed a bit between them.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Fri Mar 02, 2012 9:15 am 
Offline
Familiar Face

Joined: Sat Nov 19, 2011 10:28 am
Posts: 7
Gtk version 2.12

Thanks,
Kowsalya


Top
 Profile  
 
 Post subject: Re: Changing the 3d effect in GtkLabel
PostPosted: Wed Mar 07, 2012 8:06 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 778
Location: UK
Sorry for the delay answering.

I would suggest reading up on resource files. This is a way of affecting the styles, colours etc. of widgets see - http://live.gnome.org/GnomeArt/Tutorials/GtkThemes and API at http://developer.gnome.org/gtk/stable/gtk-Resource-Files.html you do not have to have them as separate files, you could have the text in your source. If you read the documentation it is not going to be a case of writing just one API call, but much more complex as you will need to take into account many different cases.

If doing this still does not give you the result you want then you may want to use a custom widget to get the effect you want.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group