ENH: PropertyRows have now a reference to CMakeSetupGUI and save the cache

at each callback action
This commit is contained in:
Luis Ibanez 2001-06-21 08:41:14 -04:00
parent 8fe1e1fcc6
commit 446ea3b97d
5 changed files with 71 additions and 23 deletions

View File

@ -17,7 +17,7 @@
* Constructor * Constructor
*/ */
CMakeSetupGUIImplementation CMakeSetupGUIImplementation
::CMakeSetupGUIImplementation() ::CMakeSetupGUIImplementation():m_CacheEntriesList( this )
{ {
m_BuildPathChanged = false; m_BuildPathChanged = false;
} }
@ -387,14 +387,12 @@ void
CMakeSetupGUIImplementation CMakeSetupGUIImplementation
::SaveCacheFromGUI( void ) ::SaveCacheFromGUI( void )
{ {
std::cout << "Saving cache from GUI ...";
this->FillCacheManagerFromCacheGUI(); this->FillCacheManagerFromCacheGUI();
if( m_WhereBuild != "" ) if( m_WhereBuild != "" )
{ {
cmCacheManager::GetInstance()->SaveCache( cmCacheManager::GetInstance()->SaveCache(
m_WhereBuild.c_str() ); m_WhereBuild.c_str() );
} }
std::cout << " Done ! " << std::endl;
} }

View File

@ -10,17 +10,26 @@
#include <FL/Fl_Color_Chooser.H> #include <FL/Fl_Color_Chooser.H>
#include <FL/Fl_Menu_Button.H> #include <FL/Fl_Menu_Button.H>
#include "../cmCacheManager.h" #include "../cmCacheManager.h"
#include "FLTKPropertyList.h"
#include "CMakeSetupGUIImplementation.h"
#include <cstdio> #include <cstdio>
namespace fltk { namespace fltk {
PropertyItemRow::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"")
CMakeSetupGUIImplementation * PropertyItemRow::m_CMakeSetup = 0;
PropertyItemRow
::PropertyItemRow( PropertyItem * pItem ):Fl_Tile(0,0,10,10,"")
{ {
m_PropertyItem = pItem; m_PropertyItem = pItem;
m_ItemValue = new ItemValue; m_ItemValue = new ItemValue;
const unsigned int fontsize = 11; const unsigned int fontsize = 11;
const unsigned int nameWidth = 200; const unsigned int nameWidth = 200;
@ -162,6 +171,12 @@ PropertyItemRow::~PropertyItemRow( )
void PropertyItemRow
::SetCMakeSetupGUI( CMakeSetupGUIImplementation * cmakeSetup )
{
m_CMakeSetup = cmakeSetup;
}
void void
@ -205,15 +220,18 @@ NameButtonCallback( Fl_Widget * widget, void * data)
// Remove the entry from the cache // Remove the entry from the cache
cmCacheManager::GetInstance()->RemoveCacheEntry( propertyName ); cmCacheManager::GetInstance()->RemoveCacheEntry( propertyName );
// Get the parent: Fl_Tile that manages the whole row in the GUI // Get the parent: Fl_Tile that manages the whole row in the GUI
Fl_Group * parentGroup = (Fl_Group *) (button->parent()); Fl_Group * parentGroup = dynamic_cast<Fl_Group *>(button->parent());
// Get the grandParent: Fl_Pack with the property list // Get the grandParent: Fl_Pack with the property list
Fl_Group * grandParentGroup = (Fl_Group *) parentGroup->parent(); Fl_Group * grandParentGroup = dynamic_cast<Fl_Group *>( parentGroup->parent() );
// Remove the row from the list // Remove the row from the list
grandParentGroup->remove( *parentGroup ); grandParentGroup->remove( *parentGroup );
// Destroy the row // Destroy the row
delete parentGroup; // Patricide... ? delete parentGroup; // Patricide... ?
// Redraw the list // Redraw the list
grandParentGroup->redraw(); grandParentGroup->redraw();
SaveCacheFromGUI();
return; return;
} }
break; break;
@ -225,6 +243,17 @@ NameButtonCallback( Fl_Widget * widget, void * data)
void
PropertyItemRow::
SaveCacheFromGUI( void )
{
if( m_CMakeSetup )
{
m_CMakeSetup->SaveCacheFromGUI();
}
}
void void
PropertyItemRow:: PropertyItemRow::
@ -246,6 +275,9 @@ CheckButtonCallback( Fl_Widget * widget, void * data)
pItem->m_curValue = "OFF"; pItem->m_curValue = "OFF";
} }
button->redraw(); button->redraw();
SaveCacheFromGUI();
} }
@ -259,6 +291,8 @@ InputTextCallback( Fl_Widget * widget, void * data)
item->m_curValue = input->value(); item->m_curValue = input->value();
SaveCacheFromGUI();
} }
@ -290,6 +324,8 @@ ColorSelectionCallback( Fl_Widget * widget, void * data)
colorButton->redraw(); colorButton->redraw();
SaveCacheFromGUI();
} }
@ -314,6 +350,8 @@ BrowsePathCallback( Fl_Widget * widget, void * data)
inputText->value( newpath ); inputText->value( newpath );
} }
SaveCacheFromGUI();
} }

