GTK - Some GTK Questions...

Linux specific forum
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

GTK - Some GTK Questions...

Post by Progi1984 »

Hi,
Question #1 :
i find the solution to Set Window Color with the funciton "gtk_widget_modify_bg_" but how can i get this color ?

Thank you for advance
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Question #2 :
How can I set the position (x,y) and the size (width, height) of a label in a window ?
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Question #1 :

You can use gtk_widget_get_modifier_style(), modify the 'bg' member of the GtkRcStyle struct with your GdkColor then call gtk_widget_modify_style() passing the new GtkRcStyle.

Question #2 :
* set the position : gtk_widget_set_uposition() , works only for a widget outside a container.
* modifiy the size : gtk_widget_set_size_request ()
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Question 1 :
Have you got the declaration of the structure GtkRcStyle ? I'm on Windows...

Question 2 :
How can i do for positionning a widget in a gtkcontainer ?
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Question 1 :

GtkRcStyle, gtk is a crossplateform toolkit, this is the same struct for all OSes supported ;)

Question 2 :
The easier way is to add a GtkTable to a box then pack your widget in a cell of the table.
You can then play with the space before and/or after the cell.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
Airr
User
User
Posts: 49
Joined: Tue Oct 04, 2005 4:29 am
Contact:

Post by Airr »

Why not use GtkFixed and gtk_fixed_put?
"Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager.
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

For most applications, you should not use this container! It keeps you from having to learn about the other GTK+ containers, but it results in broken applications. With GtkFixed, the following things will result in truncated text, overlapping widgets, and other display bugs:

*

Themes, which may change widget sizes.
*

Fonts other than the one you used to write the app will of course change the size of widgets containing text; keep in mind that users may use a larger font because of difficulty reading the default, or they may be using Windows or the framebuffer port of GTK+, where different fonts are available.
*

Translation of text into other languages changes its size. Also, display of non-English text will use a different font in many cases.

In addition, the fixed widget can't properly be mirrored in right-to-left languages such as Hebrew and Arabic. i.e. normally GTK+ will flip the interface to put labels to the right of the thing they label, but it can't do that with GtkFixed. So your application will not be usable in right-to-left languages.

Finally, fixed positioning makes it kind of annoying to add/remove GUI elements, since you have to reposition all the other elements. This is a long-term maintenance problem for your application.
http://developer.gnome.org/doc/API/2.0/ ... Fixed.html
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Question 1 :
KarLKoX wrote:GtkRcStyle, gtk is a crossplateform toolkit, this is the same struct for all OSes supported ;)
Yep, but i know that GtkRcStyle must be already declared in the linux version so I want to get these declarations :)

Question 2 :
KarLKoX wrote:The easier way is to add a GtkTable to a box then pack your widget in a cell of the table.
You can then play with the space before and/or after the cell.
What is better : GtkTable or GtkFixed for easy moving and sizing ?
User avatar
Airr
User
User
Posts: 49
Joined: Tue Oct 04, 2005 4:29 am
Contact:

Post by Airr »

Progi1984 wrote: What is better : GtkTable or GtkFixed for easy moving and sizing ?
Based on the documentation, GtkTable. As to which is simpler, I'd say GtkFixed as long as you can live with the potential "gotcha's".

Not to hijack this thread, but what does PB-Linux use?

AIR.
"Programming is like Poetry. Sometimes the words just escape you..." -me, to my manager.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Question 1 :
Noone has the declaration of GtkRcStyle under Linux ?

Question 2 :
I finally use a GTKTable and that works... easily :)

Question 3 :
New Question : I load an image (always under Windows) with LoadImage. How can i draw this image in a GtkImage ?
Or How can I transform a hBitmap in GdkPixmap ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

1:

Code: Select all

Structure GtkRcStyle
  parent_instance.GObject
  *name.b
  *bg_pixmap_name.b[5]
  *font_desc.PangoFontDescription
  color_flags.l[5]
  fg.GdkColor[5]
  bg.GdkColor[5]
  text.GdkColor[5]
  base.GdkColor[5]
  xthickness.l
  ythickness.l
  *rc_properties.GArray
  *rc_style_lists.GSList
  *icon_factories.GSList
  PackedFlags.l
EndStructure
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Question 1:
ts-soft : Sorry to worry you again :
Can you give the declaration of :

Code: Select all

-GObject 
-PangoFontDescription 
-GdkColor
-GArray 
-GSList 
Thank you for advance :)
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Progi1984:

Just copy the gtk related resident files from the Linux Version of PB to Windows.
They should work there as well.
quidquid Latine dictum sit altum videtur
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

With the freak solution (very good solution : Thanks for it !),
The question #1 & #2 are solved. But the question #3 is always in stand by.

Question 3 :
New Question : I load an image (always under Windows) with LoadImage. How can i draw this image in a GtkImage ?
Or How can I transform a hBitmap in GdkPixmap ?
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Question #4 : Question for Fred or Freak, which techniques do you use to position and size gadgets in your windows : gtkfixed, gtktable, gtkbox, others ?
Post Reply