|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Images do not move with widgetThanks Dmitry. I found that my application would have the arrow images in the buttons _if_ I copied the image folder from the Keypad development folder into the Application development folder. That meant that the image was not embedded in the button so back to the brewing board.
I now have Key_Button defined as the private type:
47 type Gtk_Key_Button_Record is48 new Gtk.Button.Gtk_Button_Record with 49 record 50 Label : Gtk.Label.Gtk_Label; 51 Image_Access : Gtk.Image.Gtk_Image; 52 Box : Gtk.Box.Gtk_HBox; 53 Row : Positive; 54 Column : Positive; 55 end record; I have set the image in the record thus: 59 -- Set Icon if Image /= null.60 if Image /= null then 61 -- Save the image as Gtk_Image_Record addressed by Image_Access. 62 New_Key_Button.Image_Access := new Gtk.Image.Gtk_Image_Record; 63 New_Key_Button.Image_Access.all := Image.all; 64 65 -- Put image in box. 66 Gtk.Box.Pack_Start (In_Box => New_Key_Button.Box, 67 Child => New_Key_Button.Image_Access, 68 Expand => TRUE, 69 Fill => TRUE, 70 Padding => 4); 71 end if; -- Image /= null
87 -- Put the box in the button.88 Add (Container => New_Key_Button, 89 Widget => New_Key_Button.Box);
By my reckoning, line 62 allocates memory to Image_Access. Line 63 copies the data from the memory addressed by the parameter Image to the memory addressed by Image_Access. Therefore the button should always see the image. Not so! :( I still have the same problem that the image does not appear unless the development folder includes the image folder. Still at square one. Why does my image not travel with the button? The label allocated to the button in the same box travels okay. --Rick Duley North Perth, Western Australia http://rickduley.webs.com .-_|\ / \ perth *_.-._/ v aussie : 0409 106 049 o'seas : +61 409 106 049 -------------------------------------------- "Wise men profit more from fools than fools from wise men; for the wise shun the mistakes of fools but fools do not imitate the successes of the wise." Marcus Cato (234-149 BC) _______________________________________________ gtkada mailing list gtkada@... http://lists.adacore.com/mailman/listinfo/gtkada |
|
|
Re: Images do not move with widgetOn Sun, 12 Jul 2009 18:32:58 +0800, you wrote:
> Thanks Dmitry. I found that my application would have the arrow images in > the buttons _if_ I copied the image folder from the Keypad development > folder into the Application development folder. That meant that the image > was not embedded in the button so back to the brewing board. > > I now have Key_Button defined as the private type: [...] > By my reckoning, line 62 allocates memory to Image_Access. Line 63 copies > the data from the memory addressed by the parameter Image to the memory > addressed by Image_Access. No it does not. Image data can be allocated on the server or client side of the rendering system. Independently on that your code merely copies Ada proxy object. For further information see GDK pixbuf: http://library.gnome.org/devel/gdk-pixbuf/2.16 Images shall be created using Gtk_New and never copied. > Still at square one. Why does my image not travel with the button? The > label allocated to the button in the same box travels okay. You should first answer the question where comes the image from. Is it a file, an icon factory, or an embedded image. If it is a file, the file path used in Gtk_New should be valid to the time of call. If it is an icon factory the factory should be available for the program. For embedded images see: http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#3 You create an XPM image file using GIMP, for example. Once you have it (x.xpm), you can convert it into Ada code using the xpm2ada utility. That will give you three files x.ads, x-image.ads, x-image.adb. You bind them to your project and use the function X.Image in your program, each time you need a Gtk_Image object. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de _______________________________________________ gtkada mailing list gtkada@... http://lists.adacore.com/mailman/listinfo/gtkada |
| Free embeddable forum powered by Nabble | Forum Help |