本文整理汇总了C++中Fl_Widget类的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Widget类的具体用法?C++ Fl_Widget怎么用?C++ Fl_Widget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fl_Widget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VspScreen
ManageTextureScreen::ManageTextureScreen( ScreenMgr * mgr ) : VspScreen( mgr )
{
m_TextureMgrUI = new TextureMgrUI();
m_FLTK_Window = m_TextureMgrUI->UIWindow;
m_TextureMgrUI->UIWindow->position( 775, 50 );
m_UPosSlider.Init( this, m_TextureMgrUI->uPosSlider, m_TextureMgrUI->uPosInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->uPosButton );
m_WPosSlider.Init( this, m_TextureMgrUI->wPosSlider, m_TextureMgrUI->wPosInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->wPosButton );
m_UScaleSlider.Init( this, m_TextureMgrUI->uScaleSlider, m_TextureMgrUI->uScaleInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->uScaleButton );
m_WScaleSlider.Init( this, m_TextureMgrUI->wScaleSlider, m_TextureMgrUI->wScaleInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->wScaleButton );
m_TransparencySlider.Init( this, m_TextureMgrUI->alphaSlider, m_TextureMgrUI->alphaInput, 1, "%6.5f", (VspButton*) m_TextureMgrUI->alphaButton );
m_FlipUButton.Init( this, m_TextureMgrUI->flipUButton );
m_FlipWButton.Init( this, m_TextureMgrUI->flipWButton );
m_TextureMgrUI->compChoice->callback( staticCB, this );
m_TextureMgrUI->textureChoice->callback( staticCB, this );
m_TextureMgrUI->textureNameInput->callback( staticCB, this );
m_TextureMgrUI->addTextureButton->callback( staticCB, this );
m_TextureMgrUI->delTextureButton->callback( staticCB, this );
// Add GL 2D Window.
Fl_Widget * w = m_TextureMgrUI->texGLGroup;
m_TextureMgrUI->texGLGroup->begin();
m_GlWin = new VSPGUI::VspSubGlWindow( w->x(), w->y(), w->w(), w->h(), DrawObj::VSP_TEX_PREVIEW );
m_TextureMgrUI->texGLGroup->end();
ResetCurrentSelected();
}
示例2: fl_push_clip
void
Track::draw ( void )
{
fl_push_clip( x(), y(), w(), h() );
Fl_Color saved_color = color();
if ( ! Track::colored_tracks )
color( FL_GRAY );
if ( _selected )
{
Fl_Color c = color();
color( FL_RED );
Fl_Group::draw();
color( c );
}
else
Fl_Group::draw();
if ( ((Track_Header*)child(0))->input_connector_handle == receptive_to_drop )
{
Fl_Widget *o = ((Track_Header*)child(0))->input_connector_handle;
fl_draw_box( FL_OVAL_BOX, o->x(), o->y(), o->w(), o->h(), fl_color_add_alpha( FL_GREEN, 127 ) );
}
if ( ! Track::colored_tracks )
color( saved_color );
fl_pop_clip();
}
示例3: draw_box
void cairo_box::draw(void)
{
// using fltk functions, set up white background with thin black frame
//fl_color(FL_WHITE);
//fl_rectf(x(), y(), w(), h());
draw_box();
// Rahmen außenrum?
#if 0
fl_color(FL_BLACK);
fl_rect(x(), y(), w(), h());
#endif
//fl_push_clip(100,100,100,100);
//fl_color(FL_BLACK);
//fl_line(1,1,parent()->w(),parent()->h());
// set up cairo structures
Fl_Widget *p = this;
while (p->parent ())
p = p->parent ();
//printf ("p=%p\n", p);
surface = set_surface(p->w(), p->h());
cr = cairo_create(surface);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); // set drawing color to black
cairo_new_path(cr);
//printf ("x()=%i, y()=%i, w()=%i, h()=%i\n", x(), y(), w(), h());
cairo_draw ();
// release the cairo context
cairo_destroy(cr);
cairo_surface_destroy(surface);
}
示例4: main
int main(int argc, char **argv) {
if (argc > 1) srand(atoi(argv[1]));
Fl_Window window(WIDTH,HEIGHT,argv[0]);
window.end(); // don't auto-add children
for (int i = 0; i<10000; i++) {
// make up a random size of widget:
int x = rand()%(WIDTH/GRID+1) * GRID;
int y = rand()%(HEIGHT/GRID+1) * GRID;
int w = rand()%(WIDTH/GRID+1) * GRID;
if (w < x) {w = x-w; x-=w;} else {w = w-x;}
int h = rand()%(HEIGHT/GRID+1) * GRID;
if (h < y) {h = y-h; y-=h;} else {h = h-y;}
if (w < GRID || h < GRID || w < h) continue;
// find where to insert it and see if it intersects something:
Fl_Widget *j = 0;
int n; for (n=0; n < window.children(); n++) {
Fl_Widget *o = window.child(n);
if (x<o->x()+o->w() && x+w>o->x() &&
y<o->y()+o->h() && y+h>o->y()) break;
if (!j && (y < o->y() || y == o->y() && x < o->x())) j = o;
}
// skip if intersection:
if (n < window.children()) continue;
window.insert(*(new Fl_Input(x,y,w,h)),j);
}
window.resizable(window);
window.show();
return Fl::run();
}
示例5: append
static Fl_Widget* append(
Fl_Group* g,
const char *text,
int flags
)
{
Fl_Group* saved = Fl_Group::current();
Fl_Group::current(0);
Fl_Widget* o;
if (flags & FL_SUBMENU)
{
o = new Fl_Item_Group();
if(flags&FL_MENU_RIGHTLAYOUT) ((Fl_Menu_Bar *)g)->right_layout(o);
Fl_Group::current(0);
}
else
{
o = new Fl_Item();
}
o->copy_label(text);
if (flags & FL_MENU_RADIO) o->type(Fl_Item::RADIO);
else if (flags & FL_MENU_TOGGLE) o->type(Fl_Item::TOGGLE);
// these flags have been cleverly assigned so this shift and mask
// converts from the old values to the new ones:
o->set_flag((flags<<12)&(FL_INACTIVE|FL_VALUE|FL_INVISIBLE));
if (insert_here) {g->insert(*o, insert_here-1); insert_here = 0;}
else g->add(o);
if (flags & FL_MENU_DIVIDER) g->add(new Fl_Divider());
Fl_Group::current(saved);
return o;
}
示例6: add_from_list
static void add_from_list(WidgetList &lst, Panel *self, int &X, bool inc) {
WidgetListIt it = lst.begin(), ite = lst.end();
Fl_Widget *o;
while(it != ite) {
o = *it;
/* 'inc == false' means we are going from right to left */
if(!inc)
X -= o->w();
/* place it correctly */
o->position(X, o->y());
self->add(o);
if(inc) {
X += DEFAULT_SPACING;
X += o->w();
} else {
X -= DEFAULT_SPACING;
}
it = lst.erase(it);
}
}
示例7: del
void Abstract_Widget::del()
{
//if (_del)
// return;
//_del = true;
//DJV_DEBUG(String_Format("Abstract_Widget::del(%%)").
// arg(layout_item::debug_path(this)));
Callback::del();
_layout.reset();
Fl_Widget * widget = dynamic_cast<Fl_Widget *>(this);
DJV_ASSERT(widget);
if (widget->parent())
{
//DJV_DEBUG_PRINT("fltk remove");
widget->parent()->remove(widget);
widget->parent(0);
}
Fl::delete_widget(widget);
DJV_APP->widget_del(this);
}
示例8: layout_children
void Taskbar::layout_children(void) {
if(!children())
return;
Fl_Widget *o;
int X = x() + Fl::box_dx(box());
int Y = y() + Fl::box_dy(box());
int W = w() - Fl::box_dw(box());
int child_w = DEFAULT_CHILD_W;
int sz = children();
int all_buttons_w = 0;
/* figure out the bounds */
for(int i = 0; i < sz; i++)
all_buttons_w += child(i)->w() + DEFAULT_SPACING;
if(all_buttons_w > W) {
int reduce = (all_buttons_w - W) / sz;
child_w -= reduce;
}
/* now, position each child and resize it if needed */
for(int i = 0; i < sz; i++) {
o = child(i);
o->resize(X, Y, child_w, o->h());
X += o->w() + DEFAULT_SPACING;
}
}
示例9: update
void update()
{
int rot_val = (int)rot->value();
int scale_val = (int)scale->value();
for (int i = window->children(); i--; )
{
// all window children
Fl_Widget *wc = window->child(i);
if(wc==scale||wc==rot) continue;
Fl_String str("@");
if(scale_val>0) {
str+="+"+Fl_String(scale_val);
} else if(scale_val<0) {
str+=Fl_String(scale_val);
}
if(rot_val>0) {
str+=Fl_String(rot_val);
}
str+=(char*)wc->user_data();
wc->copy_label(str.c_str());
}
window->redraw();
}
示例10: fl_font
void Fl_TooltipBox::layout()
{
fl_font(label_font(), label_size());
int ww, hh;
ww = MAX_WIDTH;
fl_measure(tip, ww, hh, FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_INSIDE);
ww += 6; hh += 6;
// find position on the screen of the widget:
int ox = Fl::event_x_root();
//int ox = X+W/2;
int oy = Y + H+2;
for (Fl_Widget* p = widget; p; p = p->parent())
{
//ox += p->x();
oy += p->y();
}
if (ox+ww > Fl::w()) ox = Fl::w() - ww;
if (ox < 0) ox = 0;
if (H > 30)
{
oy = Fl::event_y_root()+13;
if (oy+hh > Fl::h()) oy -= 23+hh;
}
else
{
if (oy+hh > Fl::h()) oy -= (4+hh+H);
}
if (oy < 0) oy = 0;
resize(ox, oy, ww, hh);
Fl_Menu_Window::layout();
}
示例11: Fl_Group
void onelabGroup::addParameter(onelab::parameter &p)
{
if(!p.getVisible() || CTX::instance()->solver.showInvisibleParameters) return;
bool highlight = false;
Fl_Color c;
if(getFlColor(p.getAttribute("Highlight"), c)) highlight = true;
Fl_Tree_Item *n = _tree->add(p.getName().c_str());
if(!n) return;
n->labelsize(FL_NORMAL_SIZE + 4);
_tree->begin();
int ww = _baseWidth - (n->depth() + 1) * _indent;
ww *= _widgetLabelRatio; // FIXME CHANGE THIS
int hh = n->labelsize() + 4;
Fl_Group *grp = new Fl_Group(1, 1, ww, hh);
Fl_Widget *widget = _addParameterWidget(p, ww, hh, n, highlight, c);
grp->end();
if(!_enableTreeWidgetResize) grp->resizable(0);
_treeWidgets.push_back(grp);
widget->copy_label(p.getShortName().c_str());
std::string help = p.getLabel().size() ? p.getLabel() : p.getShortName();
if(p.getHelp().size()) help += ":\n" + p.getHelp();
widget->copy_tooltip(help.c_str());
n->widget(grp);
_tree->end();
if(p.getAttribute("Closed") == "1" && p.getPath().size()) _tree->close(p.getPath().c_str(), 0);
_tree->redraw();
}
示例12: child
void TaskBar::update_active(Window active)
{
for(int n=0; n<children(); n++)
{
Fl_Widget *w = child(n);
Window win = w->argument();
if(GetState(win) == IconicState)
w->label_color(fl_inactive(FL_BLACK));
else
w->label_color(Fl_Button::default_style->label_color);
if(active==win) {
TaskBar::active = win;
w->set_value();
w->color(fl_lighter(Fl_Button::default_style->color));
w->highlight_color(fl_lighter(Fl_Button::default_style->color));
} else {
w->clear_value();
w->color(Fl_Button::default_style->color);
w->highlight_color(Fl_Button::default_style->highlight_color);
}
}
redraw();
}
示例13: Sprites
//----------------------------------------------------
// Constructor. Creates all of the widgets.
// Add new widgets here
//----------------------------------------------------
JetpackUI::JetpackUI() {
// Initialize
sprites = new Sprites();
animating = false;
level_cache = NULL;
// Create the main window
m_mainWindow = new Fl_Double_Window(DEFAULT_WIDTH, DEFAULT_HEIGHT, "Jetpack");
m_mainWindow->user_data((void*)(this)); // record self to be used by static callback functions
// install menu bar
m_menubar_editor = new Fl_Menu_Bar(0, 0, DEFAULT_WIDTH, DEFAULT_MARGIN);
m_menubar_editor->menu(menuitems_e);
m_menubar_gamePlay = new Fl_Menu_Bar(0, 0, DEFAULT_WIDTH, DEFAULT_MARGIN);
m_menubar_gamePlay->menu(menuitems_g);
m_menubar_gamePlay->hide();
m_menubar_editor->show();
Fl_Group* group_f = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT);
LoadingMenu *loader = new LoadingMenu(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, "Load Level", this);
group_f->end();
group_f->hide();
Fl_Group* group_h = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT);
SavingMenu *saver = new SavingMenu(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, "Save Level", this);
group_h->end();
group_h->hide();
Fl_Group* group_g = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT);
// install editor view window
Maestro *game = new Maestro(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT - DEFAULT_MARGIN, this, "");
group_g->end();
group_g->hide();
Fl_Group* group_e = new Fl_Group(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT);
// install gameplay view window
Editor *editor = new Editor(0, DEFAULT_MARGIN, DEFAULT_WIDTH, DEFAULT_HEIGHT - DEFAULT_MARGIN, "");
editor->m_UI = this;
group_e->end();
//group_e->hide();
m_mainWindow->end();
//// Set dimensions
m_nPaintWidth = m_nWidth = DEFAULT_WIDTH;
m_nPaintHeight = m_nHeight = DEFAULT_HEIGHT - DEFAULT_MARGIN;
m_editor_group = group_e;
m_gamePlay_group = group_g;
m_load_group = group_f;
m_save_group = group_h;
m_editor = editor;
m_gamePlay = game;
m_loader = loader;
m_saver = saver;
m_current = editor;
m_mainWindow->iconize(); // IMPORTANT
startAnimating();
Fl_Widget * icon = fl_message_icon();
icon->hide();
}
示例14: children
void gLiquidScroll::resize(int X, int Y, int W, int H) {
int nc = children()-2; // skip hscrollbar and vscrollbar
for ( int t=0; t<nc; t++) { // tell children to resize to our new width
Fl_Widget *c = child(t);
c->resize(c->x(), c->y(), W-24, c->h()); // W-24: leave room for scrollbar
}
init_sizes(); // tell scroll children changed in size
Fl_Scroll::resize(X,Y,W,H);
}
示例15:
void
JACK_Module::draw ( void )
{
Module::draw();
if ( this == receptive_to_drop )
{
Fl_Widget *o = input_connection_handle;
fl_draw_box( FL_OVAL_BOX, o->x(), o->y(), o->w(), o->h(), fl_color_add_alpha( FL_GREEN, 127 ) );
}
}