void TaskBar::update_active(Window active) { for(int n=0; n<children(); n++) { Fl_Widget *w = child(n); Window win = w->argument(); if(GetState(win) == IconicState) w->label_color(fl_inactive(FL_BLACK)); else w->label_color(Fl_Button::default_style->label_color); if(active==win) { TaskBar::active = win; w->set_value(); w->color(fl_lighter(Fl_Button::default_style->color)); w->highlight_color(fl_lighter(Fl_Button::default_style->color)); } else { w->clear_value(); w->color(Fl_Button::default_style->color); w->highlight_color(Fl_Button::default_style->highlight_color); } } redraw(); }
void draw ( void ) { if ( use_cairo ) fl_push_use_cairo(true); fl_rectf( x(), y(), w(), h(), FL_BLACK ); unsigned long long then = get_ts(); fl_push_clip( x(), y(), w(), h() ); int count = 400; /* draw stuff */ int i = 0; for ( ; i < count; ++i ) fl_draw_box( boxtype, x(), y(), w(), h(), fl_lighter( FL_BLACK ) ); fl_pop_clip(); unsigned long long now = get_ts(); double elapsedms = (now - then) / 1000.0; static char text[256]; sprintf( text, "Drew %i boxes in in %fms", i, elapsedms ); fl_color( FL_RED ); fl_draw( text, x(), y(), w(), h(), FL_ALIGN_CENTER | FL_ALIGN_INSIDE ); draw_label(); if ( use_cairo ) fl_pop_use_cairo(); }
int Flu_Button :: handle( int event ) { if( !active_r() ) return Fl_Button::handle( event ); switch( event ) { case FL_MOVE: { checkLink(); return 1; } case FL_ENTER: { if( active() ) { Fl_Button::color( fl_lighter( col ) ); Fl_Button::selection_color( fl_lighter( sCol ) ); } checkLink(); redraw(); return 1; } break; case FL_LEAVE: { Fl_Button::color( col ); Fl_Button::selection_color( sCol ); checkLink(); redraw(); return 1; break; } } if( retBtn ) { if( event == FL_SHORTCUT && (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) { do_callback(); return 1; } } return Fl_Button::handle( event ); }
EDE_Calendar::EDE_Calendar(int x,int y,int w,int h,const char *lbl) : Fl_Group(x,y,w,h,lbl) { unsigned int i; // Calendar contents, correct size and position is set by layout() // Header box m_monthNameBox = new Fl_Box(x,y,w,16); m_monthNameBox->box(FL_NO_BOX); // Weekday headers for (i = 0; i < 7; i++) { m_dayNameBoxes[i] = new Fl_Box(x+i*16,y+16,16,16); m_dayNameBoxes[i]->box(FL_FLAT_BOX); m_dayNameBoxes[i]->color(fl_color_average(color(), FL_GREEN, 0.8)); // get first two letters of day name edelib::Date d; d.set(1900,1,7+i); // 1.1.1900 was Monday char tmp[3]; snprintf(tmp,3,"%s", d.day_name()); m_dayNameBoxes[i]->copy_label(tmp); } // Fillers (parts of calendar without day buttons) for (int i=0; i<3; i++) { m_filler[i] = new Fl_Box(x,y,16,16); m_filler[i]->box(FL_FLAT_BOX); m_filler[i]->color(fl_color_average(color(), FL_BLACK, 0.95)); // very mild grayish } // Day buttons for (i = 0; i < 31; i++) { m_dayButtons[i] = new Fl_Box(0,0,16,16); char tmp[3]; snprintf(tmp,3, "%d", (i+1)); m_dayButtons[i]->copy_label(tmp); } // Switch buttons for (i = 0; i < 4; i++) { Fl_Repeat_Button* o; m_switchButtons[i] = o = new Fl_Repeat_Button(x,y,16,16,switchLabels[i]); o->callback(EDE_Calendar::cbSwitchButtonClicked, (long)monthChanges[i]); o->labelcolor(fl_darker(FL_BACKGROUND_COLOR)); o->selection_color(fl_lighter(FL_BACKGROUND_COLOR)); } end(); reset(); // this will eventually call layout() }
void MainMenu::draw() { Fl_Boxtype box = this->box(); Fl_Flags flags; Fl_Color color = this->color(); Fl_Color lcolor = label_color(); if (!active_r()) flags = FL_INACTIVE; else if (m_open) flags = FL_VALUE; else flags = 0; if (belowmouse()) { flags = flags|FL_HIGHLIGHT; color = fl_lighter(color); lcolor = fl_lighter(label_color()); if(!color) color = this->color(); if(!lcolor) color = this->label_color(); } box->draw(0, 0, this->w(), this->h(), color, flags); int X=0, Y=0, W=w(), H=h(); box->inset(X,Y,W,H); if(image()) { int imY = (h()/2)-(image()->height()/2); image()->draw(6, imY, image()->width(), image()->height(), flags); X+=image()->width()+6; } else { X += 4; W -= 4; } fl_font(label_font(), label_size()); label_type()->draw(label(), X, Y, W-X, H, lcolor, flags|FL_ALIGN_LEFT); }
void CInstaller::Init(int argc, char **argv) { const int buttonsy = WindowH()-ButtonHeight()-ButtonHSpacing(); m_pMainWindow = new Fl_Double_Window(WindowW(), WindowH(), "Nixstaller"); m_pMainWindow->callback(CancelCB, this); Fl_Group *maingroup = new Fl_Group(0, 0, WindowW(), WindowH()); maingroup->resizable(NULL); maingroup->box(FL_FLAT_BOX); maingroup->color(fl_lighter(FL_BACKGROUND_COLOR)); Fl_Pack *mainpack = new Fl_Pack(0, 0, WindowW(), WindowH()-90); mainpack->resizable(NULL); mainpack->type(Fl_Pack::VERTICAL); CreateHeader(); m_pWizard = new Fl_Wizard(0, m_pHeaderGroup->h(), WindowW(), (buttonsy-m_pHeaderGroup->h()-ButtonHSpacing())); m_pWizard->box(FL_ENGRAVED_BOX); m_pWizard->end(); mainpack->end(); m_pCancelButton = new Fl_Button(ButtonWOffset(), buttonsy, 0, ButtonHeight(), GetTranslation("Cancel")); SetButtonWidth(m_pCancelButton); m_pCancelButton->callback(CancelCB, this); m_pButtonPack = new Fl_Pack(0, buttonsy, 0, ButtonHeight()); m_pButtonPack->type(Fl_Pack::HORIZONTAL); m_pButtonPack->spacing(ButtonWSpacing()); m_pBackButton = new Fl_Button(0, buttonsy, 0, ButtonHeight(), CreateText("@<- %s", GetTranslation("Back"))); SetButtonWidth(m_pBackButton); m_pBackButton->callback(BackCB, this); m_pNextButton = new Fl_Button(0, buttonsy, 0, ButtonHeight(), CreateText("%s @->", GetTranslation("Next"))); SetButtonWidth(m_pNextButton); m_pNextButton->callback(NextCB, this); m_pButtonPack->end(); UpdateButtonPack(); maingroup->end(); CBaseInstall::Init(argc, argv); Fl_Shared_Image *img = Fl_Shared_Image::get(GetLogoFName()); if (img) { m_pLogoBox = new Fl_Box(HeaderSpacing(), HeaderSpacing(), img->w()+HeaderSpacing(), img->h()); m_pLogoBox->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE); m_pLogoBox->image(img); m_pHeaderGroup->add(m_pLogoBox); } int size = m_pWizard->children(); for (int i=0; i<size; i++) { CInstallScreen *screen = GetScreen(m_pWizard->child(i)); if (screen->CanActivate()) { ActivateScreen(screen); break; } } m_pMainWindow->end(); m_pMainWindow->show(argc, argv); }
FL_EXPORT_C(Fl_Color, fl_lighterC)(Fl_Color c){return fl_lighter(c);}
extern "C" bool fltk_theme() { Fl_Boxtype vertup = new Fl_Shaded_Box(FL_THIN_UP_BOX, true); Fl_Boxtype vertdown = new Fl_Shaded_Box(FL_THIN_DOWN_BOX, true); Fl_Boxtype vertfr = new Fl_Shaded_Box(FL_BORDER_BOX, true); Fl_Boxtype vertflat = new Fl_Shaded_Box(FL_FLAT_BOX, true); Fl_Boxtype verthl = new Fl_Shaded_Box(FL_HIGHLIGHT_BOX, true); Fl_Boxtype horup = new Fl_Shaded_Box(FL_THIN_UP_BOX, false); Fl_Boxtype hordown = new Fl_Shaded_Box(FL_THIN_DOWN_BOX, false); //Fl_Boxtype horfr = new Fl_Shaded_Box(FL_BORDER_BOX, false); Fl_Boxtype horflat = new Fl_Shaded_Box(FL_FLAT_BOX, false); Fl_Color bc = fl_rgb(180,210,230); Fl_Style::scrollbar_width = 15; Fl_Widget::default_style->box = vertdown; //Fl_Widget::default_style->button_box = vertup; Fl_Widget::default_style->color = bc; //Fl_Widget::default_style->highlight_color = FL_LIGHT2; Fl_Style* s; if ((s = Fl_Style::find("window"))) { s->box = FL_FLAT_BOX;//vertflat; s->color = fl_rgb(180,200,215); } if ((s = Fl_Style::find("group"))) { s->box = FL_NO_BOX; s->color = bc; s->button_color = bc; } if ((s = Fl_Style::find("menu"))) { s->selection_text_color = fl_darker(FL_BLUE); s->selection_color = bc; s->box = vertfr; s->color = fl_lighter(FL_BLUE); s->button_box = vertfr; } if ((s = Fl_Style::find("menu bar"))) { s->color = bc; s->highlight_label_color = fl_darker(FL_BLUE); s->selection_text_color = fl_darker(FL_BLUE); s->highlight_color = FL_GRAY; s->box = vertflat; s->button_box = FL_NO_BOX; } if ((s = Fl_Style::find("choice"))) { s->box = FL_THIN_DOWN_BOX; s->button_color = bc; } if ((s = Fl_Style::find("button"))) { s->selection_color = fl_darker(bc); s->color = bc; s->box = vertup; } if ((s = Fl_Style::find("scrollbar"))) { s->color = bc; s->button_color = bc; s->button_box = vertup; } if ((s = Fl_Style::find("menu button"))) { s->color = bc; s->box = vertup; } if((s = Fl_Style::find("browser"))) { s->box = FL_THIN_DOWN_BOX; s->color = fl_rgb(235,245,255); } if((s = Fl_Style::find("input browser"))) { s->box = FL_THIN_DOWN_BOX; s->button_color = bc; s->color = fl_rgb(235,245,255); } if((s = Fl_Style::find("input"))) { s->box = hordown; } if ((s = Fl_Style::find("listview header"))) { s->button_box = vertup; s->button_color = bc; } if ((s = Fl_Style::find("listview"))) { s->button_color = fl_lighter(bc); } if ((s = Fl_Style::find("slider"))) { s->box = hordown; s->button_box = horup; s->color = bc; s->button_color = fl_darker(bc); s->focus_box = FL_NO_BOX; } if ((s = Fl_Style::find("value slider"))) { s->box = hordown; s->button_box = horup; s->color = bc; s->button_color = fl_darker(bc); s->focus_box = FL_NO_BOX; } if ((s = Fl_Style::find("highlight button"))) { s->box = verthl; s->color = bc; s->highlight_color = fl_lighter(bc); } if ((s = Fl_Style::find("tool bar"))) { //s->highlight_color = FL_GRAY; s->box = vertup; } if ((s = Fl_Style::find("tabs"))) { s->box = FL_THIN_UP_BOX; s->color = fl_rgb(180,200,215); s->button_color = fl_rgb(180,200,215); } if ((s = Fl_Style::find("pack"))) { s->box = horflat; } if ((s = Fl_Style::find("workspace"))) { s->box = FL_THIN_DOWN_BOX;; } if ((s = Fl_Style::find("mdi viewport"))) { s->box = FL_FLAT_BOX;//vertflat; s->color = fl_rgb(180,200,215); } if ((s = Fl_Style::find("panel"))) { s->box = horup; s->color = bc; } if ((s = Fl_Style::find("light button"))) { s->selection_color = fl_lighter(FL_BLUE); } if ((s = Fl_Style::find("calendar"))) { s->box = FL_NO_BOX; s->button_box = vertup; s->button_color = fl_rgb(60,120,200); } return true; }
int dialog_checklist(std::string checklist_options, bool return_value, bool check_all, char separator) { Fl_Group *g, *g_inside, *buttongroup; Fl_Box *dummy1, *dummy2; Fl_Return_Button *but_ok; Fl_Button *but_cancel; Fl_Check_Browser *browser; std::vector<std::string> vec; size_t vec_size; int range; split(checklist_options, separator, vec); vec_size = vec.size(); if (vec_size < 2) { title = "error: checklist"; msg = "Two or more options required!"; dialog_message(MESSAGE_TYPE_INFO); return 1; } if (!title) { title = "Select your option(s)"; } win = new Fl_Double_Window(420, 356, title); win->callback(close_cb, 1); { g = new Fl_Group(0, 0, 420, 310); { g_inside = new Fl_Group(0, 0, 420, 310); { browser = new Fl_Check_Browser(10, 10, 400, 299); browser->box(FL_THIN_DOWN_BOX); browser->color(fl_lighter(fl_lighter(FL_BACKGROUND_COLOR))); browser->clear_visible_focus(); for (auto it = vec.begin(); it != vec.end(); ++it) { std::string &s = *it; browser->add(s.c_str()); } if (check_all) { browser->check_all(); } dummy1 = new Fl_Box(10, 308, 400, 1); dummy1->box(FL_NO_BOX); vec.clear(); } g_inside->resizable(dummy1); g_inside->end(); } g->resizable(g_inside); g->end(); buttongroup = new Fl_Group(0, 310, 420, 42); { int but_w = measure_button_width(fl_cancel, 20); range = but_w + 40; but_cancel = new Fl_Button(win->w() - 10 - but_w, 320, but_w, 26, fl_cancel); but_cancel->callback(close_cb, 1); but_w = measure_button_width(fl_ok, 40); but_ok = new Fl_Return_Button(but_cancel->x() - 10 - but_w, 320, but_w, 26, fl_ok); but_ok->callback(close_cb, 0); dummy2 = new Fl_Box(but_ok->x() - 1, 310, 1, 1); dummy2->box(FL_NO_BOX); } buttongroup->resizable(dummy2); buttongroup->end(); } run_window(win, g, range, 100); if (ret == 0) { std::string list; for (size_t i = 1; i <= vec_size; ++i) { if (return_value) { if (browser->checked(i)) { list.append(quote); list.append(browser->text(i)); list.append(quote); list.push_back(separator); } } else { list.append(quote); list += (browser->checked(i)) ? "TRUE" : "FALSE"; list.append(quote); list.push_back(separator); } } /* strip trailing separator */ list.pop_back(); std::cout << list << std::endl; } return ret; }
void Module::draw_box ( void ) { fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) ); int tw, th, tx, ty; tw = w(); th = h(); ty = y(); tx = x(); fl_push_clip( tx, ty, tw, th ); Fl_Color c = is_default() ? FL_BLACK : color(); c = active() && ! bypass() ? c : fl_inactive( c ); int spacing = w() / instances(); for ( int i = instances(); i--; ) { fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, Fl::belowmouse() == this ? fl_lighter( c ) : c ); } if ( this == Fl::focus() ) { fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() ); } if ( audio_input.size() && audio_output.size() ) { /* maybe draw control indicators */ if ( control_input.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); if ( control_output.size() ) fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); } Fl_Group::draw_children(); fl_pop_clip(); }
/* called when we are inserted */ void Plotter2DObj::_inserted(pnot cb, RangeManager * rm, void * data, void * data2, int hintWidth) { MTOOLS_ASSERT(isFltkThread()); // the owner should be calling from the fltk thread ! if (((pnot)_ownercb) != nullptr) // we are already inserted, detach before going further { MTOOLS_DEBUG("Plotter2DObj::_inserted, already inserted, we detach before going any further"); MTOOLS_ASSERT(((pnot)_ownercb) != cb); // make sure it is a different owner. detach(); // ok, we detach from the previous owner. } _ownercb = cb; //save the callback _data = data; //save the data _data2 = data2;// and the additional data _rm = rm; //save the range manager Fl_Group::current(0); // prevent adding to option window to some other window. _extOptionWin = nullptr; _di = inserted(_optionWin, hintWidth); // get the drawable object and the option window MTOOLS_ASSERT((Drawable2DInterface*)_di != nullptr); // the drawable object should exist. Fl_Group::current(0); // close the FL_group if needed. /* we create the window */ int ow = (_optionWin == nullptr) ? hintWidth : _optionWin->w(); // extended option window _extOptionWin = new Fl_Group(0, 0, ow,40); // create the extended group _extOptionWin->box(FL_UP_BOX); _titleBox = new Fl_Box(0, 0, ow, 40); _titleBox->color(fl_lighter(FL_BACKGROUND_COLOR)); _titleBox->box(FL_UP_BOX); _nameBox = new Fl_Button(55, 0, ow - 55, 20, _name.c_str()); _nameBox->color(fl_lighter(FL_BACKGROUND_COLOR)); _nameBox->labelcolor(FL_BLACK); _nameBox->box(FL_UP_BOX); _nameBox->labelfont(0); _nameBox->labelsize(16); _nameBox->callback(_nameColorCB_static, this); setNameWidgetColor(); _upButton = new Fl_Button(0, 0, 20, 20, "@#8->"); _upButton->labelcolor(FL_BLACK); _upButton->box(FL_UP_BOX); _upButton->callback(_upButtonCB_static, this); _downButton = new Fl_Button(20, 0, 20, 20, "@#2->"); _downButton->labelcolor(FL_BLACK); _downButton->box(FL_UP_BOX); _downButton->callback(_downButtonCB_static, this); _onOffButton = new Fl_Light_Button(40, 0, 15, 20); _onOffButton->color2(FL_RED); _onOffButton->box(FL_UP_BOX); _onOffButton->value(1); _onOffButton->callback(_onOffButtonCB_static, this); _useRangeX = new Fl_Button(2, 22, 15, 16, "X"); _useRangeX->color(fl_lighter(FL_BACKGROUND_COLOR)); _useRangeX->labelcolor(FL_BLACK); _useRangeX->box(FL_UP_BOX); _useRangeX->labelfont(10); _useRangeX->labelsize(10); _useRangeX->callback(_useRangeXCB_static, this); if (!hasFavouriteRangeX()) { _useRangeX->deactivate(); } _useRangeY = new Fl_Button(2 + 15, 22, 15, 16, "Y"); _useRangeY->color(fl_lighter(FL_BACKGROUND_COLOR)); _useRangeY->labelcolor(FL_BLACK); _useRangeY->box(FL_UP_BOX); _useRangeY->labelfont(10); _useRangeY->labelsize(10); _useRangeY->callback(_useRangeYCB_static, this); if (!hasFavouriteRangeY()) { _useRangeY->deactivate(); } _useRangeXY = new Fl_Button(2 + 30, 22, 23, 16, "X/Y"); _useRangeXY->color(fl_lighter(FL_BACKGROUND_COLOR)); _useRangeXY->labelcolor(FL_BLACK); _useRangeXY->box(FL_UP_BOX); _useRangeXY->labelfont(10); _useRangeXY->labelsize(10); _useRangeXY->callback(_useRangeXYCB_static, this); if (!(hasFavouriteRangeX() && hasFavouriteRangeY())) { _useRangeXY->deactivate(); } _opacitySlider = new Fl_Value_Slider(60, 23, ow - 105 - 80, 14); _opacitySlider->labelfont(0); _opacitySlider->labelsize(11); _opacitySlider->color(fl_lighter(FL_BACKGROUND_COLOR)); _opacitySlider->align(Fl_Align(FL_ALIGN_LEFT)); _opacitySlider->box(FL_FLAT_BOX); _opacitySlider->type(FL_HOR_NICE_SLIDER); _opacitySlider->range(0, 1.0); _opacitySlider->step(0.01); _opacitySlider->value(_opacity); _opacitySlider->color2(FL_RED); _opacitySlider->callback(_opacitySliderCB_static, this); _progBar = nullptr; _nbthl = nullptr; if (((Drawable2DInterface*)_di)->nbThreads()>0) // check if the object uses threads { _nbth = ((Drawable2DInterface*)_di)->nbThreads(); _nbthl = new Fl_Box(ow - 105 - 15, 23, 14, 14); _nbthl->labelsize(10); _nbthl->box(FL_FLAT_BOX); _nbthl->color(fl_darker(FL_GRAY)); _nbthl->copy_label(mtools::toString(_nbth).c_str()); _progBar = new Fl_Progress(ow - 105, 22, 84, 16); _progBar->minimum(0.0); _progBar->maximum(100.0); _progBar->value(100.0); _progBar->color(fl_darker(FL_GRAY)); _progBar->labelcolor(FL_WHITE); _progBar->selection_color(FL_RED); _progBar->labelsize(11); _progVal = -1; _progBar->copy_label("stopped"); // and add the timer Fl::add_timeout(0.1, _timerCB_static, this); } _unrollButton = new Fl_Button(ow - 20, 22, 16, 16, "@-42>>"); _unrollButton->labelcolor(fl_lighter(FL_BLACK)); _unrollButton->box(FL_UP_BOX); _unrollButton->callback(_unrollButtonCB_static, this); if (_optionWin == nullptr) { _unrollButton->deactivate(); } _extOptionWin->end(); _extOptionWin->resizable(0); if (!_drawOn) // deactivate widget if object not enabled { _nameBox->deactivate(); _useRangeX->deactivate(); _useRangeY->deactivate(); _useRangeXY->deactivate(); _opacitySlider->deactivate(); if (_progBar != nullptr) _progBar->deactivate(); if (_optionWin != nullptr) _optionWin->deactivate(); } setParam(rm->getRange(), rm->getWinSize()); // save the parameters for the range of the drawing which will be applied when we enable the object enable(_drawOn); // so maybe right now, or later on... return; }
void EDE_Calendar::update_calendar() { unsigned int i; // Find first day of week edelib::Date d=active_date_; d.set(d.year(), d.month(), 1); int day_of_week = d.day_of_week()-1; // Show/hide first filler if (day_of_week>0) m_filler[0]->show(); else m_filler[0]->hide(); // Days int row=2; for (i=0; i<d.days_in_month(); i++) { Fl_Box* btn = m_dayButtons[i]; // shortcut btn->show(); // Set button color Fl_Color daycolor = color(); // base color is the color of calendar if (day_of_week==0) // Special color for sunday daycolor = fl_color_average(daycolor, FL_BLUE, 0.8); if (i==(uint)today_date_.day()-1 && d.month()==today_date_.month() && d.year()==today_date_.year()) btn->color(fl_color_average(daycolor, FL_RED, 0.5)); // today else if (i==(uint)active_date_.day()-1) btn->color(fl_lighter(daycolor)); else btn->color(daycolor); // Set downbox for active day if (i==(uint)active_date_.day()-1) btn->box(FL_DOWN_BOX); else btn->box(FL_FLAT_BOX); day_of_week++; if (day_of_week==7) { day_of_week=0; row++; } } // Hide remaining buttons for (i=d.days_in_month(); i<31; i++) m_dayButtons[i]->hide(); // Show/hide second filler if (day_of_week<6) m_filler[1]->show(); else m_filler[1]->hide(); // Show/hide third filler if (row<7) m_filler[2]->show(); else m_filler[2]->hide(); // Set title static char title[30]; // No month name should be larger than 24 chars, even when localized // and we can't show it anyway cause the box is too small snprintf (title, 30, "%s, %d", d.month_name(), d.year()); m_monthNameBox->copy_label(title); // Calculate tooltip (distance between today and active date) static char tooltip_str[1024]; tooltip_str[0] = '\0'; if (today_date_ != active_date_) { long dist = date_distance(today_date_, active_date_); long weeks = dist/7; int wdays = dist%7; int months=0; int mdays=0; int years=0; int ymonths=0; // Find lower date, first part of tooltip edelib::Date d1,d2; if (today_date_ < active_date_) { d1=today_date_; d2=active_date_; snprintf(tooltip_str, 1023, _("In %ld days"), dist); } else { d2=today_date_; d1=active_date_; snprintf(tooltip_str, 1023, _("%ld days ago"), dist); } // If necessary, calculate distance in m/d and y/m/d format if (dist>30) { months = d2.month() - d1.month() + (d2.year() - d1.year())*12; mdays = d2.day() - d1.day(); if (mdays<1) { mdays += d2.days_in_month(); months--; } } if (months>11) { years = months/12; ymonths = months%12; } // Append those strings using snprintf if (weeks) { char* tmp = strdup(tooltip_str); snprintf(tooltip_str, 1023, _("%s\n%ld weeks and %d days"), tmp, weeks, wdays); free(tmp); } if (months) { char* tmp = strdup(tooltip_str); snprintf(tooltip_str, 1023, _("%s\n%d months and %d days"), tmp, months, mdays); free(tmp); } if (years) { char* tmp = strdup(tooltip_str); snprintf(tooltip_str, 1023, _("%s\n%d years, %d months and %d days"), tmp, years, ymonths, mdays); free(tmp); } } tooltip(tooltip_str); layout(x(),y(),w(),h()); // relayout buttons if neccessary redraw(); }