diff --git a/components/jvcllaz/design/JvCustomControls/images/images.txt b/components/jvcllaz/design/JvCustomControls/images/images.txt index 9890e700d..897e65261 100644 --- a/components/jvcllaz/design/JvCustomControls/images/images.txt +++ b/components/jvcllaz/design/JvCustomControls/images/images.txt @@ -1,6 +1,7 @@ tjvtabbar.bmp tjvmoderntabbarpainter.bmp -Tjvtabbarxppainter.bmp +tjvtabbarxppainter.bmp +tjvgammapanel.bmp tjvoutlookbar.png tjvoutlookbar_150.png tjvoutlookbar_200.png diff --git a/components/jvcllaz/design/JvCustomControls/images/tjvgammapanel.bmp b/components/jvcllaz/design/JvCustomControls/images/tjvgammapanel.bmp new file mode 100644 index 000000000..40b505f68 Binary files /dev/null and b/components/jvcllaz/design/JvCustomControls/images/tjvgammapanel.bmp differ diff --git a/components/jvcllaz/design/JvCustomControls/jvcustomreg.pas b/components/jvcllaz/design/JvCustomControls/jvcustomreg.pas index c047ceb2a..a1fe21a5a 100644 --- a/components/jvcllaz/design/JvCustomControls/jvcustomreg.pas +++ b/components/jvcllaz/design/JvCustomControls/jvcustomreg.pas @@ -17,6 +17,7 @@ uses Classes, ImgList, Controls, LResources, PropEdits, GraphPropEdits, ComponentEditors, JvDsgnConsts, JvValidateEdit, + JvGammaPanel, JvOutlookBar, JvOutlookBarEditors, // JvTabBar, JvTabBarXPPainter, JvThumbImage, JvThumbnails, JvThumbViews, @@ -30,8 +31,8 @@ begin // TJvTabBar, TJvModernTabBarPainter, TJvTabBarXPPainter, // moved to PageComps TJvOutlookBar, TJvThumbView, TJvThumbnail, TJvThumbImage, - TJvTimeLine, - TJvTMTimeLine, + TJvTimeLine, TJvTMTimeLine, + TJvGammaPanel, TJvImagesViewer, TJvImageListViewer, TJvOwnerDrawViewer ]); diff --git a/components/jvcllaz/examples/JvGammaPanel/JvGammaPanelDemo.lpi b/components/jvcllaz/examples/JvGammaPanel/JvGammaPanelDemo.lpi new file mode 100644 index 000000000..62eae385a --- /dev/null +++ b/components/jvcllaz/examples/JvGammaPanel/JvGammaPanelDemo.lpi @@ -0,0 +1,83 @@ + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="JvCustomLazR"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="JvGammaPanelDemo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="main.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="../../bin/JvGammaPanelDemo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <UseExternalDbgSyms Value="True"/> + </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/jvcllaz/examples/JvGammaPanel/JvGammaPanelDemo.lpr b/components/jvcllaz/examples/JvGammaPanel/JvGammaPanelDemo.lpr new file mode 100644 index 000000000..fcb58d2f1 --- /dev/null +++ b/components/jvcllaz/examples/JvGammaPanel/JvGammaPanelDemo.lpr @@ -0,0 +1,22 @@ +program JvGammaPanelDemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX} + cthreads, + {$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, main + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/jvcllaz/examples/JvGammaPanel/main.lfm b/components/jvcllaz/examples/JvGammaPanel/main.lfm new file mode 100644 index 000000000..714332041 --- /dev/null +++ b/components/jvcllaz/examples/JvGammaPanel/main.lfm @@ -0,0 +1,34 @@ +object Form1: TForm1 + Left = 340 + Height = 393 + Top = 128 + Width = 431 + AutoSize = True + Caption = 'JvGammaPanel demo' + ClientHeight = 393 + ClientWidth = 431 + LCLVersion = '2.1.0.0' + object JvGammaPanel1: TJvGammaPanel + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + Left = 8 + Top = 8 + OnChangeColor = JvGammaPanel1ChangeColor + end + object StaticText1: TLabel + AnchorSideLeft.Control = JvGammaPanel1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = JvGammaPanel1 + AnchorSideTop.Side = asrCenter + Left = 105 + Height = 45 + Top = 111 + Width = 214 + BorderSpacing.Left = 32 + BorderSpacing.Right = 8 + Caption = ' This is a test... ' + Font.Height = -32 + ParentColor = False + ParentFont = False + end +end diff --git a/components/jvcllaz/examples/JvGammaPanel/main.pas b/components/jvcllaz/examples/JvGammaPanel/main.pas new file mode 100644 index 000000000..525ee0c68 --- /dev/null +++ b/components/jvcllaz/examples/JvGammaPanel/main.pas @@ -0,0 +1,43 @@ +unit main; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, JvGammaPanel, + JvTypes; + +type + + { TForm1 } + + TForm1 = class(TForm) + JvGammaPanel1: TJvGammaPanel; + StaticText1: TLabel; + procedure JvGammaPanel1ChangeColor(Sender: TObject; Foreground, + Background: TColor); + private + + public + + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.JvGammaPanel1ChangeColor(Sender: TObject; Foreground, + Background: TColor); +begin + StaticText1.Color := Background; + StaticText1.Font.Color := Foreground; +end; + +end. + diff --git a/components/jvcllaz/packages/jvcustomlazr.lpk b/components/jvcllaz/packages/jvcustomlazr.lpk index fdcca5bb2..0d0ca45e9 100644 --- a/components/jvcllaz/packages/jvcustomlazr.lpk +++ b/components/jvcllaz/packages/jvcustomlazr.lpk @@ -16,7 +16,7 @@ TimeLine, OutlookBar, Thumbnail viewer, ImageViewer, ImageListViewer, OwnerDrawViewer"/> <License Value="The JVCL is released in accordance with the MPL 1.1 license. To get your own copy or read it, go to http://www.mozilla.org/MPL/MPL-1.1.html. "/> <Version Major="1" Release="6"/> - <Files Count="12"> + <Files Count="13"> <Item1> <Filename Value="..\run\JvCustomControls\jvtimeline.pas"/> <UnitName Value="JvTimeLine"/> @@ -65,6 +65,10 @@ TimeLine, OutlookBar, Thumbnail viewer, ImageViewer, ImageListViewer, OwnerDrawV <Filename Value="..\run\JvCustomControls\jvvalidateedit.pas"/> <UnitName Value="jvvalidateedit"/> </Item12> + <Item13> + <Filename Value="..\run\JvCustomControls\jvgammapanel.pas"/> + <UnitName Value="JvGammaPanel"/> + </Item13> </Files> <RequiredPkgs Count="2"> <Item1> diff --git a/components/jvcllaz/resource/jvcustomreg.res b/components/jvcllaz/resource/jvcustomreg.res index 90fc54cae..2894342b1 100644 Binary files a/components/jvcllaz/resource/jvcustomreg.res and b/components/jvcllaz/resource/jvcustomreg.res differ diff --git a/components/jvcllaz/resource/jvgammapanel.res b/components/jvcllaz/resource/jvgammapanel.res new file mode 100644 index 000000000..a76b25f9e Binary files /dev/null and b/components/jvcllaz/resource/jvgammapanel.res differ diff --git a/components/jvcllaz/run/JvCustomControls/jvgammapanel.pas b/components/jvcllaz/run/JvCustomControls/jvgammapanel.pas new file mode 100644 index 000000000..d57e13c6e --- /dev/null +++ b/components/jvcllaz/run/JvCustomControls/jvgammapanel.pas @@ -0,0 +1,407 @@ +{----------------------------------------------------------------------------- +The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/MPL-1.1.html + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for +the specific language governing rights and limitations under the License. + +The Original Code is: JvGammaPanel.PAS, released on 2001-02-28. + +The Initial Developer of the Original Code is Sébastien Buysse [sbuysse att buypin dott com] +Portions created by Sébastien Buysse are Copyright (C) 2001 Sébastien Buysse. +All Rights Reserved. + +Contributor(s): Michael Beck [mbeck att bigfoot dott com]. + +You may retrieve the latest version of this file at the Project JEDI's JVCL home page, +located at http://jvcl.delphi-jedi.org + +Modifications: + 2/11/2000 Added the Align and AutoSize property (Request of Brad T.) + 2004/01/06 VisualCLX compatibilty + +Known Issues: +-----------------------------------------------------------------------------} +// $Id$ + +unit JvGammaPanel; + +//{$I jvcl.inc} +{$MODE OBJFPC}{$H+} + + +interface + +uses + Types, SysUtils, Classes, + //Windows, Messages, + Graphics, Controls, Dialogs, + ExtCtrls, StdCtrls, + JvTypes; +// JvTypes, JvComponent; + +type + TJvGammaPanel = class(TWinControl) //TJvWinControl) + private + FForegroundColor: TColor; + FBackgroundColor: TColor; + LastCol: TColor; + FPanel1: TPanel; + FPanel2: TPanel; + FPanel3: TPanel; + FPanel4: TPanel; + FRLabel: TLabel; + FGLabel: TLabel; + FBLabel: TLabel; + FXLabel: TLabel; + FGamma: TImage; + FChoosed: TImage; + FForegroundColorImg: TImage; + FBackgroundColorImg: TImage; + FOnChangeColor: TJvChangeColorEvent; + procedure ChangeColor(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure ColorSeek(Sender: TObject; Shift: TShiftState; X, Y: Integer); + procedure Exchange(Sender: TObject); + procedure SetForegroundColor(const Value: TColor); + procedure SetBackgroundColor(const Value: TColor); + procedure Color1Click(Sender: TObject); + procedure Color2Click(Sender: TObject); + protected + procedure BoundsChanged; override; + procedure DoChangeColor(AForegroundColor, ABackgroundColor: TColor); virtual; + public + constructor Create(AOwner: TComponent); override; + published + property Align; + property AutoSize; + property BorderSpacing; + property Height default 250; + property Width default 65; + property ForegroundColor: TColor read FForegroundColor write SetForegroundColor default clBlack; + property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor default clWhite; + property OnChangeColor: TJvChangeColorEvent read FOnChangeColor write FOnChangeColor; + end; + + +implementation + +uses + LCLIntf, + JvResources; + +{$R ../../resource/jvgammapanel.res} + +constructor TJvGammaPanel.Create(AOwner: TComponent); +var + p5: Integer; +begin + inherited Create(AOwner); + Width := 65; + Height := 250; + FForegroundColor := clBlack; + FBackgroundColor := clWhite; + + FPanel1 := TPanel.Create(Self); + with FPanel1 do + begin + Parent := Self; +// Width := 65; +// Height := 250; + Align := alClient; + BevelInner := bvLowered; + BevelOuter := bvRaised; + Visible := True; + end; + + FPanel2 := TPanel.Create(FPanel1); + with FPanel2 do + begin + Parent := FPanel1; + Left := 5; + Top := 5; + Width := 55; + Height := 105; + BevelInner := bvLowered; + BevelOuter := bvRaised; + Visible := True; + end; + + FPanel3 := TPanel.Create(FPanel1); + with FPanel3 do + begin + Parent := FPanel1; + Left := 5; + Top := 115; + Width := 55; + Height := 50; + BevelInner := bvLowered; + BevelOuter := bvRaised; + Visible := True; + end; + + FPanel4 := TPanel.Create(FPanel1); + with FPanel4 do + begin + Parent := FPanel1; + Left := 5; + Top := 170; + Width := 55; + Height := 75; + BevelInner := bvLowered; + BevelOuter := bvRaised; + Visible := True; + end; + + FRLabel := TLabel.Create(FPanel4); + with FRLabel do + begin + Top := 2; + Left := 5; + AutoSize := True; + { + Font.Size := 8; + Font.Name := 'Arial'; + } + Caption := RsDefaultR; + Transparent := True; + Parent := FPanel4; + end; + + FGLabel := TLabel.Create(FPanel4); + with FGLabel do + begin + Top := 14; + Left := 5; + AutoSize := True; + { + Font.Name := 'Arial'; + Font.Size := 8; + } + Caption := RsDefaultG; + Transparent := True; + Parent := FPanel4; + end; + + FBLabel := TLabel.Create(FPanel4); + with FBLabel do + begin + Top := 26; + Left := 5; + { + Font.Size := 8; + Font.Name := 'arial'; + } + AutoSize := True; + Caption := RsDefaultB; + Transparent := True; + Parent := FPanel4; + end; + + FGamma := TImage.Create(FPanel2); + with FGamma do + begin + Parent := FPanel2; + Stretch := False; + Center := True; + AutoSize := True; + Picture.Bitmap.PixelFormat := pf24bit; + Width := 55; + Height := 105; + OnMouseDown := @ChangeColor; + OnMouseMove := @ColorSeek; + Align := alClient; + Picture.Bitmap.LoadFromResourceName(HInstance, 'JvGammaPanelCOLORS'); + Cursor := crCross; + end; + + FChoosed := TImage.Create(FPanel4); + with FChoosed do + begin + Top := 40; + Left := 12; + Width := 30; + Height := 30; + Parent := FPanel4; + Visible := True; + Stretch := False; + Align := alNone; +// Picture.Bitmap := TBitmap.Create; + Picture.Bitmap.Width := Width; + Picture.Bitmap.Height := Height; + Canvas.Brush.Color := clBlack; + Canvas.Brush.Style := bsSolid; + Canvas.FillRect(Rect(0, 0, Width, Height)); + end; + + FForegroundColorImg := TImage.Create(FPanel3); + with FForegroundColorImg do + begin + Left := 5; + Top := 5; + Width := 25; + Height := 25; +// Picture.Bitmap := TBitmap.Create; + Picture.Bitmap.Width := FChoosed.Width; + Picture.Bitmap.Height := FChoosed.Height; + Canvas.Brush.Color := clBlack; + Canvas.Brush.Style := bsSolid; + Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + Hint := RsHint2; + ShowHint := True; + OnClick := @Color1Click; + Parent := FPanel3; + Visible := True; + end; + + FBackgroundColorImg := TImage.Create(FPanel3); + with FBackgroundColorImg do + begin + Left := 25; + Top := 20; + Height := 25; + Width := 25; +// Picture.Bitmap := TBitmap.Create; + Picture.Bitmap.Width := FChoosed.Width; + Picture.Bitmap.Height := FChoosed.Height; + Canvas.Brush.Color := clWhite; + Canvas.Brush.Style := bsSolid; + Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + Hint := RsHint1; + ShowHint := True; + OnClick := @Color2Click; + Parent := FPanel3; + Visible := True; + end; + + FXLabel := TLabel.Create(FPanel3); + with FXLabel do + begin + Left := 7; + Top := 32; + AutoSize := True; + Caption := RsXCaption; + Hint := RsLabelHint; + OnClick := @Exchange; + ShowHint := True; + Visible := True; + Parent := FPanel3; + end; +end; + +procedure TJvGammaPanel.ChangeColor(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + if Button = mbLeft then + begin + FForegroundColor := LastCol; + FForegroundColorImg.Canvas.Brush.Color := FForegroundColor; + FForegroundColorImg.Canvas.Brush.Style := bsSolid; + FForegroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + DoChangeColor(FForegroundColor, FBackgroundColor); + end + else + if Button = mbRight then + begin + FBackgroundColor := LastCol; + FBackgroundColorImg.Canvas.Brush.Color := FBackgroundColor; + FBackgroundColorImg.Canvas.Brush.Style := bsSolid; + FBackgroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + DoChangeColor(FForegroundColor, FBackgroundColor); + end; +end; + +procedure TJvGammaPanel.Color1Click(Sender: TObject); +begin + with TColorDialog.Create(Self) do + begin + if Execute then + SetForegroundColor(Color); + Free; + end; +end; + +procedure TJvGammaPanel.Color2Click(Sender: TObject); +begin + with TColorDialog.Create(Self) do + begin + if Execute then + SetBackgroundColor(Color); + Free; + end; +end; + +procedure TJvGammaPanel.ColorSeek(Sender: TObject; Shift: TShiftState; X, Y: Integer); +var + Col: TColor; +begin + if not PtInRect(Bounds(0, 0, FGamma.Picture.Width, FGamma.Picture.Height), Point(X,Y)) then + Exit; // asn for Linux/X11 + Col := FGamma.Picture.Bitmap.Canvas.Pixels[X, Y]; + LastCol := Col; + FRLabel.Caption := Format(RsRedFormat, [GetRValue(Col)]); + FGLabel.Caption := Format(RsGreenFormat, [GetGValue(Col)]); + FBLabel.Caption := Format(RsBlueFormat, [GetBValue(Col)]); + FChoosed.Canvas.Brush.Color := Col; + FChoosed.Canvas.Brush.Style := bsSolid; + FChoosed.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); +end; + +procedure TJvGammaPanel.Exchange(Sender: TObject); +var + Col: TColor; +begin + // exchange colors + Col := FForegroundColor; + FForegroundColor := FBackgroundColor; + FBackgroundColor := Col; + + FForegroundColorImg.Canvas.Brush.Color := FForegroundColor; + FForegroundColorImg.Canvas.Brush.Style := bsSolid; + FForegroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + + FBackgroundColorImg.Canvas.Brush.Color := FBackgroundColor; + FBackgroundColorImg.Canvas.Brush.Style := bsSolid; + FBackgroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + + if Assigned(FOnChangeColor) then + FOnChangeColor(Self, FForegroundColor, FBackgroundColor); +end; + +procedure TJvGammaPanel.SetForegroundColor(const Value: TColor); +begin + FForegroundColor := Value; + FForegroundColorImg.Canvas.Brush.Color := FForegroundColor; + FForegroundColorImg.Canvas.Brush.Style := bsSolid; + FForegroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + if Assigned(FOnChangeColor) then + FOnChangeColor(Self, FForegroundColor, FBackgroundColor); +end; + +procedure TJvGammaPanel.SetBackgroundColor(const Value: TColor); +begin + FBackgroundColor := Value; + FBackgroundColorImg.Canvas.Brush.Color := FBackgroundColor; + FBackgroundColorImg.Canvas.Brush.Style := bsSolid; + FBackgroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height)); + if Assigned(FOnChangeColor) then + FOnChangeColor(Self, FForegroundColor, FBackgroundColor); +end; + +procedure TJvGammaPanel.BoundsChanged; +begin + Width := 65; + Height := 250; + if Assigned(FForegroundColorImg) then + FForegroundColorImg.BringToFront; +end; + +procedure TJvGammaPanel.DoChangeColor(AForegroundColor, ABackgroundColor: TColor); +begin + if Assigned(FOnChangeColor) then + FOnChangeColor(Self, AForegroundColor, ABackgroundColor); +end; + + +end.