UIGDetailsElement::UIGDetailsElement(UIGDetailsSet *pParent, DetailsElementType type, bool fOpened) : UIGDetailsItem(pParent) , m_pSet(pParent) , m_type(type) , m_iCornerRadius(10) , m_iMinimumHeaderWidth(0) , m_iMinimumHeaderHeight(0) , m_iMinimumTextWidth(0) , m_iMinimumTextHeight(0) , m_fClosed(!fOpened) , m_pButton(0) , m_iAdditionalHeight(0) , m_fAnimationRunning(false) , m_fHovered(false) , m_fNameHovered(false) , m_pHighlightMachine(0) , m_pForwardAnimation(0) , m_pBackwardAnimation(0) , m_iAnimationDuration(400) , m_iDefaultDarkness(100) , m_iHighlightDarkness(90) , m_iAnimationDarkness(m_iDefaultDarkness) { /* Prepare element: */ prepareElement(); /* Prepare button: */ prepareButton(); /* Setup size-policy: */ setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); /* Add item to the parent: */ AssertMsg(parentItem(), ("No parent set for details element!")); parentItem()->addItem(this); }
UIGDetailsElement::UIGDetailsElement(UIGDetailsSet *pParent, DetailsElementType type, bool fOpened) : UIGDetailsItem(pParent) , m_pSet(pParent) , m_type(type) , m_iCornerRadius(10) , m_fClosed(!fOpened) , m_pButton(0) , m_iAdditionalHeight(0) , m_fAnimationRunning(false) , m_fHovered(false) , m_fNameHoveringAccessible(false) , m_fNameHovered(false) , m_pHighlightMachine(0) , m_pForwardAnimation(0) , m_pBackwardAnimation(0) , m_iAnimationDuration(400) , m_iDefaultDarkness(103) , m_iHighlightDarkness(90) , m_iAnimationDarkness(m_iDefaultDarkness) { /* Prepare element: */ prepareElement(); /* Prepare button: */ prepareButton(); /* Update size-policy/hint: */ setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); /* Update: */ updateHoverAccessibility(); /* Add item to the parent: */ parentItem()->addItem(this); }
void K3bListView::placeEditor( K3bListViewItem* item, int col ) { ensureItemVisible( item ); QRect r = itemRect( item ); r.setX( contentsToViewport( QPoint(header()->sectionPos( col ), 0) ).x() ); r.setWidth( header()->sectionSize( col ) - 1 ); // check if the column is fully visible if( visibleWidth() < r.right() ) r.setRight(visibleWidth()); r = QRect( viewportToContents( r.topLeft() ), r.size() ); if( item->pixmap( col ) ) { r.setX( r.x() + item->pixmap(col)->width() ); } // the tree-stuff is painted in the first column if( col == 0 ) { r.setX( r.x() + item->depth() * treeStepSize() ); if( rootIsDecorated() ) r.setX( r.x() + treeStepSize() ); } if( item->needButton(col) ) { prepareButton( item, col ); m_editorButton->setFixedHeight( r.height() ); // for now we make a square button m_editorButton->setFixedWidth( m_editorButton->height() ); r.setWidth( r.width() - m_editorButton->width() ); moveChild( m_editorButton, r.right(), r.y() ); } if( QWidget* editor = prepareEditor( item, col ) ) { editor->resize( r.size() ); // editor->resize( QSize( r.width(), editor->minimumSizeHint().height() ) ); moveChild( editor, r.x(), r.y() ); } }
int main( int argc, char **argv ) { // I18N #ifdef HAVE_SETLOCALE setlocale( LC_MESSAGES, "" ); // with glibc read LC_ALL first setlocale( LC_NUMERIC, "POSIX" ); // to avoid incompatibility between ifs files. #endif #ifdef ENABLE_NLS #ifdef WIN32 bindtextdomain( PACKAGE, "locale" ); #else bindtextdomain( PACKAGE, LOCALEDIR ); #endif textdomain( PACKAGE ); #endif // localization of some strings of FLTK: fl_no = _("No"); fl_yes = _("Yes"); fl_ok = _("OK"); fl_cancel = _("Cancel"); fl_close = _("Close"); Fl_File_Chooser::add_favorites_label = _("Add to Favorites"); Fl_File_Chooser::all_files_label = _("All Files (*)"); Fl_File_Chooser::custom_filter_label = _("Custom Filter"); Fl_File_Chooser::existing_file_label = _("Please choose an existing file!"); Fl_File_Chooser::favorites_label = _("Favorites"); Fl_File_Chooser::filename_label = _("Filename:"); #ifdef WIN32 Fl_File_Chooser::filesystems_label = _("My Computer"); #else Fl_File_Chooser::filesystems_label = _("File Systems"); #endif Fl_File_Chooser::manage_favorites_label = _("Manage Favorites"); Fl_File_Chooser::preview_label = _("Preview"); Fl_File_Chooser::show_label = _("Show:"); string skeletonToOpen; #ifdef HAVE_UNISTD_H while ( true ) { int c = getopt( argc, argv, "vhp:" ); if ( c == -1 ) { break; } switch ( c ) { case 'p': paramFile = optarg; break; case 'v': cerr << "Glito v" << VERSION << "\nCopyright (C) 2002-2003 Emmanuel Debanne\n" << _("Glito is distributed under the terms of the GNU General Public License.\n"); return 0; default: case 'h': usage(); return 0; } } if ( optind < argc ) { skeletonToOpen = argv[optind]; ++optind; if ( optind < argc ) { usage(); return 0; } } #endif // default size of the window int width = 600; int height = 450; const int menuHeight = 30; const int toolbarHeight = 27; const int toolHeight = 25; const string paramXML( IS::readStringInFile(paramFile) ); if ( !paramXML.empty() ) { if ( !IS::ToXML::extractFirst( paramXML, "parameters" ).empty() ) { width = atoi( IS::ToXML::extractFirst( paramXML, "frameWidth" ).c_str() ); height = atoi( IS::ToXML::extractFirst( paramXML, "frameHeight" ).c_str() ); } else { cerr << _("Failed to open: ") << paramFile << '\n'; } } Fl_Window window( width, height + menuHeight + toolbarHeight ); // if the window is closed, the application exits: window.callback(quit_cb); Fl_Menu_Bar menubar( 0, 0, width, menuHeight ); menubar.box(FL_PLASTIC_UP_BOX); // in the main to allow gettext to do its job. #ifdef WIN32 manualFile = ""; #else manualFile = DOCDIR; #endif manualFile += _("manual_en.html"); static Fl_Menu_Item menutable[] = { {_("&File"), 0, 0, 0, FL_SUBMENU}, //0 {_("&Open"), FL_CTRL+'O', skeleton_open_cb}, {_("&Save"), FL_CTRL+'S', skeleton_save_cb}, {_("&Export to Fractint"), 0, export_fractint_cb, 0, FL_MENU_DIVIDER}, #ifdef HAVE_LIBPNG {_("Set Fast Save Directory"), 0, set_snapshotPath_cb}, {_("Fast Save"), 'f', saveSnapshot_cb, NULL, FL_MENU_DIVIDER}, {_("Save PNG"), 0, saveImage_cb, (void*)Image::PNG}, #endif {_("Save PGM"), 0, saveImage_cb, (void*)Image::PGM}, {_("Save BMP bitmap"), 0, saveImage_cb, (void*)Image::BMPB}, {_("Save BMP gray"), 0, saveImage_cb, (void*)Image::BMPG, FL_MENU_DIVIDER}, {_("Edit &Paramaters"), 'p', parameters_cb}, {_("Open Paramaters"), 0, open_parameters_cb}, {_("Sa&ve parameters"), 0, save_parameters_cb, 0, FL_MENU_DIVIDER}, {_("&Quit"), FL_CTRL+'Q', quit_cb}, //10 {0}, {_("&Skeleton"), 0, 0, 0, FL_SUBMENU}, {_("&New"), FL_CTRL+'N', skeleton_new_cb}, {_("&Random"), 'h', skeleton_random_cb, 0, FL_MENU_DIVIDER}, {_("&Dimension"), FL_CTRL+'D', skeleton_dimension_cb}, {_("&Coordinates"), 0, skeleton_coordinates_cb, 0, FL_MENU_DIVIDER}, {_("out Memory1"), '1', outMemory_cb, (void*)1}, {_("out Memory2"), '2', outMemory_cb, (void*)2}, {_("out Memory3"), '3', outMemory_cb, (void*)3}, {_("out Memory4"), '4', outMemory_cb, (void*)4, FL_MENU_DIVIDER},//20 {_("in Memory1"), '5', inMemory_cb, (void*)1}, {_("in Memory2"), '6', inMemory_cb, (void*)2}, {_("in Memory3"), '7', inMemory_cb, (void*)3}, {_("in Memory4"), '8', inMemory_cb, (void*)4}, {0}, {_("&Function"), 0, 0, 0, FL_SUBMENU}, {_("Pre&vious"), 'v', function_previous_cb}, {_("&Next"), 'n', function_next_cb, 0, FL_MENU_DIVIDER}, {_("&Cut"), FL_CTRL+'X', function_cut_cb}, {_("C&opy"), FL_CTRL+'C', function_copy_cb}, {_("&Paste"), FL_CTRL+'V', function_paste_cb, 0, FL_MENU_DIVIDER}, {_("&Reshape"), 's', function_reshape_cb, 0, FL_MENU_DIVIDER}, //32 // the following items are modified by Glito::setSystemType() {_("&Linear"), 0, systemType_cb, (void *)LINEAR, FL_MENU_RADIO|FL_MENU_VALUE}, //33 {_("&Sinusoidal"), 0, systemType_cb, (void *)SINUSOIDAL, FL_MENU_RADIO}, //34 {_("&Julia"), 0, systemType_cb, (void *)JULIA, FL_MENU_RADIO}, //35 {_("&Formulas"), 0, systemType_cb, (void *)FORMULA, FL_MENU_RADIO|FL_MENU_DIVIDER}, //36 {_("&Edit Formulas"), 0, edit_formula_cb}, {0}, {_("&Color"), 0, 0, 0, FL_SUBMENU}, {_("Open Color Map"), 0, readColorMap_cb}, {_("Color / B&W"), 0, colorBW_cb, 0, FL_MENU_DIVIDER}, {_("Maps:")}, {_("Autumn"), 0, readDefinedMap_cb, (void*)0}, {_("Fast"), 0, readDefinedMap_cb, (void*)-1}, {_("CMY"), 0, readDefinedMap_cb, (void*)1}, {_("RGB"), 0, readDefinedMap_cb, (void*)2}, {_("Light CMY"), 0, readDefinedMap_cb, (void*)3}, {_("Dark"), 0, readDefinedMap_cb, (void*)4}, {_("Rich"), 0, readDefinedMap_cb, (void*)5}, {0}, {_("&Animation"), 0, 0, 0, FL_SUBMENU}, {_("&Zoom"), 'z', animation_zoom_cb}, {_("&Transition: Mem1 <-> Mem2"), 't', animation_transition_cb}, {_("&Rotation"), 'r', animation_rotation_cb}, {_("&Stop"), ' ', animation_stop_cb, 0, FL_MENU_DIVIDER}, #ifdef HAVE_LIBMNG {_("Save Zoom as MNG"), 0, saveAnimation_cb, (void*)0}, {_("Save Transition as MNG"), 0, saveAnimation_cb, (void*)1}, {_("Save Rotation as MNG"), 0, saveAnimation_cb, (void*)2}, #endif {0}, {_("&Help"), 0, 0, 0, FL_SUBMENU}, {_("Docu&mentation"), FL_F+1, documentation_cb}, {_("&Demo"), 0, demo_cb}, {_("&About"), 0, about_cb}, {0}, {0} }; menubar.menu(menutable); // the shortcuts are handled by the menu everywhere: //menubar.global(); glito = new Glito( 0, menuHeight + toolbarHeight, width, height ); if ( !IS::ToXML::extractFirst( paramXML, "parameters" ).empty() ) { glito->readParameters( paramXML ); } if ( !skeletonToOpen.empty() ) { if ( !glito->skel.fromXML( IS::readStringInFile(skeletonToOpen) ) ) { cerr << _("Failed to open: ") << skeletonToOpen << '\n'; } glito->setSystemType(); } Fl::visual( FL_DOUBLE | FL_INDEX ); // to allow the preview of PNG files in the file chooser: Fl_File_Icon::load_system_icons(); // the size of glito is changed when the size of the window is changed: window.add_resizable(*glito); // ********* toolbar *********** { Fl_Group* o = new Fl_Group( 0, menuHeight, width, toolbarHeight ); o->resizable(NULL); // not resizable int x = 0; const int toolSpace = 9; const int toolInter = 1; { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Open") ); o->image( icon_file_open ); o->callback( (Fl_Callback*)skeleton_open_cb ); x += toolHeight + toolInter; } #ifdef HAVE_LIBPNG { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Save PNG") ); o->image( icon_save_file ); o->callback( (Fl_Callback*)saveImage_cb, (void*)Image::PNG ); x += toolHeight + toolInter; } { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Fast save") ); o->image( icon_save_fast ); o->callback( (Fl_Callback*)saveSnapshot_cb ); x += toolHeight + toolInter; } #endif x += toolSpace; { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Parameters") ); o->image( icon_param ); o->callback( (Fl_Callback*)parameters_cb ); x += toolHeight + toolInter; } x += toolSpace; { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Color / B&W") ); o->image( icon_colorbw ); o->callback( (Fl_Callback*)colorBW_cb ); x += toolHeight + toolInter; } { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Open Color Map") ); o->image( icon_colormap ); o->callback( (Fl_Callback*)readColorMap_cb ); x += toolHeight + toolInter; } x += toolSpace; { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Random") ); o->image( icon_hazard ); o->callback( (Fl_Callback*)skeleton_random_cb ); x += toolHeight + toolInter; } x += toolSpace; { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Previous function") ); o->image( icon_previous ); o->callback( (Fl_Callback*)function_previous_cb ); x += toolHeight + toolInter; } { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Next function") ); o->image( icon_next ); o->callback( (Fl_Callback*)function_next_cb ); x += toolHeight + toolInter; } x += toolSpace; { Fl_Button* o = new Fl_Button( x, menuHeight+1, toolHeight, toolHeight ); prepareButton(o); o->tooltip( _("Enlarge") ); o->image( icon_larger ); o->callback( (Fl_Callback*)view_large_cb ); x += toolHeight + toolInter; } x += toolSpace; { Fl_Light_Button* o = new Fl_Light_Button( x, menuHeight+1, toolHeight+20, toolHeight ); prepareButton(o); o->tooltip( _("Rot/Dil") ); o->image( icon_rotdil ); o->callback( (Fl_Callback*)mouse_cb ); x += toolHeight + toolInter; } o->end(); } window.end(); window.show(argc,argv); /* Pixmap p = XCreateBitmapFromData( fl_display, DefaultRootWindow(fl_display), icon_bits, icon_width, icon_height ); window.icon((char *)p); */ glito->show(); menubar.show(); { // seed for the random generator: time_t t; time(&t); srand( (unsigned int)t ); } return Fl::run(); }