> rafa wrote:
> > I have tested align method of Fl_Button, but I can not get to solve my
> > problem.
> > Image inside Fl_Button is center horizontally, but not vertically.
>
> Hmm, it should be centered.
>
> The following works for me in 1.1.9 and 1.3.x; when you compile
> the following, doesn't the image show up centered?
>
> In this example, I purposefully made the button much larger
> than the image so centering is clear.
>
> Compare this code to yours to see what's wrong.
> I find I can even comment out the align() and the image remains
> centered in all directions, as apparently that's the default.
>
> Maybe your original image isn't symmetrically cropped?
>
> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> #include <FL/Fl_Shared_Image.H> // fl_register_images
> #include <FL/Fl_Pixmap.H>
> #include <FL/Fl_Button.H>
> static const char *x_xpm[] = { // this is a .xpm file
> "14 14 2 1",
> " c None",
> "x c #585858",
> " ",
> " xxxxx ",
> " xxxxxxxxx ",
> " xxxxxxxxx ",
> " xx xxx xx ",
> " xxx x xxx ",
> " xxxx xxxx ",
> " xxxx xxxx ",
> " xxx x xxx ",
> " xx xxx xx ",
> " xxxxxxxxx ",
> " xxxxxxxxx ",
> " xxxxx ",
> " "};
>
> int main() {
> fl_register_images(); // initialize image lib
> Fl_Window win(720,486); // make a window
> Fl_Button but(10,10,100,100); // make a button
> Fl_Pixmap x(x_xpm); // assign xpm to a pixmap
> but.image(x); // attach pixmap to button as image
> but.align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
> win.show();
> return(Fl::run());
> }
Greg, your code is correct, icon is placed centered. I have modified for load
my icon from xpm file, and work fine too.
Then I have checked my code, but mine is in the same order than yours. I don't
understand where is the problem. The only difference is your code don't use
dynamic variables, but this is a silly thing.
Here is my method. As you can see it is like yours.
void FrameWnd::Create()
{
// Initiliza image lib
fl_register_images();
// Load open file XPM icon.
//m_FolderIcon = new Fl_XPM_Image("folder-open.xpm");
// Place widgets on main window.
this->begin();
// Edit for Icon name.
m_Edit1 = new Fl_Input(80,10,100,25,"Icon name");
// Edit for Icon path.
m_Edit2 = new Fl_Input(80,40,100,25,"Icon path");
// Icon Size.
m_Choice1 = new Fl_Choice(80,70,100,25,"Icon Size");
// Edit for Command.
m_Edit3 = new Fl_Input(80,100,100,25,"Command");
// Button for icon path explore.
m_Button1 = new Fl_Button(180,40,50,50,"");
m_FolderIcon = new Fl_XPM_Image("folder-open.xpm");
m_Button1->image(m_FolderIcon);
m_Button1->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
// Button for command explore.
m_Button2 = new Fl_Button(180,100,100,25,"explore");
// Accept button.
m_Button3 = new Fl_Button(20,130,100,35,"Accept");
// Cancel button.
m_Button4 = new Fl_Button(125,130,100,35,"Cancelar");
this->end();
// Adding Buttons callbacks.
m_Button1->callback(Button1_SCB, this);
m_Button2->callback(Button2_SCB, this);
m_Button3->callback(Button3_SCB, this);
m_Button4->callback(Button4_SCB, this);
}
Thanks,
Rafa
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk