MG: fixed TColorDialog set color

git-svn-id: trunk@340 -
This commit is contained in:
lazarus 2001-10-08 08:05:08 +00:00
parent 10f39f4d33
commit 4c04295209
3 changed files with 51 additions and 8 deletions

View File

@ -81,6 +81,8 @@ type
function SetValue (Sender : TObject; Data : pointer) : integer;
function SetProperties (Sender: TObject) : integer;
procedure AttachMenu(Sender: TObject);
procedure SetColorDialogColor(ColorSelection: PGtkColorSelection;
Color: TColor);
function HashPaintMessage(p: pointer): integer;
function FindPaintMessage(HandleWnd: HWnd): PLazQueueItem;
@ -278,6 +280,9 @@ end.
{ =============================================================================
$Log$
Revision 1.21 2001/10/08 08:05:08 lazarus
MG: fixed TColorDialog set color
Revision 1.20 2001/10/07 07:28:33 lazarus
MG: fixed setpixel and TCustomForm.OnResize event

View File

@ -692,6 +692,8 @@ activate_time : the time at which the activation event occurred.
end;
end;
gtk_window_set_position(PGtkWindow(handle), GTK_WIN_POS_CENTER);
if Sender is TColorDialog then
SetColorDialogColor(Pointer(Handle),TColorDialog(Sender).Color);
gtk_widget_show(PGtkWidget(handle));
gtk_window_set_modal(PGtkWindow(handle), true);
end;
@ -2513,6 +2515,35 @@ begin
TLMSetGetPixel(data^).PixColor := GDKColorIDToRGB(GDKColorIndex);
end;
{------------------------------------------------------------------------------
Method: TGtkObject.SetColorDialogColor
Params: ColorSelection : a gtk color selection dialog;
Color : the color to select
Returns: nothing
Set the color of the coor selection dialog
------------------------------------------------------------------------------}
procedure TgtkObject.SetColorDialogColor(ColorSelection: PGtkColorSelection;
Color: TColor);
var
SelectionColor: PGDouble; // currently only used by TColorDialog
colorSel : GTK_COLOR_SELECTION;
begin
GetMem(SelectionColor,4*SizeOf(GDouble));
try
Color:=ColorToRGB(Color);
SelectionColor[0]:=(Color and $ff)/255;
SelectionColor[1]:=((Color shr 8) and $ff)/255;
SelectionColor[2]:=((Color shr 16) and $ff)/255;
SelectionColor[3]:=0.0;
colorSel := GTK_COLOR_SELECTION(
(GTK_COLOR_SELECTION_DIALOG(ColorSelection))^.colorsel);
gtk_color_selection_set_color(colorSel,SelectionColor);
finally
FreeMem(SelectionColor);
end;
end;
{------------------------------------------------------------------------------
Method: TGtkObject.GetValue
Params: Sender : the lcl object which called this func via SenMessage
@ -3050,6 +3081,9 @@ end;
{ =============================================================================
$Log$
Revision 1.58 2001/10/08 08:05:08 lazarus
MG: fixed TColorDialog set color
Revision 1.57 2001/10/07 07:28:34 lazarus
MG: fixed setpixel and TCustomForm.OnResize event

View File

@ -718,8 +718,9 @@ end;
function TGDKColorToTColor(value : TGDKColor) : TColor;
begin
ReportNotObsolete('TgdkColortoTColor');
result := ((value.blue div 257) shl 16) + ((value.green div 257) shl 8) + (value.red div 257);
//ReportNotObsolete('TgdkColortoTColor');
Result := ((Value.Blue div 257) shl 16) + ((Value.Green div 257) shl 8)
+ (Value.Red div 257);
end;
function TColortoTGDKColor(value : TColor) : TGDKColor;
@ -771,6 +772,9 @@ end;
{ =============================================================================
$Log$
Revision 1.22 2001/10/08 08:05:08 lazarus
MG: fixed TColorDialog set color
Revision 1.21 2001/10/07 07:28:34 lazarus
MG: fixed setpixel and TCustomForm.OnResize event