Пример #1
0
    //constructeur
    Fl_Progress_Window()  : Fl_Window(238,105,"Progression...")
    {
        // Progress 1 Label
        Fl_Box *label = new Fl_Box(10,10,215,15,"Pourcentage Général:");
        label->labelsize(12);
        label->labelfont(1);
        label->labelcolor((Fl_Color)136);
        label->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);

        //Progress1
        progress1 = new Fl_Progress(10,28,215,20,"0%");
        progress1->selection_color((Fl_Color)175);
        progress1->maximum(100);
        progress1->minimum(0);
        progress1->labelsize(12);

        // Progress filename (label progress 2)
        progress_filename = new Fl_Box(10,52,215,15, "Fichier:");
        progress_filename->labelsize(12);
        progress_filename->labelfont(1);
        progress_filename->labelcolor((Fl_Color)136);
        progress_filename->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);

        // Progress 2
        progress2 = new Fl_Progress(10,70,215,20,"0%");
        progress2->maximum(100);
        progress2->minimum(0);
        progress2->labelsize(12);
        progress2->selection_color((Fl_Color)175);

        //fin du window...
        this->set_modal();
        this->end();
    }
Пример #2
0
void butt_cb(Fl_Widget *butt, void *data)
{
	// Deactivate the button
	butt->deactivate();                        // prevent button from being pressed again
	Fl::check();                               // give fltk some cpu to gray out button
	// Make the progress bar
	Fl_Window *w = (Fl_Window*)data;           // access parent window
	w->begin();                                // add progress bar to it..
	Fl_Progress *progress = new Fl_Progress(10,50,200,30);

	progress->minimum(0);                      // set progress range to be 0.0 ~ 1.0
	progress->maximum(1);
	progress->color(0x88888800);               // background color
	progress->selection_color(0x4444ff00);     // progress bar color
	progress->labelcolor(FL_WHITE);            // percent text color
	w->end();                                  // end adding to window
	// Computation loop..

	for ( int t=1; t<=500; t++ )
	{
		progress->value(t/500.0);              // update progress bar with 0.0 ~ 1.0 value
		char percent[10];
		sprintf(percent, "%d%%", int((t/500.0)*100.0));
		progress->label(percent);              // update progress bar's label
		Fl::check();                           // give fltk some cpu to update the screen
		Sleep(1000);                          // 'your stuff' that's compute intensive
	}

	// Cleanup
	w->remove(progress);                       // remove progress bar from window
	delete(progress);                          // deallocate it
	butt->activate();                          // reactivate button
	w->redraw();                               // tell window to redraw now that progress removed
}
Scheme_Object*
spark_fltk_progress::minimum(int argc, Scheme_Object** argv)
{
  DEFAULT_RET_INIT;

  Fl_Progress* p = _get_fl_progress(argc, argv, 0);
  if (p)
    {
      if (argc == 1)
	{
	  float v = p->minimum();
	  _ret_ = scheme_make_float(v);
	}
      else
	{
	  double x = 0.0f;
	  spark::Utils::double_from_scheme_double(argv[1], x);
	  p->minimum(static_cast<float>(x));
	  _ret_ = scheme_true;
	}
    }

  DEFAULT_RET_FINISH;
}
Пример #4
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;
}