├── Resources ├── gtk+.png ├── gnome_icon_48.png └── ThemeImages │ └── common_outlineUnexpandable.tiff ├── GGScrollStepperCell.h ├── GGScrollKnobCell.h ├── INSTALL ├── GtkInfo.plist ├── README ├── NSWindow+Gnome.m ├── GSBrowserTitleCell+Gnome.m ├── NSScrollView+Gnome.m ├── GGnomeTheme.h ├── GGScrollStepperCell.m ├── GNUmakefile ├── NSMenuView+Gnome.m ├── NSSliderCell+Gnome.m ├── NSTableHeaderCell+Gnome.m ├── GGScrollKnobCell.m ├── GGnomeThemeInitialization.h ├── NSScroller+Gnome.m ├── NSBrowser+Gnome.m ├── NSPopUpButtonCell+Gnome.m ├── NSTableHeaderView+Gnome.m ├── GGPainter.h ├── ChangeLog ├── NSTabView+Gnome.m ├── NSTableView+Gnome.m ├── GGnomeThemeInitialization.m ├── GGnomeTheme.m ├── COPYING └── GGPainter.m /Resources/gtk+.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/plugins-themes-Gtk/HEAD/Resources/gtk+.png -------------------------------------------------------------------------------- /Resources/gnome_icon_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/plugins-themes-Gtk/HEAD/Resources/gnome_icon_48.png -------------------------------------------------------------------------------- /Resources/ThemeImages/common_outlineUnexpandable.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnustep/plugins-themes-Gtk/HEAD/Resources/ThemeImages/common_outlineUnexpandable.tiff -------------------------------------------------------------------------------- /GGScrollStepperCell.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface GGScrollStepperCell : NSButtonCell 4 | { 5 | BOOL horizontal; 6 | } 7 | 8 | - (BOOL) isHorizontal; 9 | - (void) setHorizontal: (BOOL) value; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /GGScrollKnobCell.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @interface GGScrollKnobCell : NSButtonCell 4 | { 5 | BOOL knob; 6 | BOOL horizontal; 7 | } 8 | 9 | - (BOOL) isKnob; 10 | - (void) setKnob: (BOOL) value; 11 | 12 | - (BOOL) isHorizontal; 13 | - (void) setHorizontal: (BOOL) value; 14 | 15 | 16 | + (GGScrollKnobCell *) newWithKnob: (BOOL)is_knob horizontal: (BOOL) horizontal; 17 | @end 18 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation 2 | ------------ 3 | 4 | Just compile the Gnome bundle : 5 | 6 | make 7 | 8 | and as superuser: 9 | 10 | make install 11 | 12 | Now, just try to activate the theme (for example with SystemPrefrences.app) 13 | and run a GNUstep program ... :-) 14 | 15 | or type on the command line: 16 | 17 | defaults write NSGlobalDomain GSTheme GnomeTheme 18 | 19 | Thanks, GC 20 | 21 | Dependencies 22 | ------------ 23 | 24 | On Debian-derivatives: 25 | 26 | * libgtk2.0-dev 27 | * libgconf2-dev 28 | -------------------------------------------------------------------------------- /GtkInfo.plist: -------------------------------------------------------------------------------- 1 | { 2 | NSExecutable = "Gtk"; 3 | NSPrincipalClass = "GGnomeTheme"; 4 | GSThemeAuthors = ( 5 | "Hans Baier", 6 | "Gregory John Casamento", 7 | ); 8 | GSThemeDetails = "Gtk theme"; 9 | GSThemeIcon = gnome_icon_48.png; 10 | GSThemePreview = gtk+.png; 11 | GSThemeDomain = { 12 | NSScrollViewInterfaceStyle = NSWindows95InterfaceStyle; 13 | NSScrollerInterfaceStyle = NSWindows95InterfaceStyle; 14 | NSMenuInterfaceStyle = NSWindows95InterfaceStyle; 15 | GSSuppressAppIcon = YES; 16 | GSScrollerButtonsOffset = 0.0; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ======== 2 | Gnome Theme 3 | ======== 4 | 5 | Gnome is a theme engine for GNUstep which 6 | uses the current Gtk+-Theme selected in Gnome 7 | for drawing its widgets. 8 | 9 | The theme can be activated via the Info panel 10 | theme manager or in SystemPreferences. 11 | 12 | The theme can also be activated manually, like so: 13 | defaults write NSGlobalDomain GSTheme GnomeTheme 14 | 15 | Installation 16 | ------------ 17 | 18 | as usual, but if you like, then 19 | see the INSTALL file. 20 | 21 | The libraries needed for this are provided by the following debian packages 22 | * libgconf2-dev 23 | * libgtk2.0-dev 24 | * libglib2.0-dev 25 | 26 | These libraries should pull in the needed headers and .so files needed to support the build -------------------------------------------------------------------------------- /NSWindow+Gnome.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "GGPainter.h" 4 | #import "GGnomeTheme.h" 5 | 6 | @implementation GGnomeTheme (NSWindow) 7 | 8 | - (void) reparentWindow: (NSWindow *)window 9 | { 10 | Class cacheWindowClass = NSClassFromString(@"GSCacheW"); 11 | Class iconWindowClass = NSClassFromString(@"NSIconWindow"); 12 | Class menuPanelClass = NSClassFromString(@"NSMenuPanel"); 13 | if([window isKindOfClass: [NSWindow class]] && 14 | [window isKindOfClass: iconWindowClass] == NO && 15 | [window isKindOfClass: cacheWindowClass] == NO && 16 | [window isKindOfClass: menuPanelClass] == NO) 17 | { 18 | NSLog(@"Reparent window to GtkWindow here for NSWindow %@, number %d.",[window title],[window windowNumber]); 19 | } 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /GSBrowserTitleCell+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GGnomeTheme.h" 4 | #include "GGPainter.h" 5 | 6 | @implementation GGnomeTheme (GSBrowserTitleCell) 7 | - (void) drawBrowserHeaderCell: (NSCell *)cell 8 | withFrame: (NSRect)cellFrame 9 | inView: (NSView *)controlView 10 | { 11 | GGPainter *painter = [GGPainter instance]; 12 | 13 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView.GtkButton"]; 14 | 15 | GtkStateType state = GTK_STATE_NORMAL; 16 | 17 | if (![cell isEnabled]) { 18 | state = GTK_STATE_INSENSITIVE; 19 | } 20 | 21 | NSImage *img = [painter paintBox: widget 22 | withPart: "button" 23 | andSize: cellFrame 24 | withClip: NSZeroRect 25 | usingState: GTK_STATE_NORMAL 26 | shadow: GTK_SHADOW_OUT 27 | style: widget->style]; 28 | 29 | 30 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: NO]; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /NSScrollView+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "GGnomeTheme.h" 5 | 6 | @implementation GGnomeTheme (NSScrollView) 7 | - (void) drawScrollViewRect: (NSRect)rect 8 | inView: (NSView *)view 9 | { 10 | NSScrollView *scrollView = (NSScrollView *)view; 11 | NSGraphicsContext *ctxt = GSCurrentContext(); 12 | GSTheme *theme = [GSTheme theme]; 13 | NSColor *color; 14 | NSString *name; 15 | NSBorderType borderType = [scrollView borderType]; 16 | NSRect bounds = [view bounds]; 17 | 18 | name = [theme nameForElement: scrollView]; 19 | if (name == nil) 20 | { 21 | name = @"NSScrollView"; 22 | } 23 | color = [theme colorNamed: name state: GSThemeNormalState]; 24 | if (color == nil) 25 | { 26 | color = [NSColor controlDarkShadowColor]; 27 | } 28 | 29 | switch (borderType) 30 | { 31 | case NSNoBorder: 32 | // NSLog(@"No border"); 33 | break; 34 | 35 | case NSLineBorder: 36 | // NSLog(@"Line"); 37 | [color set]; 38 | NSFrameRect(bounds); 39 | break; 40 | 41 | case NSBezelBorder: 42 | // NSLog(@"Bezel"); 43 | [theme drawGrayBezel: bounds withClip: rect]; 44 | break; 45 | 46 | case NSGrooveBorder: 47 | // NSLog(@"Groove"); 48 | [theme drawGroove: bounds withClip: rect]; 49 | break; 50 | } 51 | 52 | [color set]; 53 | DPSsetlinewidth(ctxt, 1); 54 | } 55 | @end 56 | -------------------------------------------------------------------------------- /GGnomeTheme.h: -------------------------------------------------------------------------------- 1 | #ifndef __CAMAELON_DRAW_FUNCTIONS_H__ 2 | #define __CAMAELON_DRAW_FUNCTIONS_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | @interface GGnomeTheme : GSTheme 9 | { 10 | NSTimer *updateTimer; 11 | id menuRegistry; 12 | } 13 | 14 | - (void) activate; 15 | 16 | //- (NSRect) drawButton: (NSRect)border withClip: (NSRect)clip; 17 | - (void) drawButton: (NSRect)frame 18 | in: (NSCell*)cell 19 | view: (NSView*)view 20 | style: (int)style 21 | state: (GSThemeControlState)state; 22 | 23 | - (void) drawFocusFrame: (NSRect) frame view: (NSView*) view; 24 | 25 | - (NSRect) drawDarkBezel: (NSRect)border withClip: (NSRect)clip isFlipped: (BOOL)flag; 26 | - (NSRect) drawDarkBezel: (NSRect)border withClip: (NSRect)clip; 27 | - (NSRect) drawGrayBezel: (NSRect)border withClip: (NSRect)clip; 28 | - (NSRect) drawGroove: (NSRect)border withClip: (NSRect)clip; 29 | 30 | - (void) drawBorderType: (NSBorderType)aType 31 | frame: (NSRect)frame 32 | view: (NSView*)view; 33 | 34 | - (NSCell*) cellForScrollerKnob: (BOOL)horizontal; 35 | - (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal; 36 | 37 | - (void) drawStepperUpButton: (NSRect) aRect; 38 | - (void) drawStepperHighlightUpButton: (NSRect) aRect; 39 | - (void) drawStepperDownButton: (NSRect) aRect; 40 | - (void) drawStepperHighlightDownButton: (NSRect) aRect; 41 | @end 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /GGScrollStepperCell.m: -------------------------------------------------------------------------------- 1 | #include "GGScrollStepperCell.h" 2 | #include "GGPainter.h" 3 | 4 | @implementation GGScrollStepperCell 5 | - (BOOL) isHorizontal 6 | { 7 | return horizontal; 8 | } 9 | 10 | - (void) setHorizontal: (BOOL) value 11 | { 12 | horizontal = value; 13 | } 14 | 15 | - (GGScrollStepperCell *) newWithKnob: (BOOL)is_knob horizontal: (BOOL) is_horizontal 16 | { 17 | GGScrollStepperCell *cell = [[GGScrollStepperCell alloc] initTextCell: @""]; 18 | [cell setHorizontal: is_horizontal]; 19 | return cell; 20 | } 21 | 22 | 23 | // Private helper method overridden in subclasses 24 | - (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame 25 | inView: (NSView*)controlView 26 | { 27 | GGPainter *painter = [GGPainter instance]; 28 | GtkWidget *widget = [GGPainter getWidget: horizontal ? @"GtkHScrollbar" : @"GtkVScrollbar"]; 29 | NSImage *img; 30 | // GtkRange *range = GTK_RANGE(widget); 31 | 32 | if (widget == nil) 33 | { 34 | [super _drawBorderAndBackgroundWithFrame: cellFrame 35 | inView: controlView]; 36 | return; 37 | } 38 | 39 | img = [painter paintBox: widget 40 | withPart: horizontal ? "hscrollbar" : "vscrollbar" 41 | andSize: cellFrame 42 | withClip: NSZeroRect 43 | usingState: _cell.is_highlighted ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL 44 | shadow: _cell.is_highlighted ? GTK_SHADOW_IN : GTK_SHADOW_OUT 45 | style: widget->style]; 46 | 47 | 48 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: YES]; 49 | } 50 | @end 51 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | ifeq ($(GNUSTEP_MAKEFILES),) 2 | GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) 3 | endif 4 | ifeq ($(GNUSTEP_MAKEFILES),) 5 | $(error You need to set GNUSTEP_MAKEFILES before compiling!) 6 | endif 7 | 8 | 9 | include $(GNUSTEP_MAKEFILES)/common.make 10 | 11 | MYCFLAGS = $(shell pkg-config --cflags glib-2.0 gtk+-2.0 gconf-2.0) 12 | 13 | ADDITIONAL_OBJCFLAGS = -Wno-import -g $(MYCFLAGS) -O0 # -Wall -O2 14 | ADDITIONAL_CFLAGS = $(MYCFLAGS) 15 | 16 | Gtk_BUNDLE_LIBS = $(shell pkg-config --libs glib-2.0 gtk+-2.0 gconf-2.0) 17 | 18 | # 19 | # Main 20 | # 21 | PACKAGE_NAME = Gtk 22 | BUNDLE_NAME = Gtk 23 | BUNDLE_EXTENSION = .theme 24 | VERSION = 1 25 | 26 | Gtk_PRINCIPAL_CLASS = GGnomeTheme 27 | Gtk_INSTALL_DIR = $(GNUSTEP_LIBRARY)/Themes 28 | Gtk_RESOURCE_FILES = \ 29 | Resources/gnome_icon_48.png \ 30 | Resources/ThemeImages/common_outlineUnexpandable.tiff 31 | 32 | # 33 | # Class files 34 | # 35 | Gtk_OBJC_FILES = \ 36 | GSBrowserTitleCell+Gnome.m \ 37 | NSPopUpButtonCell+Gnome.m \ 38 | NSMenuView+Gnome.m \ 39 | NSSliderCell+Gnome.m \ 40 | NSTableHeaderCell+Gnome.m \ 41 | NSTableHeaderView+Gnome.m \ 42 | NSTableView+Gnome.m \ 43 | NSScrollView+Gnome.m \ 44 | NSScroller+Gnome.m \ 45 | NSTabView+Gnome.m \ 46 | NSBrowser+Gnome.m \ 47 | NSWindow+Gnome.m \ 48 | GGScrollKnobCell.m \ 49 | GGScrollStepperCell.m \ 50 | GGPainter.m \ 51 | GGnomeThemeInitialization.m \ 52 | GGnomeTheme.m 53 | 54 | -include GNUmakefile.preamble 55 | 56 | include $(GNUSTEP_MAKEFILES)/bundle.make 57 | 58 | -include GNUmakefile.postamble 59 | -------------------------------------------------------------------------------- /NSMenuView+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GGnomeTheme.h" 4 | #include "GGPainter.h" 5 | 6 | @implementation GGnomeTheme (NSMenuView) 7 | 8 | - (void) drawMenuRect: (NSRect)rect 9 | inView: (NSView *)view 10 | isHorizontal: (BOOL)horizontal 11 | itemCells: (NSArray *)itemCells 12 | { 13 | int i = 0; 14 | int howMany = [itemCells count]; 15 | NSMenuView *menuView = (NSMenuView *)view; 16 | NSRect bounds = [view bounds]; 17 | 18 | GGPainter *painter = [GGPainter instance]; 19 | GtkWidget *widget = [GGPainter getWidget: @"GtkMenu"]; 20 | 21 | NSImage *img = [painter paintBox: widget 22 | withPart: "menu" 23 | andSize: bounds 24 | withClip: NSZeroRect 25 | usingState: GTK_STATE_NORMAL 26 | shadow: GTK_SHADOW_OUT 27 | style: widget->style]; 28 | [painter drawAndReleaseImage: img inFrame: bounds flipped: NO]; 29 | 30 | // Draw the menu cells. 31 | for (i = 0; i < howMany; i++) 32 | { 33 | NSRect aRect; 34 | NSMenuItemCell *aCell; 35 | 36 | aRect = [menuView rectOfItemAtIndex: i]; 37 | aRect.size.width -= 1; 38 | if(!horizontal && i == howMany - 1) 39 | { 40 | aRect.origin.y += 2; 41 | } 42 | 43 | if (NSIntersectsRect(rect, aRect) == YES) 44 | { 45 | aCell = [menuView menuItemCellForItemAtIndex: i]; 46 | [aCell drawWithFrame: aRect inView: menuView]; 47 | } 48 | } 49 | } 50 | 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /NSSliderCell+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GGnomeTheme.h" 4 | #include "GGPainter.h" 5 | 6 | 7 | @implementation GGnomeTheme (NSSliderCell) 8 | - (void) drawBarInside: (NSRect)rect 9 | inCell: (NSCell *)cell 10 | flipped: (BOOL)flipped 11 | { 12 | 13 | [[NSColor windowBackgroundColor] drawSwatchInRect: rect]; 14 | 15 | BOOL horizontal = (rect.size.width > rect.size.height); 16 | 17 | GGPainter *painter = [GGPainter instance]; 18 | GtkWidget *widget = [GGPainter getWidget: horizontal ? @"GtkHScale" : @"GtkVScale"]; 19 | 20 | NSImage *img = [painter paintBox: widget 21 | withPart: "trough" 22 | andSize: rect 23 | withClip: NSZeroRect 24 | usingState: [cell isEnabled] ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE 25 | shadow: GTK_SHADOW_IN 26 | style: widget->style]; 27 | 28 | [painter drawAndReleaseImage: img inFrame: rect flipped: YES]; 29 | } 30 | 31 | - (void) drawKnobInCell: (NSCell *)cell 32 | { 33 | NSSliderCell *sliderCell = (NSSliderCell *)cell; 34 | NSView *controlView = [cell controlView]; 35 | 36 | [sliderCell setBordered: NO]; 37 | [sliderCell setBezeled: NO]; 38 | 39 | NSRect knobRect = [sliderCell knobRectFlipped: [controlView isFlipped]]; 40 | 41 | BOOL horizontal = (knobRect.size.width > knobRect.size.height); 42 | 43 | if (horizontal) 44 | knobRect.origin.y += 1; 45 | else 46 | knobRect.origin.x += 1; 47 | 48 | [sliderCell drawKnob: knobRect]; 49 | } 50 | @end 51 | -------------------------------------------------------------------------------- /NSTableHeaderCell+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GGnomeTheme.h" 3 | #include "GGPainter.h" 4 | 5 | @implementation GGnomeTheme (NSTableHeaderCell) 6 | - (NSRect) tableHeaderCellDrawingRectForBounds: (NSRect)theRect 7 | { 8 | return theRect; 9 | } 10 | 11 | - (void) drawTableHeaderCell: (NSTableHeaderCell *)cell 12 | withFrame: (NSRect)cellFrame 13 | inView: (NSView *)controlView 14 | state: (GSThemeControlState)aState 15 | { 16 | GGPainter *painter = [GGPainter instance]; 17 | 18 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView.GtkButton"]; 19 | 20 | GtkStateType state = GTK_STATE_NORMAL; 21 | 22 | if (![cell isEnabled]) { 23 | state = GTK_STATE_INSENSITIVE; 24 | } 25 | 26 | NSImage *img = [painter paintBox: widget 27 | withPart: "button" 28 | andSize: cellFrame 29 | withClip: NSZeroRect 30 | usingState: (aState == GSThemeHighlightedState) ? 31 | GTK_STATE_ACTIVE : GTK_STATE_NORMAL 32 | shadow: GTK_SHADOW_OUT 33 | style: widget->style]; 34 | 35 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: YES]; 36 | } 37 | 38 | - (void) drawTableCornerView: (NSView *)view withClip: (NSRect)aRect 39 | { 40 | NSRect cellFrame = aRect; 41 | 42 | GGPainter *painter = [GGPainter instance]; 43 | 44 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView.GtkButton"]; 45 | 46 | // GtkStateType state = GTK_STATE_NORMAL; 47 | 48 | NSImage *img = [painter paintBox: widget 49 | withPart: "button" 50 | andSize: cellFrame 51 | withClip: NSZeroRect 52 | usingState: GTK_STATE_NORMAL 53 | shadow: GTK_SHADOW_OUT 54 | style: widget->style]; 55 | 56 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: YES]; 57 | } 58 | @end 59 | -------------------------------------------------------------------------------- /GGScrollKnobCell.m: -------------------------------------------------------------------------------- 1 | #include "GGScrollKnobCell.h" 2 | #include "GGPainter.h" 3 | 4 | @implementation GGScrollKnobCell 5 | - (BOOL) isKnob 6 | { 7 | return knob; 8 | } 9 | 10 | - (void) setKnob: (BOOL) value 11 | { 12 | knob = value; 13 | } 14 | 15 | - (BOOL) isHorizontal 16 | { 17 | return horizontal; 18 | } 19 | 20 | - (void) setHorizontal: (BOOL) value 21 | { 22 | horizontal = value; 23 | } 24 | 25 | 26 | + (GGScrollKnobCell *) newWithKnob: (BOOL)is_knob horizontal: (BOOL) is_horizontal 27 | { 28 | GGScrollKnobCell *cell = [[GGScrollKnobCell alloc] initTextCell: @""]; 29 | [cell setKnob: is_knob]; 30 | [cell setHorizontal: is_horizontal]; 31 | return cell; 32 | } 33 | 34 | 35 | // Private helper method overridden in subclasses 36 | - (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame 37 | inView: (NSView*)controlView 38 | { 39 | GGPainter *painter = [GGPainter instance]; 40 | 41 | GtkWidget *widget = [GGPainter getWidget: horizontal ? @"GtkHScrollbar" : @"GtkVScrollbar"]; 42 | 43 | if (widget == nil) 44 | { 45 | [super _drawBorderAndBackgroundWithFrame: cellFrame 46 | inView: controlView]; 47 | return; 48 | } 49 | 50 | NSImage *img; 51 | 52 | if ([self isKnob]) { 53 | img = [painter paintSlider: widget 54 | withPart: "slider" 55 | andSize: cellFrame 56 | usingState: GTK_STATE_NORMAL 57 | shadow: GTK_SHADOW_OUT 58 | style: widget->style 59 | orientation: horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL]; 60 | 61 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: YES]; 62 | } else { 63 | img = [painter paintBox: widget 64 | withPart: "trough" 65 | andSize: cellFrame 66 | withClip: NSZeroRect 67 | usingState: GTK_STATE_NORMAL 68 | shadow: GTK_SHADOW_OUT 69 | style: widget->style]; 70 | 71 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: YES]; 72 | } 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /GGnomeThemeInitialization.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Parts Copyright (C) 2007-2008 Trolltech ASA. All rights reserved. 4 | ** Objective C parts (C) 2009 Hans Baier 5 | ** 6 | ** Parts of this file are derived from the QGtkStyle project on Trolltech Labs. 7 | ** 8 | ** This file may be used under the terms of the GNU General Public 9 | ** License version 2.0 as published by the Free Software Foundation 10 | ** and appearing in the file LICENSE.GPL included in the packaging of 11 | ** this file. Please review the following information to ensure GNU 12 | ** General Public Licensing requirements will be met: 13 | ** http://www.trolltech.com/products/qt/opensource.html 14 | ** 15 | ** If you are unsure which license is appropriate for your use, please 16 | ** review the following information: 17 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 18 | ** sales department at sales@trolltech.com. 19 | ** 20 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | ** 23 | ****************************************************************************/ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | NSString *getGConfString(NSString *value); 34 | NSString *getThemeName(); 35 | NSString *getDefaultFontName(); 36 | NSString *getMonospaceFontName(); 37 | 38 | void init_gtk_window(); 39 | void setup_gtk_widget(GtkWidget* widget); 40 | void add_widget(GtkWidget *widget);; 41 | void init_gtk_widgets(); 42 | void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* style, void* foo); 43 | NSString *classPath(GtkWidget *widget); 44 | void add_widget_to_map(GtkWidget *widget); 45 | void add_all_sub_widgets(GtkWidget *widget, gpointer v); 46 | void add_widget(GtkWidget *widget); 47 | NSSize scale_size(NSSize orig, gfloat factor); 48 | void replace_icon(NSString *icon_name, NSImage *new_image); 49 | void setup_icons(); 50 | NSColorList *setup_palette(); 51 | void setup_fonts(); 52 | -------------------------------------------------------------------------------- /NSScroller+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "GGPainter.h" 5 | #include "GGnomeTheme.h" 6 | 7 | @implementation GGnomeTheme (NSScroller) 8 | 9 | /* 10 | * draw the scroller 11 | */ 12 | - (void) drawScrollerRect: (NSRect)rect 13 | inView: (NSView *)view 14 | hitPart: (NSScrollerPart)hitPart 15 | isHorizontal: (BOOL) isHorizontal 16 | { 17 | NSScroller *scroller = (NSScroller *)view; 18 | NSRect rectForPartIncrementLine; 19 | NSRect rectForPartDecrementLine; 20 | NSRect rectForPartKnobSlot; 21 | NSRect bounds = [view bounds]; 22 | 23 | rectForPartIncrementLine = [scroller rectForPart: NSScrollerIncrementLine]; 24 | rectForPartDecrementLine = [scroller rectForPart: NSScrollerDecrementLine]; 25 | rectForPartKnobSlot = [scroller rectForPart: NSScrollerKnobSlot]; 26 | 27 | [[[view window] backgroundColor] set]; 28 | NSRectFill (rect); 29 | 30 | ///////////////// BEGIN ADDITION 31 | GGPainter *painter = [GGPainter instance]; 32 | 33 | GtkWidget *widget = [GGPainter getWidget: isHorizontal ? 34 | @"GtkHScrollbar" : @"GtkVScrollbar"]; 35 | 36 | if (widget) 37 | { 38 | NSImage *img; 39 | img = [painter paintBox: widget 40 | withPart: "trough" 41 | andSize: bounds 42 | withClip: NSZeroRect 43 | usingState: GTK_STATE_NORMAL 44 | shadow: GTK_SHADOW_OUT 45 | style: widget->style]; 46 | 47 | [painter drawAndReleaseImage: img inFrame: bounds flipped: YES]; 48 | } 49 | ///////////////// END ADDITION 50 | 51 | if (NSIntersectsRect (rect, rectForPartKnobSlot) == YES) 52 | { 53 | [scroller drawKnobSlot]; 54 | [scroller drawKnob]; 55 | } 56 | 57 | if (NSIntersectsRect (rect, rectForPartDecrementLine) == YES) 58 | { 59 | [scroller drawArrow: NSScrollerDecrementArrow 60 | highlight: hitPart == NSScrollerDecrementLine]; 61 | } 62 | if (NSIntersectsRect (rect, rectForPartIncrementLine) == YES) 63 | { 64 | [scroller drawArrow: NSScrollerIncrementArrow 65 | highlight: hitPart == NSScrollerIncrementLine]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /NSBrowser+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "GGnomeTheme.h" 5 | 6 | @implementation GGnomeTheme (NSBrowser) 7 | 8 | - (void) drawBrowserRect: (NSRect)rect 9 | inView: (NSView *)view 10 | withScrollerRect: (NSRect)scrollerRect 11 | columnSize: (NSSize)columnSize 12 | { 13 | float scrollerWidth = [NSScroller scrollerWidth]; 14 | NSBrowser *browser = (NSBrowser *)view; 15 | NSRect bounds = [view bounds]; 16 | 17 | // Load the first column if not already done 18 | if (![browser isLoaded]) 19 | { 20 | [browser loadColumnZero]; 21 | } 22 | 23 | // Draws titles 24 | if ([browser isTitled]) 25 | { 26 | int i; 27 | 28 | for (i = [browser firstVisibleColumn]; 29 | i <= [browser lastVisibleColumn]; 30 | ++i) 31 | { 32 | NSRect titleRect = [browser titleFrameOfColumn: i]; 33 | if (NSIntersectsRect (titleRect, rect) == YES) 34 | { 35 | [browser drawTitleOfColumn: i 36 | inRect: titleRect]; 37 | } 38 | } 39 | } 40 | 41 | // Draws scroller border 42 | // deleted 43 | 44 | if (![browser separatesColumns]) 45 | { 46 | NSPoint p1,p2; 47 | int i, visibleColumns; 48 | float hScrollerWidth = [browser hasHorizontalScroller] ? 49 | scrollerWidth : 0; 50 | 51 | // Columns borders 52 | [self drawGrayBezel: bounds withClip: rect]; 53 | 54 | [[NSColor blackColor] set]; 55 | visibleColumns = [browser numberOfVisibleColumns]; 56 | for (i = 1; i < visibleColumns; i++) 57 | { 58 | p1 = NSMakePoint((columnSize.width * i) + 2 + (i-1), 59 | columnSize.height + hScrollerWidth + 2); 60 | p2 = NSMakePoint((columnSize.width * i) + 2 + (i-1), 61 | hScrollerWidth + 2); 62 | [NSBezierPath strokeLineFromPoint: p1 toPoint: p2]; 63 | } 64 | 65 | // Horizontal scroller border 66 | if ([browser hasHorizontalScroller]) 67 | { 68 | p1 = NSMakePoint(2, hScrollerWidth + 2); 69 | p2 = NSMakePoint(rect.size.width - 2, hScrollerWidth + 2); 70 | [NSBezierPath strokeLineFromPoint: p1 toPoint: p2]; 71 | } 72 | } 73 | [(GGnomeTheme *)[GSTheme theme] drawDarkBezel: bounds withClip: rect isFlipped: NO]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /NSPopUpButtonCell+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "GGnomeTheme.h" 4 | #include "GGPainter.h" 5 | 6 | // NOTE: Get the alternate images working later. 7 | static NSImage *_pbc_image[5]; 8 | 9 | @interface NSPopUpButtonCell (GnomeTheme) 10 | - (NSImage *) _currentArrowImage; 11 | @end 12 | 13 | @implementation GGnomeTheme (NSPopUpButtonCell) 14 | 15 | - (NSImage *) _currentArrowImageForTheme: (NSPopUpButtonCell *)cell 16 | { 17 | if ([cell pullsDown]) 18 | { 19 | if ([cell arrowPosition] == NSPopUpNoArrow) 20 | { 21 | return nil; 22 | } 23 | 24 | if ([cell preferredEdge] == NSMinYEdge) 25 | { 26 | return _pbc_image[1]; 27 | } 28 | else if ([cell preferredEdge] == NSMaxXEdge) 29 | { 30 | return _pbc_image[2]; 31 | } 32 | else if ([cell preferredEdge] == NSMaxYEdge) 33 | { 34 | return _pbc_image[3]; 35 | } 36 | else if ([cell preferredEdge] == NSMinXEdge) 37 | { 38 | return _pbc_image[4]; 39 | } 40 | else 41 | { 42 | return _pbc_image[1]; 43 | } 44 | } 45 | else 46 | { 47 | return _pbc_image[0]; 48 | } 49 | } 50 | 51 | /* 52 | * This drawing uses the same code that is used to draw cells in the menu. 53 | */ 54 | - (void) drawPopUpButtonCellInteriorWithFrame: (NSRect)cellFrame 55 | withCell: (NSCell *)cell 56 | inView: (NSView *)controlView 57 | { 58 | GGPainter *painter = [GGPainter instance]; 59 | 60 | GtkWidget *button = [GGPainter getWidget: @"GtkComboBox.GtkToggleButton"]; 61 | 62 | NSImage *img = [painter paintBox: button 63 | withPart: "button" 64 | andSize: cellFrame 65 | withClip: NSZeroRect 66 | usingState: GTK_STATE_NORMAL 67 | shadow: GTK_SHADOW_OUT 68 | style: button->style]; 69 | 70 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: YES]; 71 | 72 | GtkWidget *widget = [GGPainter getWidget: @"GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator"]; 73 | 74 | img = [painter paintVLine: widget 75 | withPart: "vseparator" 76 | andSize: cellFrame 77 | usingState: GTK_STATE_NORMAL 78 | style: widget->style]; 79 | 80 | NSSize arrowSize = [[(NSPopUpButtonCell *)cell _currentArrowImage] size]; //ForTheme: (NSPopUpButtonCell *)cell] size]; 81 | 82 | [img drawInRect: NSMakeRect(cellFrame.size.width - 2*arrowSize.width - 2*widget->style->xthickness, cellFrame.size.height - widget->style->ythickness, 3, cellFrame.size.height - 2*widget->style->ythickness) 83 | fromRect: NSMakeRect(0, 0, 3, cellFrame.size.height) 84 | operation: NSCompositeSourceOver 85 | fraction: 1.0]; 86 | 87 | RELEASE(img); 88 | } 89 | @end 90 | -------------------------------------------------------------------------------- /NSTableHeaderView+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GGnomeTheme.h" 3 | #include "GGPainter.h" 4 | 5 | @implementation GGnomeTheme (NSTableHeaderView) 6 | /* 7 | * Overidden Methods 8 | */ 9 | - (void)drawTableHeaderRect: (NSRect)aRect 10 | inView: (NSView *)view 11 | { 12 | NSTableHeaderView *tableHeaderView = (NSTableHeaderView *)view; 13 | NSTableView *tableView = [tableHeaderView tableView]; 14 | NSArray *columns; 15 | int firstColumnToDraw; 16 | int lastColumnToDraw; 17 | NSRect drawingRect; 18 | NSTableColumn *column; 19 | NSTableColumn *highlightedTableColumn; 20 | float width; 21 | int i; 22 | NSCell *cell; 23 | 24 | if (tableView == nil) 25 | return; 26 | 27 | firstColumnToDraw = [tableHeaderView columnAtPoint: NSMakePoint (aRect.origin.x, 28 | aRect.origin.y)]; 29 | if (firstColumnToDraw == -1) 30 | firstColumnToDraw = 0; 31 | 32 | lastColumnToDraw = [tableHeaderView columnAtPoint: NSMakePoint (NSMaxX (aRect), 33 | aRect.origin.y)]; 34 | if (lastColumnToDraw == -1) 35 | lastColumnToDraw = [tableView numberOfColumns] - 1; 36 | 37 | drawingRect = [tableHeaderView headerRectOfColumn: firstColumnToDraw]; 38 | if (![tableHeaderView isFlipped]) 39 | { 40 | drawingRect.origin.y++; 41 | } 42 | //avoid gap: drawingRect.size.height--; 43 | 44 | columns = [tableView tableColumns]; 45 | highlightedTableColumn = [tableView highlightedTableColumn]; 46 | 47 | for (i = firstColumnToDraw; i < lastColumnToDraw; i++) 48 | { 49 | column = [columns objectAtIndex: i]; 50 | width = [column width]; 51 | drawingRect.size.width = width; 52 | cell = [column headerCell]; 53 | if ((column == highlightedTableColumn) 54 | || [tableView isColumnSelected: i]) 55 | { 56 | [cell setHighlighted: YES]; 57 | } 58 | else 59 | { 60 | [cell setHighlighted: NO]; 61 | } 62 | [cell drawWithFrame: drawingRect 63 | inView: tableHeaderView]; 64 | drawingRect.origin.x += width; 65 | } 66 | if (lastColumnToDraw == [tableView numberOfColumns] - 1) 67 | { 68 | column = [columns objectAtIndex: lastColumnToDraw]; 69 | width = [column width] - 1; 70 | drawingRect.size.width = width; 71 | cell = [column headerCell]; 72 | if ((column == highlightedTableColumn) 73 | || [tableView isColumnSelected: lastColumnToDraw]) 74 | { 75 | [cell setHighlighted: YES]; 76 | } 77 | else 78 | { 79 | [cell setHighlighted: NO]; 80 | } 81 | [cell drawWithFrame: drawingRect 82 | inView: tableHeaderView]; 83 | drawingRect.origin.x += width; 84 | } 85 | else 86 | { 87 | column = [columns objectAtIndex: lastColumnToDraw]; 88 | width = [column width]; 89 | drawingRect.size.width = width; 90 | cell = [column headerCell]; 91 | if ((column == highlightedTableColumn) 92 | || [tableView isColumnSelected: lastColumnToDraw]) 93 | { 94 | [cell setHighlighted: YES]; 95 | } 96 | else 97 | { 98 | [cell setHighlighted: NO]; 99 | } 100 | [cell drawWithFrame: drawingRect 101 | inView: tableHeaderView]; 102 | drawingRect.origin.x += width; 103 | } 104 | 105 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView"]; 106 | [[GGPainter fromGdkColor: widget->style->dark[GTK_STATE_NORMAL]] set]; 107 | NSFrameRect(aRect); 108 | } 109 | @end 110 | -------------------------------------------------------------------------------- /GGPainter.h: -------------------------------------------------------------------------------- 1 | #ifndef GGPAINTER_H 2 | #define GGPAINTER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | @interface GGPainter : NSObject 10 | { 11 | @private 12 | GtkWidget *m_window; 13 | BOOL m_alpha; 14 | } 15 | 16 | + (GGPainter *) instance; 17 | 18 | + (NSMutableDictionary *) widgetMap; 19 | + (GtkWidget *) getWidget: (NSString *) widgetName; 20 | + (void) setWidget: (GtkWidget *) widget forKey: (NSString *) key; 21 | 22 | + (NSColor *) fromGdkColor: (GdkColor) gdk_color; 23 | - (NSImage *) fromPixbuf: (GdkPixbuf *) pixbuf; 24 | - (NSImage *) stockIcon: (const gchar *) iconName; 25 | - (NSImage *) stockIcon: (const gchar *) iconName withSize: (GtkIconSize) size; 26 | - (NSImage *) namedIcon: (const gchar *) iconName withSize: (gint) size; 27 | 28 | - (void) drawAndReleaseImage: (NSImage *) image inFrame: (NSRect) cellFrame flipped: (BOOL) flipped; 29 | - (void) drawAndReleaseImage: (NSImage *) image inFrame: (NSRect) cellFrame withClip: (NSRect) clip; 30 | 31 | - (id) init; 32 | 33 | - (GtkStyle *) getWidgetStyle: (GtkWidget *) gtkWidget; 34 | - (GtkStyle *) gtkStyle; 35 | - (GtkStateType) gtkState: (GSThemeControlState) gs_state forCell: (NSCell *) cell; 36 | 37 | - (NSString *) uniqueNameForPart: (NSString *) part 38 | state: (GtkStateType) state 39 | shadow: (GtkShadowType) shadow 40 | size: (NSRect) size 41 | widget: (GtkWidget *) widget; 42 | 43 | 44 | - (NSImage *) paintBox: (GtkWidget *) gtkWidget 45 | withPart: (const gchar *) part 46 | andSize: (const NSRect) rect 47 | withClip: (const NSRect) clip 48 | usingState: (GtkStateType) state 49 | shadow: (GtkShadowType) shadow 50 | style: (GtkStyle *) style; 51 | 52 | - (NSImage *) paintFlatBox: (GtkWidget *) gtkWidget 53 | withPart: (const gchar *) part 54 | andSize: (const NSRect) size 55 | withClip: (const NSRect) clip 56 | usingState: (GtkStateType) state 57 | shadow: (GtkShadowType) shadow 58 | style: (GtkStyle *) style; 59 | 60 | - (NSImage *) paintExtension: (GtkWidget *) gtkWidget 61 | withPart: (const gchar *) part 62 | andSize: (const NSRect) size 63 | withClip: (const NSRect) clip 64 | usingState: (GtkStateType) state 65 | shadow: (GtkShadowType) shadow 66 | position: (GtkPositionType) position 67 | style: (GtkStyle *) style; 68 | 69 | - (NSImage *) paintShadow: (GtkWidget *) gtkWidget 70 | withPart: (const gchar *) part 71 | andSize: (const NSRect) size 72 | usingState: (GtkStateType) state 73 | shadow: (GtkShadowType) shadow 74 | style: (GtkStyle *) style; 75 | 76 | - (NSImage *) paintHLine: (GtkWidget *) gtkWidget 77 | withPart: (const gchar *) part 78 | andSize: (const NSRect) size 79 | usingState: (GtkStateType) state 80 | style: (GtkStyle *) style; 81 | 82 | 83 | - (NSImage *) paintVLine: (GtkWidget *) gtkWidget 84 | withPart: (const gchar *) part 85 | andSize: (const NSRect) size 86 | usingState: (GtkStateType) state 87 | style: (GtkStyle *) style; 88 | 89 | - (NSImage *) paintFocus: (GtkWidget *) gtkWidget 90 | withPart: (const gchar *) part 91 | andSize: (const NSRect) size 92 | usingState: (GtkStateType) state 93 | style: (GtkStyle *) style; 94 | 95 | - (NSImage *) paintOption: (GtkWidget *) gtkWidget 96 | withPart: (const gchar *) part 97 | andSize: (const NSRect) size 98 | usingState: (GtkStateType) state 99 | shadow: (GtkShadowType) shadow 100 | style: (GtkStyle *) style; 101 | 102 | - (NSImage *) drawRadioButton: (NSSize)size 103 | state: (GtkStateType)state 104 | shadow: (GtkShadowType) shadow; 105 | 106 | - (NSImage *) drawCheckButton: (NSSize)size 107 | state: (GtkStateType)state 108 | shadow: (GtkShadowType) shadow; 109 | 110 | - (NSImage *) paintSlider: (GtkWidget *) gtkWidget 111 | withPart: (const gchar *) part 112 | andSize: (const NSRect) size 113 | usingState: (GtkStateType) state 114 | shadow: (GtkShadowType) shadow 115 | style: (GtkStyle *) style 116 | orientation: (GtkOrientation) orientation; 117 | 118 | - (NSImage *) drawVerticalSlider: (NSSize)size 119 | state: (GtkStateType)state 120 | shadow: (GtkShadowType) shadow; 121 | 122 | - (NSImage *) drawHorizontalSlider: (NSSize)size 123 | state: (GtkStateType)state 124 | shadow: (GtkShadowType) shadow; 125 | 126 | - (NSImage *) paintArrow: (GtkWidget *) gtkWidget 127 | withPart: (const gchar *) part 128 | andSize: (const NSRect) size 129 | usingState: (GtkStateType) state 130 | shadow: (GtkShadowType) shadow 131 | style: (GtkStyle *) style 132 | arrowType: (GtkArrowType) type 133 | fill: (BOOL) fill; 134 | 135 | - (NSImage *) paintExpander: (GtkWidget *) gtkWidget 136 | withPart: (const gchar *) part 137 | andSize: (const NSRect) size 138 | usingState: (GtkStateType) state 139 | expanderStyle: (GtkExpanderStyle) style; 140 | 141 | - (NSImage *) drawScrollbarArrow: (NSSize) size 142 | type: (GtkArrowType) type 143 | shadow: (GtkShadowType) shadow; 144 | 145 | - (NSImage *) drawMenuItemArrow: (NSSize) size; 146 | 147 | - (NSImage *) drawPopUpButtonArrow: (NSSize) size; 148 | 149 | - (NSImage *) drawTreeViewExpander: (NSSize) size withExpanderStyle: (GtkExpanderStyle) style; 150 | @end 151 | 152 | #endif // GGPAINTER_H 153 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2017-12-18 Ivan Vucica 2 | 3 | * INSTALL: List some of the Debian dependencies for easier reference. 4 | 5 | 2017-08-04 Fred Kiefer 6 | 7 | * GGnomeThemeInitialization.m: Remove duplicate call to 8 | setup_gtk_widget(). 9 | 10 | 2014-11-29 German Arias 11 | 12 | * NSTabView+Gnome.m: Fix problem where top tabs are drawn as bottom 13 | tabs and vice versa. 14 | 15 | 2014-01-15 Niels Grewe 16 | 17 | * GGnomeTheme.m: Load the DBusMenu bundle and use the remote menu 18 | if available. 19 | * GGnomeThemeInitialization.m: Fix getGConfString() to not raise 20 | an exception if the key is empty. 21 | 22 | 2013-12-25 German Arias 23 | 24 | * GGnomeTheme.m: Add -doesProcessEventsForPopUpMenu to return YES, since 25 | this works now. 26 | 27 | 2012-03-06 Eric Wasylishen 28 | 29 | * GGnomeThemeInitialization.m: 30 | - Remove an image from the NSImage name dictionary by calling 31 | [img setName: nil] rather than [img setName: @"kick_..."];. 32 | - Remove radio/checkbox/slider images before installing new 33 | ones (since -setName: does nothing if an image name 34 | is already in use, so it's important to remove the old image) 35 | 36 | 2012-03-06 Eric Wasylishen 37 | 38 | * GGScrollKnobCell.m: 39 | * NSScroller+Gnome.m: 40 | * GGnomeThemeInitialization.m: 41 | * GGScrollStepperCell.m: 42 | * GGPainter.m: Quick fixes for segfaults from dereferencing 43 | NULL widgets. 44 | 45 | 2012-03-06 Eric Wasylishen 46 | 47 | * GNUmakefile: Use pkg-config. Put linker commands in 48 | Gtk_BUNDLE_LIBS. Remove reference to etoile.make. 49 | 50 | 2012-03-06 00:16-EST Gregory John Casamento 51 | 52 | * NSWindow+Gnome.m: Stub to be called when reparenting 53 | an Xwindow into a GtkWindow for native menus. 54 | 55 | 2012-03-06 00:14-EST Gregory John Casamento 56 | 57 | * GGnomeTheme.h: keep timer 58 | * GGnomeThemeInitialization.m: Initialize gconf so that 59 | theme recieves notifications when theme is changed. 60 | * GGnomeTheme.m: Changes to support theme update when 61 | theme changes. 62 | * GNUmakefile: Update makefile to include new source file. 63 | * GtkInfo.plist: Fix icon issue. 64 | 65 | 2011-06-09 14:04-EDT Gregory John Casamento 66 | 67 | * GGnomeThemeInitialization.h: Added declarations for functions 68 | to get the font based on the default from GNOME. 69 | * GGnomeThemeInitialization.m: Call functions to get the font 70 | from the GNOME config. If it is not one which is available to 71 | GNUstep pick "Liberation Sans" or "Liberation Mono" if those 72 | are unavailable do not change. 73 | 74 | 2011-06-09 11:08-EDT Gregory John Casamento 75 | 76 | * NSTabView+Gnome.m: Move the tabs over a little when drawing them 77 | so that the align better with the notebook widget underneath. 78 | 79 | 2011-06-08 15:25-EDT Gregory John Casamento 80 | 81 | * NSTabView+Gnome.m: Correct notebook widget drawing. 82 | 83 | 2011-06-03 01:11-EDT Gregory John Casamento 84 | 85 | * NSBrowser+Gnome.m: Draw border. 86 | * NSScrollView+Gnome.m: Remove logging. 87 | * NSTabView+Gnome.m: Cleanup 88 | 89 | 2011-06-02 18:08-EDT Gregory John Casamento 90 | 91 | * GGnomeTheme.[hm]: Remove method to draw grayBezel 92 | * NSScrollView+Gnome.m: Add debugging information here for now. 93 | * NSTabView+Gnome.m: Various fixesa and corrections. Correction for 94 | tab view issue. For now use the button method to draw the border. 95 | 96 | 2011-04-10 16:45-EST Gregory John Casamento 97 | 98 | * GGnomeTheme.m: Correct drawing issue with horizontal portion of 99 | menu. 100 | 101 | 2011-03-20 German Arias 102 | 103 | * NSTabView+Gnome.m: No draw tabs if the style doesn't 104 | have these. 105 | 106 | 2011-03-16 11:05-EDT Ivan Vucica 107 | 108 | * GGnomeThemeInitialization.m: Better choice of some FS icons. 109 | * GNUmakefile: Initialize GNUSTEP_MAKEFILES if not initialized. 110 | Patch applied by: greg.casamento@gmail.com 111 | 112 | 2011-01-16 05:01-EST Gregory John Casamento 113 | 114 | * GGnomeTheme.m 115 | * NSMenuView+Gnome.m: Change drawing to avoid issue with 116 | lines being drawn after selection. The solution is something 117 | of a hack. This indicates that there might need to be methods 118 | altering the frame in the theme later on. 119 | 120 | 2011-01-16 03:20-EST Gregory John Casamento 121 | 122 | * GnomeThemeInfo.plist: Added setting to use in-window menus. 123 | 124 | 2010-12-22 17:41-EST Gregory John Casamento 125 | 126 | * GnomeThemeInfo.plist: Supress the app icon in this mode. 127 | 128 | 2010-11-27 Gregory Casamento 129 | 130 | * Changed all previously modified files to be 131 | a category on GGnomeTheme instead of GSTheme to 132 | make certain they are loadable from the theme 133 | manager. 134 | 135 | 2010-11-27 Gregory Casamento 136 | 137 | * NSTableHeaderView+Gnome.m: Use new theme methods. 138 | 139 | 2010-11-26 Gregory Casamento 140 | 141 | * NSTableHeaderCell+Gnome.m: Use new theme methods. 142 | 143 | 2010-11-26 Gregory Casamento 144 | 145 | * NSSliderCell+Gnome.m: Use new theme methods. 146 | 147 | 2010-11-26 Gregory Casamento 148 | 149 | * NSScrollView+Gnome.m: Use new theme methods. 150 | 151 | 2010-11-26 Gregory Casamento 152 | 153 | * NSMenuView+Gnome.m: Use new theme methods. 154 | 155 | 2010-11-26 Gregory Casamento 156 | 157 | * NSBrowser+Gnome.m: Use new theme methods. 158 | 159 | 2010-11-26 Gregory Casamento 160 | 161 | * NSScroller+Gnome.m: Use new theme methods. 162 | 163 | 2010-11-26 Gregory Casamento 164 | 165 | * NSTabView+Gnome.m: Use new theme methods. 166 | 167 | 2010-01-09 Hans Baier 168 | 169 | * Initial import; thus dicontinuing my git repository on 170 | http://github.com/hansfbaier/gnustep-gnome 171 | note that as of now the theme crashes when activated with 172 | SystemPreferences.app, but it works when activated with defaults 173 | Note also, this isn't perfect yet and still has a lot of rough 174 | edges (eg. the Makefile), contributions welcome ;) 175 | -------------------------------------------------------------------------------- /NSTabView+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "GGPainter.h" 5 | #include "GGnomeTheme.h" 6 | 7 | @implementation GGnomeTheme (NSTabView) 8 | // Drawing. 9 | - (void) drawTabViewRect: (NSRect)rect 10 | inView: (NSView *)view 11 | withItems: (NSArray *)items 12 | selectedItem: (NSTabViewItem *)selected 13 | { 14 | NSGraphicsContext *ctxt = GSCurrentContext(); 15 | int howMany = [items count]; 16 | int i; 17 | int previousState = 0; 18 | NSRect bounds = [view bounds]; 19 | NSRect aRect = [view bounds]; 20 | NSColor *backgroundColour = [[view window] backgroundColor]; 21 | BOOL truncate = [(NSTabView *)view allowsTruncatedLabels]; 22 | NSTabViewType type = [(NSTabView *)view tabViewType]; 23 | NSTabView *tabView = (NSTabView *)view; 24 | GGPainter *painter = [GGPainter instance]; 25 | GtkWidget *widget = [GGPainter getWidget: @"GtkNotebook"]; 26 | NSImage *img = nil; 27 | // NSColor *lineColour = [NSColor highlightColor]; 28 | 29 | // Make sure some tab is selected 30 | if (!selected && howMany > 0) 31 | [tabView selectFirstTabViewItem: nil]; 32 | 33 | DPSgsave(ctxt); 34 | 35 | switch (type) 36 | { 37 | default: 38 | case NSTopTabsBezelBorder: 39 | aRect.size.height -= 16; 40 | img = [painter paintBox: widget 41 | withPart: "notebook" 42 | andSize: aRect 43 | withClip: rect 44 | usingState: GTK_STATE_NORMAL 45 | shadow: GTK_SHADOW_OUT 46 | style: widget->style]; 47 | 48 | [painter drawAndReleaseImage: img inFrame: aRect flipped: NO]; 49 | // [self drawButton: aRect withClip: rect]; 50 | break; 51 | 52 | case NSBottomTabsBezelBorder: 53 | aRect.size.height -= 16; 54 | aRect.origin.y += 16; 55 | img = [painter paintBox: widget 56 | withPart: "notebook" 57 | andSize: aRect 58 | withClip: rect 59 | usingState: GTK_STATE_NORMAL 60 | shadow: GTK_SHADOW_OUT 61 | style: widget->style]; 62 | 63 | [painter drawAndReleaseImage: img inFrame: aRect flipped: NO]; 64 | aRect.origin.y -= 16; 65 | // [self drawButton: aRect withClip: rect]; 66 | break; 67 | 68 | case NSLeftTabsBezelBorder: 69 | aRect.size.width -= 18; 70 | aRect.origin.x += 18; 71 | img = [painter paintBox: widget 72 | withPart: "notebook" 73 | andSize: aRect 74 | withClip: rect 75 | usingState: GTK_STATE_NORMAL 76 | shadow: GTK_SHADOW_OUT 77 | style: widget->style]; 78 | 79 | [painter drawAndReleaseImage: img inFrame: aRect flipped: NO]; 80 | // [self drawButton: aRect withClip: rect]; 81 | break; 82 | 83 | case NSRightTabsBezelBorder: 84 | aRect.size.width -= 18; 85 | img = [painter paintBox: widget 86 | withPart: "notebook" 87 | andSize: aRect 88 | withClip: rect 89 | usingState: GTK_STATE_NORMAL 90 | shadow: GTK_SHADOW_OUT 91 | style: widget->style]; 92 | 93 | [painter drawAndReleaseImage: img inFrame: aRect flipped: NO]; 94 | // [self drawButton: aRect withClip: rect]; 95 | break; 96 | 97 | case NSNoTabsBezelBorder: 98 | img = [painter paintBox: widget 99 | withPart: "notebook" 100 | andSize: aRect 101 | withClip: rect 102 | usingState: GTK_STATE_NORMAL 103 | shadow: GTK_SHADOW_OUT 104 | style: widget->style]; 105 | 106 | [painter drawAndReleaseImage: img inFrame: aRect flipped: NO]; 107 | // [self drawButton: aRect withClip: rect]; 108 | break; 109 | 110 | case NSNoTabsLineBorder: 111 | [[NSColor controlDarkShadowColor] set]; 112 | NSFrameRect(aRect); 113 | break; 114 | 115 | case NSNoTabsNoBorder: 116 | break; 117 | } 118 | 119 | NSPoint iP; 120 | GtkPositionType position; 121 | float labelYCorrection; 122 | if (type == NSTopTabsBezelBorder) 123 | { 124 | iP.x = bounds.origin.x; 125 | iP.y = bounds.origin.y; 126 | position = GTK_POS_TOP; // sic! 127 | labelYCorrection = 1.0; 128 | } 129 | else if (type == NSBottomTabsBezelBorder) 130 | { 131 | iP.x = bounds.origin.x; 132 | iP.y = bounds.size.height - 16; 133 | position = GTK_POS_BOTTOM; // sic! 134 | labelYCorrection = -2.0; 135 | } 136 | 137 | if ((type != NSNoTabsBezelBorder) && 138 | (type != NSNoTabsLineBorder) && 139 | (type != NSNoTabsNoBorder)) 140 | { 141 | for (i = 0; i < howMany; i++) 142 | { 143 | NSRect r; 144 | NSRect fRect; 145 | NSTabViewItem *anItem = [items objectAtIndex: i]; 146 | NSTabState itemState = [anItem tabState]; 147 | NSSize s = [anItem sizeOfLabel: truncate]; 148 | 149 | r.origin.x = iP.x + 3; // move it over slightly to align better. 150 | r.origin.y = iP.y; 151 | r.size.width = s.width + 16; 152 | r.size.height = 15; 153 | 154 | fRect = r; 155 | 156 | if (itemState == NSSelectedTab) 157 | { 158 | // Undraw the line that separates the tab from its view. 159 | if (type == NSBottomTabsBezelBorder) 160 | fRect.origin.y += 1; 161 | else if (type == NSTopTabsBezelBorder) 162 | fRect.origin.y -= 1; 163 | 164 | fRect.size.height += 1; 165 | } 166 | [backgroundColour set]; 167 | NSRectFill(fRect); 168 | 169 | if (itemState == NSSelectedTab) 170 | { 171 | img = [painter paintExtension: widget 172 | withPart: "tab" 173 | andSize: r 174 | withClip: NSZeroRect 175 | usingState: GTK_STATE_NORMAL 176 | shadow: GTK_SHADOW_OUT 177 | position: position 178 | style: widget->style]; 179 | iP.x += r.size.width; 180 | } 181 | else if (itemState == NSBackgroundTab) 182 | { 183 | img = [painter paintExtension: widget 184 | withPart: "tab" 185 | andSize: r 186 | withClip: NSZeroRect 187 | usingState: GTK_STATE_ACTIVE 188 | shadow: GTK_SHADOW_OUT 189 | position: position 190 | style: widget->style]; 191 | iP.x += r.size.width - 4; 192 | } 193 | else 194 | NSLog(@"Unhandled case.\n"); 195 | 196 | if (itemState == NSSelectedTab && i == howMany -1) 197 | r.size.width += 4; 198 | 199 | [painter drawAndReleaseImage: img inFrame: r flipped: NO]; 200 | 201 | // Label 202 | [anItem drawLabel: truncate inRect: NSMakeRect(r.origin.x + (r.size.width - s.width)/2, r.origin.y + labelYCorrection, s.width, s.height)]; 203 | 204 | previousState = itemState; 205 | } 206 | } 207 | // FIXME: Missing drawing code for other cases 208 | 209 | DPSgrestore(ctxt); 210 | } 211 | @end 212 | -------------------------------------------------------------------------------- /NSTableView+Gnome.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "GGPainter.h" 5 | #include "GGnomeTheme.h" 6 | 7 | @interface NSTableView (GGnomePrivate) 8 | - (float *) _columnOrigins; 9 | - (void) _willDisplayCell: (NSCell*)cell 10 | forTableColumn: (NSTableColumn *)tb 11 | row: (int)index; 12 | @end 13 | 14 | @implementation GGnomeTheme (NSTableView) 15 | - (void) drawTableViewBackgroundInClipRect: (NSRect)clipRect 16 | inView: (NSView *)view 17 | withBackgroundColor: (NSColor *)backgroundColor 18 | { 19 | GGPainter *painter = [GGPainter instance]; 20 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView"]; 21 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE); 22 | 23 | NSImage *img = [painter paintFlatBox: widget 24 | withPart: "cell_even" 25 | andSize: clipRect 26 | withClip: NSZeroRect 27 | usingState: GTK_STATE_NORMAL 28 | shadow: GTK_SHADOW_NONE 29 | style: widget->style]; 30 | 31 | [painter drawAndReleaseImage: img inFrame: clipRect flipped: NO]; 32 | } 33 | 34 | - (void) drawTableViewGridInClipRect: (NSRect)aRect 35 | inView: (NSView *)view 36 | { 37 | float minX = NSMinX (aRect); 38 | float maxX = NSMaxX (aRect); 39 | float minY = NSMinY (aRect); 40 | float maxY = NSMaxY (aRect); 41 | int i; 42 | float x_pos; 43 | int startingColumn; 44 | int endingColumn; 45 | NSRect bounds = [view bounds]; 46 | NSTableView *tableView = (NSTableView *)view; 47 | NSGraphicsContext *ctxt = GSCurrentContext (); 48 | float position; 49 | int numberOfColumns = [tableView numberOfColumns]; 50 | int startingRow = [tableView rowAtPoint: 51 | NSMakePoint (bounds.origin.x, minY)]; 52 | int endingRow = [tableView rowAtPoint: 53 | NSMakePoint (bounds.origin.x, maxY)]; 54 | 55 | /* Using columnAtPoint:, rowAtPoint: here calls them only twice 56 | 57 | per drawn rect */ 58 | x_pos = minX; 59 | i = 0; 60 | float *columnOrigins = [tableView _columnOrigins]; 61 | NSColor *gridColor = [tableView gridColor]; 62 | int numberOfRows = [tableView numberOfRows]; 63 | int rowHeight = [tableView rowHeight]; 64 | 65 | while ((i < numberOfColumns) && (x_pos > columnOrigins[i])) 66 | { 67 | i++; 68 | } 69 | startingColumn = (i - 1); 70 | 71 | x_pos = maxX; 72 | // Nota Bene: we do *not* reset i 73 | while ((i < numberOfColumns) && (x_pos > columnOrigins[i])) 74 | { 75 | i++; 76 | } 77 | endingColumn = (i - 1); 78 | 79 | if (endingColumn == -1) 80 | endingColumn = numberOfColumns - 1; 81 | /* 82 | int startingColumn = [tableView columnAtPoint: 83 | NSMakePoint (minX, bounds.origin.y)]; 84 | int endingColumn = [tableView columnAtPoint: 85 | NSMakePoint (maxX, bounds.origin.y)]; 86 | */ 87 | 88 | DPSgsave (ctxt); 89 | DPSsetlinewidth (ctxt, 1); 90 | [gridColor set]; 91 | 92 | 93 | GGPainter *painter = [GGPainter instance]; 94 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView"]; 95 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE); 96 | 97 | NSRect image_rect = NSMakeRect(0, 0, maxX - minX, rowHeight); 98 | 99 | NSImage *even_row_image = [painter paintFlatBox: widget 100 | withPart: "cell_even_ruled" 101 | andSize: image_rect 102 | withClip: NSZeroRect 103 | usingState: GTK_STATE_NORMAL 104 | shadow: GTK_SHADOW_NONE 105 | style: widget->style]; 106 | 107 | NSImage *odd_row_image = [painter paintFlatBox: widget 108 | withPart: "cell_odd_ruled" 109 | andSize: image_rect 110 | withClip: NSZeroRect 111 | usingState: GTK_STATE_NORMAL 112 | shadow: GTK_SHADOW_NONE 113 | style: widget->style]; 114 | if (numberOfRows > 0) 115 | { 116 | /* Draw rows */ 117 | if (startingRow == -1) 118 | startingRow = 0; 119 | if (endingRow == -1) 120 | endingRow = numberOfRows - 1; 121 | 122 | position = bounds.origin.y; 123 | position += startingRow * rowHeight; 124 | for (i = startingRow; i <= endingRow + 1; i++) 125 | { 126 | NSRect r = NSMakeRect(minX, position, maxX - minX, rowHeight); 127 | 128 | if (i%2 == 0) 129 | [even_row_image drawInRect: r fromRect: image_rect operation: NSCompositeSourceOver fraction: 1.0]; 130 | else 131 | [odd_row_image drawInRect: r fromRect: image_rect operation: NSCompositeSourceOver fraction: 1.0]; 132 | 133 | position += rowHeight; 134 | } 135 | } 136 | 137 | RELEASE(even_row_image); 138 | RELEASE(odd_row_image); 139 | 140 | gint line_width; 141 | gint8 *dash_list; 142 | float dash_list_float[2]; 143 | GdkGCValues lineGCValues; 144 | NSArray *tableColumns = [tableView tableColumns]; 145 | 146 | gdk_gc_get_values(&widget->style->black_gc[GTK_STATE_NORMAL], &lineGCValues); 147 | // NSColor *lineColor = [GGPainter fromGdkColor: lineGCValues.background]; 148 | 149 | gtk_widget_style_get (widget, 150 | "grid-line-width", &line_width, 151 | "grid-line-pattern", (gchar *)&dash_list, 152 | NULL); 153 | dash_list_float[0] = (float) dash_list[0]; 154 | dash_list_float[1] = (float) dash_list[1]; 155 | 156 | [gridColor set]; 157 | 158 | DPSsetlinewidth(ctxt, (float) line_width); 159 | DPSsetdash(ctxt, dash_list_float, 2, 0); 160 | 161 | if (numberOfColumns > 0) 162 | { 163 | int lastRowPosition = position - rowHeight; 164 | /* Draw vertical lines */ 165 | if (startingColumn == -1) 166 | startingColumn = 0; 167 | if (endingColumn == -1) 168 | endingColumn = numberOfColumns - 1; 169 | 170 | for (i = startingColumn; i <= endingColumn; i++) 171 | { 172 | DPSmoveto (ctxt, columnOrigins[i], minY); 173 | DPSlineto (ctxt, columnOrigins[i], lastRowPosition); 174 | DPSstroke (ctxt); 175 | } 176 | position = columnOrigins[endingColumn]; 177 | position += [[tableColumns objectAtIndex: endingColumn] width]; 178 | /* Last vertical line must moved a pixel to the left */ 179 | if (endingColumn == (numberOfColumns - 1)) 180 | position -= 1; 181 | DPSmoveto (ctxt, position, minY); 182 | DPSlineto (ctxt, position, lastRowPosition); 183 | DPSstroke (ctxt); 184 | } 185 | 186 | DPSgrestore (ctxt); 187 | } 188 | 189 | 190 | - (void) highlightTableViewSelectionInClipRect: (NSRect)clipRect 191 | inView: (NSView *)view 192 | selectingColumns: (BOOL)selectingColumns 193 | { 194 | NSTableView *tableView = (NSTableView *)view; 195 | //int numberOfRows = [tableView numberOfRows]; 196 | int numberOfColumns = [tableView numberOfColumns]; 197 | 198 | if (selectingColumns == NO) 199 | { 200 | int selectedRowsCount; 201 | int row; 202 | int startingRow, endingRow; 203 | 204 | GGPainter *painter = [GGPainter instance]; 205 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView"]; 206 | int numberOfRows = [tableView numberOfRows]; 207 | selectedRowsCount = [[tableView selectedRowIndexes] count]; 208 | 209 | if (selectedRowsCount == 0) 210 | return; 211 | 212 | /* highlight selected rows */ 213 | startingRow = [tableView rowAtPoint: NSMakePoint(0, NSMinY(clipRect))]; 214 | endingRow = [tableView rowAtPoint: NSMakePoint(0, NSMaxY(clipRect))]; 215 | 216 | if (startingRow == -1) 217 | startingRow = 0; 218 | if (endingRow == -1) 219 | endingRow = numberOfRows - 1; 220 | 221 | row = [[tableView selectedRowIndexes] indexGreaterThanOrEqualToIndex: startingRow]; 222 | while ((row != NSNotFound) && (row <= endingRow)) 223 | { 224 | NSRect rowRect = [tableView rectOfRow: row]; 225 | 226 | NSImage *img = [painter paintFocus: widget 227 | withPart: "treeview" 228 | andSize: rowRect 229 | usingState: GTK_STATE_NORMAL 230 | style: widget->style]; 231 | 232 | [painter drawAndReleaseImage: img inFrame: rowRect flipped: YES]; 233 | 234 | //NSRectFill(NSIntersectionRect([tableView rectOfRow: row], clipRect)); 235 | row = [[tableView selectedRowIndexes] indexGreaterThanIndex: row]; 236 | } 237 | } 238 | else // Selecting columns 239 | { 240 | unsigned int selectedColumnsCount; 241 | unsigned int column; 242 | int startingColumn, endingColumn; 243 | 244 | selectedColumnsCount = [[tableView selectedColumnIndexes] count]; 245 | 246 | if (selectedColumnsCount == 0) 247 | return; 248 | 249 | /* highlight selected columns */ 250 | startingColumn = [tableView columnAtPoint: NSMakePoint(NSMinX(clipRect), 0)]; 251 | endingColumn = [tableView columnAtPoint: NSMakePoint(NSMaxX(clipRect), 0)]; 252 | 253 | if (startingColumn == -1) 254 | startingColumn = 0; 255 | if (endingColumn == -1) 256 | endingColumn = numberOfColumns - 1; 257 | 258 | column = [[tableView selectedColumnIndexes] indexGreaterThanOrEqualToIndex: startingColumn]; 259 | while ((column != NSNotFound) && (column <= endingColumn)) 260 | { 261 | NSHighlightRect(NSIntersectionRect([tableView rectOfColumn: column], 262 | clipRect)); 263 | column = [[tableView selectedColumnIndexes] indexGreaterThanIndex: column]; 264 | } 265 | } 266 | } 267 | 268 | - (void) drawTableViewRect: (NSRect)aRect 269 | inView: (NSView *)view 270 | { 271 | int startingRow; 272 | int endingRow; 273 | int i; 274 | NSTableView *tableView = (NSTableView *)view; 275 | int numberOfRows = [tableView numberOfRows]; 276 | int numberOfColumns = [tableView numberOfColumns]; 277 | BOOL drawsGrid = [tableView drawsGrid]; 278 | NSRect bounds = [view bounds]; 279 | 280 | /* Draw background */ 281 | [tableView drawBackgroundInClipRect: aRect]; 282 | 283 | if ((numberOfRows == 0) || (numberOfColumns == 0)) 284 | { 285 | return; 286 | } 287 | 288 | /* Draw grid */ 289 | if (drawsGrid) 290 | { 291 | [tableView drawGridInClipRect: aRect]; 292 | } 293 | 294 | /* Draw selection */ 295 | [tableView highlightSelectionInClipRect: aRect]; 296 | 297 | /* Draw visible cells */ 298 | /* Using rowAtPoint: here calls them only twice per drawn rect */ 299 | startingRow = [tableView rowAtPoint: NSMakePoint (0, NSMinY (aRect))]; 300 | endingRow = [tableView rowAtPoint: NSMakePoint (0, NSMaxY (aRect))]; 301 | 302 | if (startingRow == -1) 303 | { 304 | startingRow = 0; 305 | } 306 | if (endingRow == -1) 307 | { 308 | endingRow = numberOfRows - 1; 309 | } 310 | // NSLog(@"drawRect : %d-%d", startingRow, endingRow); 311 | { 312 | SEL sel = @selector(drawRow:clipRect:); 313 | IMP imp = [tableView methodForSelector: sel]; 314 | 315 | for (i = startingRow; i <= endingRow; i++) 316 | { 317 | (*imp)(tableView, sel, i, aRect); 318 | } 319 | } 320 | 321 | // paint frame around table view like in Gtk+ 322 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView"]; 323 | [[GGPainter fromGdkColor: widget->style->dark[GTK_STATE_NORMAL]] set]; 324 | NSFrameRect(bounds); 325 | } 326 | 327 | - (void) drawTableViewRow: (int)rowIndex 328 | clipRect: (NSRect)clipRect 329 | inView: (NSView *)view 330 | { 331 | NSTableView *tableView = (NSTableView *)view; 332 | int startingColumn; 333 | int endingColumn; 334 | NSTableColumn *tb; 335 | NSRect drawingRect; 336 | NSCell *cell; 337 | int i; 338 | float x_pos; 339 | id dataSource = [tableView dataSource]; 340 | NSArray *tableColumns = [tableView tableColumns]; 341 | // int numberOfRows = [tableView numberOfRows]; 342 | int numberOfColumns = [tableView numberOfColumns]; 343 | float *columnOrigins = [tableView _columnOrigins]; 344 | int editedRow = [tableView editedRow]; 345 | int editedColumn = [tableView editedColumn]; 346 | 347 | if (dataSource == nil) 348 | { 349 | return; 350 | } 351 | 352 | /* Using columnAtPoint: here would make it called twice per row per drawn 353 | rect - so we avoid it and do it natively */ 354 | 355 | /* Determine starting column as fast as possible */ 356 | x_pos = NSMinX (clipRect); 357 | i = 0; 358 | while ((i < numberOfColumns) && (x_pos > columnOrigins[i])) 359 | { 360 | i++; 361 | } 362 | startingColumn = (i - 1); 363 | 364 | if (startingColumn == -1) 365 | startingColumn = 0; 366 | 367 | /* Determine ending column as fast as possible */ 368 | x_pos = NSMaxX (clipRect); 369 | // Nota Bene: we do *not* reset i 370 | while ((i < numberOfColumns) && (x_pos > columnOrigins[i])) 371 | { 372 | i++; 373 | } 374 | endingColumn = (i - 1); 375 | 376 | if (endingColumn == -1) 377 | endingColumn = numberOfColumns - 1; 378 | 379 | /* Draw the row between startingColumn and endingColumn */ 380 | for (i = startingColumn; i <= endingColumn; i++) 381 | { 382 | if (i != editedColumn || rowIndex != editedRow) 383 | { 384 | tb = [tableColumns objectAtIndex: i]; 385 | cell = [tb dataCellForRow: rowIndex]; 386 | [tableView _willDisplayCell: cell 387 | forTableColumn: tb 388 | row: rowIndex]; 389 | [cell setObjectValue: [dataSource tableView: tableView 390 | objectValueForTableColumn: tb 391 | row: rowIndex]]; 392 | drawingRect = [tableView frameOfCellAtColumn: i 393 | row: rowIndex]; 394 | [cell drawWithFrame: drawingRect inView: tableView]; 395 | } 396 | } 397 | } 398 | @end 399 | -------------------------------------------------------------------------------- /GGnomeThemeInitialization.m: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Parts Copyright (C) 2007-2008 Trolltech ASA. All rights reserved. 4 | ** Objective C parts (C) 2009 Hans Baier 5 | ** 6 | ** Parts of this file are derived from the QGtkStyle project on Trolltech Labs. 7 | ** 8 | ** This file may be used under the terms of the GNU General Public 9 | ** License version 2.0 as published by the Free Software Foundation 10 | ** and appearing in the file LICENSE.GPL included in the packaging of 11 | ** this file. Please review the following information to ensure GNU 12 | ** General Public Licensing requirements will be met: 13 | ** http://www.trolltech.com/products/qt/opensource.html 14 | ** 15 | ** If you are unsure which license is appropriate for your use, please 16 | ** review the following information: 17 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 18 | ** sales department at sales@trolltech.com. 19 | ** 20 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | ** 23 | ****************************************************************************/ 24 | 25 | #include "GGnomeThemeInitialization.h" 26 | #include "GGnomeTheme.h" 27 | #include "GGPainter.h" 28 | 29 | BOOL hasRgbaColormap = NO; 30 | 31 | static int displayDepth = -1; 32 | 33 | NSString *getGConfString(NSString *value) 34 | { 35 | NSString *retVal = nil; 36 | 37 | g_type_init(); 38 | GConfClient* client = gconf_client_get_default(); 39 | GError *err = 0; 40 | char *str = gconf_client_get_string(client, [value UTF8String], &err); 41 | if (!err) { 42 | if (NULL != str) 43 | { 44 | retVal = [NSString stringWithUTF8String: str]; 45 | g_free(str); 46 | } 47 | } 48 | g_object_unref(client); 49 | if (err) 50 | g_error_free (err); 51 | 52 | return retVal; 53 | } 54 | 55 | NSString *getThemeName() 56 | { 57 | return getGConfString(@"/desktop/gnome/interface/gtk_theme"); 58 | } 59 | 60 | NSString *getDefaultFontName() 61 | { 62 | return getGConfString(@"/desktop/gnome/interface/font_name"); 63 | } 64 | 65 | NSString *getMonospaceFontName() 66 | { 67 | return getGConfString(@"/desktop/gnome/interface/monospace_font_name"); 68 | } 69 | 70 | typedef int (*x11ErrorHandler)(Display*, XErrorEvent*); 71 | 72 | void init_gtk_window() 73 | { 74 | static NSString *themeName = nil; 75 | 76 | if ( [GGPainter getWidget: @"GtkWindow"] == (GtkWidget *)nil && [themeName length] == 0) 77 | { 78 | NSLog (@"initializing GtkWindow"); 79 | themeName = getThemeName(); 80 | 81 | x11ErrorHandler gs_x_errhandler = XSetErrorHandler(0); 82 | gtk_init (NULL, NULL); 83 | gconf_init(0, NULL, NULL); 84 | GdkScreen *screen; 85 | GdkColormap *cmap; 86 | screen = gdk_screen_get_default(); 87 | cmap = gdk_screen_get_rgba_colormap (screen); 88 | 89 | // Enable this to get cairo performance improvements 90 | // currently disabled due to painting glitches 91 | if (cmap) { 92 | hasRgbaColormap = YES; 93 | gdk_screen_set_default_colormap (screen, cmap); 94 | } 95 | XSetErrorHandler(gs_x_errhandler); 96 | 97 | GtkWidget* gtkWindow = gtk_window_new(GTK_WINDOW_POPUP); 98 | gtk_widget_realize(gtkWindow); 99 | if (displayDepth == -1) 100 | displayDepth = gdk_drawable_get_depth(gtkWindow->window); 101 | 102 | [GGPainter setWidget: gtkWindow forKey: @"GtkWindow"]; 103 | NSLog (@"initializing GtkWindow finished =========="); 104 | } 105 | } 106 | 107 | void setup_gtk_widget(GtkWidget* widget) 108 | { 109 | if (GTK_IS_WIDGET(widget)) { 110 | static GtkWidget* protoLayout = 0; 111 | 112 | if (!protoLayout) { 113 | protoLayout = gtk_fixed_new(); 114 | gtk_container_add((GtkContainer*)[GGPainter getWidget: @"GtkWindow"], protoLayout); 115 | } 116 | 117 | assert(protoLayout); 118 | 119 | gtk_container_add((GtkContainer*)(protoLayout), widget); 120 | gtk_widget_realize(widget); 121 | } 122 | } 123 | 124 | void add_widget(GtkWidget *widget); 125 | 126 | void init_gtk_widgets() 127 | { 128 | if ( [GGPainter getWidget: @"GtkButton"] == (GtkWidget *)nil) { 129 | add_widget(gtk_button_new()); 130 | add_widget(gtk_hbutton_box_new()); 131 | add_widget(gtk_check_button_new()); 132 | add_widget(gtk_radio_button_new(NULL)); 133 | add_widget(gtk_combo_box_new()); 134 | // add_widget(gtk_combo_box_entry_new()); 135 | add_widget(gtk_entry_new()); 136 | add_widget(gtk_frame_new(NULL)); 137 | // add_widget(gtk_expander_new("")); 138 | // add_widget(gtk_statusbar_new()); 139 | add_widget(gtk_hscale_new((GtkAdjustment*)(gtk_adjustment_new(1, 0, 1, 0, 0, 0)))); 140 | add_widget(gtk_hscrollbar_new(NULL)); 141 | add_widget(gtk_progress_bar_new()); 142 | add_widget(gtk_notebook_new()); 143 | add_widget(gtk_spin_button_new((GtkAdjustment*) 144 | (gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3)); 145 | 146 | GtkWidget *gtkTreeView = gtk_tree_view_new(); 147 | gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new()); 148 | gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new()); 149 | gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new()); 150 | add_widget(gtkTreeView); 151 | 152 | GtkWidget *gtkMenuBar = gtk_menu_bar_new(); 153 | 154 | GtkWidget *gtkMenuBarItem = gtk_menu_item_new(); 155 | gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem); 156 | gtk_widget_realize(gtkMenuBarItem); 157 | 158 | // Create menu 159 | GtkWidget *gtkMenu = gtk_menu_new(); 160 | gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu); 161 | gtk_widget_realize(gtkMenu); 162 | 163 | GtkWidget *gtkMenuItem = gtk_menu_item_new(); 164 | gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem); 165 | gtk_widget_realize(gtkMenuItem); 166 | 167 | GtkWidget *gtkCheckMenuItem = gtk_check_menu_item_new(); 168 | gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem); 169 | gtk_widget_realize(gtkCheckMenuItem); 170 | 171 | GtkWidget *gtkMenuSeparator = gtk_separator_menu_item_new(); 172 | gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator); 173 | 174 | add_widget(gtkMenuBar); 175 | add_widget(gtkMenu); 176 | 177 | /* 178 | GtkWidget *toolbar = gtk_toolbar_new(); 179 | gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1); 180 | add_widget(toolbar); 181 | */ 182 | add_widget(gtk_vscale_new((GtkAdjustment*)(gtk_adjustment_new(1, 0, 1, 0, 0, 0)))); 183 | add_widget(gtk_vscrollbar_new(NULL)); 184 | } 185 | NSLog(@"Widget Map initialized: %@", [[GGPainter widgetMap] description]); 186 | } 187 | 188 | void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* style, void* foo) 189 | { 190 | static NSString *oldTheme = @"gs_not_set"; 191 | 192 | init_gtk_widgets(); 193 | 194 | if ( ![oldTheme isEqualToString: getThemeName()] ) { 195 | ASSIGN(oldTheme, getThemeName()); 196 | //TODO care about widget palette stuff here 197 | } 198 | } 199 | 200 | NSString *classPath(GtkWidget *widget) 201 | { 202 | char* class_path; 203 | gtk_widget_path (widget, NULL, &class_path, NULL); 204 | NSString *path = [NSString stringWithUTF8String: class_path]; 205 | 206 | // Remove the prefixes 207 | path = [path stringByReplacingString: @"GtkWindow." withString: @""]; 208 | path = [path stringByReplacingString: @"GtkFixed." withString: @""]; 209 | 210 | return path; 211 | } 212 | 213 | void add_widget_to_map(GtkWidget *widget) 214 | { 215 | if (GTK_IS_WIDGET(widget)) { 216 | gtk_widget_realize(widget); 217 | NSLog(@"registering widget: %@", classPath(widget)); 218 | [GGPainter setWidget: widget forKey: classPath(widget)]; 219 | } 220 | } 221 | 222 | void add_all_sub_widgets(GtkWidget *widget, gpointer v) 223 | { 224 | add_widget_to_map(widget); 225 | if (GTK_CHECK_TYPE ((widget), gtk_container_get_type())) 226 | gtk_container_forall((GtkContainer*)widget, add_all_sub_widgets, NULL); 227 | } 228 | 229 | void add_widget(GtkWidget *widget) 230 | { 231 | if (widget) { 232 | setup_gtk_widget(widget); 233 | add_all_sub_widgets(widget, 0); 234 | g_signal_connect(widget, "style-set", G_CALLBACK(gtkStyleSetCallback), NULL); 235 | } 236 | } 237 | 238 | NSSize scale_size(NSSize orig, gfloat factor) 239 | { 240 | return NSMakeSize(orig.width * factor, orig.height * factor); 241 | } 242 | 243 | void replace_icon(NSString *icon_name, NSImage *new_image) 244 | { 245 | if (new_image) 246 | { 247 | NSImage *img = [NSImage imageNamed: icon_name]; 248 | [img setName: nil]; 249 | [new_image setName: icon_name]; 250 | } 251 | } 252 | 253 | void setup_icons() 254 | { 255 | GGPainter *painter = [GGPainter instance]; 256 | [[painter stockIcon: GTK_STOCK_HOME] setName: @"common_Home"]; 257 | // [[painter namedIcon: "gdu-mount" withSize: 22] setName: @"common_Mount"]; 258 | // [[painter namedIcon: "gdu-unmount" withSize: 22] setName: @"common_Unmount"]; 259 | [[painter stockIcon: GTK_STOCK_OK] setName: @"common_ret"]; 260 | [[painter stockIcon: GTK_STOCK_CLOSE withSize: GTK_ICON_SIZE_MENU] setName: @"common_Close"]; 261 | [[painter stockIcon: GTK_STOCK_CLOSE withSize: GTK_ICON_SIZE_MENU] setName: @"common_CloseH"]; 262 | 263 | [[painter namedIcon: "folder" withSize: 48] setName: @"common_Folder"]; 264 | [[painter namedIcon: "folder_home" withSize: 48] setName: @"common_HomeDirectory"]; 265 | 266 | // radio button theme images 267 | NSSize imgSize = [[NSImage imageNamed: @"NSHighlightedRadioButton"] size]; 268 | 269 | [[NSImage imageNamed: @"common_RadioOn"] setName: nil]; 270 | [[painter drawRadioButton: imgSize state: GTK_STATE_NORMAL shadow: GTK_SHADOW_IN] setName: @"common_RadioOn"]; 271 | 272 | [[NSImage imageNamed: @"common_RadioOff"] setName: nil]; 273 | [[painter drawRadioButton: imgSize state: GTK_STATE_NORMAL shadow: GTK_SHADOW_OUT] setName: @"common_RadioOff"]; 274 | [[painter namedIcon: "unknown" withSize: 48] setName: @"common_Unknown"]; 275 | [[painter namedIcon: "exec" withSize: 48] setName: @"common_UnknownTool"]; 276 | [[painter namedIcon: "computer" withSize: 48] setName: @"common_Root_PC"]; 277 | 278 | // check button theme images 279 | imgSize = [[NSImage imageNamed: @"NSSwitch"] size]; 280 | 281 | [[NSImage imageNamed: @"common_SwitchOn"] setName: nil]; 282 | [[painter drawCheckButton: imgSize state: GTK_STATE_NORMAL shadow: GTK_SHADOW_IN] setName: @"common_SwitchOn"]; 283 | [[NSImage imageNamed: @"common_SwitchOff"] setName: nil]; 284 | [[painter drawCheckButton: imgSize state: GTK_STATE_NORMAL shadow: GTK_SHADOW_OUT] setName: @"common_SwitchOff"]; 285 | 286 | NSString *icon_name = nil; 287 | NSImage *img; 288 | 289 | img = [NSImage imageNamed: @"common_SliderVert"]; 290 | [img setName: nil]; 291 | img = [painter drawHorizontalSlider: [img size] state: GTK_STATE_NORMAL shadow: GTK_SHADOW_OUT]; 292 | [img setName: @"common_SliderHoriz"]; 293 | 294 | img = [NSImage imageNamed: @"common_SliderHoriz"]; 295 | [img setName: nil]; 296 | img = [painter drawVerticalSlider: [img size] state: GTK_STATE_NORMAL shadow: GTK_SHADOW_OUT]; 297 | [img setName: @"common_SliderVert"]; 298 | 299 | gfloat arrow_scaling = 0.91; 300 | icon_name = @"common_ArrowLeft"; 301 | img = [NSImage imageNamed: icon_name]; 302 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_LEFT shadow: GTK_SHADOW_NONE]); 303 | 304 | icon_name = @"common_ArrowLeftH"; 305 | img = [NSImage imageNamed: icon_name]; 306 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_LEFT shadow: GTK_SHADOW_NONE]); 307 | 308 | icon_name = @"common_ArrowRight"; 309 | img = [NSImage imageNamed: icon_name]; 310 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_RIGHT shadow: GTK_SHADOW_NONE]); 311 | 312 | icon_name = @"common_ArrowRightH"; 313 | img = [NSImage imageNamed: icon_name]; 314 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_RIGHT shadow: GTK_SHADOW_NONE]); 315 | 316 | icon_name = @"common_ArrowUp"; 317 | img = [NSImage imageNamed: icon_name]; 318 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_UP shadow: GTK_SHADOW_NONE]); 319 | 320 | icon_name = @"common_ArrowUpH"; 321 | img = [NSImage imageNamed: icon_name]; 322 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_UP shadow: GTK_SHADOW_NONE]); 323 | 324 | icon_name = @"common_ArrowDown"; 325 | img = [NSImage imageNamed: icon_name]; 326 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_DOWN shadow: GTK_SHADOW_NONE]); 327 | 328 | icon_name = @"common_ArrowDownH"; 329 | img = [NSImage imageNamed: icon_name]; 330 | replace_icon(icon_name, [painter drawScrollbarArrow: scale_size([img size], arrow_scaling) type: GTK_ARROW_DOWN shadow: GTK_SHADOW_NONE]); 331 | 332 | icon_name = @"common_Nibble"; 333 | img = [NSImage imageNamed: icon_name]; 334 | replace_icon(icon_name, [painter drawPopUpButtonArrow: [img size]]); 335 | 336 | icon_name = @"common_3DArrowDown"; 337 | img = [NSImage imageNamed: icon_name]; 338 | replace_icon(icon_name, [painter drawPopUpButtonArrow: [img size]]); 339 | 340 | icon_name = @"common_3DArrowRight"; 341 | img = [NSImage imageNamed: icon_name]; 342 | replace_icon(icon_name, [painter drawScrollbarArrow: [img size] type: GTK_ARROW_RIGHT shadow: GTK_SHADOW_NONE]); 343 | 344 | icon_name = @"common_3DArrowRightH"; 345 | img = [NSImage imageNamed: icon_name]; 346 | replace_icon(icon_name, [painter drawScrollbarArrow: [img size] type: GTK_ARROW_RIGHT shadow: GTK_SHADOW_IN]); 347 | 348 | icon_name = @"NSMenuArrow"; 349 | img = [NSImage imageNamed: icon_name]; 350 | replace_icon(icon_name, [painter drawScrollbarArrow: [img size] type: GTK_ARROW_RIGHT shadow: GTK_SHADOW_NONE]); 351 | 352 | icon_name = @"common_outlineCollapsed"; 353 | img = [NSImage imageNamed: icon_name]; 354 | replace_icon(icon_name, [painter drawTreeViewExpander: [img size] withExpanderStyle: GTK_EXPANDER_COLLAPSED]); 355 | 356 | icon_name = @"common_outlineExpanded"; 357 | img = [NSImage imageNamed: icon_name]; 358 | replace_icon(icon_name, [painter drawTreeViewExpander: [img size] withExpanderStyle: GTK_EXPANDER_EXPANDED]); 359 | 360 | icon_name = @"common_outlineExpanded"; 361 | img = [NSImage imageNamed: icon_name]; 362 | replace_icon(icon_name, [painter drawTreeViewExpander: [img size] withExpanderStyle: GTK_EXPANDER_EXPANDED]); 363 | 364 | img = [NSImage imageNamed: @"common_outlineUnexpandable"]; 365 | /* 366 | [img lockFocus]; 367 | [[NSColor colorWithCalibratedWhite: 1.0 alpha: 0.0] set]; 368 | NSRectFill(NSMakeRect(0, 0, [img size].width, [img size].height)); 369 | [img unlockFocus]; 370 | */ 371 | } 372 | 373 | NSColorList *setup_palette() 374 | { 375 | GtkStyle *windowstyle = [GGPainter getWidget: @"GtkWindow"]->style; 376 | 377 | NSColorList *systemcolors = [[NSColorList alloc] initWithName: @"System" 378 | fromFile: nil]; 379 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->bg[GTK_STATE_NORMAL]] forKey: @"controlBackgroundColor"]; 380 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->mid[GTK_STATE_NORMAL]] forKey: @"controlColor"]; 381 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->bg[GTK_STATE_SELECTED]] forKey: @"selectedControlColor"]; 382 | //* 383 | // [systemcolors setColor: [NSColor redColor] forKey: @"controlColor"]; 384 | // [systemcolors setColor: [NSColor greenColor] forKey: @"controlBackgroundColor"]; 385 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->text[GTK_STATE_SELECTED]] forKey: @"selectedControlTextColor"]; 386 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->fg[GTK_STATE_PRELIGHT]] forKey: @"controlHighlightColor"]; 387 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->light[GTK_STATE_PRELIGHT]] forKey: @"controlLightHighlightColor"]; 388 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->mid[GTK_STATE_NORMAL]] forKey: @"controlShadowColor"]; 389 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->dark[GTK_STATE_NORMAL]] forKey: @"controlDarkShadowColor"]; 390 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->text[GTK_STATE_NORMAL]] forKey: @"controlTextColor"]; 391 | //*/ 392 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->text[GTK_STATE_INSENSITIVE]] forKey: @"disabledControlTextColor"]; 393 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->bg[GTK_STATE_NORMAL]] forKey: @"windowBackgroundColor"]; 394 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->fg[GTK_STATE_NORMAL]] forKey: @"windowFrameColor"]; 395 | [systemcolors setColor: [GGPainter fromGdkColor: windowstyle->fg[GTK_STATE_INSENSITIVE]] forKey: @"windowFrameTextColor"]; 396 | 397 | if ([GGPainter getWidget: @"GtkHScrollbar"]) 398 | [systemcolors setColor: [GGPainter fromGdkColor: [GGPainter getWidget: @"GtkHScrollbar"]->style->bg[GTK_STATE_NORMAL]] forKey: @"scrollBarColor"]; 399 | 400 | // Fill in the rest of them... 401 | [systemcolors setColor: [NSColor whiteColor] 402 | forKey: @"textBackgroundColor"]; 403 | [systemcolors setColor: [NSColor blackColor] 404 | forKey: @"textColor"]; 405 | 406 | return systemcolors; 407 | } 408 | 409 | NSFont *fontFromNameAndSize(NSString *nameAndSize) 410 | { 411 | NSString *fontName = nil; 412 | NSString *fontSize = nil; 413 | NSScanner *scanner = [NSScanner scannerWithString: nameAndSize]; 414 | [scanner scanUpToCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] 415 | intoString: &fontName]; 416 | [scanner scanCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] 417 | intoString: NULL]; 418 | [scanner scanUpToCharactersFromSet: [NSCharacterSet whitespaceAndNewlineCharacterSet] 419 | intoString: &fontSize]; 420 | float fSize = [fontSize floatValue] + 3; // not sure why this is needed. GS seems to be rendering fonts smaller than GNOME. 421 | NSFont *font = [NSFont fontWithName: fontName 422 | size: fSize]; 423 | 424 | if(font == nil) 425 | { 426 | if([fontName isEqualToString: @"Sans"]) 427 | { 428 | font = [NSFont fontWithName: @"Liberation Sans" 429 | size: fSize]; 430 | } 431 | if([fontName isEqualToString: @"Monospace"]) 432 | { 433 | font = [NSFont fontWithName: @"Liberation Mono" 434 | size: fSize]; 435 | } 436 | } 437 | 438 | return font; 439 | } 440 | 441 | void setup_fonts() 442 | { 443 | NSString *defaultFontNameAndSize = getDefaultFontName(); 444 | NSString *monoFontNameAndSize = getMonospaceFontName(); 445 | NSFont *defaultFont = fontFromNameAndSize(defaultFontNameAndSize); 446 | if(defaultFont != nil) 447 | { 448 | [NSFont setUserFont: defaultFont]; 449 | } 450 | NSFont *fixedFont = fontFromNameAndSize(monoFontNameAndSize); 451 | if(fixedFont != nil) 452 | { 453 | [NSFont setUserFixedPitchFont:fixedFont]; 454 | } 455 | } 456 | -------------------------------------------------------------------------------- /GGnomeTheme.m: -------------------------------------------------------------------------------- 1 | #include "GGnomeTheme.h" 2 | #include "GGPainter.h" 3 | #include "GGScrollKnobCell.h" 4 | #include "GGScrollStepperCell.h" 5 | #include "GGnomeThemeInitialization.h" 6 | #include 7 | 8 | #include 9 | 10 | static BOOL _added_callback = NO; 11 | static NSImage *_pbc_image[5]; 12 | 13 | void gconf_key_changed_callback(GConfClient *client, 14 | guint cnxn_id, 15 | GConfEntry *entry, 16 | gpointer user_data) 17 | { 18 | // NSLog(@"Changed..."); 19 | [[GSTheme theme] deactivate]; 20 | [[GSTheme theme] activate]; 21 | } 22 | 23 | @interface GGnomeTheme (Private) 24 | - (void) drawStepperButton: (NSRect) aRect withArrowType: (GtkArrowType) arrow_type pressed: (BOOL) pressed; 25 | @end 26 | 27 | /* 28 | * The class used by the DBus menu registry 29 | */ 30 | static Class _menuRegistryClass; 31 | 32 | @implementation GGnomeTheme 33 | - (Class)_findDBusMenuRegistryClass 34 | { 35 | NSString *path; 36 | NSBundle *bundle; 37 | NSArray *paths; 38 | NSUInteger count; 39 | 40 | if (Nil != _menuRegistryClass) 41 | { 42 | return _menuRegistryClass; 43 | } 44 | paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, 45 | NSAllDomainsMask, YES); 46 | count = [paths count]; 47 | while (count-- > 0) 48 | { 49 | path = [paths objectAtIndex: count]; 50 | path = [path stringByAppendingPathComponent: @"Bundles"]; 51 | path = [path stringByAppendingPathComponent: @"DBusMenu"]; 52 | path = [path stringByAppendingPathExtension: @"bundle"]; 53 | bundle = [NSBundle bundleWithPath: path]; 54 | if (bundle != nil) 55 | { 56 | if ((_menuRegistryClass = [bundle principalClass]) != Nil) 57 | { 58 | break; 59 | } 60 | } 61 | } 62 | return _menuRegistryClass; 63 | } 64 | 65 | - (id) initWithBundle: (NSBundle *)bundle 66 | { 67 | if((self = [super initWithBundle: bundle]) != nil) 68 | { 69 | ASSIGN(_pbc_image[0], [NSImage imageNamed: @"common_Nibble"]); 70 | ASSIGN(_pbc_image[1], [NSImage imageNamed: @"common_3DArrowDown"]); 71 | } 72 | menuRegistry = [[self _findDBusMenuRegistryClass] new]; 73 | return self; 74 | } 75 | 76 | - (void) drawButton: (NSRect)frame 77 | in: (NSCell*)cell 78 | view: (NSView*)view 79 | style: (int)style 80 | state: (GSThemeControlState)state 81 | { 82 | GGPainter *painter = [GGPainter instance]; 83 | 84 | GtkWidget *button = [GGPainter getWidget: @"GtkButton"]; 85 | 86 | NSImage *img = [painter paintBox: button 87 | withPart: "button" 88 | andSize: frame 89 | withClip: NSZeroRect 90 | usingState: [painter gtkState: state forCell: cell] 91 | shadow: GTK_SHADOW_OUT 92 | style: button->style]; 93 | 94 | [painter drawAndReleaseImage: img inFrame: frame flipped: YES]; 95 | } 96 | 97 | - (void) drawFocusFrame: (NSRect) frame view: (NSView*) view 98 | { 99 | GGPainter *painter = [GGPainter instance]; 100 | GtkWidget *button = [GGPainter getWidget: @"GtkButton"]; 101 | // NSRect vbounds = [view bounds]; 102 | 103 | GTK_WIDGET_SET_FLAGS(button, GTK_HAS_DEFAULT); 104 | NSImage *img = [painter paintFocus: button 105 | withPart: "button" 106 | andSize: frame 107 | usingState: GTK_STATE_NORMAL 108 | style: button->style]; 109 | 110 | [painter drawAndReleaseImage: img inFrame: frame flipped: YES]; 111 | 112 | GTK_WIDGET_UNSET_FLAGS(button, GTK_HAS_DEFAULT); 113 | } 114 | 115 | 116 | - (NSRect) drawGrayBezel: (NSRect)border withClip: (NSRect)clip 117 | { 118 | /* 119 | GtkWidget *entry = [GGPainter getWidget: @"GtkEntry"]; 120 | GGPainter *painter = [GGPainter instance]; 121 | NSImage *img = [painter paintShadow: entry 122 | withPart: "entry" 123 | andSize: border 124 | usingState: GTK_STATE_NORMAL 125 | shadow: GTK_SHADOW_IN 126 | style: entry->style]; 127 | 128 | [painter drawAndReleaseImage: img inFrame: border flipped: YES]; 129 | return border; 130 | */ 131 | return [self drawDarkBezel: border withClip: clip]; 132 | } 133 | 134 | - (NSRect) drawProgressIndicatorBezel: (NSRect)bounds withClip: (NSRect) rect 135 | { 136 | return [self drawDarkBezel: bounds withClip: rect]; 137 | } 138 | 139 | - (void) drawProgressIndicatorBarDeterminate: (NSRect)bounds; 140 | { 141 | GGPainter *painter = [GGPainter instance]; 142 | GtkWidget *widget = [GGPainter getWidget: @"GtkProgressBar"]; 143 | 144 | NSImage *img = [[GGPainter instance] paintBox: widget 145 | withPart: "bar" 146 | andSize: bounds 147 | withClip: NSZeroRect 148 | usingState: GTK_STATE_PRELIGHT 149 | shadow: GTK_SHADOW_OUT 150 | style: widget->style]; 151 | 152 | [painter drawAndReleaseImage: img inFrame: bounds flipped: YES]; 153 | } 154 | 155 | 156 | 157 | /** Draw a dark bezel border */ 158 | - (NSRect) drawDarkBezel: (NSRect)border withClip: (NSRect)clip isFlipped: (BOOL)flag 159 | { 160 | NSRect r = border; 161 | GGPainter *painter = [GGPainter instance]; 162 | GtkWidget *widget = [GGPainter getWidget: @"GtkFrame"]; 163 | 164 | NSImage *img = [painter paintShadow: widget 165 | withPart: "frame" 166 | andSize: r 167 | usingState: GTK_STATE_NORMAL 168 | shadow: GTK_SHADOW_IN 169 | style: widget->style]; 170 | // [painter drawAndReleaseImage: img inFrame: r withClip: clip]; 171 | [painter drawAndReleaseImage: img inFrame: r flipped: flag]; 172 | return r; 173 | } 174 | 175 | - (NSRect) drawDarkBezel: (NSRect)border withClip: (NSRect)clip 176 | { 177 | return [self drawDarkBezel: border 178 | withClip: clip 179 | isFlipped: YES]; 180 | } 181 | 182 | - (NSRect) drawGroove: (NSRect)border withClip: (NSRect)clip 183 | { 184 | NSRect r = border; 185 | GGPainter *painter = [GGPainter instance]; 186 | GtkWidget *widget = [GGPainter getWidget: @"GtkFrame"]; 187 | 188 | NSImage *img = [painter paintShadow: widget 189 | withPart: "frame" 190 | andSize: r 191 | usingState: GTK_STATE_NORMAL 192 | shadow: GTK_SHADOW_ETCHED_IN 193 | style: widget->style]; 194 | 195 | [painter drawAndReleaseImage: img inFrame: r withClip: clip]; 196 | // [painter drawAndReleaseImage: img inFrame: r flipped: YES]; 197 | return r; 198 | } 199 | 200 | - (void) drawBorderType: (NSBorderType)aType 201 | frame: (NSRect)frame 202 | view: (NSView*)view 203 | { 204 | GGPainter *painter = [GGPainter instance]; 205 | GtkWidget *entry = [GGPainter getWidget: @"GtkEntry"]; 206 | NSImage *img = nil; 207 | 208 | switch (aType) 209 | { 210 | case NSLineBorder: 211 | [[NSColor controlDarkShadowColor] set]; 212 | NSFrameRect(frame); 213 | break; 214 | case NSGrooveBorder: 215 | [self drawGroove: frame withClip: NSZeroRect]; 216 | break; 217 | case NSBezelBorder: 218 | img = [painter paintShadow: entry 219 | withPart: "entry" 220 | andSize: frame 221 | usingState: GTK_STATE_NORMAL 222 | shadow: GTK_SHADOW_IN 223 | style: entry->style]; 224 | 225 | [painter drawAndReleaseImage: img inFrame: frame flipped: YES]; 226 | case NSNoBorder: 227 | default: 228 | break; 229 | } 230 | } 231 | 232 | - (float) defaultScrollerWidth 233 | { 234 | GtkWidget *widget = [GGPainter getWidget: @"GtkHScrollbar"]; 235 | gint slider_width = 16; 236 | gtk_widget_style_get (GTK_WIDGET (widget), "slider-width", &slider_width, NULL); 237 | return (float)slider_width; 238 | } 239 | 240 | - (NSCell*) cellForScrollerKnob: (BOOL)horizontal 241 | { 242 | GGScrollKnobCell *cell; 243 | cell = [GGScrollKnobCell newWithKnob: YES horizontal: horizontal]; 244 | if (cell != nil) 245 | { 246 | [cell setButtonType: NSMomentaryChangeButton]; 247 | if (horizontal) 248 | { 249 | [self setName: GSScrollerHorizontalKnob 250 | forElement: cell 251 | temporary: YES]; 252 | } 253 | else 254 | { 255 | [self setName: GSScrollerVerticalKnob 256 | forElement: cell 257 | temporary: YES]; 258 | } 259 | RELEASE(cell); 260 | } 261 | return cell; 262 | } 263 | 264 | - (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal 265 | { 266 | GGScrollKnobCell *cell; 267 | 268 | cell = [GGScrollKnobCell newWithKnob: NO horizontal: horizontal]; 269 | 270 | if (horizontal) 271 | [self setName: GSScrollerHorizontalSlot forElement: cell temporary: YES]; 272 | else 273 | [self setName: GSScrollerVerticalSlot forElement: cell temporary: YES]; 274 | 275 | RELEASE(cell); 276 | return cell; 277 | } 278 | 279 | - (NSButtonCell*) cellForScrollerArrow: (NSScrollerArrow)arrow 280 | horizontal: (BOOL)horizontal 281 | { 282 | GGScrollStepperCell *cell; 283 | NSString *name; 284 | 285 | cell = [[GGScrollStepperCell alloc] init]; 286 | [cell setHorizontal: horizontal]; 287 | if (horizontal) 288 | { 289 | if (arrow == NSScrollerDecrementArrow) 290 | { 291 | [cell setHighlightsBy: 292 | NSChangeBackgroundCellMask | NSContentsCellMask]; 293 | [cell setImage: [NSImage imageNamed: @"common_ArrowLeft"]]; 294 | [cell setAlternateImage: [NSImage imageNamed: @"common_ArrowLeftH"]]; 295 | [cell setImagePosition: NSImageOnly]; 296 | name = GSScrollerLeftArrow; 297 | } 298 | else 299 | { 300 | [cell setHighlightsBy: 301 | NSChangeBackgroundCellMask | NSContentsCellMask]; 302 | [cell setImage: [NSImage imageNamed: @"common_ArrowRight"]]; 303 | [cell setAlternateImage: [NSImage imageNamed: @"common_ArrowRightH"]]; 304 | [cell setImagePosition: NSImageOnly]; 305 | name = GSScrollerRightArrow; 306 | } 307 | } 308 | else 309 | { 310 | if (arrow == NSScrollerDecrementArrow) 311 | { 312 | [cell setHighlightsBy: 313 | NSChangeBackgroundCellMask | NSContentsCellMask]; 314 | [cell setImage: [NSImage imageNamed: @"common_ArrowUp"]]; 315 | [cell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]]; 316 | [cell setImagePosition: NSImageOnly]; 317 | name = GSScrollerUpArrow; 318 | } 319 | else 320 | { 321 | [cell setHighlightsBy: 322 | NSChangeBackgroundCellMask | NSContentsCellMask]; 323 | [cell setImage: [NSImage imageNamed: @"common_ArrowDown"]]; 324 | [cell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]]; 325 | [cell setImagePosition: NSImageOnly]; 326 | name = GSScrollerDownArrow; 327 | } 328 | } 329 | [self setName: name forElement: cell temporary: YES]; 330 | RELEASE(cell); 331 | return cell; 332 | } 333 | 334 | 335 | - (void) drawStepperCell: (NSCell*)cell 336 | withFrame: (NSRect)cellFrame 337 | inView: (NSView*)controlView 338 | highlightUp: (BOOL)highlightUp 339 | highlightDown: (BOOL)highlightDown 340 | { 341 | NSRect upRect; 342 | NSRect downRect; 343 | NSRect twoButtons; 344 | 345 | upRect = [self stepperUpButtonRectWithFrame: cellFrame]; 346 | downRect = [self stepperDownButtonRectWithFrame: cellFrame]; 347 | 348 | twoButtons = downRect; 349 | twoButtons.origin.y--; 350 | twoButtons.size.width++; 351 | twoButtons.size.height = 2 * upRect.size.height + 1; 352 | 353 | { 354 | GGPainter *painter = [GGPainter instance]; 355 | 356 | GtkWidget *widget = [GGPainter getWidget: @"GtkSpinButton"]; 357 | 358 | GtkStateType state = GTK_STATE_NORMAL; 359 | 360 | if (![cell isEnabled]) { 361 | state = GTK_STATE_INSENSITIVE; 362 | } 363 | 364 | GtkShadowType rc_shadow_type; 365 | gtk_widget_style_get (GTK_WIDGET (widget), "shadow-type", &rc_shadow_type, NULL); 366 | 367 | NSImage *img = [painter paintBox: widget 368 | withPart: "spinbutton" 369 | andSize: twoButtons 370 | withClip: NSZeroRect 371 | usingState: state 372 | shadow: rc_shadow_type 373 | style: widget->style]; 374 | 375 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: NO]; 376 | } 377 | 378 | if (highlightUp) 379 | [self drawStepperHighlightUpButton: upRect]; 380 | else 381 | [self drawStepperUpButton: upRect]; 382 | 383 | if (highlightDown) 384 | [self drawStepperHighlightDownButton: downRect]; 385 | else 386 | [self drawStepperDownButton: downRect]; 387 | 388 | } 389 | 390 | - (void) drawStepperUpButton: (NSRect) aRect 391 | { 392 | [self drawStepperButton: aRect withArrowType: GTK_ARROW_UP pressed: NO]; 393 | } 394 | 395 | - (void) drawStepperDownButton: (NSRect) aRect 396 | { 397 | [self drawStepperButton: aRect withArrowType: GTK_ARROW_DOWN pressed: NO]; 398 | } 399 | 400 | - (void) drawStepperHighlightUpButton: (NSRect) aRect 401 | { 402 | [self drawStepperButton: aRect withArrowType: GTK_ARROW_UP pressed: YES]; 403 | } 404 | 405 | - (void) drawStepperHighlightDownButton: (NSRect) aRect 406 | { 407 | [self drawStepperButton: aRect withArrowType: GTK_ARROW_DOWN pressed: YES]; 408 | } 409 | 410 | 411 | - (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell 412 | withFrame: (NSRect)cellFrame 413 | inView: (NSView *)controlView 414 | state: (GSThemeControlState)state 415 | isHorizontal: (BOOL)isHorizontal 416 | { 417 | GGPainter *painter = [GGPainter instance]; 418 | 419 | if (isHorizontal) 420 | { 421 | NSRect newFrame = cellFrame; 422 | newFrame.size.height -= 2; 423 | cellFrame = [cell drawingRectForBounds: cellFrame]; 424 | // [[cell backgroundColor] set]; 425 | // NSRectFill(cellFrame); 426 | // return; 427 | } 428 | 429 | // Set cell's background color 430 | [[cell backgroundColor] set]; 431 | NSRectFill(cellFrame); 432 | 433 | if (state == GSThemeHighlightedState) 434 | { 435 | // cellFrame.size.height -= 2; 436 | GtkWidget *widget = [GGPainter getWidget: @"GtkMenu.GtkMenuItem"]; 437 | 438 | GtkShadowType selected_shadow_type; 439 | gtk_widget_style_get (widget, 440 | "selected-shadow-type", &selected_shadow_type, 441 | NULL); 442 | 443 | NSImage *img = [painter paintBox: widget 444 | withPart: "menuitem" 445 | andSize: cellFrame 446 | withClip: NSZeroRect 447 | usingState: GTK_STATE_PRELIGHT 448 | shadow: selected_shadow_type 449 | style: widget->style]; 450 | 451 | [painter drawAndReleaseImage: img inFrame: cellFrame flipped: NO]; 452 | } 453 | } 454 | 455 | - (NSImage *) arrowImageForMenuItemCell 456 | { 457 | NSImage *arrow = [NSImage imageNamed: @"NSMenuArrow"]; 458 | return [[GGPainter instance] drawMenuItemArrow: [arrow size]]; 459 | } 460 | 461 | - (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell 462 | state: (GSThemeControlState)state 463 | { 464 | GtkStyle *style = [GGPainter getWidget: @"GtkMenu.GtkMenuItem"]->style; 465 | return [GGPainter fromGdkColor: style->bg[GTK_STATE_NORMAL]]; 466 | } 467 | 468 | - (void) timerCallback: (NSTimer *)timer 469 | { 470 | // NSLog(@"Call gtk mainloop"); 471 | gtk_main_iteration_do(FALSE); 472 | } 473 | 474 | - (void) activate 475 | { 476 | init_gtk_window(); 477 | init_gtk_widgets(); 478 | setup_icons(); 479 | setup_fonts(); 480 | setup_palette(); 481 | 482 | if(_added_callback == NO) 483 | { 484 | /* Get the GconfClient, tell it we want to monitor /apps/metacity/general */ 485 | GConfClient* client = gconf_client_get_default(); 486 | 487 | gconf_client_add_dir(client, 488 | "/desktop/gnome/interface", 489 | GCONF_CLIENT_PRELOAD_NONE, 490 | NULL); 491 | /* Connect the check_button to a callback that can toggle it when the option 492 | * is changed by some outside program. 493 | */ 494 | gconf_client_notify_add(client, 495 | "/desktop/gnome/interface/gtk_theme", 496 | gconf_key_changed_callback, 497 | NULL, 498 | NULL, 499 | NULL); 500 | 501 | _added_callback = YES; 502 | updateTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)0.25 503 | target:self 504 | selector:@selector(timerCallback:) 505 | userInfo:NULL 506 | repeats:YES]; 507 | } 508 | 509 | NSLog (@"Gnome theme initialized"); 510 | [super activate]; 511 | } 512 | 513 | - (NSColorList *) colors 514 | { 515 | return setup_palette(); 516 | } 517 | 518 | - (BOOL) menuShouldShowIcon 519 | { 520 | return NO; 521 | } 522 | 523 | - (BOOL) doesProcessEventsForPopUpMenu 524 | { 525 | return YES; 526 | } 527 | @end 528 | 529 | @implementation GGnomeTheme (Private) 530 | 531 | - (void) drawStepperButton: (NSRect) aRect withArrowType: (GtkArrowType) arrow_type pressed: (BOOL) pressed 532 | { 533 | GGPainter *painter = [GGPainter instance]; 534 | GtkWidget *widget = [GGPainter getWidget: @"GtkSpinButton"]; 535 | 536 | GtkStateType state_type; 537 | GtkShadowType shadow_type; 538 | 539 | if (pressed) 540 | { 541 | state_type = GTK_STATE_ACTIVE; 542 | shadow_type = GTK_SHADOW_IN; 543 | } 544 | else 545 | { 546 | state_type = GTK_STATE_NORMAL; 547 | shadow_type = GTK_SHADOW_OUT; 548 | } 549 | 550 | 551 | NSRect r = aRect; 552 | NSImage *img = [painter paintBox: widget 553 | withPart: (arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down" 554 | andSize: r 555 | withClip: NSZeroRect 556 | usingState: state_type 557 | shadow: shadow_type 558 | style: widget->style]; 559 | 560 | [painter drawAndReleaseImage: img inFrame: r flipped: NO]; 561 | 562 | r = NSInsetRect(aRect, 3.5, 3.5); 563 | 564 | img = [painter paintArrow: widget 565 | withPart: "spinbutton" 566 | andSize: r 567 | usingState: state_type 568 | shadow: shadow_type 569 | style: widget->style 570 | arrowType: arrow_type 571 | fill: YES]; 572 | 573 | [painter drawAndReleaseImage: img inFrame: r flipped: NO]; 574 | } 575 | 576 | - (NSRect) drawColorWellBorder: (NSColorWell*)well 577 | withBounds: (NSRect)bounds 578 | withClip: (NSRect)clipRect 579 | { 580 | NSRect aRect = bounds; 581 | NSRect wellRect; 582 | 583 | if (NSIntersectsRect(aRect, clipRect) == NO) 584 | { 585 | return aRect; 586 | } 587 | 588 | if ([well isBordered]) 589 | { 590 | /* 591 | * Draw border. 592 | */ 593 | GGPainter *painter = [GGPainter instance]; 594 | 595 | GtkWidget *button = [GGPainter getWidget: @"GtkButton"]; 596 | 597 | GtkStateType state = GTK_STATE_NORMAL; 598 | 599 | if (![well isEnabled]) { 600 | state = GTK_STATE_INSENSITIVE; 601 | } 602 | 603 | NSImage *img = [painter paintBox: button 604 | withPart: "button" 605 | andSize: bounds 606 | withClip: NSZeroRect 607 | usingState: state 608 | shadow: GTK_SHADOW_OUT 609 | style: button->style]; 610 | 611 | [painter drawAndReleaseImage: img inFrame: bounds flipped: NO]; 612 | 613 | aRect = NSInsetRect(aRect, 2.0, 2.0); 614 | 615 | /* 616 | * Set an inset rect for the color area 617 | */ 618 | wellRect = NSInsetRect(bounds, 8.0, 8.0); 619 | } 620 | else 621 | { 622 | wellRect = bounds; 623 | } 624 | 625 | aRect = wellRect; 626 | 627 | /* 628 | * OpenStep 4.2 behavior is to omit the inner border for 629 | * non-enabled NSColorWell objects. 630 | */ 631 | if ([well isEnabled]) 632 | { 633 | /* 634 | * Draw inner frame. 635 | */ 636 | [[GSTheme theme] drawGroove: aRect withClip: clipRect]; 637 | aRect = NSInsetRect(aRect, 1.0, 1.0); 638 | } 639 | 640 | return aRect; 641 | } 642 | 643 | - (void)setMenu: (NSMenu*)m forWindow: (NSWindow*)w 644 | { 645 | if (nil != menuRegistry) 646 | { 647 | [menuRegistry setMenu: m forWindow: w]; 648 | } 649 | else 650 | { 651 | [super setMenu: m forWindow: w]; 652 | } 653 | } 654 | 655 | @end 656 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /GGPainter.m: -------------------------------------------------------------------------------- 1 | #include "GGPainter.h" 2 | 3 | // static BOOL usePixmapCache = YES; 4 | 5 | extern BOOL hasRgbaColormap; 6 | 7 | void gdkrect_to_nsrect (GdkRectangle* gdkrect, NSRect* nsrect) 8 | { 9 | nsrect->origin.x = gdkrect->x; // - nsrect->size.height; 10 | nsrect->origin.y = gdkrect->y; 11 | nsrect->size.width = gdkrect->width; 12 | nsrect->size.height = gdkrect->height; 13 | } 14 | 15 | void nsrect_to_gdkrect (NSRect* nsrect, GdkRectangle* gdkrect) 16 | { 17 | gdkrect->x = nsrect->origin.x + gdkrect->height; 18 | gdkrect->y = nsrect->origin.y; 19 | gdkrect->width = nsrect->size.width; 20 | gdkrect->height = nsrect->size.height; 21 | } 22 | 23 | #undef GTK_OBJECT_FLAGS 24 | #define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags) 25 | 26 | #if GS_WORDS_BIGENDIAN 27 | # define GS_RED 3 28 | # define GS_GREEN 2 29 | # define GS_BLUE 1 30 | # define GS_ALPHA 0 31 | #else 32 | # define GS_RED 0 33 | # define GS_GREEN 1 34 | # define GS_BLUE 2 35 | # define GS_ALPHA 3 36 | #endif 37 | 38 | #define GTK_RED 2 39 | #define GTK_GREEN 1 40 | #define GTK_BLUE 0 41 | #define GTK_ALPHA 3 42 | 43 | static inline void reorder_color_bytes(guchar *data, int width, int height, gboolean alpha) { 44 | int i; 45 | for (i = 0; i < width * height * (alpha ? 4 : 3); i += (alpha ? 4 : 3)) { 46 | unsigned char r, g, b; 47 | r = data[i + GTK_RED]; 48 | g = data[i + GTK_GREEN]; 49 | b = data[i + GTK_BLUE]; 50 | data[i + GS_RED] = r; 51 | data[i + GS_GREEN] = g; 52 | data[i + GS_BLUE] = b; 53 | } 54 | } 55 | 56 | static inline GdkPixmap *init_pixmap_and_cairo_for_rect(GtkWidget *m_window, NSRect rect, GtkStyle **style, cairo_t **cr, cairo_surface_t **pixmap_surface) 57 | { 58 | GdkPixmap *pixmap = gdk_pixmap_new(GDK_DRAWABLE(m_window->window), rect.size.width, rect.size.height, -1); 59 | if (!pixmap) 60 | return NULL; 61 | *style = gtk_style_attach (*style, m_window->window); 62 | 63 | *cr = gdk_cairo_create (pixmap); 64 | cairo_set_operator(*cr, CAIRO_OPERATOR_SOURCE); 65 | cairo_set_source_rgba(*cr, 0, 0, 0, 0); 66 | cairo_paint(*cr); 67 | *pixmap_surface= cairo_get_target(*cr); 68 | cairo_surface_flush(*pixmap_surface); 69 | return pixmap; 70 | } 71 | 72 | static inline NSImage *create_ns_image_from_pixmap(BOOL m_alpha, NSRect rect, GdkPixmap *pixmap, cairo_t *cr, cairo_surface_t **pixmap_surface) 73 | { 74 | cairo_surface_t *result_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, rect.size.width, rect.size.height); 75 | cairo_t *cr_result = cairo_create (result_surface); 76 | cairo_set_source_surface(cr_result, pixmap_surface, 0, 0); 77 | cairo_paint(cr_result); 78 | cairo_destroy(cr); 79 | cairo_destroy(cr_result); 80 | 81 | unsigned char *data = cairo_image_surface_get_data (result_surface); 82 | reorder_color_bytes(data, rect.size.width, rect.size.height, m_alpha); 83 | NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] init]; 84 | [bitmap initWithBitmapDataPlanes: (unsigned char **) &data 85 | pixelsWide: rect.size.width 86 | pixelsHigh: rect.size.height 87 | bitsPerSample: 8 88 | samplesPerPixel: (m_alpha ? 4 : 3) 89 | hasAlpha: m_alpha ? YES : NO 90 | isPlanar: NO 91 | colorSpaceName: NSCalibratedRGBColorSpace 92 | bytesPerRow: 0 93 | bitsPerPixel: 0 94 | ]; 95 | NSImage *cache = [[NSImage alloc] init]; 96 | [cache addRepresentation: bitmap]; 97 | 98 | gdk_drawable_unref(pixmap); 99 | 100 | return cache; 101 | } 102 | 103 | @implementation GGPainter 104 | 105 | + (GGPainter *) instance 106 | { 107 | static GGPainter *theInstance = nil; 108 | 109 | // @synchronized(self) 110 | { 111 | if (theInstance == nil) { 112 | theInstance = [[GGPainter alloc] init]; 113 | [theInstance retain]; 114 | } 115 | } 116 | 117 | return theInstance; 118 | } 119 | 120 | + (NSMutableDictionary *) widgetMap 121 | { 122 | static NSMutableDictionary *gtkWidgetMap = nil; 123 | 124 | // @synchronized(self) 125 | { 126 | if (gtkWidgetMap == nil) { 127 | gtkWidgetMap = [NSMutableDictionary dictionaryWithCapacity: 20]; 128 | [gtkWidgetMap retain]; 129 | } 130 | } 131 | 132 | return gtkWidgetMap; 133 | } 134 | 135 | + (GtkWidget *) getWidget: (NSString *) widgetName 136 | { 137 | NSValue *result = [[GGPainter widgetMap] objectForKey: widgetName]; 138 | 139 | if (result != nil) 140 | return [result pointerValue]; 141 | else 142 | return (GtkWidget *)nil; 143 | } 144 | 145 | + (void) setWidget: (GtkWidget *) widget forKey: (NSString *) key 146 | { 147 | [[GGPainter widgetMap] setValue: [NSValue valueWithPointer: widget] forKey: key]; 148 | } 149 | 150 | #define COLOR_COMPONENT(gdkcolor, component) (((float)gdkcolor.component)/(float)65535) 151 | 152 | + (NSColor *) fromGdkColor: (GdkColor) gdk_color 153 | { 154 | return [NSColor colorWithCalibratedRed: COLOR_COMPONENT(gdk_color, red) 155 | green: COLOR_COMPONENT(gdk_color, green) 156 | blue: COLOR_COMPONENT(gdk_color, blue) 157 | alpha: 1.0]; 158 | } 159 | 160 | - (NSImage *) stockIcon: (const gchar *) iconName 161 | { 162 | return [self stockIcon: iconName withSize: GTK_ICON_SIZE_SMALL_TOOLBAR]; 163 | } 164 | 165 | - (NSImage *) stockIcon: (const gchar *) iconName withSize: (GtkIconSize) size 166 | { 167 | GtkStyle *style = [self gtkStyle]; 168 | GtkIconSet* iconSet = gtk_style_lookup_icon_set (style, iconName); 169 | GdkPixbuf* icon = gtk_icon_set_render_icon(iconSet, 170 | style, 171 | GTK_TEXT_DIR_LTR, 172 | GTK_STATE_NORMAL, 173 | size, 174 | NULL, 175 | "button"); 176 | 177 | NSImage *converted = [self fromPixbuf: icon]; 178 | 179 | gdk_pixbuf_unref(icon); 180 | 181 | return converted; 182 | } 183 | 184 | - (NSImage *) namedIcon: (const gchar *) iconName withSize: (gint) size 185 | { 186 | // GtkStyle *style = [self gtkStyle]; 187 | GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); 188 | assert(icon_theme); 189 | GdkPixbuf* icon = gtk_icon_theme_load_icon(icon_theme, iconName, size, 0, NULL); 190 | NSImage *converted = nil; 191 | if(icon) 192 | { 193 | //assert(icon); 194 | converted = [self fromPixbuf: icon]; 195 | gdk_pixbuf_unref(icon); 196 | } 197 | else 198 | { 199 | NSLog(@"Failed to look up theme-based icon for iconName %s, using default.",iconName); 200 | } 201 | 202 | return converted; 203 | } 204 | 205 | - (void) drawAndReleaseImage: (NSImage *) image 206 | inFrame: (NSRect) cellFrame 207 | flipped: (BOOL) flipped 208 | { 209 | if (flipped) { 210 | [NSGraphicsContext saveGraphicsState]; 211 | NSAffineTransform *t = [NSAffineTransform transform]; 212 | 213 | // by scaling Y negatively, we effectively flip the image: 214 | [t scaleXBy:1.0 yBy:-1.0]; 215 | [t concat]; 216 | [image drawInRect: NSMakeRect(cellFrame.origin.x, 217 | -( cellFrame.origin.y + 218 | cellFrame.size.height ), 219 | cellFrame.size.width, 220 | cellFrame.size.height) 221 | fromRect: NSMakeRect(0, 0, cellFrame.size.width, cellFrame.size.height) 222 | operation: NSCompositeSourceOver 223 | fraction: 1.0]; 224 | [NSGraphicsContext restoreGraphicsState]; 225 | } else { 226 | [image drawInRect: cellFrame 227 | fromRect: NSMakeRect(0, 0, cellFrame.size.width, cellFrame.size.height) 228 | operation: NSCompositeSourceOver 229 | fraction: 1.0]; 230 | } 231 | 232 | RELEASE(image); 233 | } 234 | 235 | - (void) drawAndReleaseImage: (NSImage *) image inFrame: (NSRect) cellFrame withClip: (NSRect) clip 236 | { 237 | [NSGraphicsContext saveGraphicsState]; 238 | NSRectClip(clip); 239 | 240 | [self drawAndReleaseImage: image inFrame: cellFrame flipped: NO]; 241 | 242 | [NSGraphicsContext restoreGraphicsState]; 243 | } 244 | 245 | 246 | - (NSImage *) fromPixbuf: (GdkPixbuf *) pixbuf 247 | { 248 | cairo_surface_t *result_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); 249 | cairo_t *cr_result = cairo_create (result_surface); 250 | gdk_cairo_set_source_pixbuf(cr_result, pixbuf, 0, 0); 251 | cairo_paint(cr_result); 252 | cairo_destroy(cr_result); 253 | unsigned char *data = cairo_image_surface_get_data (result_surface); 254 | NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] init]; 255 | 256 | int width = gdk_pixbuf_get_width(pixbuf); 257 | int height = gdk_pixbuf_get_height(pixbuf); 258 | gboolean alpha = gdk_pixbuf_get_has_alpha(pixbuf); 259 | 260 | reorder_color_bytes(data, width, height, alpha); 261 | 262 | [bitmap initWithBitmapDataPlanes: (unsigned char **) &data 263 | pixelsWide: width 264 | pixelsHigh: height 265 | bitsPerSample: 8 266 | samplesPerPixel: (alpha ? 4 : 3) 267 | hasAlpha: alpha ? YES : NO 268 | isPlanar: NO 269 | colorSpaceName: NSCalibratedRGBColorSpace 270 | bytesPerRow: 0 271 | bitsPerPixel: 0 272 | ]; 273 | NSImage *converted = [[NSImage alloc] init]; 274 | [converted addRepresentation: bitmap]; 275 | return converted; 276 | } 277 | 278 | - (id) init 279 | { 280 | if ((self = [super init])) 281 | { 282 | m_alpha = YES; 283 | m_window = GTK_WIDGET([GGPainter getWidget: @"GtkWindow"]); 284 | } 285 | 286 | return self; 287 | } 288 | 289 | - (GtkStateType) gtkState: (GSThemeControlState) gs_state forCell: (NSCell *) cell 290 | { 291 | GtkStateType gtk_state = GTK_STATE_NORMAL; 292 | 293 | if ([cell isEnabled]) { 294 | if (gs_state == GSThemeNormalState) 295 | gtk_state = GTK_STATE_NORMAL; 296 | else if (gs_state == GSThemeHighlightedState) 297 | gtk_state = GTK_STATE_PRELIGHT; 298 | else if (gs_state == GSThemeSelectedState) 299 | gtk_state = GTK_STATE_ACTIVE; 300 | } else 301 | gtk_state = GTK_STATE_INSENSITIVE; 302 | return gtk_state; 303 | } 304 | 305 | - (GtkStyle *) getWidgetStyle: (GtkWidget *) gtkWidget 306 | { 307 | assert(gtkWidget); 308 | GtkStyle* style = gtkWidget->style; 309 | assert(style); 310 | return style; 311 | } 312 | 313 | - (GtkStyle *) gtkStyle 314 | { 315 | return [self getWidgetStyle: [GGPainter getWidget: @"GtkWindow"]]; 316 | } 317 | 318 | - (NSString *) uniqueNameForPart: (NSString *) key 319 | state: (GtkStateType) state 320 | shadow: (GtkShadowType) shadow 321 | size: (NSRect) size 322 | widget: (GtkWidget *) widget 323 | { 324 | // Note the widget arg should ideally use the widget path, though would compromise performance 325 | NSString *tmp = [NSString stringWithFormat: @"%@-%u-%u-%ux%u-%qx", key, state, shadow, 326 | size.size.width, size.size.height, widget]; 327 | return tmp; 328 | } 329 | 330 | 331 | #define PAINT_FUNCTION_BODY(contents) \ 332 | NSRect rect = size; \ 333 | cairo_t *cr; \ 334 | cairo_surface_t **pixmap_surface; \ 335 | GdkPixmap *pixmap = init_pixmap_and_cairo_for_rect(m_window, rect, &style, &cr, &pixmap_surface); \ 336 | \ 337 | contents; \ 338 | \ 339 | return create_ns_image_from_pixmap(m_alpha, rect, pixmap, cr, pixmap_surface); \ 340 | 341 | 342 | - (NSImage *) paintBox: (GtkWidget *) gtkWidget 343 | withPart: (const gchar *) part 344 | andSize: (const NSRect) size 345 | withClip: (const NSRect) clip 346 | usingState: (GtkStateType) state 347 | shadow: (GtkShadowType) shadow 348 | style: (GtkStyle *) style 349 | { 350 | PAINT_FUNCTION_BODY( 351 | GdkRectangle gdk_clip; 352 | nsrect_to_gdkrect((NSRect *)&clip, &gdk_clip); 353 | 354 | gtk_paint_box (style, 355 | pixmap, 356 | state, 357 | shadow, 358 | NSEqualRects(clip, NSZeroRect) ? NULL : &gdk_clip, 359 | gtkWidget, 360 | part, 361 | 0, 0, 362 | rect.size.width, 363 | rect.size.height); 364 | 365 | )// PAINT_FUNCTION_BODY 366 | } 367 | 368 | - (NSImage *) paintFlatBox: (GtkWidget *) gtkWidget 369 | withPart: (const gchar *) part 370 | andSize: (const NSRect) size 371 | withClip: (const NSRect) clip 372 | usingState: (GtkStateType) state 373 | shadow: (GtkShadowType) shadow 374 | style: (GtkStyle *) style 375 | { 376 | PAINT_FUNCTION_BODY( 377 | GdkRectangle gdk_clip; 378 | nsrect_to_gdkrect((NSRect *)&clip, &gdk_clip); 379 | 380 | gtk_paint_flat_box (style, 381 | pixmap, 382 | state, 383 | shadow, 384 | NSEqualRects(clip, NSZeroRect) ? NULL : &gdk_clip, 385 | gtkWidget, 386 | part, 387 | 0, 0, 388 | rect.size.width, 389 | rect.size.height); 390 | ) 391 | } 392 | 393 | - (NSImage *) paintExtension: (GtkWidget *) gtkWidget 394 | withPart: (const gchar *) part 395 | andSize: (const NSRect) size 396 | withClip: (const NSRect) clip 397 | usingState: (GtkStateType) state 398 | shadow: (GtkShadowType) shadow 399 | position: (GtkPositionType) position 400 | style: (GtkStyle *) style 401 | { 402 | PAINT_FUNCTION_BODY( 403 | GdkRectangle gdk_clip; 404 | nsrect_to_gdkrect((NSRect *)&clip, &gdk_clip); 405 | 406 | gtk_paint_extension (style, 407 | pixmap, 408 | state, 409 | shadow, 410 | NSEqualRects(clip, NSZeroRect) ? NULL : &gdk_clip, 411 | gtkWidget, 412 | (gchar *)part, 413 | 0, 0, 414 | rect.size.width, 415 | rect.size.height, 416 | position); 417 | 418 | )// PAINT_FUNCTION_BODY 419 | } 420 | 421 | - (NSImage *) paintShadow: (GtkWidget *) gtkWidget 422 | withPart: (const gchar *) part 423 | andSize: (const NSRect) size 424 | usingState: (GtkStateType) state 425 | shadow: (GtkShadowType) shadow 426 | style: (GtkStyle *) style 427 | { 428 | PAINT_FUNCTION_BODY(gtk_paint_shadow (style, 429 | pixmap, 430 | state, 431 | shadow, 432 | NULL, 433 | gtkWidget, 434 | part, 435 | 0, 0, 436 | rect.size.width, 437 | rect.size.height)) 438 | } 439 | 440 | - (NSImage *) paintHLine: (GtkWidget *) gtkWidget 441 | withPart: (const gchar *) part 442 | andSize: (const NSRect) size 443 | usingState: (GtkStateType) state 444 | style: (GtkStyle *) style 445 | { 446 | PAINT_FUNCTION_BODY(gtk_paint_hline (style, 447 | pixmap, 448 | state, 449 | NULL, 450 | gtkWidget, 451 | part, 452 | 0, 453 | rect.size.width, 454 | 0)) 455 | } 456 | 457 | - (NSImage *) paintVLine: (GtkWidget *) gtkWidget 458 | withPart: (const gchar *) part 459 | andSize: (const NSRect) size 460 | usingState: (GtkStateType) state 461 | style: (GtkStyle *) style 462 | { 463 | PAINT_FUNCTION_BODY(gtk_paint_vline (style, 464 | pixmap, 465 | state, 466 | NULL, 467 | gtkWidget, 468 | part, 469 | 0, 470 | rect.size.height, 471 | 0)) 472 | } 473 | 474 | 475 | - (NSImage *) paintFocus: (GtkWidget *) gtkWidget 476 | withPart: (const gchar *) part 477 | andSize: (const NSRect) size 478 | usingState: (GtkStateType) state 479 | style: (GtkStyle *) style 480 | { 481 | PAINT_FUNCTION_BODY(gtk_paint_focus (style, 482 | pixmap, 483 | state, 484 | NULL, 485 | gtkWidget, 486 | part, 487 | 0, 0, 488 | rect.size.width, 489 | rect.size.height)) 490 | } 491 | 492 | - (NSImage *) paintOption: (GtkWidget *) gtkWidget 493 | withPart: (const gchar *) part 494 | andSize: (const NSRect) size 495 | usingState: (GtkStateType) state 496 | shadow: (GtkShadowType) shadow 497 | style: (GtkStyle *) style 498 | { 499 | PAINT_FUNCTION_BODY(gtk_paint_option (style, 500 | pixmap, 501 | state, 502 | shadow, 503 | NULL, 504 | gtkWidget, 505 | part, 506 | 0, 0, 507 | rect.size.width, 508 | rect.size.height)) 509 | } 510 | 511 | - (NSImage *) drawRadioButton: (NSSize)size 512 | state: (GtkStateType)state 513 | shadow: (GtkShadowType) shadow 514 | { 515 | GGPainter *painter = [GGPainter instance]; 516 | GtkWidget *button = [GGPainter getWidget: @"GtkRadioButton"]; 517 | // GtkStyle *gtk_style = [painter gtkStyle]; 518 | 519 | NSImage *img = [painter paintOption: button 520 | withPart: "button" 521 | andSize: NSMakeRect(0, 0, size.height, size.width) 522 | usingState: state 523 | shadow: shadow 524 | style: button->style]; 525 | 526 | return img; 527 | } 528 | 529 | - (NSImage *) paintCheck: (GtkWidget *) gtkWidget 530 | withPart: (const gchar *) part 531 | andSize: (const NSRect) size 532 | usingState: (GtkStateType) state 533 | shadow: (GtkShadowType) shadow 534 | style: (GtkStyle *) style 535 | { 536 | PAINT_FUNCTION_BODY(gtk_paint_check (style, 537 | pixmap, 538 | state, 539 | shadow, 540 | NULL, 541 | gtkWidget, 542 | part, 543 | 0, 0, 544 | rect.size.width, 545 | rect.size.height)) 546 | } 547 | 548 | - (NSImage *) drawCheckButton: (NSSize)size 549 | state: (GtkStateType)state 550 | shadow: (GtkShadowType) shadow 551 | { 552 | GGPainter *painter = [GGPainter instance]; 553 | GtkWidget *button = [GGPainter getWidget: @"GtkCheckButton"]; 554 | // GtkStyle *gtk_style = [painter gtkStyle]; 555 | 556 | 557 | NSImage *img = [painter paintCheck: button 558 | withPart: "checkbutton" 559 | andSize: NSMakeRect(0, 0, size.height, size.width) 560 | usingState: state 561 | shadow: shadow 562 | style: button->style]; 563 | 564 | return img; 565 | } 566 | 567 | - (NSImage *) paintSlider: (GtkWidget *) gtkWidget 568 | withPart: (const gchar *) part 569 | andSize: (const NSRect) size 570 | usingState: (GtkStateType) state 571 | shadow: (GtkShadowType) shadow 572 | style: (GtkStyle *) style 573 | orientation: (GtkOrientation) orientation 574 | { 575 | PAINT_FUNCTION_BODY(gtk_paint_slider (style, 576 | pixmap, 577 | state, 578 | shadow, 579 | NULL, 580 | gtkWidget, 581 | part, 582 | 0, 0, 583 | rect.size.width, 584 | rect.size.height, 585 | orientation)) 586 | } 587 | 588 | 589 | 590 | - (NSImage *) drawVerticalSlider: (NSSize)size 591 | state: (GtkStateType)state 592 | shadow: (GtkShadowType) shadow 593 | { 594 | GGPainter *painter = [GGPainter instance]; 595 | GtkWidget *widget = [GGPainter getWidget: @"GtkVScale"]; 596 | // GtkStyle *gtk_style = [painter gtkStyle]; 597 | 598 | 599 | NSImage *img = [painter paintSlider: widget 600 | withPart: "vscale" 601 | andSize: NSMakeRect(0, 0, size.height, size.width) 602 | usingState: state 603 | shadow: shadow 604 | style: widget->style 605 | orientation: GTK_ORIENTATION_VERTICAL]; 606 | 607 | return img; 608 | } 609 | 610 | - (NSImage *) drawHorizontalSlider: (NSSize)size 611 | state: (GtkStateType)state 612 | shadow: (GtkShadowType) shadow 613 | { 614 | GGPainter *painter = [GGPainter instance]; 615 | 616 | GtkWidget *widget = [GGPainter getWidget: @"GtkHScale"]; 617 | 618 | NSImage *img = [painter paintSlider: widget 619 | withPart: "hscale" 620 | andSize: NSMakeRect(0, 0, size.height, size.width) 621 | usingState: state 622 | shadow: shadow 623 | style: widget->style 624 | orientation: GTK_ORIENTATION_HORIZONTAL]; 625 | 626 | return img; 627 | } 628 | 629 | - (NSImage *) paintArrow: (GtkWidget *) gtkWidget 630 | withPart: (const gchar *) part 631 | andSize: (const NSRect) size 632 | usingState: (GtkStateType) state 633 | shadow: (GtkShadowType) shadow 634 | style: (GtkStyle *) style 635 | arrowType: (GtkArrowType) type 636 | fill: (BOOL) fill 637 | { 638 | PAINT_FUNCTION_BODY(gtk_paint_arrow (style, 639 | pixmap, 640 | state, 641 | shadow, 642 | NULL, 643 | gtkWidget, 644 | part, 645 | type, 646 | fill, 647 | 0, 0, 648 | rect.size.width, 649 | rect.size.height)) 650 | } 651 | 652 | - (NSImage *) paintExpander: (GtkWidget *) gtkWidget 653 | withPart: (const gchar *) part 654 | andSize: (const NSRect) size 655 | usingState: (GtkStateType) state 656 | expanderStyle: (GtkExpanderStyle) expanderStyle 657 | { 658 | GtkStyle *style = gtkWidget->style; 659 | PAINT_FUNCTION_BODY(gtk_paint_expander ( style, 660 | pixmap, 661 | state, 662 | NULL, 663 | gtkWidget, 664 | part, 665 | size.origin.x + size.size.width / 2, 666 | size.origin.y + size.size.height / 2, 667 | expanderStyle)) 668 | } 669 | 670 | 671 | 672 | - (NSImage *) drawScrollbarArrow: (NSSize) size 673 | type: (GtkArrowType) type 674 | shadow: (GtkShadowType) shadow 675 | { 676 | GGPainter *painter = [GGPainter instance]; 677 | 678 | BOOL horizontal = (type != GTK_ARROW_UP || GTK_ARROW_DOWN); 679 | 680 | GtkWidget *widget = [GGPainter getWidget: horizontal ? @"GtkHScrollbar" : @"GtkVScrollbar"]; 681 | 682 | if (widget == NULL) 683 | return nil; 684 | 685 | NSImage *arrow = [painter paintArrow: widget 686 | withPart: horizontal ? "hscrollbar" : "vscrollbar" 687 | andSize: NSMakeRect(0, 0, size.height, size.width) 688 | usingState: GTK_STATE_NORMAL 689 | shadow: shadow 690 | style: widget->style 691 | arrowType: type 692 | fill: YES]; 693 | 694 | return arrow; 695 | } 696 | 697 | - (NSImage *) drawMenuItemArrow: (NSSize) size 698 | { 699 | GGPainter *painter = [GGPainter instance]; 700 | 701 | GtkWidget *widget = [GGPainter getWidget: @"GtkMenu.GtkMenuItem"]; 702 | 703 | if (widget == NULL) 704 | return nil; 705 | 706 | NSImage *arrow = [painter paintArrow: widget 707 | withPart: "menuitem" 708 | andSize: NSMakeRect(0, 0, size.height, size.width) 709 | usingState: GTK_STATE_NORMAL 710 | shadow: GTK_SHADOW_OUT 711 | style: widget->style 712 | arrowType: GTK_ARROW_RIGHT 713 | fill: YES]; 714 | 715 | return arrow; 716 | } 717 | 718 | - (NSImage *) drawPopUpButtonArrow: (NSSize) size 719 | { 720 | GGPainter *painter = [GGPainter instance]; 721 | 722 | GtkWidget *widget = [GGPainter getWidget: @"GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"]; 723 | 724 | if (widget == NULL) 725 | return nil; 726 | 727 | NSImage *arrow = [painter paintArrow: widget 728 | withPart: "arrow" 729 | andSize: NSMakeRect(0, 0, size.height, size.width) 730 | usingState: GTK_STATE_NORMAL 731 | shadow: GTK_SHADOW_NONE 732 | style: widget->style 733 | arrowType: GTK_ARROW_DOWN 734 | fill: YES]; 735 | 736 | return arrow; 737 | } 738 | 739 | - (NSImage *) drawTreeViewExpander: (NSSize) size withExpanderStyle: (GtkExpanderStyle) style 740 | { 741 | GGPainter *painter = [GGPainter instance]; 742 | 743 | GtkWidget *widget = [GGPainter getWidget: @"GtkTreeView"]; 744 | 745 | if (widget == NULL) 746 | return nil; 747 | 748 | return [painter paintExpander: widget 749 | withPart: "treeview" 750 | andSize: NSMakeRect(0, widget->style->ythickness, size.width, size.height) 751 | usingState: GTK_STATE_NORMAL 752 | expanderStyle: style]; 753 | } 754 | 755 | @end 756 | --------------------------------------------------------------------------------