You've already forked lazarus-ccr
mbColorLib: Fix painting issues of mbColorPalette
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5516 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -104,7 +104,6 @@ type
|
|||||||
|
|
||||||
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
|
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
// procedure KeyDownInterface(var Key: Word; Shift: TShiftState); override;
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
|
|
||||||
@@ -347,7 +346,7 @@ begin
|
|||||||
try
|
try
|
||||||
// OffScreen.PixelFormat := pf32bit;
|
// OffScreen.PixelFormat := pf32bit;
|
||||||
OffScreen.Width := Width;
|
OffScreen.Width := Width;
|
||||||
OffScreen.Height := HeightOf(FColorCombRect) + HeightOf(FBWCombRect);
|
OffScreen.Height := HeightOfRect(FColorCombRect) + HeightOfRect(FBWCombRect);
|
||||||
//Parent background
|
//Parent background
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
if Color = clDefault then
|
if Color = clDefault then
|
||||||
|
@@ -42,9 +42,9 @@ object Form1: TForm1
|
|||||||
Height = 363
|
Height = 363
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 403
|
Width = 403
|
||||||
ActivePage = TabSheet2
|
ActivePage = TabSheet3
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
TabIndex = 1
|
TabIndex = 2
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnMouseMove = PageControl1MouseMove
|
OnMouseMove = PageControl1MouseMove
|
||||||
object TabSheet1: TTabSheet
|
object TabSheet1: TTabSheet
|
||||||
@@ -56,7 +56,7 @@ object Form1: TForm1
|
|||||||
Height = 287
|
Height = 287
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 377
|
Width = 377
|
||||||
SelectedColor = 553990
|
SelectedColor = 685062
|
||||||
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
||||||
LPickerHintFormat = 'Luminance: %l'
|
LPickerHintFormat = 'Luminance: %l'
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
@@ -208,8 +208,8 @@ object Form1: TForm1
|
|||||||
Height = 253
|
Height = 253
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 385
|
Width = 385
|
||||||
HorzScrollBar.Page = 75
|
HorzScrollBar.Page = 385
|
||||||
VertScrollBar.Page = 234
|
VertScrollBar.Page = 250
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderStyle = bsNone
|
BorderStyle = bsNone
|
||||||
ClientHeight = 253
|
ClientHeight = 253
|
||||||
@@ -217,10 +217,10 @@ object Form1: TForm1
|
|||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
object mbColorPalette1: TmbColorPalette
|
object mbColorPalette1: TmbColorPalette
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 234
|
Height = 250
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 385
|
Width = 385
|
||||||
Align = alTop
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
Colors.Strings = (
|
Colors.Strings = (
|
||||||
'clBlack'
|
'clBlack'
|
||||||
'$00330000'
|
'$00330000'
|
||||||
@@ -481,7 +481,6 @@ object Form1: TForm1
|
|||||||
)
|
)
|
||||||
HintFormat = 'RGB(%r, %g, %b)'#13'Hex: %h'
|
HintFormat = 'RGB(%r, %g, %b)'#13'Hex: %h'
|
||||||
AutoHeight = True
|
AutoHeight = True
|
||||||
CellStyle = csCorel
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnSelColorChange = mbColorPalette1SelColorChange
|
OnSelColorChange = mbColorPalette1SelColorChange
|
||||||
OnMouseMove = mbColorPalette1MouseMove
|
OnMouseMove = mbColorPalette1MouseMove
|
||||||
@@ -505,7 +504,7 @@ object Form1: TForm1
|
|||||||
Text = 'soAscending'
|
Text = 'soAscending'
|
||||||
end
|
end
|
||||||
object ComboBox3: TComboBox
|
object ComboBox3: TComboBox
|
||||||
Left = 124
|
Left = 127
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 300
|
Top = 300
|
||||||
Width = 87
|
Width = 87
|
||||||
@@ -561,7 +560,7 @@ object Form1: TForm1
|
|||||||
Width = 15
|
Width = 15
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
Min = 0
|
Min = 0
|
||||||
OnChanging = UpDown1Changing
|
OnChangingEx = UpDown1ChangingEx
|
||||||
Position = 18
|
Position = 18
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
Thousands = False
|
Thousands = False
|
||||||
|
@@ -140,6 +140,8 @@ type
|
|||||||
procedure HRingPicker1Change(Sender: TObject);
|
procedure HRingPicker1Change(Sender: TObject);
|
||||||
procedure HRingPicker1MouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure HRingPicker1MouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
Y: Integer);
|
Y: Integer);
|
||||||
|
procedure UpDown1ChangingEx(Sender: TObject; var AllowChange: Boolean;
|
||||||
|
NewValue: SmallInt; Direction: TUpDownDirection);
|
||||||
procedure VColorPicker2Change(Sender: TObject);
|
procedure VColorPicker2Change(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure CheckBox1Click(Sender: TObject);
|
procedure CheckBox1Click(Sender: TObject);
|
||||||
@@ -149,7 +151,6 @@ type
|
|||||||
procedure ComboBox2Change(Sender: TObject);
|
procedure ComboBox2Change(Sender: TObject);
|
||||||
procedure ComboBox3Change(Sender: TObject);
|
procedure ComboBox3Change(Sender: TObject);
|
||||||
procedure ComboBox4Change(Sender: TObject);
|
procedure ComboBox4Change(Sender: TObject);
|
||||||
procedure UpDown1Changing(Sender: TObject; var AllowChange: Boolean);
|
|
||||||
procedure CbWebSsafeClick(Sender: TObject);
|
procedure CbWebSsafeClick(Sender: TObject);
|
||||||
procedure Button5Click(Sender: TObject);
|
procedure Button5Click(Sender: TObject);
|
||||||
procedure CbSwatchStyleClick(Sender: TObject);
|
procedure CbSwatchStyleClick(Sender: TObject);
|
||||||
@@ -167,6 +168,9 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
{$R mxico.res} //MXS icon resource file, for internet shortcut only
|
{$R mxico.res} //MXS icon resource file, for internet shortcut only
|
||||||
|
|
||||||
|
uses
|
||||||
|
RGBHSLUtils;
|
||||||
|
|
||||||
procedure TForm1.tb1Change(Sender: TObject);
|
procedure TForm1.tb1Change(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
sc.opacity := tb1.position;
|
sc.opacity := tb1.position;
|
||||||
@@ -314,6 +318,9 @@ end;
|
|||||||
// only for internet shortcuts
|
// only for internet shortcuts
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
MaxHue := 360;
|
||||||
|
MaxSat := 240;
|
||||||
|
MaxLum := 240;
|
||||||
with TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MXS Website.url') do
|
with TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MXS Website.url') do
|
||||||
try
|
try
|
||||||
WriteString('InternetShortcut','URL', 'http://mxs.bergsoft.net');
|
WriteString('InternetShortcut','URL', 'http://mxs.bergsoft.net');
|
||||||
@@ -360,11 +367,11 @@ begin
|
|||||||
mbcolorpalette1.CellStyle := tcellstyle(combobox4.ItemIndex);
|
mbcolorpalette1.CellStyle := tcellstyle(combobox4.ItemIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.UpDown1Changing(Sender: TObject;
|
procedure TForm1.UpDown1ChangingEx(Sender: TObject; var AllowChange: Boolean;
|
||||||
var AllowChange: Boolean);
|
NewValue: SmallInt; Direction: TUpDownDirection);
|
||||||
begin
|
begin
|
||||||
allowchange := true;
|
allowchange := true;
|
||||||
mbcolorpalette1.CellSize := abs(updown1.Position);
|
mbcolorpalette1.CellSize := abs(NewValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.CbWebSsafeClick(Sender: TObject);
|
procedure TForm1.CbWebSsafeClick(Sender: TObject);
|
||||||
|
@@ -38,6 +38,7 @@ type
|
|||||||
function MouseOnPicker(X, Y: Integer): Boolean; virtual;
|
function MouseOnPicker(X, Y: Integer): Boolean; virtual;
|
||||||
procedure PaintParentBack; virtual; overload;
|
procedure PaintParentBack; virtual; overload;
|
||||||
procedure PaintParentBack(ACanvas: TCanvas); overload;
|
procedure PaintParentBack(ACanvas: TCanvas); overload;
|
||||||
|
procedure PaintParentBack(ACanvas: TCanvas; ARect: TRect); overload;
|
||||||
procedure PaintParentBack(ABitmap: TBitmap); overload;
|
procedure PaintParentBack(ABitmap: TBitmap); overload;
|
||||||
function ShowHintWindow(APoint: TPoint; AText: String): Boolean; virtual;
|
function ShowHintWindow(APoint: TPoint; AText: String): Boolean; virtual;
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
@@ -58,7 +59,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LCLIntf;
|
LCLIntf, mbUtils;
|
||||||
|
|
||||||
const
|
const
|
||||||
HINT_SHOW_DELAY = 50;
|
HINT_SHOW_DELAY = 50;
|
||||||
@@ -183,7 +184,6 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ABitmap.Canvas.Brush.Color := Color;
|
ABitmap.Canvas.Brush.Color := Color;
|
||||||
ABitmap.Canvas.FillRect(ABitmap.Canvas.ClipRect);
|
ABitmap.Canvas.FillRect(ABitmap.Canvas.ClipRect);
|
||||||
// Canvas.Draw(0, 0, ABitmap);
|
|
||||||
|
|
||||||
{$IFDEF DELPHI_7_UP}{$IFDEF DELPHI}
|
{$IFDEF DELPHI_7_UP}{$IFDEF DELPHI}
|
||||||
if ParentBackground then
|
if ParentBackground then
|
||||||
@@ -200,6 +200,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TmbBasicPicker.PaintParentBack(ACanvas: TCanvas);
|
procedure TmbBasicPicker.PaintParentBack(ACanvas: TCanvas);
|
||||||
|
var
|
||||||
|
R: TRect;
|
||||||
|
begin
|
||||||
|
R := Rect(0, 0, Width, Height);
|
||||||
|
PaintParentBack(ACanvas, R);
|
||||||
|
(*
|
||||||
var
|
var
|
||||||
OffScreen: TBitmap;
|
OffScreen: TBitmap;
|
||||||
begin
|
begin
|
||||||
@@ -217,6 +223,27 @@ begin
|
|||||||
finally
|
finally
|
||||||
Offscreen.Free;
|
Offscreen.Free;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TmbBasicPicker.PaintParentBack(ACanvas: TCanvas; ARect: TRect);
|
||||||
|
var
|
||||||
|
OffScreen: TBitmap;
|
||||||
|
begin
|
||||||
|
Offscreen := TBitmap.Create;
|
||||||
|
try
|
||||||
|
// Offscreen.PixelFormat := pf32bit;
|
||||||
|
if Color = clDefault then begin
|
||||||
|
Offscreen.Transparent := true;
|
||||||
|
Offscreen.TransparentColor := clForm; //GetDefaultColor(dctBrush);
|
||||||
|
end;
|
||||||
|
Offscreen.Width := WidthOfRect(ARect);
|
||||||
|
Offscreen.Height := HeightOfRect(ARect);
|
||||||
|
PaintParentBack(Offscreen);
|
||||||
|
ACanvas.Draw(ARect.Left, ARect.Top, Offscreen);
|
||||||
|
finally
|
||||||
|
Offscreen.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Build and show the hint window
|
// Build and show the hint window
|
||||||
|
@@ -33,7 +33,6 @@ type
|
|||||||
FMouseLoc: TMouseLoc;
|
FMouseLoc: TMouseLoc;
|
||||||
FMouseOver, FMouseDown, FAutoHeight: boolean;
|
FMouseOver, FMouseDown, FAutoHeight: boolean;
|
||||||
FColCount, FRowCount, FTop, FLeft, FIndex, FCheckedIndex, FCellSize, FTotalCells: integer;
|
FColCount, FRowCount, FTop, FLeft, FIndex, FCheckedIndex, FCellSize, FTotalCells: integer;
|
||||||
FTempBmp: TBitmap;
|
|
||||||
//PBack: TBitmap;
|
//PBack: TBitmap;
|
||||||
FState: TColorCellState;
|
FState: TColorCellState;
|
||||||
FColors, FNames: TStrings;
|
FColors, FNames: TStrings;
|
||||||
@@ -72,13 +71,13 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure PaintTransparentGlyph(ACanvas: TCanvas; R: TRect);
|
procedure PaintTransparentGlyph(ACanvas: TCanvas; R: TRect);
|
||||||
procedure DrawCell(clr: string);
|
procedure DrawCell(ACanvas: TCanvas; AColor: string);
|
||||||
procedure DrawCellBack(ACanvas: TCanvas; R: TRect; AIndex: integer);
|
procedure DrawCellBack(ACanvas: TCanvas; R: TRect; AIndex: integer);
|
||||||
procedure ColorsChange(Sender: TObject);
|
procedure ColorsChange(Sender: TObject);
|
||||||
procedure Click; override;
|
procedure Click; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure SelectCell(i: integer);
|
procedure SelectCell(i: integer);
|
||||||
procedure CreateWnd; override;
|
// procedure CreateWnd; override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
@@ -173,6 +172,9 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
mbUtils;
|
||||||
|
|
||||||
{ TmbColorPalette }
|
{ TmbColorPalette }
|
||||||
|
|
||||||
constructor TmbColorPalette.Create(AOwner: TComponent);
|
constructor TmbColorPalette.Create(AOwner: TComponent);
|
||||||
@@ -182,16 +184,13 @@ begin
|
|||||||
// DoubleBuffered := true;
|
// DoubleBuffered := true;
|
||||||
// PBack := TBitmap.Create;
|
// PBack := TBitmap.Create;
|
||||||
// PBack.PixelFormat := pf32bit;
|
// PBack.PixelFormat := pf32bit;
|
||||||
FTempBmp := TBitmap.Create;
|
|
||||||
//FTempBmp.PixelFormat := pf32bit;
|
|
||||||
{$IFDEF DELPHI_7_UP} {$IFDEF DELPHI}
|
{$IFDEF DELPHI_7_UP} {$IFDEF DELPHI}
|
||||||
ParentBackground := true;
|
ParentBackground := true;
|
||||||
{$ENDIF} {$ENDIF}
|
{$ENDIF} {$ENDIF}
|
||||||
TabStop := true;
|
TabStop := true;
|
||||||
ParentShowHint := true;
|
ParentShowHint := true;
|
||||||
ShowHint := false;
|
ShowHint := false;
|
||||||
Width := 180;
|
SetInitialBounds(0, 0, 180, 126);
|
||||||
Height := 126;
|
|
||||||
FMouseLoc := mlNone;
|
FMouseLoc := mlNone;
|
||||||
FMouseOver := false;
|
FMouseOver := false;
|
||||||
FMouseDown := false;
|
FMouseDown := false;
|
||||||
@@ -221,7 +220,7 @@ end;
|
|||||||
destructor TmbColorPalette.Destroy;
|
destructor TmbColorPalette.Destroy;
|
||||||
begin
|
begin
|
||||||
//PBack.Free;
|
//PBack.Free;
|
||||||
FTempBmp.Free;
|
FBufferBmp.Free;
|
||||||
FNames.Free;
|
FNames.Free;
|
||||||
FColors.Free;
|
FColors.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
@@ -232,6 +231,7 @@ begin
|
|||||||
if Parent = nil then
|
if Parent = nil then
|
||||||
exit;
|
exit;
|
||||||
FColCount := Width div FCellSize;
|
FColCount := Width div FCellSize;
|
||||||
|
{7
|
||||||
if FAutoHeight and (FColCount <> 0) then
|
if FAutoHeight and (FColCount <> 0) then
|
||||||
begin
|
begin
|
||||||
if FColors.Count mod FColCount > 0 then
|
if FColors.Count mod FColCount > 0 then
|
||||||
@@ -240,8 +240,11 @@ begin
|
|||||||
Height := (FColors.Count div FColCount) * FCellSize;
|
Height := (FColors.Count div FColCount) * FCellSize;
|
||||||
end;
|
end;
|
||||||
if Height = 0 then Height := FCellSize;
|
if Height = 0 then Height := FCellSize;
|
||||||
|
}
|
||||||
FRowCount := Height div FCellSize;
|
FRowCount := Height div FCellSize;
|
||||||
|
{
|
||||||
Width := FColCount * FCellSize;
|
Width := FColCount * FCellSize;
|
||||||
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TmbColorPalette.GetTotalRowCount: integer;
|
function TmbColorPalette.GetTotalRowCount: integer;
|
||||||
@@ -251,13 +254,16 @@ begin
|
|||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure TmbColorPalette.CreateWnd;
|
procedure TmbColorPalette.CreateWnd;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{
|
||||||
CalcAutoHeight;
|
CalcAutoHeight;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
}
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
(*
|
(*
|
||||||
procedure TmbColorPalette.PaintParentBack;
|
procedure TmbColorPalette.PaintParentBack;
|
||||||
{$IFDEF DELPHI_7_UP}
|
{$IFDEF DELPHI_7_UP}
|
||||||
@@ -297,15 +303,19 @@ end; *)
|
|||||||
procedure TmbColorPalette.Paint;
|
procedure TmbColorPalette.Paint;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
|
bmp: TBitmap;
|
||||||
begin
|
begin
|
||||||
{ PBack.Width := Width;
|
{ PBack.Width := Width;
|
||||||
PBack.Height := Height;
|
PBack.Height := Height;
|
||||||
PaintParentBack(PBack);
|
PaintParentBack(PBack);
|
||||||
}
|
}
|
||||||
//make bmp
|
//make bmp
|
||||||
FTempBmp.Width := Width;
|
if FBufferBmp = nil then
|
||||||
FTempBmp.Height := Height;
|
FBufferBmp := TBitmap.Create;
|
||||||
PaintParentBack(FTempBmp);
|
FBufferBmp.Width := Width;
|
||||||
|
FBufferBmp.Height := Height;
|
||||||
|
PaintParentBack(FBufferBmp);
|
||||||
|
FBufferBmp.Transparent := false; // a transparent bitmap does not show the selection ?!
|
||||||
|
|
||||||
//reset counters
|
//reset counters
|
||||||
FTotalCells := FColors.Count - 1;
|
FTotalCells := FColors.Count - 1;
|
||||||
@@ -316,12 +326,29 @@ begin
|
|||||||
for i := 0 to FColors.Count - 1 do
|
for i := 0 to FColors.Count - 1 do
|
||||||
begin
|
begin
|
||||||
if FColors.Strings[i] <> '' then
|
if FColors.Strings[i] <> '' then
|
||||||
DrawCell(FColors.Strings[i]);
|
DrawCell(FBufferBmp.Canvas, FColors.Strings[i]);
|
||||||
Inc(FLeft);
|
Inc(FLeft);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//draw the bmp
|
//draw the bmp
|
||||||
Canvas.Draw(0, 0, FTempBmp);
|
if Color = clDefault then
|
||||||
|
begin
|
||||||
|
// Use temporary bitmap to draw the buffer bitmap transparently
|
||||||
|
bmp := TBitmap.Create;
|
||||||
|
try
|
||||||
|
bmp.SetSize(Width, Height);
|
||||||
|
if Color = clDefault then begin
|
||||||
|
bmp.Transparent := true;
|
||||||
|
bmp.TransparentColor := clForm;
|
||||||
|
end;
|
||||||
|
bmp.Canvas.Draw(0, 0, FBufferBmp);
|
||||||
|
Canvas.Draw(0, 0, bmp);
|
||||||
|
finally
|
||||||
|
bmp.Free;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Canvas.Draw(0, 0, FBufferBmp);
|
||||||
|
|
||||||
//csDesiging border
|
//csDesiging border
|
||||||
if csDesigning in ComponentState then
|
if csDesigning in ComponentState then
|
||||||
@@ -335,7 +362,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TmbColorPalette.DrawCell(clr: string);
|
procedure TmbColorPalette.DrawCell(ACanvas: TCanvas; AColor: string);
|
||||||
var
|
var
|
||||||
R: Trect;
|
R: Trect;
|
||||||
FCurrentIndex: integer;
|
FCurrentIndex: integer;
|
||||||
@@ -343,7 +370,7 @@ var
|
|||||||
Handled: boolean;
|
Handled: boolean;
|
||||||
begin
|
begin
|
||||||
// set props
|
// set props
|
||||||
if (FLeft + 1) * FCellSize > FTempBmp.Width then
|
if (FLeft + 1) * FCellSize > Width then
|
||||||
begin
|
begin
|
||||||
Inc(FTop);
|
Inc(FTop);
|
||||||
FLeft := 0;
|
FLeft := 0;
|
||||||
@@ -377,41 +404,42 @@ begin
|
|||||||
FState := ccsNone;
|
FState := ccsNone;
|
||||||
|
|
||||||
//paint
|
//paint
|
||||||
DrawCellBack(FTempBmp.Canvas, R, FCurrentIndex);
|
DrawCellBack(ACanvas, R, FCurrentIndex);
|
||||||
|
|
||||||
// fire the event
|
// fire the event
|
||||||
Handled := false;
|
Handled := false;
|
||||||
|
c := mbStringToColor(AColor);
|
||||||
if Assigned(FOnPaintCell) then
|
if Assigned(FOnPaintCell) then
|
||||||
case FCellStyle of
|
case FCellStyle of
|
||||||
csDefault:
|
csDefault:
|
||||||
FOnPaintCell(FTempBmp.Canvas, R, mbStringToColor(clr), FCurrentIndex, FState, FTStyle, Handled);
|
FOnPaintCell(ACanvas, R, c, FCurrentIndex, FState, FTStyle, Handled);
|
||||||
csCorel:
|
csCorel:
|
||||||
if FColCount = 1 then
|
if FColCount = 1 then
|
||||||
FOnPaintCell(FTempBmp.Canvas, R, mbStringToColor(clr), FCurrentIndex, FState, FTStyle, Handled)
|
FOnPaintCell(ACanvas, R, c, FCurrentIndex, FState, FTStyle, Handled)
|
||||||
else
|
else
|
||||||
FOnPaintCell(FTempBmp.Canvas, Rect(R.Left, R.Top, R.Right + 1, R.Bottom), mbStringToColor(clr), FCurrentIndex, FState, FTStyle, Handled);
|
FOnPaintCell(ACanvas, Rect(R.Left, R.Top, R.Right + 1, R.Bottom), c,
|
||||||
|
FCurrentIndex, FState, FTStyle, Handled);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not Handled then
|
if not Handled then
|
||||||
begin
|
begin
|
||||||
// if standard colors draw the rect
|
// if standard colors draw the rect
|
||||||
c := mbStringToColor(clr);
|
if not SameText(AColor, 'clCustom') and not SameText(AColor, 'clTransparent') then
|
||||||
if not SameText(clr, 'clCustom') and not SameText(clr, 'clTransparent') then
|
|
||||||
case FCellStyle of
|
case FCellStyle of
|
||||||
csDefault:
|
csDefault:
|
||||||
begin
|
begin
|
||||||
InflateRect(R, -3, -3);
|
InflateRect(R, -3, -3);
|
||||||
if Enabled then
|
if Enabled then
|
||||||
begin
|
begin
|
||||||
FTempBmp.Canvas.Brush.Color := c;
|
ACanvas.Brush.Color := c;
|
||||||
FTempBmp.Canvas.Pen.Color := clBtnShadow;
|
ACanvas.Pen.Color := clBtnShadow;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
FTempBmp.Canvas.Brush.Color := clGray;
|
ACanvas.Brush.Color := clGray;
|
||||||
FTempBmp.Canvas.Pen.Color := clGray;
|
ACanvas.Pen.Color := clGray;
|
||||||
end;
|
end;
|
||||||
FTempBmp.Canvas.Rectangle(R);
|
ACanvas.Rectangle(R);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -429,17 +457,17 @@ begin
|
|||||||
Dec(R.Right);
|
Dec(R.Right);
|
||||||
end;
|
end;
|
||||||
if Enabled then
|
if Enabled then
|
||||||
FTempBmp.Canvas.Brush.Color := c
|
ACanvas.Brush.Color := c
|
||||||
else
|
else
|
||||||
FTempBmp.Canvas.Brush.Color := clGray;
|
ACanvas.Brush.Color := clGray;
|
||||||
FTempBmp.Canvas.FillRect(R);
|
ACanvas.FillRect(R);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//if transparent draw the glyph
|
//if transparent draw the glyph
|
||||||
if SameText(clr, 'clTransparent') then
|
if SameText(AColor, 'clTransparent') then
|
||||||
PaintTransparentGlyph(FTempBmp.Canvas, R);
|
PaintTransparentGlyph(ACanvas, R);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -454,7 +482,7 @@ begin
|
|||||||
with ThemeServices do
|
with ThemeServices do
|
||||||
if Enabled then
|
if Enabled then
|
||||||
case FState of
|
case FState of
|
||||||
ccsNone: ;
|
ccsNone: ; //PaintParentBack(ACanvas, R);
|
||||||
// ccsNone: ACanvas.CopyRect(R, PBack.Canvas, R);
|
// ccsNone: ACanvas.CopyRect(R, PBack.Canvas, R);
|
||||||
ccsOver: DrawElement(ACanvas.Handle, GetElementDetails(ttbButtonHot), R);
|
ccsOver: DrawElement(ACanvas.Handle, GetElementDetails(ttbButtonHot), R);
|
||||||
ccsDown: DrawElement(ACanvas.Handle, GetElementDetails(ttbButtonPressed), R);
|
ccsDown: DrawElement(ACanvas.Handle, GetElementDetails(ttbButtonPressed), R);
|
||||||
@@ -586,6 +614,7 @@ begin
|
|||||||
else if FColCount > 1 then
|
else if FColCount > 1 then
|
||||||
Inc(R.Right);
|
Inc(R.Right);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
with ACanvas do
|
with ACanvas do
|
||||||
case FTStyle of
|
case FTStyle of
|
||||||
tsPhotoshop:
|
tsPhotoshop:
|
||||||
@@ -660,7 +689,7 @@ end;
|
|||||||
procedure TmbColorPalette.Resize;
|
procedure TmbColorPalette.Resize;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
//CalcAutoHeight; // wp: will cause a ChangedBounds endless loop
|
CalcAutoHeight; // wp: will cause a ChangedBounds endless loop
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -15,8 +15,12 @@ function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
|||||||
|
|
||||||
function HighContrastColor(AColor: TColor): TColor;
|
function HighContrastColor(AColor: TColor): TColor;
|
||||||
|
|
||||||
function HeightOf(R: TRect): Integer;
|
function HeightOfRect(R: TRect): Integer;
|
||||||
function WidthOf(R: TRect): Integer;
|
function WidthOfRect(R: TRect): Integer;
|
||||||
|
function IsEmptyRect(R: TRect): Boolean;
|
||||||
|
|
||||||
|
const
|
||||||
|
EMPTY_RECT: TRect = (Left: -1; Top: -1; Right: -1; Bottom: -1);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@@ -53,16 +57,21 @@ begin
|
|||||||
Result := sqr(p.x - ctr.x) + sqr(p.y - ctr.y) <= sqr(Radius);
|
Result := sqr(p.x - ctr.x) + sqr(p.y - ctr.y) <= sqr(Radius);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function HeightOf(R: TRect): Integer;
|
function HeightOfRect(R: TRect): Integer;
|
||||||
begin
|
begin
|
||||||
Result := R.Bottom - R.Top;
|
Result := R.Bottom - R.Top;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function WidthOf(R: TRect): Integer;
|
function WidthOfRect(R: TRect): Integer;
|
||||||
begin
|
begin
|
||||||
Result := R.Right - R.Left;
|
Result := R.Right - R.Left;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IsEmptyRect(R: TRect): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (R.Left = -1) and (R.Top = -1) and (R.Right = -1) and (R.Bottom = -1);
|
||||||
|
end;
|
||||||
|
|
||||||
function HighContrastColor(AColor: TColor): TColor;
|
function HighContrastColor(AColor: TColor): TColor;
|
||||||
begin
|
begin
|
||||||
if GetRValue(AColor) + GetGValue(AColor) + GetBValue(AColor) > 3*128 then
|
if GetRValue(AColor) + GetGValue(AColor) + GetBValue(AColor) > 3*128 then
|
||||||
|
Reference in New Issue
Block a user