本文整理汇总了C++中Fl_Box::w方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Box::w方法的具体用法?C++ Fl_Box::w怎么用?C++ Fl_Box::w使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Box
的用法示例。
在下文中一共展示了Fl_Box::w方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void Splash::run(void) {
E_ASSERT(slist != NULL);
if(!show_splash) {
while(next_client_nosplash())
;
return;
}
fl_register_images();
String path, splash_theme_path;
#ifdef USE_LOCAL_CONFIG
splash_theme_path = "splash-themes/";
#else
splash_theme_path = Resource::find_data("themes/splash-themes", RES_SYS_ONLY);
if(splash_theme_path.empty()) {
E_WARNING(E_STRLOC ": Unable to locate splash themes in $XDG_DATA_DIRS directories\n");
return;
}
#endif
splash_theme_path += E_DIR_SEPARATOR;
splash_theme_path += *splash_theme;
if(!file_test(splash_theme_path.c_str(), FILE_TEST_IS_DIR)) {
E_WARNING(E_STRLOC ": Unable to locate '%s' in '%s' theme directory\n",
splash_theme->c_str(), splash_theme_path.c_str());
return;
}
/* setup widgets */
begin();
Fl_Box* bimg = new Fl_Box(0, 0, w(), h());
Fl_Image* splash_img = 0;
path = build_filename(splash_theme_path.c_str(), "background.png");
splash_img = Fl_Shared_Image::get(path.c_str());
if(splash_img) {
int W = splash_img->w();
int H = splash_img->h();
/* update window and Box sizes */
size(W, H);
bimg->size(W, H);
bimg->image(splash_img);
}
/*
* place message box at the bottom with
* nice offset (10 px) from window borders
*/
msgbox = new Fl_Box(10, h() - 25 - 10, w() - 20, 25);
/*
* Setup icons positions, based on position of msgbox assuming someone
* will not abuse splash to start hundrets of programs, since icons will
* be placed only in horizontal order, one line, so in case their large
* number, some of them will go out of window borders.
*
* Icon box will be 64x64 so larger icons can fit too.
*
* This code will use Fl_Group (moving group, later, will move all icons
* saving me from code mess), but will not update it's w() for two reasons:
* icons does not use it, and will be drawn correctly, and second, setting
* width will initiate fltk layout engine which will mess everything up.
*/
Fl_Group* icon_group = new Fl_Group(10, msgbox->y() - 10 - 64, 0, 64);
int X = icon_group->x();
int Y = icon_group->y();
/* offset between icons */
int ioffset = 5;
/* FIXME: use malloc/something instead this */
icons = new Fl_Box*[slist->size()];
icon_group->begin();
int i = 0;
const char* imgpath;
Fl_Image* iconimg = 0;
for(StartupItemListIter it = slist->begin(); it != slist->end(); ++it, ++i) {
Fl_Box* bb = new Fl_Box(X, Y, 64, 64);
path = build_filename(splash_theme_path.c_str(), (*it)->icon.c_str());
imgpath = path.c_str();
iconimg = Fl_Shared_Image::get(imgpath);
if(!iconimg) {
bb->label(_("No image"));
bb->align(FL_ALIGN_INSIDE | FL_ALIGN_WRAP);
} else
bb->image(iconimg);
bb->hide();
X += bb->w() + ioffset;
icons[i] = bb;
//.........这里部分代码省略.........