diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-11-17 16:18:15 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-11-17 16:18:15 +0100 |
| commit | d884d5168984d36a5c08f4814e81b070d7c964d3 (patch) | |
| tree | 9743d99642487bececce0093866e71196a0731ba /libgtk_kylix/GTKControls.pas | |
| parent | cb5cb517c068a470662bd1d08bef61265376c802 (diff) | |
| download | tuxcmd-d884d5168984d36a5c08f4814e81b070d7c964d3.tar.xz | |
Use getters instead of direct access to structuresv0.6.71
This will hopefully fix remaining GUI issues on PPC64. Needs further testing!
Also, libgtk_kylix sources have been altered for use with gtk2forpascal-1.0.7 for Kylix compilation.
Diffstat (limited to 'libgtk_kylix/GTKControls.pas')
| -rw-r--r-- | libgtk_kylix/GTKControls.pas | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/libgtk_kylix/GTKControls.pas b/libgtk_kylix/GTKControls.pas index c55f2a1..35719a8 100644 --- a/libgtk_kylix/GTKControls.pas +++ b/libgtk_kylix/GTKControls.pas @@ -413,10 +413,11 @@ begin end; function TGTKControl.GetEnabled: boolean; +var b: gboolean; begin - Result := False; - if (csDestroying in ComponentState) then Exit; - Result := GTK_WIDGET_SENSITIVE(FWidget); + b := False; + if not (csDestroying in ComponentState) then g_object_get(FWidget, 'sensitive', @b, nil); + Result := b; end; procedure TGTKControl.SetEnabled(const Value: boolean); @@ -464,17 +465,28 @@ end; function TGTKControl.GetTooltip: string; var TooltipsData : PGtkTooltipsData; + text: PChar; begin + text := nil; Result := ''; - TooltipsData := gtk_tooltips_data_get(FWidget); - if Assigned(TooltipsData) then Result := PgcharToString(TooltipsData^.tip_text); + if Application.GTKVersion_2_12_0_Up then begin + g_object_get(FWidget, 'tooltip-text', @text, nil); + if text <> nil then Result := string(text); + end else begin + TooltipsData := gtk_tooltips_data_get(FWidget); + if Assigned(TooltipsData) then Result := PgcharToString(TooltipsData^.tip_text); + end; end; procedure TGTKControl.SetTooltip(Value: string); var FParentForm : TCustomGTKForm; begin - FParentForm := GetParentForm(Self); - if FParentForm <> nil then gtk_tooltips_set_tip(FParentForm.Tooltips.FObject, FWidget, StringToPgchar(Value), nil); + if Application.GTKVersion_2_12_0_Up then + g_object_set(FWidget, 'tooltip-text', PChar(Value), nil) + else begin + FParentForm := GetParentForm(Self); + if FParentForm <> nil then gtk_tooltips_set_tip(FParentForm.Tooltips.FObject, FWidget, StringToPgchar(Value), nil); + end; end; procedure TGTKControl.SetFocus; @@ -484,10 +496,11 @@ begin end; function TGTKControl.GetCanFocus: boolean; +var b: gboolean; begin - Result := False; - if (csDestroying in ComponentState) then Exit; - Result := GTK_WIDGET_CAN_FOCUS(FWidget); + b := False; + if not (csDestroying in ComponentState) then g_object_get(FWidget, 'can-focus', @b, nil); + Result := b; end; procedure TGTKControl.SetCanFocus(Value: boolean); @@ -498,11 +511,14 @@ begin end; function TGTKControl.GetFocused: boolean; +var b: boolean; begin + b := False; Result := False; try if (csDestroying in ComponentState) or (FWidget = nil) then Exit; - Result := GTK_WIDGET_HAS_FOCUS(FWidget); + g_object_get(FWidget, 'has-focus', @b, nil); + Result := b; except end; end; @@ -738,17 +754,17 @@ begin end; function TGTKControl.GetDefault: boolean; +var b: gboolean; begin - Result := False; - if (csDestroying in ComponentState) then Exit; - Result := GTK_WIDGET_HAS_DEFAULT(FWidget); + b := False; + if not (csDestroying in ComponentState) then g_object_get(FWidget, 'has-default', @b, nil); + Result := b; end; procedure TGTKControl.SetDefault(Value: boolean); begin if (csDestroying in ComponentState) then Exit; - GTK_WIDGET_SET_FLAGS(FWidget, GTK_CAN_DEFAULT); -// gtk_widget_grab_default(FWidget); + g_object_set(FWidget, 'can-default', Ord(Value), nil); end; procedure TGTKControl.Invalidate; @@ -839,8 +855,11 @@ begin end; function TGTKContainer.GetChildrenCount: integer; +var List: PGList; begin - Result := g_list_length(gtk_container_get_children(PGtkContainer(FWidget))); + List := gtk_container_get_children(PGtkContainer(FWidget)); + Result := g_list_length(List); + g_list_free(List); end; (********************************************************************************************************************************) @@ -968,6 +987,7 @@ end; function TGTKTooltips.GetEnabled: boolean; begin + // FIXME: This is horrible expression Result := Boolean(gtk2.enabled(FObject^)); end; @@ -1007,8 +1027,11 @@ begin end; function TGTKTable.GetRowCount: integer; +var nrows: guint; begin - Result := PGtkTable(FWidget)^.nrows; + nrows := 1; + g_object_get(FWidget, 'n-rows', @nrows, nil); + Result := nrows; end; procedure TGTKTable.SetRowCount(Value: integer); @@ -1017,8 +1040,11 @@ begin end; function TGTKTable.GetColCount: integer; +var ncols: guint; begin - Result := PGtkTable(FWidget)^.ncols; + ncols := 1; + g_object_get(FWidget, 'n-columns', @ncols, nil); + Result := ncols; end; procedure TGTKTable.SetColCount(Value: integer); |
