summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-06-09 10:01:20 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-06-09 10:01:20 +0000
commit990f428fb090074f37a5c3a7994f035808044a7d (patch)
tree2be457e9377d398378ee59f93a1e1d853d0e3510 /extras
parent6e0e18817931e70f11b318c29008eb483ad3f742 (diff)
downloadfpGUI-990f428fb090074f37a5c3a7994f035808044a7d.tar.xz
* Fixed the tiGUIIni read/write formstate information for tiOPF based applications.
* Fixed the updating of rows in the StringGrid composite mediator (tiOPF) * Minor update to the message dialog include file.
Diffstat (limited to 'extras')
-rw-r--r--extras/tiopf/gui/tiCompositeMediators.pas24
-rw-r--r--extras/tiopf/gui/tiDialogs.pas28
-rw-r--r--extras/tiopf/gui/tiGUIINI.pas43
3 files changed, 62 insertions, 33 deletions
diff --git a/extras/tiopf/gui/tiCompositeMediators.pas b/extras/tiopf/gui/tiCompositeMediators.pas
index adb7e69c..1d4ac348 100644
--- a/extras/tiopf/gui/tiCompositeMediators.pas
+++ b/extras/tiopf/gui/tiCompositeMediators.pas
@@ -662,12 +662,12 @@ var
lFieldName: string;
lMediatorView: TStringGridRowMediator;
begin
- FView.Objects[0, ARowIdx] := AData;
+ FView.Objects[0, ARowIdx] := AData; // set Object reference inside grid
for i := 0 to tiNumToken(FDisplayNames, cFieldDelimiter)-1 do
begin
lField := tiToken(FDisplayNames, cFieldDelimiter, i+1);
lFieldName := tiFieldName(lField);
- FView.Cells[i, ARowIdx] := AData.PropValue[lFieldName];
+ FView.Cells[i, ARowIdx] := AData.PropValue[lFieldName]; // set Cell text
lMediatorView := TStringGridRowMediator.CreateCustom(AData, FView, FDisplayNames, ARowIdx, FIsObserving);
FMediatorList.Add(lMediatorView);
end;
@@ -678,6 +678,7 @@ var
i: integer;
lField: string;
lColumnTotalWidth: integer;
+ row: integer;
begin
lColumnTotalWidth := 0;
for i := 0 to tiNumToken(FDisplayNames, cFieldDelimiter)-1 do
@@ -693,10 +694,14 @@ begin
lColumnTotalWidth := lColumnTotalWidth + FView.ColumnWidth[i] + 20;
end;
- for i := 0 to FModel.Count-1 do
+ row := 0; // keep track of last grid row used
+ for i := 0 to FModel.Count-1 do // loop through all items
begin
if (not FModel.Items[i].Deleted) or FShowDeleted then
- DoCreateItemMediator(FModel.Items[i], i);
+ begin
+ DoCreateItemMediator(FModel.Items[i], row);
+ inc(row);
+ end;
end;
end;
@@ -705,7 +710,10 @@ begin
//Setup default properties for the StringGrid
FView.RowSelect := True;
FView.ColumnCount := tiNumToken(FDisplayNames, cFieldDelimiter);
- FView.RowCount := FModel.Count;
+ if FShowDeleted then
+ FView.RowCount := FModel.Count
+ else
+ FView.RowCount := FModel.CountNotDeleted;
end;
procedure TCompositeStringGridMediator.RebuildStringGrid;
@@ -715,9 +723,10 @@ begin
{ This rebuilds the whole list. Not very efficient. }
View.BeginUpdate;
try
+ SetupGUIandObject;
FMediatorList.Clear;
- for i := View.ColumnCount-1 downto 0 do
- View.DeleteColumn(i);
+// for i := View.ColumnCount-1 downto 0 do
+// View.DeleteColumn(i);
CreateSubMediators;
finally
View.EndUpdate;
@@ -777,6 +786,7 @@ end;
procedure TCompositeStringGridMediator.Update(ASubject: TtiObject);
begin
+ writeln('Mediator.Update');
Assert(FModel = ASubject);
RebuildStringGrid;
end;
diff --git a/extras/tiopf/gui/tiDialogs.pas b/extras/tiopf/gui/tiDialogs.pas
index 430cd194..3743bbb3 100644
--- a/extras/tiopf/gui/tiDialogs.pas
+++ b/extras/tiopf/gui/tiDialogs.pas
@@ -31,6 +31,13 @@ uses
procedure tiShowVariant(AValue: Variant; pHeading: string = 'Show variant');
// Show the contents of a stream
procedure tiShowStream(const AValue: TStream; const pHeading: string = 'Show stream');
+ // Show a <Yes>, <No> dialog box, and return true if <Yes> was selected
+ function tiAppConfirmation(const AMessage: string): boolean; overload;
+ function tiAppConfirmation(const AMessage: string; const AValues: array of const): boolean; overload;
+ // Show a message
+ procedure tiAppMessage(const AMessage: string);
+ // Show a warning
+ procedure tiAppWarning(const AMessage: string);
implementation
@@ -142,5 +149,26 @@ begin
end;
end;
+function tiAppConfirmation(const AMessage: string): boolean;
+begin
+ Result := TfpgMessageDialog.Question('', AMessage) = mbYes
+end;
+
+function tiAppConfirmation(const AMessage: string;
+ const AValues: array of const): boolean;
+begin
+ Result := tiAppConfirmation(Format(AMessage, AValues));
+end;
+
+procedure tiAppMessage(const AMessage: string);
+begin
+ TfpgMessageDialog.Information('', AMessage);
+end;
+
+procedure tiAppWarning(const AMessage: string);
+begin
+ TfpgMessageDialog.Warning('', AMessage);
+end;
+
end.
diff --git a/extras/tiopf/gui/tiGUIINI.pas b/extras/tiopf/gui/tiGUIINI.pas
index 9593dba7..d1f34d29 100644
--- a/extras/tiopf/gui/tiGUIINI.pas
+++ b/extras/tiopf/gui/tiGUIINI.pas
@@ -54,18 +54,17 @@ begin
Assert(AForm <> nil, 'AForm not assigned');
LINISection := AForm.Name + 'State';
// Read form position, -1 if not stored in registry
- LTop := readInteger(LINISection, 'Top', -1);
- LLeft := readInteger(LINISection, 'Left', -1);
- // The form pos was found in the registr
+ LTop := readInteger(LINISection, 'Top', -1);
+ LLeft := readInteger(LINISection, 'Left', -1);
+ // The form pos was found in the ini file
if (LTop <> -1) and (LLeft <> -1) then
begin
AForm.Top := readInteger(LINISection, 'Top', AForm.Top);
AForm.Left := readInteger(LINISection, 'Left', AForm.Left);
AForm.WindowPosition := wpUser;
- // No form pos in the registry, so default to screen center
end
else
- begin
+ begin // No form pos in the ini file, so default to screen center
if Assigned(fpgApplication.MainForm) and (fpgApplication.MainForm <> AForm) then
AForm.WindowPosition := wpAuto
else
@@ -85,19 +84,15 @@ begin
AForm.Height := readInteger(LINISection, 'Height', LHeight);
AForm.Width := readInteger(LINISection, 'Width', LWidth);
end;
-// AForm.WindowState := TWindowState(ReadInteger(LINISection, 'WindowState', ord(wsNormal)));
// If the form is off screen (positioned outside all monitor screens) then
// center the form on screen.
- //{$IFDEF MSWINDOWS}
- //if (AForm.FormStyle <> fsMDIChild) {$IFNDEF FPC} and tiFormOffScreen(AForm) {$ENDIF} then
- //begin
- //if Assigned(Application.MainForm) and (Application.MainForm <> AForm) then
- //AForm.Position := poMainFormCenter
- //else
- //AForm.Position:= poScreenCenter;
- //end;
- //{$ENDIF MSWINDOWS}
+ if AForm.WindowPosition = wpUser then
+ begin
+ if (AForm.Top < 0) or (AForm.Top > fpgApplication.ScreenHeight) or
+ (AForm.Left < 0) or (AForm.Left > fpgApplication.ScreenWidth) then
+ AForm.WindowPosition := wpScreenCenter;
+ end;
end;
procedure TtiGuiINIFile.WriteFormState(AForm: TfpgForm);
@@ -105,17 +100,13 @@ var
LINISection: string;
begin
LINISection := AForm.Name + 'State';
-// writeInteger(LINISection, 'WindowState', ord(AForm.WindowState));
-// if AForm.WindowState = wsNormal then
-// begin
- WriteInteger(LINISection, 'Top', AForm.Top);
- WriteInteger(LINISection, 'Left', AForm.Left);
- if AForm.Sizeable then
- begin
- WriteInteger(LINISection, 'Height', AForm.Height);
- WriteInteger(LINISection, 'Width', AForm.Width);
- end;
-// end;
+ WriteInteger(LINISection, 'Top', AForm.Top);
+ WriteInteger(LINISection, 'Left', AForm.Left);
+ if AForm.Sizeable then
+ begin
+ WriteInteger(LINISection, 'Height', AForm.Height);
+ WriteInteger(LINISection, 'Width', AForm.Width);
+ end;
end;
initialization