PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Possible to add not tiled backgrounds? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Possible to add not tiled backgrounds?
#37
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 1  
Hi,
i´m adding a little skin option to into my tool. At this point, i´ve found no way to add an image to the background eg. right aligned no-repeat. Is this possible in php-gtk2? Have you done this allready?

Btw.. if i uses png-images as background, cmd crashes. If i use gif, all work fine! Do you know this problem. I´m on windows vista!

Regards,
Andreas
 
  The administrator has disabled public write access.
#39
kksou (Admin)
Admin
Posts: 254
graph
User Online Now Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 7  
Hi Andreas,

Are you adding the background image to GtkWindow? Or some other widgets?

Regards,
/kksou
 
 
Last Edit: 2008/01/23 01:56 By kksou.
  The administrator has disabled public write access.
#40
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 1  
I´m adding the images to the GtkWindow and some GtkEventBox.

For both, i need this feature, if possible.

Here is an screenshot, where you can see, what i do on my application. The GtkEventBox is e.g. behind the top search area.


Fullscreen: http://www.camya.com/ecc/images/20080120_newbg1024.gif

Regards,
Andreas
 
 
Last Edit: 2008/01/23 06:37 By ecc.
  The administrator has disabled public write access.
#41
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 1  
Ok, found an solution... but this isnt 100% :-(

Code:
$pixbuf = GdkPixbuf::new_from_file('image.gif');
$gcObject = $gtkWindow->get_style()->black_gc; # get GdkGCWin32 object
$pixbuf->render_to_drawable($gtkWindow->window, $gcObject, 0, 0, 0, 0, 
$pixbuf->get_height(), $pixbuf->get_width(), GDK_RGB_DITHER_NORMAL);
# $gtkWindow->window gets gdkWindow from gtkWindow
I´m using glade for gui creation. So, the image is not show. If i add
Code:
$gtkWindow->show();
i see the image a second, and than php crash :-) Maybe you have an idea. Btw... GdkPixbuf::render_to_drawable() is deprecated: use GdkDrawable::draw_pixbuf() So, maybe we can try also draw_pixbuf for that!
 
 
Last Edit: 2008/01/23 23:23 By ecc.
  The administrator has disabled public write access.
#42
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 1  
Ok, i think, this looks 100% valid and not deprecated... but... :-)
.. the image only flashes and than is invisible. How to make it sticky?

Code:
$pixbuf = GdkPixbuf::new_from_file('image.gif');
$gcObject = $gtkWindow->get_style()->black_gc;
$gtkWindow->window->draw_pixbuf($gcObject, $pixbuf, 0, 0, 0, 0);
Regards, Andreas http://www.camya.com/
 
  The administrator has disabled public write access.
#43
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 1  
Some resources:

python gtk2 doku... very good!!!!
http://www.pygtk.org/pygtk2reference/class-gdkdrawable.html#method-gdkdrawable--draw-pixbuf

php-gtk2 doku... very hmmm... ok, links to other gtk2 dokus will be a fine addition :-)
This could help every php-gtk2 developer, because this can easyly abstracted to to php-gtk2 syntax
http://php-gtk2.de/manual/en/html/gdk/gdk.gdkdrawable.method.draw_pixbuf.html
 
  The administrator has disabled public write access.
#44
kksou (Admin)
Admin
Posts: 254
graph
User Online Now Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 7  
Hi Andreas,

I've a couple of possible solutions. One of them is similar to what you have described above, i.e. using GdkDrawable::draw_pixbuf().

Before I come out with sample codes for this, could you please let me know a bit more of what you have in mind:

1) I saw the screen of your application. (Very nice, indeed!) So, you want to have some untiled background image in the search area of your application? It already looked quite crowded. So where do you intend to put this background image?

2) Do you want to align the image to the left, right, top or bottom of that GtkEventBox?

3) Does the size of the search area (where you want to put the background image) changes when the user stretch the window to a different size? Or does the size of that area remain fix?

Regards,
/kksou
 
 
Last Edit: 2008/01/24 01:32 By kksou.
  The administrator has disabled public write access.
#45
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 1  
Hi kksou,

1. The users can simply create own themes by changing some images. So my plan is to give them the ablity to add an background for the gtkWindow and and the the left (navigation) and right pane (details). (maybe also some other widgets). Also the search area background is skinable. (ok, if i say skinable, i only mean background change)

2. That is the plan :-) If this is possible, this could be great.

3. Yes, the area changes to different size.

Regards,
Andreas
 
  The administrator has disabled public write access.
#46
kksou (Admin)
Admin
Posts: 254
graph
User Online Now Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 2 Weeks ago Karma: 7  
Hi Andreas,

1. Aligning background image to top left is relatively easier:
Recipe 418: How to place a background image in GtkWindow - Part 3 - align top left using GtkStyle, or
Recipe 420: How to place a background image in GtkWindow - Part 5 - align top left - using GdkDrawable draw_pixbuf?

ttt

2. Aligning background image to bottom right is a bit more challenging:
Recipe 421: How to place a background image in GtkWindow - Part 6 - align bottom right - GdkDrawable draw_pixbuf?

3. Have also included one sample code that illustrates changing the background image on-the-fly (guess this is what you have in mind):
Recipe 422: How to change background image on the fly?

Note that all the above sample codes work for GtkWindow. I'll come out with similar examples for GtkEventBox. But if you're in a hurry, they use about the same technique.

Regards,
/kksou

p.s. With regards to your question
Btw.. if i uses png-images as background, cmd crashes. If i use gif, all work fine! Do you know this problem. I´m on windows vista!

If you've noticed, I used png image files for all these sample codes. I suspect it's your version of php-gtk. You might want to download a copy of the windows binary from http://gtk.php.net/download.php. Try that copy of php-gtk. It should work right out of the box.
 
 
Last Edit: 2008/01/24 15:18 By kksou.
  The administrator has disabled public write access.
#47
ecc (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Possible to add not tiled backgrounds? 7 Months, 1 Week ago Karma: 1  
Hi,
your examples work very good for the window. Good work. Thank you. I think, i will implement this feature soon.

Now the eventboxes :-) It seams, that there is an problem with the default background and png alpha. If the eventbox has an "visible window", the assigned background png with alpha is shown. But because of the "visible window", you cant look through the png image. You only see the eventbox background (grey box by default). Have you an idea how to asign png with alpha transperency to an eventbox without "visible window" so you can see the window background trought the png?

Thank you for you great research!

Andreas
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Copyright © 2006-2008. kksou.com. All Rights Reserved