boolean MonoKitImpl::match(const Style& s1, const Style& s2, const char* n) { String name(n); String v1, v2; boolean b1 = s1.find_attribute(n, v1); boolean b2 = s2.find_attribute(n, v2); return (!b1 && !b2) || (b1 && b2 && v1 == v2); }
const Font* World::font() const { const Font* f = nil; Style* s = style(); String v; if (s->find_attribute("font", v) || s->find_attribute("Font", v)) { f = Font::lookup(v); } if (f == nil) { f = Font::lookup("fixed"); } return f; }
const Color* World::foreground() const { const Color* c = nil; Style* s = style(); String v; if (s->find_attribute("foreground", v) || s->find_attribute("Foreground", v) ) { c = Color::lookup(display(), v); } if (c == nil) { c = new Color(0.0, 0.0, 0.0, 1.0); } return c; }
void FieldEditorImpl::build( FieldEditor* e, const char* str, FieldEditorAction* a ) { WidgetKit& kit = *kit_; kit.begin_style("FieldEditor"); Style* s = kit.style(); bs_ = new FieldButton(e, a); editor_ = new FieldStringEditor(bs_, str, kit_, s); Glyph* g = editor_; if (s->value_is_on("beveled")) { g = kit.inset_frame( new Background( LayoutKit::instance()->h_margin(editor_, 2.0), kit.background() ) ); } e->body(g); cursor_is_on_ = false; blink_handler_ = new IOCallback(FieldEditorImpl)( this, &FieldEditorImpl::blink_cursor ); float sec = 0.5; s->find_attribute("cursorFlashRate", sec); flash_rate_ = long(sec * 1000000); kit.end_style(); }
void PrintableWindow::xmove(int left1, int top) { const Display& d = *display(); WindowRep& w = *((Window*)this)->rep(); Style* q = Session::instance()->style(); Coord WMOffsetX, WMOffsetY; if (xoff == -999 && yoff == -999) { if (!q->find_attribute("window_manager_offset_x", WMOffsetX)) { WMOffsetX = 5.; } if (!q->find_attribute("window_manager_offset_y", WMOffsetY)) { WMOffsetY = 26.; } xoff = (int)WMOffsetX; yoff = (int)WMOffsetY; } xoff = yoff = 0; //printf("%lx xmove(%d,%d) XMoveWindow(%d,%d)\n", (long)this,left1, top, left1+xoff, top+yoff); XMoveWindow(d.rep()->display_, w.xwindow_, left1+xoff, top+yoff); }
void NPInsetFrame::print(Printer* p, const Allocation& a) const { Style* s = WidgetKit::instance()->style(); long i=1; s->find_attribute("scene_print_border", i); //printf("NPInsetFrame %ld\n", i); if (i) { body()->print(p, a); } else { ((MonoGlyph*)body())->body()->print(p, a); } }
void TextLineAdjuster::addButtons() { WidgetKit* kit = WidgetKit::instance(); LayoutKit* lkit = LayoutKit::instance(); Style* style = kit->style(); Stepper* left = kit->left_mover(adjustable_); Stepper* right = kit->right_mover(adjustable_); Coord mover_size = 15.0; style->find_attribute("mover_size", mover_size); box_->prepend(lkit->h_fixed_span(left, mover_size)); box_->append(lkit->h_fixed_span(right, mover_size)); }
GFieldEditor::GFieldEditor(const char* init, GFieldEditorAction* act, float minwidth) : InputHandler(nil, Session::instance()->style()) { field_ = new EivTextBuffer(); if (init && strlen(init) > 0) { field_->Insert(0, init, strlen(init)); } point_pos_ = 0; mark_pos_ = 0; action_ = act; minwidth_ = minwidth; cursor_is_on_= false; int thickness; Style *s = Session::instance()->style(); s->find_attribute("frameThickness", _frame_thickness); make_body(); }
void SessionRep::init_display() { String name; if (style_->find_attribute(String("display"), name)) { default_ = Display::open(name); } else { default_ = Display::open(); } if (default_ == nil) { if (name.length() > 0) { fprintf( stderr, "can't open display %.*s\n", name.length(), name.string() ); } else { fprintf(stderr, "can't open DISPLAY\n"); } exit(1); } connect(default_); }
void XYView::init(Coord x1, Coord y1, Coord xs, Coord ys, Scene* s, Coord xsize, Coord ysize) { set_pick_epsilon(); xsize_orig_ = xsize; ysize_orig_ = ysize; csize(0., xsize, 0., ysize); origin(x1, y1); x_span(xs); y_span(ys); canvas(NULL); parent_ = NULL; //not reffed append_view(s); #if 0 if (view_margin_ == fil) { Style* style = Session::instance()->style(); if (!style->find_attribute("view_margin", view_margin_)) { view_margin_ = 0; } view_margin_ *= 72; } #endif }
int main(int argc, char** argv) { Session* session = new Session("Ifc", argc, argv, options, props); Style* s = session->style(); String sep; s->find_attribute("separator", sep); DialogKit& dialogs = *DialogKit::instance(); FileChooser* fc = dialogs.file_chooser(((argc == 2) ? argv[1] : "."), s); ApplicationWindow* w = new ApplicationWindow(fc); w->style(s); w->map(); int status = 1; for (;;) { if (!fc->run()) { status = 1; break; } const String* name = fc->selected(); if (name != nil) { if (sep == "") { printf("%.*s%c", name->length(), name->string(), '\0'); } else { printf( "%.*s%.*s", name->length(), name->string(), sep.length(), sep.string() ); } fflush(stdout); status = 0; } if (!s->value_is_on("static")) { break; } } w->unmap(); delete w; delete session; return status; }
void SessionRep::init_display(Display* display) { String name; if (display != nil) { default_ = display; } else if (style_->find_attribute(String("display"), name)) { default_ = Display::open(name); } else { const char* defaultvar = (char*)getenv( "DISPLAY" ); default_ = Display::open(defaultvar ? defaultvar : ":0.0"); } if (default_ == nil) { if (name.length() > 0) { fprintf( stderr, "can't open display %.*s\n", name.length(), name.string() ); } else { fprintf(stderr, "can't open DISPLAY\n"); } exit(1); } connect(default_); }
void SymChooserImpl::build() { WidgetKit& kit = *kit_; const LayoutKit& layout = *LayoutKit::instance(); Style* s = style_; kit.push_style(); kit.style(s); String caption(""); s->find_attribute("caption", caption); String subcaption("Enter Symbol name:"); s->find_attribute("subcaption", subcaption); String open("Accept"); s->find_attribute("open", open); String close("Cancel"); s->find_attribute("cancel", close); long rows = 10; s->find_attribute("rows", rows); const Font* f = kit.font(); FontBoundingBox bbox; f->font_bbox(bbox); Coord height = rows * (bbox.ascent() + bbox.descent()) + 1.0; Coord width; if (!s->find_attribute("width", width)) { width = 16 * f->width('m') + 3.0; } int i; Action* accept = new ActionCallback(SymChooserImpl)( this, &SymChooserImpl::accept_browser ); Action* cancel = new ActionCallback(SymChooserImpl)( this, &SymChooserImpl::cancel_browser ); editor_ = DialogKit::instance()->field_editor( "", s, new FieldEditorCallback(SymChooserImpl)( this, &SymChooserImpl::editor_accept, nil ) ); browser_index_ = 0; for (i=0; i < nbrowser_; ++i) { fbrowser_[i] = new FileBrowser(kit_, new SymBrowserAccept(this, i), nil); } fchooser_->remove_all_input_handlers(); fchooser_->append_input_handler(editor_); for (i=0; i < nbrowser_; ++i) { fchooser_->append_input_handler(fbrowser_[i]); } fchooser_->next_focus(); Glyph* g = layout.vbox(); if (caption.length() > 0) { g->append(layout.r_margin(kit.fancy_label(caption), 5.0, fil, 0.0)); } if (subcaption.length() > 0) { g->append(layout.r_margin(kit.fancy_label(subcaption), 5.0, fil, 0.0)); } g->append(layout.vglue(5.0, 0.0, 2.0)); g->append(editor_); g->append(layout.vglue(5.0, 0.0, 2.0)); g->append(makeshowmenu()); g->append(layout.vglue(15.0, 0.0, 12.0)); PolyGlyph* h = layout.hbox(nbrowser_); Glyph* b; for (i=0; i < nbrowser_; ++i) { b = layout.hbox( layout.vcenter( kit.inset_frame( layout.margin( layout.natural_span(fbrowser_[i], width, height), 1.0 ) ), 1.0 ), layout.hspace(4.0), kit.vscroll_bar(fbrowser_[i]->adjustable()) ); h->append(b); } g->append(h); g->append(layout.vspace(15.0)); if (s->value_is_on("filter")) { FieldEditorAction* action = new FieldEditorCallback(SymChooserImpl)( this, &SymChooserImpl::filter_accept, nil ); filter_ = add_filter( s, "filterPattern", "", "filterCaption", "Filter:", g, action ); if (s->value_is_on("directoryFilter")) { directory_filter_ = add_filter( s, "directoryFilterPattern", "", "directoryFilterCaption", "Name Filter:", g, action ); } else { directory_filter_ = nil; } } else { filter_ = nil; directory_filter_ = nil; } g->append( layout.hbox( layout.hglue(10.0), layout.vcenter(kit.default_button(open, accept)), layout.hglue(10.0, 0.0, 5.0), layout.vcenter(kit.push_button(close, cancel)), layout.hglue(10.0) ) ); fchooser_->body( layout.vcenter(kit.outset_frame(layout.margin(g, 5.0)), 1.0) ); kit.pop_style(); load(0); }
boolean MFKitImpl::match(const Style& s1, const Style& s2, const char* n) { String v1, v2; boolean b1 = s1.find_attribute(n, v1); boolean b2 = s2.find_attribute(n, v2); return !(b1 || b2) || (b1 && b2 && v1 == v2); }
void FileChooserImpl::build() { WidgetKit& kit = *kit_; const LayoutKit& layout = *LayoutKit::instance(); Style* s = style_; kit.push_style(); kit.style(s); String caption(""); s->find_attribute("caption", caption); String subcaption("Enter filename:"); s->find_attribute("subcaption", subcaption); String open("Open"); s->find_attribute("open", open); String close("Cancel"); s->find_attribute("cancel", close); long rows = 10; s->find_attribute("rows", rows); const Font* f = kit.font(); FontBoundingBox bbox; f->font_bbox(bbox); Coord height = rows * (bbox.ascent() + bbox.descent()) + 1.0; Coord width; if (!s->find_attribute("width", width)) { width = 16 * f->width('m') + 3.0; } Action* accept = new ActionCallback(FileChooserImpl)( this, &FileChooserImpl::accept_browser ); Action* cancel = new ActionCallback(FileChooserImpl)( this, &FileChooserImpl::cancel_browser ); if (editor_ == nil) { editor_ = DialogKit::instance()->field_editor( *dir_->path(), s, new FieldEditorCallback(FileChooserImpl)( this, &FileChooserImpl::accept_editor, &FileChooserImpl::cancel_editor ) ); } // added by ro2m: check for style for default selection String defsel(""); if(s->find_attribute("defaultSelection", defsel)) { editor_->field(defsel); } fbrowser_ = new FileBrowser(kit_, accept, cancel); fchooser_->remove_all_input_handlers(); fchooser_->append_input_handler(editor_); fchooser_->append_input_handler(fbrowser_); Glyph* g = layout.vbox(); if (caption.length() > 0) { g->append(layout.rmargin(kit.fancy_label(caption), 5.0, fil, 0.0)); } if (subcaption.length() > 0) { g->append(layout.rmargin(kit.fancy_label(subcaption), 5.0, fil, 0.0)); } g->append(layout.vglue(5.0, 0.0, 2.0)); g->append(editor_); g->append(layout.vglue(15.0, 0.0, 12.0)); g->append( layout.hbox( layout.vcenter( kit.inset_frame( layout.margin( layout.natural_span(fbrowser_, width, height), 1.0 ) ), 1.0 ), layout.hspace(4.0), kit.vscroll_bar(fbrowser_->adjustable()) ) ); g->append(layout.vspace(15.0)); if (s->value_is_on("filter")) { FieldEditorAction* action = new FieldEditorCallback(FileChooserImpl)( this, &FileChooserImpl::accept_filter, nil ); filter_ = add_filter( s, "filterPattern", "", "filterCaption", "Filter:", g, action ); if (s->value_is_on("directoryFilter")) { directory_filter_ = add_filter( s, "directoryFilterPattern", "", "directoryFilterCaption", "Directory Filter:", g, action ); } else { directory_filter_ = nil; } } else { filter_ = nil; directory_filter_ = nil; } g->append( layout.hbox( layout.hglue(10.0), layout.vcenter(kit.default_button(open, accept)), layout.hglue(10.0, 0.0, 5.0), layout.vcenter(kit.push_button(close, cancel)), layout.hglue(10.0) ) ); fchooser_->body( layout.back( layout.vcenter(kit.outset_frame(layout.margin(g, 5.0)), 1.0), new Target(nil, TargetPrimitiveHit) ) ); fchooser_->focus(editor_); kit.pop_style(); load(); }