void Fl_ToggleTree::draw_node(int depth, int cy, Fl_Node* node) { Fl_ToggleNode* tnode = (Fl_ToggleNode*)node; if (damage() == FL_DAMAGE_CHILD && !tnode->changed_ && damaged_ == 0) { return; } tnode->changed_ = 0; if (tnode->selected_) { fl_color(selection_color()); fl_rectf(x(), cy + 1, w(), height_(tnode) - 1); } else { fl_color((cy - y()) & 1 ? color() : alternate_color()); fl_rectf(x(), cy + 1, w(), height_(tnode) - 1); } fl_color(trim_color()); fl_line(x(), cy, x() + w(), cy); fl_color(FL_BLACK); if (draw_lines_) { int i; Fl_ToggleNode * n; fl_xyline(x()+depth*16+8, cy+8, x()+(depth+1)*16, cy+8); if (tnode->next_) fl_xyline(x()+depth*16+8, cy, x()+depth*16+8, cy+16); else fl_xyline(x()+depth*16+8, cy, x()+depth*16+8, cy+8); for (i=depth-1, n = (Fl_ToggleNode*)tnode->up_; n; i--, n = (Fl_ToggleNode*)n->up_) if (n->next_) fl_xyline(x()+i*16+8, cy, x()+i*16+8, cy+16); } if (tnode->can_open_) { if (tnode->opened_) opened_pixmap_->draw(x() + depth*16, cy); else closed_pixmap_->draw(x() + depth*16, cy); } if (tnode->selected_) textcolor(selection_label_color()); else textcolor(labelcolor()); if (tnode->label_) { int D = depth * 16 + label_offset_; draw_label(tnode->label_, D, x(), cy, w(), 16); } if (tnode->pixmap_) { tnode->pixmap_->draw(x() + depth*16 + pixmap_offset_, cy + 1); } }
void Fl_ToggleTree::edit(Fl_ToggleNode *t, int cx, int cy) { // printf("edit\n"); if (!edit_input_->visible() && t) { // printf("%d %d %d %d %s\n",cx, cy, w()-(cx-x()), height_(t), t->label()); edit_input_->resize(cx - 3, cy + 1, w() - (cx - 3 - x()), height_(t) - 1); edit_input_->value(t->label()); edit_input_->show(); edit_input_->take_focus(); } }
widget* builder_spacer::build() const { spacer* widget = new spacer(); init_control(widget); const game_logic::map_formula_callable& size = get_screen_size_variables(); const unsigned width = width_(size); const unsigned height = height_(size); if(width || height) { widget->set_best_size(point(width, height)); } DBG_GUI_G << "Window builder: placed spacer '" << id << "' with definition '" << definition << "'.\n"; return widget; }
void Lake::printPPM(const std::string &file_name) const { auto file = std::fopen(file_name.c_str(), "w"); std::fprintf(file, "P3\n%ld %ld\n255\n", height_.cols(), height_.rows()); float delta = (max_height_ > -max_depth_) ? max_height_/255 : -max_depth_/255; for (unsigned int i = 0; i < height_.rows(); i++) { for (unsigned int j = 0; j < height_.cols(); j++) { float h = height_(i, j); int height_color = static_cast<int>(h/delta + 0.5); if (h < 0) std::fprintf(file, "%d 0 0\n", -height_color); else if (h > 0) std::fprintf(file, "0 0 %d\n", height_color); else std::fputs("0 0 0\n", file); } } std::fclose(file); }
twidget* tbuilder_drawing::build() const { tdrawing* widget = new tdrawing(); init_control(widget); const game_logic::map_formula_callable& size = get_screen_size_variables(); const unsigned width = width_(size); const unsigned height = height_(size); if(width || height) { widget->set_best_size(tpoint(width, height)); } widget->canvas().front().set_cfg(draw_); DBG_GUI_G << "Window builder: placed drawing '" << id << "' with definition '" << definition << "'.\n"; return widget; }
void Lake::updateHeight(unsigned int i, unsigned int j, float height, unsigned int /* step */) { height_(i, j) += height; if (height < max_depth_) max_depth_ = height; else if (height > max_height_) max_height_ = height; }