diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-03 19:23:40 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-03 19:23:40 +0000 |
commit | cfbb1096706f6234cf8ac8fb0feefaae8b881ba9 (patch) | |
tree | f86d7fb67c7568cdd8284743f07a47cf457851ca /prototypes/miglayout/gui_mig_boundsize.pas | |
parent | cec78aca668fb7b5eba7f60852854697619573ca (diff) | |
download | fpGUI-cfbb1096706f6234cf8ac8fb0feefaae8b881ba9.tar.xz |
* Added my MiG Layout Manager code to the prototypes diretory while I continue working on the port from Java.
Diffstat (limited to 'prototypes/miglayout/gui_mig_boundsize.pas')
-rw-r--r-- | prototypes/miglayout/gui_mig_boundsize.pas | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/prototypes/miglayout/gui_mig_boundsize.pas b/prototypes/miglayout/gui_mig_boundsize.pas new file mode 100644 index 00000000..a77b6b80 --- /dev/null +++ b/prototypes/miglayout/gui_mig_boundsize.pas @@ -0,0 +1,90 @@ +unit gui_mig_boundsize; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, gui_mig_unitvalue; + +type + + { TBoundSize } + + TBoundSize = class(TObject) + private + FMin: TUnitValue; + FPref: TUnitValue; + FMax: TUnitValue; + FGapPush: Boolean; + public + constructor Create(AMinMaxPref: TUnitValue; ACreateString: string); // overloaded; + constructor Create(AMin: TUnitValue; APreferred: TUnitValue; AMax: TUnitValue; ACreateString: string); // overloaded; + constructor Create(AMin: TUnitValue; APreferred: TUnitValue; AMax: TUnitValue; AGapPush: Boolean; ACreateString: string); // overloaded; + function GetSize(const ASizeType: integer): TUnitValue; + function IsUnset: Boolean; + function GetConstraintString: string; + property Min: TUnitValue read FMin; + property Preferred: TUnitValue read FPref; + property Max: TUnitValue read FMax; + property GapPush: Boolean read FGapPush; + end; + +implementation + +uses + gui_mig_exceptions; + + +{ TBoundSize } + +function TBoundSize.IsUnset: Boolean; +begin + Result := (FMin = nil) and (FPref = nil) and (FMax = nil); +end; + +function TBoundSize.GetConstraintString: string; +begin + Result := 'null'; + {$Note TBoundSize.GetConstraintString still needs to be implemented. } +end; + +constructor TBoundSize.Create(AMinMaxPref: TUnitValue; ACreateString: string); +begin + Create(AMinMaxPref, AMinMaxPref, AMinMaxPref, ACreateString); +end; + +constructor TBoundSize.Create(AMin: TUnitValue; APreferred: TUnitValue; + AMax: TUnitValue; ACreateString: string); +begin + Create(AMin, APreferred, AMax, False, ACreateString); +end; + +constructor TBoundSize.Create(AMin: TUnitValue; APreferred: TUnitValue; + AMax: TUnitValue; AGapPush: Boolean; ACreateString: string); +begin + inherited Create; + FMin := AMin; + FPref := APreferred; + FMax := AMax; + FGapPush := AGapPush; + + {$Note TBoundSize.Create is incompleted, we still need to handle ACreateString. } +end; + +function TBoundSize.GetSize(const ASizeType: integer): TUnitValue; +begin + case ASizetype of + 0{MIN}: + result := FMin; + 1{PREF}: + result := FPref; + 2{MAX}: + result := FMax; + else + raise EIllegalArgument.CreateFmt('Unknown size: %d', [ASizeType]); + end; +end; + +end. + |