Albrecht Schlosser wrote:

Meanwhile I did my own test with a modified test/menubar.cxx, ...

For those who are interested to see what happens, I attach a diff
file here. I used it with test/menubar.cxx and with a 30x30 px
png file "icon.png".

It shows the test case (a "@icon" symbol) in both a normal widget
label and a menu item in the Font menu.

The *working* part is the green "diamond", the not working parts
are the red square and the shown icon.png (if it can be loaded).

Albrecht
--- test/menubar.cxx    2009-09-18 09:38:38.030467100 +0200
+++ private/menubar.cxx 2009-12-09 22:53:12.357640900 +0100
@@ -28,6 +28,7 @@
 #include <FL/Fl.H>
 #include <FL/Fl_Box.H>
 #include <FL/Fl_Double_Window.H>
+#include <FL/Fl_PNG_Image.H>
 #include <FL/Fl_Menu_Bar.H>
 #include <FL/Fl_Toggle_Button.H>
 #include <FL/Fl_Menu_Button.H>
@@ -140,6 +141,7 @@
     {"Engrave",        0, 0, 0, 0, FL_ENGRAVED_LABEL},
     {"Shadow", 0, 0, 0, 0, FL_SHADOW_LABEL},
     {"@->",    0, 0, 0, 0, FL_SYMBOL_LABEL},
+    {"@icon",  0, 0, 0, 0, FL_SYMBOL_LABEL},
     {0},
   {"&International",0,0,0,FL_SUBMENU},
     {"Sharp Ess",0x0000df},
@@ -183,8 +185,35 @@
 
 Fl_Menu_* menus[4];
 
+
+/* Some help stuff */
+
+#define BP fl_begin_polygon()
+#define EP fl_end_polygon()
+#define BCP fl_begin_complex_polygon()
+#define ECP fl_end_complex_polygon()
+#define BL fl_begin_line()
+#define EL fl_end_line()
+#define BC fl_begin_loop()
+#define EC fl_end_loop()
+#define vv(x,y) fl_vertex(x,y)
+
+static void draw_png_icon(Fl_Color c) {
+       fl_color(FL_RED);
+       fl_rectf(0,0,30,30);
+       fl_color(FL_GREEN);
+       BP; vv(10.0,0.0); vv(0.0,10.0); vv(-10.0,0.0); vv(0.0,-10.0); EP;
+       fl_color(c);
+       static Fl_PNG_Image *i = 0;
+       if (!i) i = new Fl_PNG_Image("icon.png");
+       i->draw(50, 50);//position problem on menuitem
+}
+
 int main(int argc, char **argv) {
   //Fl::set_color(Fl_Color(15),0,0,128);
+
+  fl_add_symbol("icon", draw_png_icon, 0);
+
   for (int i=0; i<99; i++) {
     char buf[100];
     sprintf(buf,"item %d",i);
@@ -213,6 +242,11 @@
   Fl_Box b(200,200,200,100,"Press right button\nfor a pop-up menu");
   window.resizable(&mb);
   window.size_range(300,400,0,400);
+  
+  Fl_Box b2(WIDTH-210,350,200,40,"@icon test box");
+  b2.box(FL_DOWN_BOX);
+  b2.align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
+
   window.end();
   window.show(argc, argv);
   return Fl::run();
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to