- Timestamp:
- Jul 26, 2016, 11:26:11 PM (8 years ago)
- Location:
- Common
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Common.pas
r467 r487 24 24 RegisterUnit('UPersistentForm', @UPersistentForm.Register); 25 25 RegisterUnit('UFindFile', @UFindFile.Register); 26 RegisterUnit('UScaleDPI', @UScaleDPI.Register); 26 27 end; 27 28 -
Common/Demo/PersistentForm/PersistentFormDemo.lpi
r474 r487 28 28 </local> 29 29 </RunParams> 30 <RequiredPackages Count=" 2">30 <RequiredPackages Count="3"> 31 31 <Item1> 32 <PackageName Value=" Common"/>32 <PackageName Value="FCL"/> 33 33 </Item1> 34 34 <Item2> 35 <PackageName Value="Common"/> 36 <DefaultFilename Value="../../Common.lpk" Prefer="True"/> 37 </Item2> 38 <Item3> 35 39 <PackageName Value="LCL"/> 36 </Item 2>40 </Item3> 37 41 </RequiredPackages> 38 42 <Units Count="2"> … … 40 44 <Filename Value="PersistentFormDemo.lpr"/> 41 45 <IsPartOfProject Value="True"/> 42 <UnitName Value="PersistentFormDemo"/>43 46 </Unit0> 44 47 <Unit1> … … 46 49 <IsPartOfProject Value="True"/> 47 50 <ComponentName Value="Form1"/> 51 <HasResources Value="True"/> 48 52 <ResourceBaseClass Value="Form"/> 49 53 <UnitName Value="Unit1"/> -
Common/Demo/PersistentForm/Unit1.lfm
r474 r487 1 1 object Form1: TForm1 2 Left = 7792 Left = 952 3 3 Height = 622 4 Top = 3644 Top = 489 5 5 Width = 698 6 6 Caption = 'PersistentForm demo' … … 40 40 top = 314 41 41 end 42 object XMLConfig1: TXMLConfig 43 StartEmpty = False 44 RootName = 'CONFIG' 45 left = 240 46 top = 217 47 end 42 48 end -
Common/Demo/PersistentForm/Unit1.pas
r474 r487 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons,9 StdCtrls, ExtCtrls, ComCtrls, UPersistentForm;8 Classes, SysUtils, XMLConf, FileUtil, Forms, Controls, Graphics, Dialogs, 9 Buttons, StdCtrls, ExtCtrls, ComCtrls, Menus, XMLPropStorage, UPersistentForm; 10 10 11 11 type … … 17 17 PersistentForm1: TPersistentForm; 18 18 Timer1: TTimer; 19 XMLConfig1: TXMLConfig; 19 20 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 20 21 procedure FormResize(Sender: TObject); -
Common/UFindFile.pas
r463 r487 55 55 end; 56 56 57 const 58 {$IFDEF WINDOWS} 59 FilterAll = '*.*'; 60 {$ENDIF} 61 {$IFDEF LINUX} 62 FilterAll = '*'; 63 {$ENDIF} 64 57 65 procedure Register; 58 66 … … 71 79 inherited Create(AOwner); 72 80 Path := IncludeTrailingBackslash(UTF8Encode(GetCurrentDir)); 73 FileMask := '*.*';81 FileMask := FilterAll; 74 82 FileAttr := [ffaAnyFile]; 75 83 s := TStringList.Create; … … 127 135 If not InSubFolders then Exit; 128 136 129 if SysUtils.FindFirst(UTF8Decode(inPath + '*.*'), faDirectory, Rec) = 0 then137 if SysUtils.FindFirst(UTF8Decode(inPath + FilterAll), faDirectory, Rec) = 0 then 130 138 try 131 139 repeat -
Common/UScaleDPI.pas
r469 r487 17 17 TControlDimension = class 18 18 BoundsRect: TRect; 19 AuxSize: TPoint;20 19 FontHeight: Integer; 21 20 Controls: TObjectList; // TList<TControlDimension> 21 // Class specifics 22 ButtonSize: TPoint; // TToolBar 23 CoolBandWidth: Integer; 24 ConstraintsMin: TPoint; // TForm 25 ConstraintsMax: TPoint; // TForm 22 26 constructor Create; 23 27 destructor Destroy; override; … … 74 78 destructor TControlDimension.Destroy; 75 79 begin 76 Controls.Free;80 FreeAndNil(Controls); 77 81 inherited Destroy; 78 82 end; … … 113 117 Dimensions.Controls.Clear; 114 118 if Control is TToolBar then 115 Dimensions.AuxSize := Point(TToolBar(Control).ButtonWidth, TToolBar(Control).ButtonHeight); 116 119 Dimensions.ButtonSize := Point(TToolBar(Control).ButtonWidth, TToolBar(Control).ButtonHeight); 120 if Control is TForm then begin 121 Dimensions.ConstraintsMin := Point(TForm(Control).Constraints.MinWidth, 122 TForm(Control).Constraints.MinHeight); 123 Dimensions.ConstraintsMax := Point(TForm(Control).Constraints.MaxWidth, 124 TForm(Control).Constraints.MaxHeight); 125 end; 117 126 if Control is TWinControl then 118 127 for I := 0 to TWinControl(Control).ControlCount - 1 do begin 119 if TWinControl(Control).Controls[I] is TControl then begin 128 if TWinControl(Control).Controls[I] is TControl then 129 // Do not scale docked forms twice 130 if not (TWinControl(Control).Controls[I] is TForm) then begin 120 131 NewControl := TControlDimension.Create; 121 132 Dimensions.Controls.Add(NewControl); … … 133 144 Control.Font.Height := Dimensions.FontHeight; 134 145 if Control is TToolBar then begin 135 TToolBar(Control).ButtonWidth := Dimensions.AuxSize.X; 136 TToolBar(Control).ButtonHeight := Dimensions.AuxSize.Y; 146 TToolBar(Control).ButtonWidth := Dimensions.ButtonSize.X; 147 TToolBar(Control).ButtonHeight := Dimensions.ButtonSize.Y; 148 end; 149 if Control is TForm then begin 150 TForm(Control).Constraints.MinWidth := Dimensions.ConstraintsMin.X; 151 TForm(Control).Constraints.MinHeight := Dimensions.ConstraintsMin.Y; 152 TForm(Control).Constraints.MaxWidth := Dimensions.ConstraintsMax.X; 153 TForm(Control).Constraints.MaxHeight := Dimensions.ConstraintsMax.Y; 137 154 end; 138 155 if Control is TWinControl then 139 156 for I := 0 to TWinControl(Control).ControlCount - 1 do begin 140 if TWinControl(Control).Controls[I] is TControl then begin 157 if TWinControl(Control).Controls[I] is TControl then 158 // Do not scale docked forms twice 159 if not (TWinControl(Control).Controls[I] is TForm) then begin 141 160 RestoreDimensions(TWinControl(Control).Controls[I], TControlDimension(Dimensions.Controls[I])); 142 161 end; … … 152 171 Control.Font.Height := ScaleY(Dimensions.FontHeight, DesignDPI.Y); 153 172 if Control is TToolBar then begin 154 TToolBar(Control).ButtonWidth := ScaleX(Dimensions.AuxSize.X, DesignDPI.X); 155 TToolBar(Control).ButtonHeight := ScaleY(Dimensions.AuxSize.Y, DesignDPI.Y); 173 TToolBar(Control).ButtonWidth := ScaleX(Dimensions.ButtonSize.X, DesignDPI.X); 174 TToolBar(Control).ButtonHeight := ScaleY(Dimensions.ButtonSize.Y, DesignDPI.Y); 175 end; 176 if Control is TCoolBar then begin 177 with TCoolBar(Control) do 178 for I := 0 to Bands.Count - 1 do 179 with TCoolBand(Bands[I]) do begin 180 MinWidth := ScaleX(Dimensions.ButtonSize.X, DesignDPI.X); 181 MinHeight := ScaleY(Dimensions.ButtonSize.Y, DesignDPI.Y); 182 //Width := ScaleX(Dimensions.BoundsRect.Left - 183 end; 184 end; 185 if Control is TForm then begin 186 TForm(Control).Constraints.MinWidth := ScaleX(Dimensions.ConstraintsMin.X, DesignDPI.X); 187 TForm(Control).Constraints.MaxWidth := ScaleX(Dimensions.ConstraintsMax.X, DesignDPI.X); 188 TForm(Control).Constraints.MinHeight := ScaleY(Dimensions.ConstraintsMin.Y, DesignDPI.Y); 189 TForm(Control).Constraints.MaxHeight := ScaleY(Dimensions.ConstraintsMax.Y, DesignDPI.Y); 156 190 end; 157 191 if Control is TWinControl then 158 192 for I := 0 to TWinControl(Control).ControlCount - 1 do begin 159 if TWinControl(Control).Controls[I] is TControl then begin 193 if TWinControl(Control).Controls[I] is TControl then 194 // Do not scale docked forms twice 195 if not (TWinControl(Control).Controls[I] is TForm) then begin 160 196 ScaleDimensions(TWinControl(Control).Controls[I], TControlDimension(Dimensions.Controls[I])); 161 197 end; … … 183 219 184 220 SetLength(Temp, ImgList.Count); 185 TempBmp := TBitmap.Create;186 221 for I := 0 to ImgList.Count - 1 do 187 222 begin 223 TempBmp := TBitmap.Create; 224 TempBmp.PixelFormat := pf32bit; 188 225 ImgList.GetBitmap(I, TempBmp); 189 //TempBmp.PixelFormat := pfDevice;190 226 Temp[I] := TBitmap.Create; 191 227 Temp[I].SetSize(NewWidth, NewHeight); 228 Temp[I].PixelFormat := pf32bit; 192 229 Temp[I].TransparentColor := TempBmp.TransparentColor; 193 230 //Temp[I].TransparentMode := TempBmp.TransparentMode; … … 199 236 if (Temp[I].Width = 0) or (Temp[I].Height = 0) then Continue; 200 237 Temp[I].Canvas.StretchDraw(Rect(0, 0, Temp[I].Width, Temp[I].Height), TempBmp); 201 end;202 TempBmp.Free;238 TempBmp.Free; 239 end; 203 240 204 241 ImgList.Clear; … … 272 309 end; 273 310 274 275 276 311 if Control is TToolBar then begin 277 312 ToolBarControl := TToolBar(Control);
Note:
See TracChangeset
for help on using the changeset viewer.