From b0979fbab8c2dbbbe8d198bcd16fe14ae5a60568 Mon Sep 17 00:00:00 2001 From: cpicanco Date: Wed, 14 Dec 2016 23:25:07 -0300 Subject: [PATCH] complete gui - second prototype --- experiment_designer/form_main.lfm | 79 +++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ experiment_designer/form_main.pas | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- 2 files changed, 152 insertions(+), 80 deletions(-) diff --git a/experiment_designer/form_main.lfm b/experiment_designer/form_main.lfm index 197d0b6..187ddcd 100644 --- a/experiment_designer/form_main.lfm +++ b/experiment_designer/form_main.lfm @@ -1,14 +1,14 @@ object FormDesigner: TFormDesigner - Left = 327 + Left = 291 Height = 635 - Top = 106 + Top = 44 Width = 656 - HorzScrollBar.Page = 387 - VertScrollBar.Page = 520 + HorzScrollBar.Page = 346 + VertScrollBar.Page = 616 AutoScroll = True Caption = 'Planejar Experimento' ClientHeight = 616 - ClientWidth = 656 + ClientWidth = 646 Menu = MainMenu1 OnActivate = FormActivate OnCreate = FormCreate @@ -18,12 +18,12 @@ object FormDesigner: TFormDesigner LCLVersion = '1.6.2.0' object PageControl: TPageControl Left = 0 - Height = 616 + Height = 744 Top = 0 - Width = 656 - ActivePage = TabSheetContingencies + Width = 646 + ActivePage = TabSheetExperiment Align = alClient - TabIndex = 2 + TabIndex = 0 TabOrder = 0 object TabSheetExperiment: TTabSheet Caption = 'Experimento' @@ -32,8 +32,8 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 583 - ClientWidth = 650 + ClientHeight = 711 + ClientWidth = 640 object LabelResearcherName: TLabel Left = 0 Height = 15 @@ -140,21 +140,21 @@ object FormDesigner: TFormDesigner end object GBMatrix: TGroupBox Left = 0 - Height = 122 + Height = 143 Top = 456 Width = 640 Caption = 'Tipo da Matrix' ChildSizing.LeftRightSpacing = 5 ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 105 + ClientHeight = 126 ClientWidth = 636 TabOrder = 6 object ChkColors: TCheckBox Left = 5 Height = 21 Top = 0 - Width = 169 + Width = 239 Caption = '5 cores' Checked = True Enabled = False @@ -165,7 +165,7 @@ object FormDesigner: TFormDesigner Left = 5 Height = 21 Top = 21 - Width = 169 + Width = 239 Caption = '10 linhas' Checked = True Enabled = False @@ -176,7 +176,7 @@ object FormDesigner: TFormDesigner Left = 5 Height = 21 Top = 42 - Width = 169 + Width = 239 Caption = '10 colunas' TabOrder = 2 end @@ -184,7 +184,7 @@ object FormDesigner: TFormDesigner Left = 5 Height = 21 Top = 63 - Width = 169 + Width = 239 Caption = 'Com Círculos Preechidos' OnChange = ChkDotsChange TabOrder = 3 @@ -193,16 +193,25 @@ object FormDesigner: TFormDesigner Left = 5 Height = 21 Top = 84 - Width = 169 + Width = 239 Caption = 'Com Círculos Vazados' OnChange = ChkCleanDotsChange TabOrder = 4 end + object ChkDotsCleanDots: TCheckBox + Left = 5 + Height = 21 + Top = 105 + Width = 239 + Caption = 'Com Círculos Vazados e Preenchidos' + OnChange = ChkDotsCleanDotsChange + TabOrder = 5 + end end object GBConditions: TGroupBox Left = 0 Height = 97 - Top = 583 + Top = 604 Width = 640 Caption = 'Condições' ClientHeight = 80 @@ -228,8 +237,8 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 583 - ClientWidth = 650 + ClientHeight = 711 + ClientWidth = 640 object ComboCurrentCondition: TComboBox Left = 0 Height = 27 @@ -277,6 +286,7 @@ object FormDesigner: TFormDesigner Top = 0 Width = 169 Caption = 'Reordenar' + OnClick = BtnReorderCondClick TabOrder = 2 end end @@ -353,7 +363,7 @@ object FormDesigner: TFormDesigner end object GBQuestion: TGroupBox Left = 0 - Height = 144 + Height = 164 Top = 273 Width = 640 Caption = 'Apresentar pergunta ao final do ciclo' @@ -362,7 +372,7 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 127 + ClientHeight = 147 ClientWidth = 636 TabOrder = 5 object CheckBoxShouldAskQuestion: TCheckBox @@ -374,10 +384,18 @@ object FormDesigner: TFormDesigner OnChange = CheckBoxShouldAskQuestionChange TabOrder = 0 end + object LabelQuestion: TLabel + Left = 50 + Height = 15 + Top = 26 + Width = 536 + Caption = 'Texto da Pergunta' + ParentColor = False + end object EditQuestion: TEdit Left = 50 Height = 25 - Top = 26 + Top = 46 Width = 536 OnEditingDone = EditQuestionEditingDone TabOrder = 1 @@ -387,7 +405,7 @@ object FormDesigner: TFormDesigner object CGQuestion: TCheckGroup Left = 50 Height = 71 - Top = 56 + Top = 76 Width = 536 AutoFill = True Caption = 'O que deve acontecer quando todos responderem sim?' @@ -416,7 +434,7 @@ object FormDesigner: TFormDesigner object RGEndCriteriaStyle: TRadioGroup Left = 0 Height = 80 - Top = 422 + Top = 442 Width = 640 AutoFill = True Caption = 'Estilo do critério de finalização da condição' @@ -441,7 +459,7 @@ object FormDesigner: TFormDesigner object GBEndCriteria: TGroupBox Left = 0 Height = 109 - Top = 507 + Top = 527 Width = 640 Caption = 'Valores do critério de finalização da condição' ChildSizing.LeftRightSpacing = 50 @@ -527,7 +545,7 @@ object FormDesigner: TFormDesigner object GBContingencies: TGroupBox Left = 0 Height = 97 - Top = 621 + Top = 641 Width = 640 Caption = 'Contingências e Metacontingências' ClientHeight = 80 @@ -553,8 +571,8 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 583 - ClientWidth = 650 + ClientHeight = 711 + ClientWidth = 640 Enabled = False object RGContingencyType: TRadioGroup Left = 0 @@ -626,6 +644,7 @@ object FormDesigner: TFormDesigner Top = 0 Width = 171 Caption = 'Reordenar' + OnClick = BtnReorderContingencyClick TabOrder = 2 end end diff --git a/experiment_designer/form_main.pas b/experiment_designer/form_main.pas index f7228f5..e040237 100644 --- a/experiment_designer/form_main.pas +++ b/experiment_designer/form_main.pas @@ -20,6 +20,7 @@ type BtnReorderCond: TButton; BtnReorderContingency: TButton; CGGlobal: TCheckGroup; + ChkDotsCleanDots: TCheckBox; ChkColors: TCheckBox; ChkRows: TCheckBox; ChkCols: TCheckBox; @@ -48,6 +49,7 @@ type GBContingencyRows: TGroupBox; GBContingencyConsequence: TGroupBox; GBMatrix: TGroupBox; + LabelQuestion: TLabel; LabelPointsOnConditionBegin: TLabel; LabelC1: TLabel; LabelC2: TLabel; @@ -97,6 +99,9 @@ type procedure BtnAppendContingencyClick(Sender: TObject); procedure BtnRemoveCondClick(Sender: TObject); procedure BtnRemoveContingencyClick(Sender: TObject); + procedure BtnReorderCondClick(Sender: TObject); + procedure BtnReorderContingencyClick(Sender: TObject); + procedure ChkDotsCleanDotsChange(Sender: TObject); // procedure ConsequenceMessageEditingDone(Sender: TObject); procedure ConsequenceStyleChange(Sender: TObject); @@ -321,7 +326,10 @@ begin LC += '1'; with FExperiment do if ValueExists(LS,LC+KEY_CONT_NAME) and (not FLoading) then - LoadContingency(LS,LC); + begin + LoadContingency(LS,LC); + ComboCurrentContingency.ItemIndex:=0; + end; end; end; @@ -1126,13 +1134,28 @@ end; procedure TFormDesigner.ChkCleanDotsChange(Sender: TObject); begin if ChkCleanDots.Checked then - ChkDots.Checked := not ChkCleanDots.Checked; + begin + ChkDots.Checked := not ChkCleanDots.Checked; + ChkDotsCleanDots.Checked := not ChkCleanDots.Checked; + end; end; procedure TFormDesigner.ChkDotsChange(Sender: TObject); begin if ChkDots.Checked then - ChkCleanDots.Checked := not ChkDots.Checked; + begin + ChkCleanDots.Checked := not ChkDots.Checked; + ChkDotsCleanDots.Checked := not ChkDots.Checked; + end; +end; + +procedure TFormDesigner.ChkDotsCleanDotsChange(Sender: TObject); +begin + if ChkDotsCleanDots.Checked then + begin + ChkCleanDots.Checked := not ChkDotsCleanDots.Checked; + ChkDots.Checked := not ChkDotsCleanDots.Checked; + end; end; procedure TFormDesigner.ComboCurrentConditionChange(Sender: TObject); @@ -1239,13 +1262,14 @@ begin LC + '|' + EditContingencyName.Text; ComboCurrentContingency.ItemIndex := i; SaveContingency(LS,LC); - ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text; + UpdateContingencyList(LS); end; procedure TFormDesigner.BtnRemoveCondClick(Sender: TObject); var i: integer; MustReorder: boolean; + LS: String; procedure Reorder(index : integer); var @@ -1277,27 +1301,34 @@ var end; begin - i := ComboCurrentCondition.ItemIndex; - MustReorder := i < ComboCurrentCondition.Items.Count - 1; - ComboCurrentCondition.Items.Delete(i); - if MustReorder then - Reorder(i); - case ComboCurrentCondition.Items.Count of - 0: {do nothing}; - 1..MaxInt: - if i = 1 then - ComboCurrentCondition.ItemIndex := i - else - ComboCurrentCondition.ItemIndex := i -1; - end; - ListBoxContingencies.Items.Text := ComboCurrentCondition.Items.Text; - TabSheetContingencies.Enabled := ComboCurrentCondition.Items.Count > 0; + if ComboCurrentCondition.ItemIndex > -1 then + begin + i := ComboCurrentCondition.ItemIndex; + MustReorder := i < ComboCurrentCondition.Items.Count - 1; + LS := ExtractDelimited(1, ComboCurrentCondition.Text, ['|']); + ComboCurrentCondition.Items.Delete(i); + FExperiment.EraseSection(LS); + + if MustReorder then + Reorder(i); + case ComboCurrentCondition.Items.Count of + 0: {do nothing}; + 1..MaxInt: + if i = 1 then + ComboCurrentCondition.ItemIndex := i + else + ComboCurrentCondition.ItemIndex := i -1; + end; + ListBoxContingencies.Items.Text := ComboCurrentCondition.Items.Text; + TabSheetContingencies.Enabled := ComboCurrentCondition.Items.Count > 0; + end; end; procedure TFormDesigner.BtnRemoveContingencyClick(Sender: TObject); var i: integer; MustReorder: boolean; + LS, LC: String; procedure ReadContingencyValuesInSection(LS,LC : string; var Keys : TStringList); begin @@ -1322,43 +1353,65 @@ var begin SectionKeys := TStringList.Create; with FExperiment do - for i := Index to ComboCurrentContingency.Items.Count - 1 do - begin - SectionName := ExtractDelimited(1, ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex], ['|']); - KeyPrefix := ExtractDelimited(1, ComboCurrentContingency.Items[i], ['|']); - ReadContingencyValuesInSection(SectionName,KeyPrefix, SectionKeys); - EraseContingency(SectionName,KeyPrefix); - // todo: contingencies on top, meta on bootom... - KeyPrefix := GetContingencyName(ExtractFileNameWithoutExt(KeyPrefix) = ExtractFileNameWithoutExt(KEY_METACONTINGENCY)); - for Line in SectionKeys do - begin - KeyName := SectionKeys.ExtractName(Line); - WriteString(SectionName, KeyName, SectionKeys.Values[KeyName]); - end; - SectionKeys.Clear; - ComboCurrentContingency.Items[i] := - KeyPrefix + '|' + ExtractDelimited(2, ComboCurrentContingency.Items[i], ['|']); - end; + begin + SectionName := ExtractDelimited(1, ComboCurrentCondition.Text, ['|']); + for i := Index to ComboCurrentContingency.Items.Count - 1 do + begin + KeyPrefix := ExtractDelimited(1, ComboCurrentContingency.Items[i], ['|']); + ReadContingencyValuesInSection(SectionName,KeyPrefix, SectionKeys); + EraseContingency(SectionName,KeyPrefix); + KeyPrefix := ExtractFileNameWithoutExt(KeyPrefix) + '.' + IntToStr(i); + for Line in SectionKeys do + begin + KeyName := SectionKeys.ExtractName(Line); + WriteString(SectionName, KeyName, SectionKeys.Values[KeyName]); + end; + SectionKeys.Clear; + ComboCurrentContingency.Items[i] := + KeyPrefix + '|' + ExtractDelimited(2, ComboCurrentContingency.Items[i], ['|']); + end; + end; SectionKeys.Free; end; begin - i := ComboCurrentContingency.ItemIndex; - MustReorder := i < ComboCurrentContingency.Items.Count - 1; - ComboCurrentContingency.Items.Delete(i); - if MustReorder then - Reorder(i); - case ComboCurrentContingency.Items.Count of - 0: {do nothing}; - 1..MaxInt: - if i = 1 then - ComboCurrentContingency.ItemIndex := i - else - ComboCurrentContingency.ItemIndex := i -1; - end; - UpdateContingencyList(ExtractDelimited(1,ComboCurrentCondition.Text,['|'])); + if ComboCurrentContingency.ItemIndex > -1 then + begin + i := ComboCurrentContingency.ItemIndex; + MustReorder := i < ComboCurrentContingency.Items.Count - 1; + LS := ExtractDelimited(1, ComboCurrentCondition.Text, ['|']); + LC := ExtractDelimited(1, ComboCurrentContingency.Text, ['|']); + ComboCurrentContingency.Items.Delete(i); + EraseContingency(LS,LC); + + if MustReorder then + Reorder(i); + + case ComboCurrentContingency.Items.Count of + 0: {do nothing}; + 1..MaxInt: + if i = 1 then + ComboCurrentContingency.ItemIndex := i + else + ComboCurrentContingency.ItemIndex := i -1; + end; + UpdateContingencyList(LS); + end; +end; + +procedure TFormDesigner.BtnReorderCondClick(Sender: TObject); +begin + // todo: custom reorder contingencies + ShowMessage('Não implementado.'); end; +procedure TFormDesigner.BtnReorderContingencyClick(Sender: TObject); +begin + // todo: custom reorder contingencies + ShowMessage('Não implementado.'); +end; + + procedure TFormDesigner.ConsequenceStyleChange(Sender: TObject); var LS, LC: String; -- libgit2 0.21.2