From a33f1e3f18445c3427bd676781d1bfc46cea25c2 Mon Sep 17 00:00:00 2001 From: Wizzup? Date: Sun, 20 Dec 2009 17:27:46 +0000 Subject: [PATCH] Some fixes + added Clear. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@300 3f818213-9676-44b0-a9b4-5e4c4e03d09d --- Projects/SAMufasaGUI/colourhistory.lfm | 1 + Projects/SAMufasaGUI/colourhistory.lrs | 14 +++--- Projects/SAMufasaGUI/colourhistory.pas | 57 ++++++++++------------- Projects/SAMufasaGUI/project1.lpi | 64 +++++++++++++------------- 4 files changed, 65 insertions(+), 71 deletions(-) diff --git a/Projects/SAMufasaGUI/colourhistory.lfm b/Projects/SAMufasaGUI/colourhistory.lfm index 30e9493..348e7c4 100644 --- a/Projects/SAMufasaGUI/colourhistory.lfm +++ b/Projects/SAMufasaGUI/colourhistory.lfm @@ -117,6 +117,7 @@ object ColourHistoryForm: TColourHistoryForm Caption = 'File' object CHClear: TMenuItem Caption = 'Clear' + OnClick = CHClearClick end object CHLoad: TMenuItem Caption = 'Load' diff --git a/Projects/SAMufasaGUI/colourhistory.lrs b/Projects/SAMufasaGUI/colourhistory.lrs index 159dbb5..d46c16d 100644 --- a/Projects/SAMufasaGUI/colourhistory.lrs +++ b/Projects/SAMufasaGUI/colourhistory.lrs @@ -35,11 +35,11 @@ LazarusResources.Add('TColourHistoryForm','FORMDATA',[ +'urTreeDragOver'#0#0#10'TImageList'#8'CHImages'#4'left'#3#168#1#3'top'#3#160 +#0#0#0#9'TMainMenu'#10'CHMainMenu'#4'left'#3'h'#1#3'top'#3#160#0#0#9'TMenuIt' +'em'#6'CHFile'#7'Caption'#6#4'File'#0#9'TMenuItem'#7'CHClear'#7'Caption'#6#5 - +'Clear'#0#0#9'TMenuItem'#6'CHLoad'#7'Caption'#6#4'Load'#7'OnClick'#7#11'CHLo' - +'adClick'#0#0#9'TMenuItem'#6'CHSave'#7'Caption'#6#4'Save'#7'OnClick'#7#11'CH' - +'SaveClick'#0#0#0#9'TMenuItem'#6'CHHelp'#7'Caption'#6#4'Help'#0#9'TMenuItem' - +#7'CHAbout'#7'Caption'#6#5'About'#7'OnClick'#7#12'CHAboutClick'#0#0#0#0#11'T' - +'SaveDialog'#12'CHSaveDialog'#10'DefaultExt'#6#4'.xml'#4'left'#3#136#1#3'top' - +#3#160#0#0#0#11'TOpenDialog'#12'CHOpenDialog'#10'DefaultExt'#6#4'.xml'#4'lef' - +'t'#3#200#1#3'top'#3#160#0#0#0#0 + +'Clear'#7'OnClick'#7#12'CHClearClick'#0#0#9'TMenuItem'#6'CHLoad'#7'Caption'#6 + +#4'Load'#7'OnClick'#7#11'CHLoadClick'#0#0#9'TMenuItem'#6'CHSave'#7'Caption'#6 + +#4'Save'#7'OnClick'#7#11'CHSaveClick'#0#0#0#9'TMenuItem'#6'CHHelp'#7'Caption' + +#6#4'Help'#0#9'TMenuItem'#7'CHAbout'#7'Caption'#6#5'About'#7'OnClick'#7#12'C' + +'HAboutClick'#0#0#0#0#11'TSaveDialog'#12'CHSaveDialog'#10'DefaultExt'#6#4'.x' + +'ml'#4'left'#3#136#1#3'top'#3#160#0#0#0#11'TOpenDialog'#12'CHOpenDialog'#10 + +'DefaultExt'#6#4'.xml'#4'left'#3#200#1#3'top'#3#160#0#0#0#0 ]); diff --git a/Projects/SAMufasaGUI/colourhistory.pas b/Projects/SAMufasaGUI/colourhistory.pas index 530deb1..9feab90 100644 --- a/Projects/SAMufasaGUI/colourhistory.pas +++ b/Projects/SAMufasaGUI/colourhistory.pas @@ -65,6 +65,7 @@ type ColourTree: TTreeView; procedure CHAboutClick(Sender: TObject); procedure ChangeName(Sender: TObject); + procedure CHClearClick(Sender: TObject); procedure CHLoadClick(Sender: TObject); procedure ColourTreeChange(Sender: TObject; Node: TTreeNode); procedure ColourTreeDragDrop(Sender, Source: TObject; X, Y: Integer); @@ -224,7 +225,6 @@ begin begin WriteXMLData(n, XMLNode, XMLDoc, XMLChild, C); - writeln('Walking: ' + n.text); WalkTree(n, XMLChild, XMLDoc, C); n := n.GetNextSibling; end; @@ -337,6 +337,15 @@ begin TColourPickerObject(ColourTree.Selected.Data).Name := SelectionName.Text; end; +procedure TColourHistoryForm.CHClearClick(Sender: TObject); +begin + TreeChanged:=False; + ColourTree.BeginUpdate; + ColourTree.Items.Clear; + CHImages.Clear; + ColourTree.EndUpdate; +end; + //heavily modded from http://wiki.lazarus.freepascal.org/XML_Tutorial procedure TColourHistoryForm.XML2Tree(XMLDoc: TXMLDocument); var @@ -421,10 +430,8 @@ begin IDYES : begin if CHSaveDialog.Execute then - begin - writeln('Saving to file: ' +CHSaveDialog.FileName); - ColourTree.SaveToFile(CHSaveDialog.FileName); - end else + ColourTree.SaveToFile(CHSaveDialog.FileName) + else Exit; end; end; @@ -435,26 +442,16 @@ begin begin writeln('Loading from file: ' + CHOpenDialog.FileName); ReadXMLFile(XMLDoc, CHOpenDialog.FileName); + + // Clear Tree and Images + ColourTree.BeginUpdate; + ColourTree.Items.Clear; + CHImages.Clear; + XML2Tree(XMLDoc); + ColourTree.EndUpdate; + + XMLDoc.Free; end; - - - // Clear Tree and Images - ColourTree.BeginUpdate; - - ColourTree.Items.Clear; - CHImages.Clear; - - XML2Tree(XMLDoc); - ColourTree.EndUpdate; - - - - - - - - XMLDoc.Free; - end; procedure TColourHistoryForm.CHAboutClick(Sender: TObject); @@ -480,14 +477,10 @@ procedure TColourHistoryForm.CHSaveClick(Sender: TObject); begin if CHSaveDialog.Execute then - if FileExists(CHSaveDialog.FileName) then - begin - writeln('Saving to file: ' +CHSaveDialog.FileName); - SaveToXML(CHSaveDialog.FileName); - //ColourTree.SaveToFile(CHSaveDialog.FileName); - TreeChanged:=False; - end else - writeln('no saving to file'); + begin + SaveToXML(CHSaveDialog.FileName); + TreeChanged:=False; + end; end; procedure TColourHistoryForm.FormCreate(Sender: TObject); diff --git a/Projects/SAMufasaGUI/project1.lpi b/Projects/SAMufasaGUI/project1.lpi index e6174bc..e6be159 100644 --- a/Projects/SAMufasaGUI/project1.lpi +++ b/Projects/SAMufasaGUI/project1.lpi @@ -1451,8 +1451,8 @@ - - + + @@ -1883,123 +1883,123 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +