diff --git a/lcl/interfaces/gtk/gtkint.pp b/lcl/interfaces/gtk/gtkint.pp index 756746415f..082e7b5c8e 100644 --- a/lcl/interfaces/gtk/gtkint.pp +++ b/lcl/interfaces/gtk/gtkint.pp @@ -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 diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index c11032da79..81c3d02ef6 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -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; @@ -1946,12 +1948,12 @@ begin csColorDialog : begin - P := gtk_color_selection_dialog_new(StrTemp); - // We will only add this line if we see problem in the future with the color dialog MAH 7-31-99 - // gtk_color_selection_set_update_policy(GTK_COLOR_SELECTION((GTK_COLOR_SELECTION_DIALOG(P))^.colorsel), GTK_UPDATE_DISCONTINUOUS); - gtk_signal_connect( gtk_object((GTK_COLOR_SELECTION_DIALOG(P))^.ok_button), 'clicked', gtk_signal_func(@gtkDialogOKclickedCB), Sender); - gtk_signal_connect( gtk_object((GTK_COLOR_SELECTION_DIALOG(P))^.cancel_button), 'clicked', gtk_signal_func(@gtkDialogCancelclickedCB), Sender); - gtk_signal_connect( gtk_object(P), 'destroy', gtk_Signal_Func(@gtkDialogDestroyCB), Sender); + P := gtk_color_selection_dialog_new(StrTemp); + // We will only add this line if we see problem in the future with the color dialog MAH 7-31-99 + // gtk_color_selection_set_update_policy(GTK_COLOR_SELECTION((GTK_COLOR_SELECTION_DIALOG(P))^.colorsel), GTK_UPDATE_DISCONTINUOUS); + gtk_signal_connect( gtk_object((GTK_COLOR_SELECTION_DIALOG(P))^.ok_button), 'clicked', gtk_signal_func(@gtkDialogOKclickedCB), Sender); + gtk_signal_connect( gtk_object((GTK_COLOR_SELECTION_DIALOG(P))^.cancel_button), 'clicked', gtk_signal_func(@gtkDialogCancelclickedCB), Sender); + gtk_signal_connect( gtk_object(P), 'destroy', gtk_Signal_Func(@gtkDialogDestroyCB), Sender); end; csFontDialog : @@ -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 diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index aaef85bf15..847d5f9967 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -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