mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 18:39:05 +02:00
started gtk2 stock icon overrides
partial/temp(?) workaround for dc paint offsets git-svn-id: trunk@4580 -
This commit is contained in:
parent
d17a272442
commit
9d8709e7c1
@ -1646,6 +1646,12 @@ var
|
|||||||
begin
|
begin
|
||||||
if (DC<>nil) then begin
|
if (DC<>nil) then begin
|
||||||
Result:=DC.Origin;
|
Result:=DC.Origin;
|
||||||
|
{$Ifdef GTK2}
|
||||||
|
if (DC.Wnd<>0) and not GtkWidgetIsA(PGTKWidget(DC.Wnd),GTK_TYPE_WINDOW) then begin
|
||||||
|
Inc(Result.X, PGTKWidget(DC.Wnd)^.Allocation.x);
|
||||||
|
Inc(Result.y, PGTKWidget(DC.Wnd)^.Allocation.y);
|
||||||
|
end;
|
||||||
|
{$EndIf}
|
||||||
if (DC.SpecialOrigin) and (DC.Wnd<>0) then begin
|
if (DC.SpecialOrigin) and (DC.Wnd<>0) then begin
|
||||||
Fixed := GetFixedWidget(PGTKWidget(DC.Wnd));
|
Fixed := GetFixedWidget(PGTKWidget(DC.Wnd));
|
||||||
if GtkWidgetIsA(Fixed,GTK_LAYOUT_GET_TYPE) then begin
|
if GtkWidgetIsA(Fixed,GTK_LAYOUT_GET_TYPE) then begin
|
||||||
@ -2858,9 +2864,11 @@ begin
|
|||||||
if AWindow=nil then exit;
|
if AWindow=nil then exit;
|
||||||
Container := GTK_CONTAINER (MenuItem);
|
Container := GTK_CONTAINER (MenuItem);
|
||||||
BorderWidth := Container^.flag0 and bm_TGtkContainer_border_width;
|
BorderWidth := Container^.flag0 and bm_TGtkContainer_border_width;
|
||||||
ALeft := (BorderWidth + gtk_widget_get_xthickness(gtk_widget_get_style(Widget)) + 2)
|
ALeft := {$Ifdef GTK2}Widget^.Allocation.x + {$EndIf}
|
||||||
|
(BorderWidth + gtk_widget_get_xthickness(gtk_widget_get_style(Widget)) + 2)
|
||||||
+((PGtkMenuItem(MenuItem)^.toggle_size-IconWidth) div 2);
|
+((PGtkMenuItem(MenuItem)^.toggle_size-IconWidth) div 2);
|
||||||
ATop := (Widget^.Allocation.Height - IconHeight) div 2;
|
ATop := {$Ifdef GTK2} Widget^.Allocation.y + {$EndIf}
|
||||||
|
(Widget^.Allocation.Height - IconHeight) div 2;
|
||||||
|
|
||||||
// draw icon
|
// draw icon
|
||||||
gdk_gc_set_clip_mask(gtk_widget_get_style(Widget)^.Black_gc, IconMask);
|
gdk_gc_set_clip_mask(gtk_widget_get_style(Widget)^.Black_gc, IconMask);
|
||||||
@ -4530,6 +4538,10 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.199 2003/09/06 22:56:03 ajgenius
|
||||||
|
started gtk2 stock icon overrides
|
||||||
|
partial/temp(?) workaround for dc paint offsets
|
||||||
|
|
||||||
Revision 1.198 2003/09/06 20:23:53 ajgenius
|
Revision 1.198 2003/09/06 20:23:53 ajgenius
|
||||||
fixes for gtk2
|
fixes for gtk2
|
||||||
added more wrappers for gtk1/gtk2 converstion and sanity
|
added more wrappers for gtk1/gtk2 converstion and sanity
|
||||||
|
@ -52,6 +52,7 @@ type
|
|||||||
TGtk2Object = class(TGtkObject)
|
TGtk2Object = class(TGtkObject)
|
||||||
public
|
public
|
||||||
function GetCursorPos(var lpPoint: TPoint ): Boolean; override;
|
function GetCursorPos(var lpPoint: TPoint ): Boolean; override;
|
||||||
|
function LoadStockPixmap(StockID: longint) : HBitmap; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +66,6 @@ function gdk_display_get_default:PGdkDisplay; cdecl; external gdklib;
|
|||||||
{$EndIf}
|
{$EndIf}
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -117,10 +117,71 @@ begin
|
|||||||
{$EndIf}
|
{$EndIf}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function TGtk2Object.LoadStockPixmap(StockID: longint) : HBitmap;
|
||||||
|
var
|
||||||
|
Pixmap : PGDIObject;
|
||||||
|
StockName : PChar;
|
||||||
|
IconSet : PGtkIconSet;
|
||||||
|
Pixbuf : PGDKPixbuf;
|
||||||
|
begin
|
||||||
|
Case StockID Of
|
||||||
|
idButtonOk : StockName := GTK_STOCK_OK;
|
||||||
|
idButtonCancel : StockName := GTK_STOCK_CANCEL;
|
||||||
|
idButtonYes : StockName := GTK_STOCK_YES;
|
||||||
|
idButtonNo : StockName := GTK_STOCK_NO;
|
||||||
|
idButtonHelp : StockName := GTK_STOCK_HELP;
|
||||||
|
idButtonAbort : StockName := GTK_STOCK_CANCEL;
|
||||||
|
idButtonClose : StockName := GTK_STOCK_QUIT;
|
||||||
|
|
||||||
|
idDialogWarning : StockName := GTK_STOCK_DIALOG_WARNING;
|
||||||
|
idDialogError : StockName := GTK_STOCK_DIALOG_ERROR;
|
||||||
|
idDialogInfo : StockName := GTK_STOCK_DIALOG_INFO;
|
||||||
|
idDialogConfirm : StockName := GTK_STOCK_DIALOG_QUESTION;
|
||||||
|
else begin
|
||||||
|
Result := inherited LoadStockPixmap(StockID);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (StockID >= idButtonBase) and (StockID <= idDialogBase) then
|
||||||
|
IconSet := gtk_style_lookup_icon_set(GetStyle('button'), StockName)
|
||||||
|
else
|
||||||
|
IconSet := gtk_style_lookup_icon_set(GetStyle('window'), StockName);
|
||||||
|
|
||||||
|
If (IconSet = nil) then begin
|
||||||
|
Result := inherited LoadStockPixmap(StockID);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (StockID >= idButtonBase) and (StockID <= idDialogBase) then
|
||||||
|
pixbuf := gtk_icon_set_render_icon(IconSet, GetStyle('button'), GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, GTK_ICON_SIZE_BUTTON, GetStyleWidget('button'), nil)
|
||||||
|
else
|
||||||
|
pixbuf := gtk_icon_set_render_icon(IconSet, GetStyle('window'), GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, GTK_ICON_SIZE_DIALOG, GetStyleWidget('window'), nil);
|
||||||
|
|
||||||
|
gtk_icon_set_unref(IconSet);
|
||||||
|
|
||||||
|
Pixmap := NewGDIObject(gdiBitmap);
|
||||||
|
With Pixmap^ do begin
|
||||||
|
GDIBitmapType := gbPixmap;
|
||||||
|
visual := gdk_visual_get_system();
|
||||||
|
gdk_visual_ref(visual);
|
||||||
|
colormap := gdk_colormap_get_system();
|
||||||
|
gdk_colormap_ref(colormap);
|
||||||
|
gdk_pixbuf_render_pixmap_and_mask(pixbuf, GDIPixmapObject, GDIBitmapMaskObject, 128);
|
||||||
|
end;
|
||||||
|
|
||||||
|
gdk_pixbuf_unref(pixbuf);
|
||||||
|
Result := HBitmap(Pixmap);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.5 2003/09/06 22:56:03 ajgenius
|
||||||
|
started gtk2 stock icon overrides
|
||||||
|
partial/temp(?) workaround for dc paint offsets
|
||||||
|
|
||||||
Revision 1.4 2003/09/06 20:23:53 ajgenius
|
Revision 1.4 2003/09/06 20:23:53 ajgenius
|
||||||
fixes for gtk2
|
fixes for gtk2
|
||||||
added more wrappers for gtk1/gtk2 converstion and sanity
|
added more wrappers for gtk1/gtk2 converstion and sanity
|
||||||
|
Loading…
Reference in New Issue
Block a user