View File

@ -9,6 +9,9 @@
#include <FL/Fl_Button.H> #include <FL/Fl_Button.H>
class CMakeSetupGUIImplementation;
namespace fltk { namespace fltk {
@ -30,15 +33,16 @@ class PropertyItemRow : public Fl_Tile
public: public:
PropertyItemRow( PropertyItem * ); PropertyItemRow( PropertyItem *);
~PropertyItemRow(); ~PropertyItemRow();
private: private:
PropertyItem * m_PropertyItem; PropertyItem * m_PropertyItem;
ItemValue * m_ItemValue; ItemValue * m_ItemValue;
Fl_Button * m_NameButton; Fl_Button * m_NameButton;
static CMakeSetupGUIImplementation * m_CMakeSetup;
static void CheckButtonCallback( Fl_Widget *, void *); static void CheckButtonCallback( Fl_Widget *, void *);
static void NameButtonCallback( Fl_Widget *, void *); static void NameButtonCallback( Fl_Widget *, void *);
@ -46,6 +50,11 @@ class PropertyItemRow : public Fl_Tile
static void BrowsePathCallback( Fl_Widget *, void *); static void BrowsePathCallback( Fl_Widget *, void *);
static void ColorSelectionCallback( Fl_Widget * widget, void * data); static void ColorSelectionCallback( Fl_Widget * widget, void * data);
public:
static void SetCMakeSetupGUI( CMakeSetupGUIImplementation * );
static void SaveCacheFromGUI( void );
}; };

View File

@ -10,14 +10,18 @@
#include "FL/fl_ask.H" #include "FL/fl_ask.H"
#include "FL/Fl_Button.H" #include "FL/Fl_Button.H"
#include <cstdio> #include <cstdio>
#include "CMakeSetupGUIImplementation.h"
namespace fltk { namespace fltk {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// PropertyList // PropertyList
PropertyList::PropertyList() PropertyList::PropertyList( CMakeSetupGUIImplementation * cmakeSetup )
{ {
m_CMakeSetup = cmakeSetup;
PropertyItemRow::SetCMakeSetupGUI( cmakeSetup );
} }

View File

@ -5,6 +5,9 @@
#include <string> #include <string>
class CMakeSetupGUIImplementation;
namespace fltk { namespace fltk {
@ -36,6 +39,10 @@ public:
} }
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// PropertyList window // PropertyList window
@ -53,7 +60,8 @@ public:
CHECKBOX, CHECKBOX,
PATH PATH
}; };
PropertyList();
PropertyList( CMakeSetupGUIImplementation * );
// Attributes // Attributes
public: public:
@ -93,19 +101,10 @@ protected:
int AddPropItem(PropertyItem* pItem); int AddPropItem(PropertyItem* pItem);
/*
bool m_Dirty;
int m_curSel;
int m_prevSel;
int m_nDivider;
int m_nDivTop;
int m_nDivBtm;
int m_nOldDivX;
int m_nLastBox;
*/
std::set<PropertyItem*> m_PropertyItems; std::set<PropertyItem*> m_PropertyItems;
CMakeSetupGUIImplementation * m_CMakeSetup;
}; };