mirror of
https://github.com/fltk/fltk.git
synced 2026-05-25 17:42:14 +08:00
Control resizing behavior of UI buttons
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@13099 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+63
-39
@@ -89,6 +89,7 @@ main(int argc, // I - Number of command-line arguments
|
||||
{
|
||||
Fl_Double_Window *window;// Main window
|
||||
Fl_Button *button;// Buttons
|
||||
Fl_Group *grp; // Groups
|
||||
Fl_File_Icon *icon; // New file icon
|
||||
|
||||
|
||||
@@ -109,52 +110,75 @@ main(int argc, // I - Number of command-line arguments
|
||||
tty = new Fl_Simple_Terminal(0,215,window->w(),TERMINAL_HEIGHT);
|
||||
tty->ansi(true);
|
||||
|
||||
filter = new Fl_Input(50, 10, 315, 25, "Filter:");
|
||||
// Process standard arguments and find filter argument if present
|
||||
int argn = 1;
|
||||
while (argn < argc) {
|
||||
if (Fl::arg(argc, argv, argn) == 0) break;
|
||||
// Group: limit resizing to filter input (not browse button)
|
||||
grp = new Fl_Group(0,10,400,25);
|
||||
grp->begin();
|
||||
{
|
||||
filter = new Fl_Input(50, 10, 315, 25, "Filter:");
|
||||
// Process standard arguments and find filter argument if present
|
||||
int argn = 1;
|
||||
while (argn < argc) {
|
||||
if (Fl::arg(argc, argv, argn) == 0) break;
|
||||
}
|
||||
if (argc > argn)
|
||||
filter->value(argv[argn]);
|
||||
else
|
||||
filter->value("PDF Files (*.pdf)\t"
|
||||
"PostScript Files (*.ps)\t"
|
||||
"Image Files (*.{bmp,gif,jpg,png})\t"
|
||||
"C/C++ Source Files (*.{c,C,cc,cpp,cxx})");
|
||||
|
||||
button = new Fl_Button(365, 10, 25, 25);
|
||||
button->tooltip("Click to open file browser..");
|
||||
button->callback((Fl_Callback *)show_callback);
|
||||
if ( (icon = Fl_File_Icon::find(".", Fl_File_Icon::DIRECTORY)) ) {
|
||||
// Icon found; assign it..
|
||||
button->labelcolor(FL_YELLOW);
|
||||
icon->label(button);
|
||||
} else {
|
||||
// Fallback if no icon found
|
||||
button->label("..");
|
||||
}
|
||||
}
|
||||
if (argc > argn)
|
||||
filter->value(argv[argn]);
|
||||
else
|
||||
filter->value("PDF Files (*.pdf)\t"
|
||||
"PostScript Files (*.ps)\t"
|
||||
"Image Files (*.{bmp,gif,jpg,png})\t"
|
||||
"C/C++ Source Files (*.{c,C,cc,cpp,cxx})");
|
||||
grp->end();
|
||||
grp->resizable(filter);
|
||||
|
||||
button = new Fl_Button(365, 10, 25, 25);
|
||||
button->tooltip("Click to open file browser..");
|
||||
button->callback((Fl_Callback *)show_callback);
|
||||
if ( (icon = Fl_File_Icon::find(".", Fl_File_Icon::DIRECTORY)) ) {
|
||||
// Icon found; assign it..
|
||||
button->labelcolor(FL_YELLOW);
|
||||
icon->label(button);
|
||||
} else {
|
||||
// Fallback if no icon found
|
||||
button->label("..");
|
||||
// Group: prevent resizing of the light buttons
|
||||
grp = new Fl_Group(0,45,400,55);
|
||||
grp->begin();
|
||||
{
|
||||
button = new Fl_Light_Button(50, 45, 80, 25, "MULTI");
|
||||
button->callback((Fl_Callback *)multi_callback);
|
||||
|
||||
button = new Fl_Light_Button(140, 45, 90, 25, "CREATE");
|
||||
button->callback((Fl_Callback *)create_callback);
|
||||
|
||||
button = new Fl_Light_Button(240, 45, 115, 25, "DIRECTORY");
|
||||
button->callback((Fl_Callback *)dir_callback);
|
||||
|
||||
//
|
||||
ch_extra = new Fl_Choice(150, 75, 150, 25, "Extra Group:");
|
||||
ch_extra->add("none|encodings group|check button");
|
||||
ch_extra->value(0);
|
||||
ch_extra->callback((Fl_Callback *)extra_callback);
|
||||
}
|
||||
|
||||
button = new Fl_Light_Button(50, 45, 80, 25, "MULTI");
|
||||
button->callback((Fl_Callback *)multi_callback);
|
||||
|
||||
button = new Fl_Light_Button(140, 45, 90, 25, "CREATE");
|
||||
button->callback((Fl_Callback *)create_callback);
|
||||
|
||||
button = new Fl_Light_Button(240, 45, 115, 25, "DIRECTORY");
|
||||
button->callback((Fl_Callback *)dir_callback);
|
||||
|
||||
//
|
||||
ch_extra = new Fl_Choice(150, 75, 150, 25, "Extra Group:");
|
||||
ch_extra->add("none|encodings group|check button");
|
||||
ch_extra->value(0);
|
||||
ch_extra->callback((Fl_Callback *)extra_callback);
|
||||
grp->end();
|
||||
grp->resizable(0);
|
||||
//
|
||||
files = new Fl_File_Browser(50, 105, 340, 75, "Files:");
|
||||
files->align(FL_ALIGN_LEFT);
|
||||
|
||||
button = new Fl_Button(340, 185, 50, 25, "Close");
|
||||
button->callback((Fl_Callback *)close_callback);
|
||||
// Prevent resizing close button, but keep at right edge of scrn
|
||||
grp = new Fl_Group(0,185,400,25);
|
||||
grp->begin();
|
||||
{
|
||||
Fl_Box *invis = new Fl_Box(100,185,1,1);
|
||||
invis->box(FL_NO_BOX);
|
||||
button = new Fl_Button(310, 185, 80, 25, "Close");
|
||||
button->callback((Fl_Callback *)close_callback);
|
||||
grp->resizable(invis);
|
||||
}
|
||||
grp->end();
|
||||
|
||||
window->resizable(files);
|
||||
window->end();
|
||||
|
||||
Reference in New Issue
Block a user