本文整理汇总了C++中Fl_Widget::align方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Widget::align方法的具体用法?C++ Fl_Widget::align怎么用?C++ Fl_Widget::align使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Widget
的用法示例。
在下文中一共展示了Fl_Widget::align方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
Controller_Module::connect_to ( Port *p )
{
control_output[0].connect_to( p );
clear();
Fl_Widget *w;
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
{
Fl_Light_Button *o = new Fl_Light_Button( 0, 0, 40, 40, p->name() );
w = o;
o->value( p->control_value() );
_type = TOGGLE;
/* FIXME: hack */
control = (Fl_Valuator*)o;
}
else if ( p->hints.type == Module::Port::Hints::INTEGER )
{
Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() );
control = o;
w = o;
o->type(1);
o->step(1);
if ( p->hints.ranged )
{
o->minimum( p->hints.minimum );
o->maximum( p->hints.maximum );
}
_type = SPINNER;
o->value( p->control_value() );
}
else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC )
{
Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() );
control = o;
w = o;
o->type(4);
o->color( FL_DARK1 );
o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
o->minimum(1.5);
o->maximum(0);
o->value(1);
o->textsize(9);
if ( p->hints.ranged )
{
o->minimum( p->hints.maximum );
o->maximum( p->hints.minimum );
}
o->value( p->control_value() );
_type = SLIDER;
}
else
{
{ Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() );
w = o;
control = o;
if ( p->hints.ranged )
{
DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum );
o->minimum( p->hints.minimum );
o->maximum( p->hints.maximum );
}
o->color( fl_darker( FL_GRAY ) );
o->selection_color( FL_WHITE );
o->value( p->control_value() );
}
_type = KNOB;
}
control_value = p->control_value();
w->set_visible_focus();
w->align(FL_ALIGN_TOP);
w->labelsize( 10 );
w->callback( cb_handle, this );
if ( _pad )
{
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
flg->set_visible_focus();
size( flg->w(), flg->h() );
flg->position( x(), y() );
add( flg );
}
//.........这里部分代码省略.........
示例2: if
//.........这里部分代码省略.........
else
{
Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() );
control = o;
w = o;
if ( ! _horizontal )
{
o->size( 30, 250 );
o->type(FL_VERT_NICE_SLIDER);
}
else
{
o->size(250,20);
o->type(FL_HOR_NICE_SLIDER);
}
// o->type(4);
o->color( FL_BACKGROUND2_COLOR );
o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
o->minimum(1.5);
o->maximum(0);
o->value(1);
// o->textsize(9);
if ( p->hints.ranged )
{
if ( ! _horizontal )
{
o->minimum( p->hints.maximum );
o->maximum( p->hints.minimum );
}
else
{
o->minimum( p->hints.minimum );
o->maximum( p->hints.maximum );
}
}
o->precision(2);
o->value( p->control_value() );
_type = SLIDER;
}
/* else */
/* { */
/* { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() ); */
/* w = o; */
/* control = o; */
/* if ( p->hints.ranged ) */
/* { */
/* DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum ); */
/* o->minimum( p->hints.minimum ); */
/* o->maximum( p->hints.maximum ); */
/* } */
/* o->color( fl_darker( FL_GRAY ) ); */
/* o->selection_color( FL_WHITE ); */
/* o->value( p->control_value() ); */
/* } */
/* _type = KNOB; */
/* } */
control_value = p->control_value();
w->clear_visible_focus();
w->align(FL_ALIGN_TOP);
w->labelsize( 10 );
w->callback( cb_handle, this );
if ( _pad )
{
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
flg->set_visible_focus();
size( flg->w(), flg->h() );
flg->position( x(), y() );
add( flg );
resizable(flg);
// init_sizes();
}
else
{
/* HACK: hide label */
if ( _type == TOGGLE )
{
w->align( FL_ALIGN_INSIDE );
}
else
{
w->labeltype( FL_NO_LABEL );
}
w->resize( x(), y(), this->w(), h() );
add( w );
resizable( w );
init_sizes();
}
}
示例3: editField
void fieldWindow::editField(Field *f)
{
editor_group->user_data(f);
put_on_view_btn->deactivate();
delete_btn->deactivate();
if(f == NULL){
selected_id = -1;
editor_group->hide();
empty_message->show();
loadFieldList();
return;
}
FL_NORMAL_SIZE -= _deltaFontSize;
selected_id = f->id;
empty_message->hide();
editor_group->show();
editor_group->user_data(f);
title->label(f->getName());
options_scroll->clear();
options_widget.clear();
options_scroll->begin();
int xx = options_scroll->x();
int yy = options_scroll->y();
std::string help = f->getDescription();
ConvertToHTML(help);
if (! f->options.empty())
help += std::string("<p><center><b>Options</b></center>");
for(std::map<std::string, FieldOption*>::iterator it = f->options.begin();
it != f->options.end(); it++){
Fl_Widget *input;
help += std::string("<p><b>") + it->first + "</b>";
help += " (<em>" + it->second->getTypeName() + "</em>): ";
help += it->second->getDescription();
switch(it->second->getType()){
case FIELD_OPTION_INT:
case FIELD_OPTION_DOUBLE:
input = new Fl_Value_Input(xx, yy, IW, BH, it->first.c_str());
input->align(FL_ALIGN_RIGHT);
break;
case FIELD_OPTION_BOOL:
input = new Fl_Check_Button(xx, yy, 2 * BB, BH, it->first.c_str());
input->type(FL_TOGGLE_BUTTON);
break;
case FIELD_OPTION_PATH:
{
input = new Fl_Input(xx, yy, IW, BH, it->first.c_str());
input->align(FL_ALIGN_RIGHT);
int tw = (int)fl_width(it->first.c_str());
Fl_Button *b = new Fl_Button(xx + IW + tw + 2 * WB, yy, BB, BH, "Choose");
b->callback(field_select_file_cb, input);
}
break;
case FIELD_OPTION_STRING:
input = new Fl_Input(xx, yy, IW, BH, it->first.c_str());
input->align(FL_ALIGN_RIGHT);
break;
case FIELD_OPTION_LIST:
default:
input = new Fl_Input(xx, yy, IW, BH, it->first.c_str());
input->align(FL_ALIGN_RIGHT);
break;
}
options_widget.push_back(input);
yy += BH;
}
if (! f->callbacks.empty())
help += std::string("<p><center><b>Actions</b></center>");
for(std::map<std::string, FieldCallback*>::iterator it = f->callbacks.begin();
it != f->callbacks.end(); it++){
Fl_Widget *btn;
help += std::string("<p><b>") + it->first + "</b>: ";
help += it->second->getDescription();
btn = new Fl_Button(xx, yy, IW, BH, it->first.c_str());
btn->callback(field_callback_cb, it->second);
yy += BH;
}
help_display->value(help.c_str());
options_scroll->end();
FL_NORMAL_SIZE += _deltaFontSize;
loadFieldOptions();
options_scroll->damage(1);
put_on_view_btn->activate();
delete_btn->activate();
loadFieldList();
}
示例4: layout
void Fl_Align_Group::layout()
{
Fl_Widget::layout();
if(!children()) return;
int i;
int n_lines = n_to_break() ?
(children() / n_to_break() + (children() % n_to_break()?1:0)) : 1;
bool variable_is_y = (align() & (FL_ALIGN_TOP|FL_ALIGN_BOTTOM)) != 0;
int nx = vertical() ? n_lines : n_to_break() ? n_to_break() : children();
int ny = vertical() ? n_to_break() ? n_to_break() : children() : n_lines;
int n_variable = variable_is_y ? ny : nx;
uchar label_space[256];
memset(label_space,0,n_variable*sizeof(uchar));
int u=0, v=0;
int total_label_space=0;
int numchildren = children();
if (align())
{
for (i = 0; i < numchildren; i++)
{
Fl_Widget* o = child(i);
fl_font(o->label_font(), o->label_size());
int w = this->w()-o->w(),h = this->h()-o->h();
fl_measure(o->label().c_str() ,w,h,o->flags());
if (variable_is_y) w = h;
int which = (variable_is_y == vertical()) ? u : v;
if (label_space[which] < w) label_space[which] = w;
if (++u == n_to_break()) {u = 0; v++;}
}
for (i = 0; i<n_variable; i++) total_label_space+=label_space[i];
}
int W = (w() - (variable_is_y ? 0:total_label_space) - (nx + 1)*dw()) / nx;
int H = (h() - (variable_is_y ? total_label_space:0) - (ny + 1)*dh()) / ny;
int cx = dw(), cy = dh();
int icx = cx, icy = cy;
u = v = 0;
for (i = 0; i < numchildren; i++)
{
Fl_Widget* o = child(i);
int which = (variable_is_y == vertical()) ? u : v;
int X = cx, Y = cy;
if (align() & FL_ALIGN_TOP) Y += label_space[which];
else if (!variable_is_y && align() & FL_ALIGN_LEFT) X += label_space[which];
o->resize(X,Y,W,H);
o->align(align());
o->layout();
if (++u == n_to_break())
{
u = 0; v++;
if (vertical())
{
cx += W+dw(); cy = icy;
if (!variable_is_y) cx += label_space[which];
}
else
{
cy += H+dh(); cx = icx;
if (variable_is_y) cy += label_space[which];
}
}
else
{
if (vertical())
{
cy += H+dh();
if (variable_is_y) cy += label_space[which];
}
else
{
cx += W+dw();
if (!variable_is_y) cx += label_space[which];
}
}
}
init_sizes();
}
示例5: setup
void PulseAnalysisDisplay::setup ()
{
Fl_Widget* w;
int bigx = 1000;
int bigy = 400;
int xbuffer=5, ybuffer=5;
int xsize0,xsize1,xsize2, xsize3;
int ysize0,ysize1;
int x[5];
int y[INDEPENDENT_TRACES + 3];
window = new Fl_Double_Window(bigx,bigy, "Pulse Analysis Window");
// set the current user data (void *) argument to the instance pointer
window->user_data((void*)(this));
// position the window on screen
window->resizable(window);
// begin the main window group
window->begin();
{
xsize0 = 50; // channel selector
xsize1 = 100; // color selector
xsize2 = xsize1 + xsize0 + xbuffer; // plot selector
ysize0 = 25; // standard size
ysize1 = (bigy - 2*ybuffer); // plotWindow height
x[0] = xbuffer+xbuffer; // channel
x[1] = x[0] + xsize0 + xbuffer; // color
x[2] = x[0]; // plot type
x[3] = x[1] + xsize1 + xbuffer; // plot itself
// plotWindow width
xsize3 = bigx - (x[1] + xsize1 + xbuffer) - xbuffer;
y[0] = ybuffer; // plot selector
y[1] = y[1] + ysize0 + ybuffer; // analysis enable
y[2] = y[1] + 2*ysize0 + ybuffer; // label
for (unsigned int i=0; i<INDEPENDENT_TRACES; i++)
{
y[3+i] = y[2+i] + ysize0 + ybuffer; // top of top plot choice
}
// what kind of plot the user wants to see
Fl_Menu_Item plotPopup[] =
{
{"Pulse Height", 0, (Fl_Callback*) handleEvent, (void*) this},
{"Baseline", 0, (Fl_Callback*) handleEvent, (void*) this},
{0}
};
w = plotSelector = new Fl_Choice (x[0],y[1],xsize2,ysize0,"");
plotSelector->copy(plotPopup,NULL);
w->align(FL_ALIGN_RIGHT);
// enable analysis button
w = performAnalysisFlagButton = new Fl_Light_Button(x[0],y[0],xsize2,ysize0,"Enable Analysis");
w->callback((Fl_Callback*) handleEvent, (void*) this);
// the channel selectors
w = new Fl_Box (x[0],y[2],xsize0,0,"Channel");
w->align(FL_ALIGN_TOP);
w = new Fl_Box (x[1],y[2],xsize0,0,"Color");
w->align(FL_ALIGN_TOP);
Fl_Menu_Item topChanPopup[] =
{
{"-", 0,(Fl_Callback*) handleEvent, (void*) this},
{0}
};
for (unsigned int i=0; i< INDEPENDENT_TRACES; i++)
{
w = channelSelector[i] = new Fl_Choice (x[0],y[i+2],xsize0,ysize0);
channelSelector[i]->copy(topChanPopup,NULL);
w->align(FL_ALIGN_TOP);
}
// color selector
Fl_Menu_Item colorPopup[] =
{
{"Black", 0, NULL, (void*) this},
{"Red", 0, NULL, (void*) this},
{"Blue", 0, NULL, (void*) this},
{"Green", 0, NULL, (void*) this},
{"Dark Red", 0, NULL, (void*) this},
{"Dark Blue", 0, NULL, (void*) this},
{"Dark Green", 0, NULL, (void*) this},
{"Dark Cyan", 0, NULL, (void*) this},
{0}
};
for (unsigned int i=0; i< INDEPENDENT_TRACES; i++)
{
w = traceColorSelector[i] = new Fl_Choice (x[1],y[i+2],xsize1, ysize0);
traceColorSelector[i]->copy(colorPopup,NULL);
w->align(FL_ALIGN_TOP);
}
// the actual plotter widget
plot = new plotWindow (x[3],y[0],xsize3,ysize1);
//.........这里部分代码省略.........