diff options
Diffstat (limited to 'libgtk_kylix/GTKDialogs.pas')
| -rw-r--r-- | libgtk_kylix/GTKDialogs.pas | 171 |
1 files changed, 55 insertions, 116 deletions
diff --git a/libgtk_kylix/GTKDialogs.pas b/libgtk_kylix/GTKDialogs.pas index 17b32d0..dfbe1b2 100644 --- a/libgtk_kylix/GTKDialogs.pas +++ b/libgtk_kylix/GTKDialogs.pas @@ -1,6 +1,5 @@ (* GTK-Kylix Library: GTKDialogs - Special purpose dialogs - Version 0.7.0 (last updated 2006-02-05) Copyright (C) 2006 Tomas Bzatek <tbzatek@users.sourceforge.net> This library is free software; you can redistribute it and/or @@ -24,20 +23,15 @@ unit GTKDialogs; interface -uses gtk2, gdk2, lazglib2, lazgobject2, Classes, GTKControls, GTKUtils, GTKClasses, GTKForms; - +uses lazglib2, lazgobject2, lazgdk3, lazgtk3, Classes, GTKControls, GTKStdCtrls, GTKForms; type -(****************************************** TGTKFILESELECTIONDIALOG *************************************************************) - TGTKFileSelectionDialog = class(TGTKDialog) +(****************************************** TGTKFILECHOOSERDIALOG *************************************************************) + TGTKFileChooserDialog = class(TGTKDialog) private function GetFileName: string; - function GetShowFileOpButtons: boolean; - function GetMultiSelect: boolean; procedure SetFileName(Value: string); - procedure SetShowFileOpButtons(Value: boolean); - procedure SetMultiSelect(Value: boolean); protected public constructor Create(AOwner: TComponent); override; @@ -45,45 +39,37 @@ type destructor Destroy; override; published property FileName: string read GetFileName write SetFileName; - property ShowFileOpButtons: boolean read GetShowFileOpButtons write SetShowFileOpButtons; - property MultiSelect: boolean read GetMultiSelect write SetMultiSelect; end; -(****************************************** TGTKCOLORSELECTIONDIALOG ************************************************************) - TGTKColorSelectionDialog = class(TGTKDialog) +(****************************************** TGTKCOLORBUTTON *******************************************************************) + TGTKColorButton = class(TGTKButton) private - function GetShowOpacity: boolean; - procedure SetShowOpacity(Value: boolean); - function GetShowPalette: boolean; - procedure SetShowPalette(Value: boolean); - function GetColor: TGDKColor; - procedure SetColor(Value: TGDKColor); + FColorChanged: TNotifyEvent; + function GetColor: string; + procedure SetColor(Value: string); protected public constructor Create(AOwner: TComponent); override; - constructor CreateWithTitle(AOwner: TComponent; const Title: string); destructor Destroy; override; - property Color: TGDKColor read GetColor write SetColor; + procedure SetDefaultColor; published - property ShowOpacity: boolean read GetShowOpacity write SetShowOpacity; - property ShowPalette: boolean read GetShowPalette write SetShowPalette; + property Color: string read GetColor write SetColor; + property OnColorChanged: TNotifyEvent read FColorChanged write FColorChanged; end; -(****************************************** TGTKFONTSELECTIONDIALOG *************************************************************) - TGTKFontSelectionDialog = class(TGTKDialog) +(****************************************** TGTKFontButton *************************************************************) + TGTKFontButton = class(TGTKButton) private + FFontNameChanged: TNotifyEvent; function GetFontName: string; procedure SetFontName(Value: string); - function GetPreviewText: string; - procedure SetPreviewText(Value: string); protected public constructor Create(AOwner: TComponent); override; - constructor CreateWithTitle(AOwner: TComponent; const Title: string); destructor Destroy; override; published property FontName: string read GetFontName write SetFontName; - property PreviewText: string read GetPreviewText write SetPreviewText; + property OnFontNameChanged: TNotifyEvent read FFontNameChanged write FFontNameChanged; end; (********************************************************************************************************************************) @@ -95,154 +81,107 @@ uses SysUtils, DateUtils; (********************************************************************************************************************************) (********************************************************************************************************************************) -constructor TGTKFileSelectionDialog.Create(AOwner: TComponent); +constructor TGTKFileChooserDialog.Create(AOwner: TComponent); begin inherited Create(AOwner); - FWidget := gtk_file_selection_new(nil); + FWidget := gtk_file_chooser_dialog_new(nil, PGtkWindow((AOwner as TCustomGTKForm).FWidget), GTK_FILE_CHOOSER_ACTION_OPEN, nil, [nil]); Show; end; -constructor TGTKFileSelectionDialog.CreateWithTitle(AOwner: TComponent; const Title: string); +constructor TGTKFileChooserDialog.CreateWithTitle(AOwner: TComponent; const Title: string); begin inherited Create(AOwner); - FWidget := gtk_file_selection_new(PChar(Title)); + FWidget := gtk_file_chooser_dialog_new(PChar(Title), PGtkWindow((AOwner as TCustomGTKForm).FWidget), GTK_FILE_CHOOSER_ACTION_OPEN, nil, [nil]); Show; end; -destructor TGTKFileSelectionDialog.Destroy; +destructor TGTKFileChooserDialog.Destroy; begin inherited Destroy; end; -function TGTKFileSelectionDialog.GetFileName: string; -begin - Result := string(gtk_file_selection_get_filename(PGtkFileSelection(FWidget))); -end; - -procedure TGTKFileSelectionDialog.SetFileName(Value: string); -begin - gtk_file_selection_set_filename(PGtkFileSelection(FWidget), PChar(Value)); -end; - -function TGTKFileSelectionDialog.GetShowFileOpButtons: boolean; -var b: Boolean; +function TGTKFileChooserDialog.GetFileName: string; begin - b := False; - g_object_get(PGObject(FWidget), 'show-fileops', [@b, nil]); - Result := b; + Result := String(gtk_file_chooser_get_filename(PGtkFileChooser(FWidget))); end; -procedure TGTKFileSelectionDialog.SetShowFileOpButtons(Value: boolean); +procedure TGTKFileChooserDialog.SetFileName(Value: string); begin - if Value then gtk_file_selection_show_fileop_buttons(PGtkFileSelection(FWidget)) - else gtk_file_selection_hide_fileop_buttons(PGtkFileSelection(FWidget)); -end; - -function TGTKFileSelectionDialog.GetMultiSelect: boolean; -begin - Result := gtk_file_selection_get_select_multiple(PGtkFileSelection(FWidget)); -end; - -procedure TGTKFileSelectionDialog.SetMultiSelect(Value: boolean); -begin - gtk_file_selection_set_select_multiple(PGtkFileSelection(FWidget), Value); + gtk_file_chooser_set_filename(PGtkFileChooser(FWidget), PChar(Value)); end; (********************************************************************************************************************************) (********************************************************************************************************************************) -constructor TGTKColorSelectionDialog.Create(AOwner: TComponent); +procedure GtkColorButton_color_set(widget: PGtkColorButton; user_data: gpointer); cdecl; begin - inherited Create(AOwner); - FWidget := gtk_color_selection_dialog_new(nil); - Show; + if Assigned(user_data) and Assigned(TGTKColorButton(user_data).FColorChanged) then + TGTKColorButton(user_data).FColorChanged(TGTKColorButton(user_data)); end; -constructor TGTKColorSelectionDialog.CreateWithTitle(AOwner: TComponent; const Title: string); +constructor TGTKColorButton.Create(AOwner: TComponent); begin inherited Create(AOwner); - FWidget := gtk_color_selection_dialog_new(PChar(Title)); + FWidget := gtk_color_button_new(); + g_signal_connect_data(PGObject(FWidget), 'color-set', TGCallback(@GtkColorButton_color_set), Self, nil, G_CONNECT_DEFAULT); Show; + FColorChanged := nil; end; -destructor TGTKColorSelectionDialog.Destroy; +destructor TGTKColorButton.Destroy; begin inherited Destroy; end; -function TGTKColorSelectionDialog.GetShowOpacity: boolean; +function TGTKColorButton.GetColor: string; +var c: TGdkRGBA; begin - Result := gtk_color_selection_get_has_opacity_control(PGtkColorSelection(PGtkColorSelectionDialog(FWidget)^.colorsel)); + FillChar(c, sizeof(TGdkRGBA), 0); + gtk_color_chooser_get_rgba(PGtkColorChooser(FWidget), @c); + Result := string(gdk_rgba_to_string(@c)); end; -procedure TGTKColorSelectionDialog.SetShowOpacity(Value: boolean); +procedure TGTKColorButton.SetColor(Value: string); +var c: TGdkRGBA; begin - gtk_color_selection_set_has_opacity_control(PGtkColorSelection(PGtkColorSelectionDialog(FWidget)^.colorsel), Value); + if gdk_rgba_parse(@c, PChar(Value)) then + gtk_color_chooser_set_rgba(PGtkColorChooser(FWidget), @c); end; -function TGTKColorSelectionDialog.GetShowPalette: boolean; +procedure TGTKColorButton.SetDefaultColor; begin - Result := gtk_color_selection_get_has_palette(PGtkColorSelection(PGtkColorSelectionDialog(FWidget)^.colorsel)); -end; - -procedure TGTKColorSelectionDialog.SetShowPalette(Value: boolean); -begin - gtk_color_selection_set_has_palette(PGtkColorSelection(PGtkColorSelectionDialog(FWidget)^.colorsel), Value); -end; - -function TGTKColorSelectionDialog.GetColor: TGDKColor; -var Col: gdk2.TGDkColor; -begin - FillChar(Col, sizeof(gdk2.TGDkColor), 0); - gtk_color_selection_get_current_color(PGtkColorSelection(PGtkColorSelectionDialog(FWidget)^.colorsel), @Col); - Result := PGdkColorToGDKColor(@Col); -end; - -procedure TGTKColorSelectionDialog.SetColor(Value: TGDKColor); -var Col: PGDkColor; -begin - Col := GDKColorToPGdkColor(Value); - gtk_color_selection_set_current_color(PGtkColorSelection(PGtkColorSelectionDialog(FWidget)^.colorsel), Col); + gtk_color_chooser_set_rgba(PGtkColorChooser(FWidget), nil); end; (********************************************************************************************************************************) (********************************************************************************************************************************) -constructor TGTKFontSelectionDialog.Create(AOwner: TComponent); +procedure GtkFontButton_font_set(widget: PGtkFontButton; user_data: gpointer); cdecl; begin - inherited Create(AOwner); - FWidget := gtk_font_selection_dialog_new(nil); - Show; + if Assigned(user_data) and Assigned(TGTKFontButton(user_data).FFontNameChanged) then + TGTKFontButton(user_data).FFontNameChanged(TGTKFontButton(user_data)); end; -constructor TGTKFontSelectionDialog.CreateWithTitle(AOwner: TComponent; const Title: string); +constructor TGTKFontButton.Create(AOwner: TComponent); begin inherited Create(AOwner); - FWidget := gtk_font_selection_dialog_new(PChar(Title)); + FWidget := gtk_font_button_new(); + g_signal_connect_data(PGObject(FWidget), 'font-set', TGCallback(@GtkFontButton_font_set), Self, nil, G_CONNECT_DEFAULT); Show; + FFontNameChanged := nil; end; -destructor TGTKFontSelectionDialog.Destroy; +destructor TGTKFontButton.Destroy; begin inherited Destroy; end; -function TGTKFontSelectionDialog.GetFontName: string; -begin - Result := String(gtk_font_selection_dialog_get_font_name(PGtkFontSelectionDialog(FWidget))); -end; - -procedure TGTKFontSelectionDialog.SetFontName(Value: string); -begin - gtk_font_selection_dialog_set_font_name(PGtkFontSelectionDialog(FWidget), PChar(Value)); -end; - -function TGTKFontSelectionDialog.GetPreviewText: string; +function TGTKFontButton.GetFontName: string; begin - Result := String(gtk_font_selection_dialog_get_preview_text(PGtkFontSelectionDialog(FWidget))); + Result := String(gtk_font_chooser_get_font(PGtkFontChooser(FWidget))); end; -procedure TGTKFontSelectionDialog.SetPreviewText(Value: string); +procedure TGTKFontButton.SetFontName(Value: string); begin - gtk_font_selection_dialog_set_preview_text(PGtkFontSelectionDialog(FWidget), PChar(Value)); + gtk_font_chooser_set_font(PGtkFontChooser(FWidget), PChar(Value)); end; (********************************************************************************************************************************) |
