Exemplo n.º 1
0
ct_image_window::ct_image_window( ) {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = image_window = new Fl_Double_Window(421, 528);
    w = o;
    o->user_data((void*)(this));
    { Fl_Group* o = new Fl_Group(5, 30, 410, 410);
      o->box(FL_PLASTIC_DOWN_FRAME);
      { ct_draw_area* o = ct_image = new ct_draw_area(10, 35, 400, 400, "label");
        o->box(FL_FLAT_BOX);
        o->color(FL_DARK3);
        o->selection_color(FL_BACKGROUND_COLOR);
        o->labeltype(FL_NORMAL_LABEL);
        o->labelfont(0);
        o->labelsize(14);
        o->labelcolor(FL_BLACK);
        o->align(FL_ALIGN_CENTER);
        o->when(FL_WHEN_RELEASE);
      }
      o->end();
    }
    { Fl_Menu_Bar* o = new Fl_Menu_Bar(0, 0, 100, 25);
      o->box(FL_FLAT_BOX);
      o->menu(menu_);
    }
    { Fl_Value_Slider* o = WL = new Fl_Value_Slider(40, 470, 375, 20, "WL");
      o->type(1);
      o->box(FL_PLASTIC_THIN_DOWN_BOX);
      o->minimum(-2000);
      o->maximum(7000);
      o->step(1);
      o->value(40);
      o->callback((Fl_Callback*)cb_WL);
      o->align(FL_ALIGN_LEFT);
    }
    { Fl_Value_Slider* o = WW = new Fl_Value_Slider(40, 495, 375, 20, "WW");
      o->type(1);
      o->box(FL_PLASTIC_THIN_DOWN_BOX);
      o->minimum(1);
      o->maximum(4000);
      o->step(1);
      o->value(300);
      o->callback((Fl_Callback*)cb_WW);
      o->align(FL_ALIGN_LEFT);
    }
    { Fl_Value_Slider* o = Indx = new Fl_Value_Slider(40, 445, 375, 20, "Indx");
      o->type(1);
      o->box(FL_PLASTIC_THIN_DOWN_BOX);
      o->step(1);
      o->callback((Fl_Callback*)cb_Indx);
      o->align(FL_ALIGN_LEFT);
    }
    { Fl_Progress* o = progress_bar = new Fl_Progress(115, 5, 300, 20);
      o->box(FL_PLASTIC_THIN_UP_BOX);
      o->selection_color((Fl_Color)1);
      o->hide();
    }
    o->end();
  }
}
Exemplo n.º 2
0
void IconChooser::load_from_list(list<String>& lst) {
	if(lst.empty())
		return;

	Fl_Shared_Image* img = NULL;
	int imax_w = 0;
	int imax_h = 0;
	int iw, ih;
	bool show_progress = false;

	list<String>::iterator it = lst.begin(), it_end = lst.end();

	/*
	 * lst_info contains coresponding indexes with list<String> so we can deduce what
	 * files to skip (not readable image or dimensions greater than allowed); skippable are marked as 0
	 */
	int* lst_info = new int[lst.size()];
	for(int n = 0; it != it_end; ++it, n++){
		img = Fl_Shared_Image::get((*it).c_str());

		if(!img) {
			lst_info[n] = 0;
			continue;
		}

		iw = img->w();
		ih = img->h();

		if(iw > MAX_ICON_W || ih > MAX_ICON_H) {
			lst_info[n] = 0;
			continue;
		}

		imax_w = MAX(imax_w, iw);
		imax_h = MAX(imax_h, ih);
		lst_info[n] = 1; 
	}

	/* clear potential content of ExpandableGroup */
	if(icongrp->children())
		icongrp->clear();

	if(lst.size() > 10) {
		show_progress = true;
		progress->minimum(0);
		progress->maximum(lst.size());
		progress->show();
	}

	if(imax_w < 64) 
		imax_w = 64;
	else
		imax_w += 10;

	if(imax_h < 64) 
		imax_h = 64;
	else
		imax_h += 10;

	imax_w += 5;
	imax_h += 5;

	/*
	 * focus_index() is only valid on childs before we show them and that is what we need 
	 * so other childs don't mess it when they are added
	 */
	//icongrp->focus(child(0));
	icongrp->set_visible_focus();

	IconBox* preview;
	it = lst.begin();

	for(int n = 0; it != it_end; ++it, n++) {
		img = Fl_Shared_Image::get((*it).c_str());

		if(img && lst_info[n] == 1) {
			preview = new IconBox(0, 0, imax_w, imax_h);
			preview->set_icon_path((*it));

			/* use background/selection from ExpandableGroup */
			preview->color(icongrp->color());
			preview->selection_color(icongrp->color());

			if(show_progress)
				progress->value(int((n * 100) / int(progress->maximum())));

			preview->image(img);
			preview->callback(iconbox_cb, this);
			icongrp->add(preview);

			Fl::check();
		}
	}

	progress->hide();
	delete [] lst_info;
}