head	1.17;
access;
symbols
	core-8-5-9:1.15
	core-8-5-8:1.15
	macosx-cocoa-merge:1.16
	macosx-cocoa-premerge:1.15
	macosx-carbon-freeze:1.15
	core-8-5-7:1.15
	core-8-5-6:1.15
	core-8-6-b1:1.15
	core-8-6-a3:1.15
	core-8-5-5:1.15
	core-8-6-a2:1.15
	core-8-5-4:1.15
	core-8-5-3:1.15
	core-8-6-a1:1.15
	core-8-4-19:1.2.2.11
	core-8-5-branch:1.15.0.2
	core-8-5-2:1.15
	core-8-4-18:1.2.2.11
	core-8-5-1:1.15
	core-8-4-17:1.2.2.11
	core-8-5-0:1.15
	core-8-5-b3:1.14
	core-8-5-b2:1.13
	core-8-4-16:1.2.2.10
	core-8-5-b1:1.13
	core-stablilizer-merge:1.13
	core-stabilizer-branch:1.8.0.2
	core-stabilizer-merge:1.15
	core-8-4-15:1.2.2.5
	core-8-5-a6:1.8
	core-8-5-a5:1.6
	core-8-4-14:1.2.2.4
	core-8-5-a4:1.4
	core-8-4-13:1.2.2.2
	core-8-4-12:1.2.2.1
	core-8-4-11:1.2.2.1
	core-8-5-a3:1.3
	core-8-4-10:1.2.2.1
	core-8-4-9-branch:1.2.2.1.0.2
	core-8-5-a2:1.3
	core-8-4-9:1.2.2.1
	core-8-4-8:1.2.2.1
	core-8-4-7:1.2.2.1
	core-8-5-a1:1.3
	core-8-4-6:1.2.2.1
	core-8-4-5:1.2
	mistachkin-dev-branch:1.3.0.2
	core-8-4-4:1.2
	core-8-4-3:1.2
	core-8-4-branch:1.2.0.2
	core-8-4-2:1.2
	core-8-4-1:1.2
	core-8-4-0:1.2
	macosx-8-4-merge-2002-08-31-trunk:1.2
	macosx-8-4-premerge-2002-08-31-branch:1.1.2.2
	macosx-8-4-merge-2002-08-30-branch:1.1.2.1
	macosx-8-4-merge-2002-08-20-branch:1.1.2.1
	macosx-premerge-6-9-02:1.1.2.1
	macosx-8-4-branch:1.1.0.2;
locks; strict;
comment	@ * @;


1.17
date	2009.07.06.20.29.21;	author dkf;	state Exp;
branches;
next	1.16;

1.16
date	2009.06.29.14.35.01;	author das;	state Exp;
branches;
next	1.15;

1.15
date	2007.12.13.15.27.08;	author dgp;	state Exp;
branches;
next	1.14;

1.14
date	2007.11.01.11.36.22;	author das;	state Exp;
branches;
next	1.13;

1.13
date	2007.07.02.13.05.14;	author das;	state Exp;
branches;
next	1.12;

1.12
date	2007.06.29.03.20.00;	author das;	state Exp;
branches;
next	1.11;

1.11
date	2007.06.09.17.09.39;	author das;	state Exp;
branches;
next	1.10;

1.10
date	2007.06.06.09.55.52;	author das;	state Exp;
branches;
next	1.9;

1.9
date	2007.05.31.13.38.13;	author das;	state Exp;
branches;
next	1.8;

1.8
date	2007.04.23.21.24.33;	author das;	state Exp;
branches
	1.8.2.1;
next	1.7;

1.7
date	2006.11.03.03.05.03;	author das;	state Exp;
branches;
next	1.6;

1.6
date	2006.09.11.14.41.04;	author das;	state Exp;
branches;
next	1.5;

1.5
date	2006.09.10.17.06.32;	author das;	state Exp;
branches;
next	1.4;

1.4
date	2006.03.24.14.58.01;	author das;	state Exp;
branches;
next	1.3;

1.3
date	2003.07.03.18.47.03;	author wolfsuit;	state Exp;
branches;
next	1.2;

1.2
date	2002.08.31.06.12.29;	author das;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2001.10.15.09.22.00;	author wolfsuit;	state dead;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2001.10.15.09.22.00;	author wolfsuit;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2002.08.30.18.18.16;	author das;	state Exp;
branches;
next	;

1.2.2.1
date	2004.02.16.00.42.34;	author wolfsuit;	state Exp;
branches;
next	1.2.2.2;

1.2.2.2
date	2006.03.28.02.44.13;	author das;	state Exp;
branches;
next	1.2.2.3;

1.2.2.3
date	2006.09.10.17.07.36;	author das;	state Exp;
branches;
next	1.2.2.4;

1.2.2.4
date	2006.09.11.14.41.16;	author das;	state Exp;
branches;
next	1.2.2.5;

1.2.2.5
date	2007.04.29.02.26.48;	author das;	state Exp;
branches;
next	1.2.2.6;

1.2.2.6
date	2007.05.31.13.42.12;	author das;	state Exp;
branches;
next	1.2.2.7;

1.2.2.7
date	2007.06.06.09.56.54;	author das;	state Exp;
branches;
next	1.2.2.8;

1.2.2.8
date	2007.06.09.17.10.20;	author das;	state Exp;
branches;
next	1.2.2.9;

1.2.2.9
date	2007.06.29.03.22.01;	author das;	state Exp;
branches;
next	1.2.2.10;

1.2.2.10
date	2007.07.02.13.06.14;	author das;	state Exp;
branches;
next	1.2.2.11;

1.2.2.11
date	2007.11.09.06.26.55;	author das;	state Exp;
branches;
next	;

1.8.2.1
date	2007.06.01.04.01.32;	author dgp;	state Exp;
branches;
next	1.8.2.2;

1.8.2.2
date	2007.06.12.16.22.41;	author dgp;	state Exp;
branches;
next	1.8.2.3;

1.8.2.3
date	2007.07.01.17.31.32;	author dgp;	state Exp;
branches;
next	1.8.2.4;

1.8.2.4
date	2007.07.03.02.28.13;	author dgp;	state Exp;
branches;
next	1.8.2.5;

1.8.2.5
date	2007.11.01.16.37.23;	author dgp;	state Exp;
branches;
next	;


desc
@@


1.17
log
@More marking of files as Objective-C.
@
text
@/*
 * tkMacOSXColor.c --
 *
 *	This file maintains a database of color values for the Tk
 *	toolkit, in order to avoid round-trips to the server to
 *	map color names to pixel values.
 *
 * Copyright (c) 1990-1994 The Regents of the University of California.
 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
 * Copyright 2001-2009, Apple Inc.
 * Copyright (c) 2006-2009 Daniel A. Steffen <das@@users.sourceforge.net>
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.16 2009/06/29 14:35:01 das Exp $
 */

#include "tkMacOSXPrivate.h"
#include "tkColor.h"

struct SystemColorMapEntry {
    const char *name;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;
};  /* unsigned char pixelCode; */

/*
 * Array of system color definitions: the array index is required to equal the
 * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept
 * in sync with the public pixel code values in tkMacOSXPort.h !
 */

#define MIN_PIXELCODE  30
static const struct SystemColorMapEntry systemColorMap[] = {
    { "Transparent",			    0, 0, 0 },							/*  30: TRANSPARENT_PIXEL */
    { "Highlight",			    kThemeBrushPrimaryHighlightColor, 0, 0 },			/*  31: HIGHLIGHT_PIXEL */
    { "HighlightSecondary",		    kThemeBrushSecondaryHighlightColor, 0, 0 },			/*  32: HIGHLIGHT_SECONDARY_PIXEL */
    { "HighlightText",			    kThemeBrushBlack, 0, 0 },					/*  33: HIGHLIGHT_TEXT_PIXEL */
    { "HighlightAlternate",		    kThemeBrushAlternatePrimaryHighlightColor, 0, 0 },		/*  34: HIGHLIGHT_ALTERNATE_PIXEL */
    { "ButtonText",			    0, kThemeTextColorPushButtonActive, 0 },			/*  35: CONTROL_TEXT_PIXEL */
    { "PrimaryHighlightColor",		    kThemeBrushPrimaryHighlightColor, 0, 0 },			/*  36 */
    { "ButtonFace",			    kThemeBrushButtonFaceActive, 0, 0 },			/*  37: CONTROL_BODY_PIXEL */
    { "SecondaryHighlightColor",	    kThemeBrushSecondaryHighlightColor, 0, 0 },			/*  38 */
    { "ButtonFrame",			    kThemeBrushButtonFrameActive, 0, 0 },			/*  39: CONTROL_FRAME_PIXEL */
    { "AlternatePrimaryHighlightColor",	    kThemeBrushAlternatePrimaryHighlightColor, 0, 0 },		/*  40 */
    { "WindowBody",			    kThemeBrushDocumentWindowBackground, 0, 0 },		/*  41: WINDOW_BODY_PIXEL */
    { "SheetBackground",		    kThemeBrushSheetBackground, 0, 0 },				/*  42 */
    { "MenuActive",			    kThemeBrushMenuBackgroundSelected, 0, 0 },			/*  43: MENU_ACTIVE_PIXEL */
    { "Black",				    kThemeBrushBlack, 0, 0 },					/*  44 */
    { "MenuActiveText",			    0, kThemeTextColorMenuItemSelected, 0 },			/*  45: MENU_ACTIVE_TEXT_PIXEL */
    { "White",				    kThemeBrushWhite, 0, 0 },					/*  46 */
    { "Menu",				    kThemeBrushMenuBackground, 0, 0 },				/*  47: MENU_BACKGROUND_PIXEL */
    { "DialogBackgroundActive",		    kThemeBrushDialogBackgroundActive, 0, 0 },			/*  48 */
    { "MenuDisabled",			    0, kThemeTextColorMenuItemDisabled, 0 },			/*  49: MENU_DISABLED_PIXEL */
    { "DialogBackgroundInactive",	    kThemeBrushDialogBackgroundInactive, 0, 0 },		/*  50 */
    { "MenuText",			    0, kThemeTextColorMenuItemActive, 0 },			/*  51: MENU_TEXT_PIXEL */
    { "AppearanceColor",		    0, 0, 0 },							/*  52: APPEARANCE_PIXEL */
    { "AlertBackgroundActive",		    kThemeBrushAlertBackgroundActive, 0, 0 },			/*  53 */
    { "AlertBackgroundInactive",	    kThemeBrushAlertBackgroundInactive, 0, 0 },			/*  54 */
    { "ModelessDialogBackgroundActive",	    kThemeBrushModelessDialogBackgroundActive, 0, 0 },		/*  55 */
    { "ModelessDialogBackgroundInactive",   kThemeBrushModelessDialogBackgroundInactive, 0, 0 },	/*  56 */
    { "UtilityWindowBackgroundActive",	    kThemeBrushUtilityWindowBackgroundActive, 0, 0 },		/*  57 */
    { "UtilityWindowBackgroundInactive",    kThemeBrushUtilityWindowBackgroundInactive, 0, 0 },		/*  58 */
    { "ListViewSortColumnBackground",	    kThemeBrushListViewSortColumnBackground, 0, 0 },		/*  59 */
    { "ListViewBackground",		    kThemeBrushListViewBackground, 0, 0 },			/*  60 */
    { "IconLabelBackground",		    kThemeBrushIconLabelBackground, 0, 0 },			/*  61 */
    { "ListViewSeparator",		    kThemeBrushListViewSeparator, 0, 0 },			/*  62 */
    { "ChasingArrows",			    kThemeBrushChasingArrows, 0, 0 },				/*  63 */
    { "DragHilite",			    kThemeBrushDragHilite, 0, 0 },				/*  64 */
    { "DocumentWindowBackground",	    kThemeBrushDocumentWindowBackground, 0, 0 },		/*  65 */
    { "FinderWindowBackground",		    kThemeBrushFinderWindowBackground, 0, 0 },			/*  66 */
    { "ScrollBarDelimiterActive",	    kThemeBrushScrollBarDelimiterActive, 0, 0 },		/*  67 */
    { "ScrollBarDelimiterInactive",	    kThemeBrushScrollBarDelimiterInactive, 0, 0 },		/*  68 */
    { "FocusHighlight",			    kThemeBrushFocusHighlight, 0, 0 },				/*  69 */
    { "PopupArrowActive",		    kThemeBrushPopupArrowActive, 0, 0 },			/*  70 */
    { "PopupArrowPressed",		    kThemeBrushPopupArrowPressed, 0, 0 },			/*  71 */
    { "PopupArrowInactive",		    kThemeBrushPopupArrowInactive, 0, 0 },			/*  72 */
    { "AppleGuideCoachmark",		    kThemeBrushAppleGuideCoachmark, 0, 0 },			/*  73 */
    { "IconLabelBackgroundSelected",	    kThemeBrushIconLabelBackgroundSelected, 0, 0 },		/*  74 */
    { "StaticAreaFill",			    kThemeBrushStaticAreaFill, 0, 0 },				/*  75 */
    { "ActiveAreaFill",			    kThemeBrushActiveAreaFill, 0, 0 },				/*  76 */
    { "ButtonFrameActive",		    kThemeBrushButtonFrameActive, 0, 0 },			/*  77 */
    { "ButtonFrameInactive",		    kThemeBrushButtonFrameInactive, 0, 0 },			/*  78 */
    { "ButtonFaceActive",		    kThemeBrushButtonFaceActive, 0, 0 },			/*  79 */
    { "ButtonFaceInactive",		    kThemeBrushButtonFaceInactive, 0, 0 },			/*  80 */
    { "ButtonFacePressed",		    kThemeBrushButtonFacePressed, 0, 0 },			/*  81 */
    { "ButtonActiveDarkShadow",		    kThemeBrushButtonActiveDarkShadow, 0, 0 },			/*  82 */
    { "ButtonActiveDarkHighlight",	    kThemeBrushButtonActiveDarkHighlight, 0, 0 },		/*  83 */
    { "ButtonActiveLightShadow",	    kThemeBrushButtonActiveLightShadow, 0, 0 },			/*  84 */
    { "ButtonActiveLightHighlight",	    kThemeBrushButtonActiveLightHighlight, 0, 0 },		/*  85 */
    { "ButtonInactiveDarkShadow",	    kThemeBrushButtonInactiveDarkShadow, 0, 0 },		/*  86 */
    { "ButtonInactiveDarkHighlight",	    kThemeBrushButtonInactiveDarkHighlight, 0, 0 },		/*  87 */
    { "ButtonInactiveLightShadow",	    kThemeBrushButtonInactiveLightShadow, 0, 0 },		/*  88 */
    { "ButtonInactiveLightHighlight",	    kThemeBrushButtonInactiveLightHighlight, 0, 0 },		/*  89 */
    { "ButtonPressedDarkShadow",	    kThemeBrushButtonPressedDarkShadow, 0, 0 },			/*  90 */
    { "ButtonPressedDarkHighlight",	    kThemeBrushButtonPressedDarkHighlight, 0, 0 },		/*  91 */
    { "ButtonPressedLightShadow",	    kThemeBrushButtonPressedLightShadow, 0, 0 },		/*  92 */
    { "ButtonPressedLightHighlight",	    kThemeBrushButtonPressedLightHighlight, 0, 0 },		/*  93 */
    { "BevelActiveLight",		    kThemeBrushBevelActiveLight, 0, 0 },			/*  94 */
    { "BevelActiveDark",		    kThemeBrushBevelActiveDark, 0, 0 },				/*  95 */
    { "BevelInactiveLight",		    kThemeBrushBevelInactiveLight, 0, 0 },			/*  96 */
    { "BevelInactiveDark",		    kThemeBrushBevelInactiveDark, 0, 0 },			/*  97 */
    { "NotificationWindowBackground",	    kThemeBrushNotificationWindowBackground, 0, 0 },		/*  98 */
    { "MovableModalBackground",		    kThemeBrushMovableModalBackground, 0, 0 },			/*  99 */
    { "SheetBackgroundOpaque",		    kThemeBrushSheetBackgroundOpaque, 0, 0 },			/* 100 */
    { "DrawerBackground",		    kThemeBrushDrawerBackground, 0, 0 },			/* 101 */
    { "ToolbarBackground",		    kThemeBrushToolbarBackground, 0, 0 },			/* 102 */
    { "SheetBackgroundTransparent",	    kThemeBrushSheetBackgroundTransparent, 0, 0 },		/* 103 */
    { "MenuBackground",			    kThemeBrushMenuBackground, 0, 0 },				/* 104 */
    { "Pixel",				    0, 0, 0 },							/* 105: PIXEL_MAGIC */
    { "MenuBackgroundSelected",		    kThemeBrushMenuBackgroundSelected, 0, 0 },			/* 106 */
    { "ListViewOddRowBackground",	    kThemeBrushListViewOddRowBackground, 0, 0 },		/* 107 */
    { "ListViewEvenRowBackground",	    kThemeBrushListViewEvenRowBackground, 0, 0 },		/* 108 */
    { "ListViewColumnDivider",		    kThemeBrushListViewColumnDivider, 0, 0 },			/* 109 */
    { "BlackText",			    0, kThemeTextColorBlack, 0 },				/* 110 */
    { "DialogActiveText",		    0, kThemeTextColorDialogActive, 0 },			/* 111 */
    { "DialogInactiveText",		    0, kThemeTextColorDialogInactive, 0 },			/* 112 */
    { "AlertActiveText",		    0, kThemeTextColorAlertActive, 0 },				/* 113 */
    { "AlertInactiveText",		    0, kThemeTextColorAlertInactive, 0 },			/* 114 */
    { "ModelessDialogActiveText",	    0, kThemeTextColorModelessDialogActive, 0 },		/* 115 */
    { "ModelessDialogInactiveText",	    0, kThemeTextColorModelessDialogInactive, 0 },		/* 116 */
    { "WindowHeaderActiveText",		    0, kThemeTextColorWindowHeaderActive, 0 },			/* 117 */
    { "WindowHeaderInactiveText",	    0, kThemeTextColorWindowHeaderInactive, 0 },		/* 118 */
    { "PlacardActiveText",		    0, kThemeTextColorPlacardActive, 0 },			/* 119 */
    { "PlacardInactiveText",		    0, kThemeTextColorPlacardInactive, 0 },			/* 120 */
    { "PlacardPressedText",		    0, kThemeTextColorPlacardPressed, 0 },			/* 121 */
    { "PushButtonActiveText",		    0, kThemeTextColorPushButtonActive, 0 },			/* 122 */
    { "PushButtonInactiveText",		    0, kThemeTextColorPushButtonInactive, 0 },			/* 123 */
    { "PushButtonPressedText",		    0, kThemeTextColorPushButtonPressed, 0 },			/* 124 */
    { "BevelButtonActiveText",		    0, kThemeTextColorBevelButtonActive, 0 },			/* 125 */
    { "BevelButtonInactiveText",	    0, kThemeTextColorBevelButtonInactive, 0 },			/* 126 */
    { "BevelButtonPressedText",		    0, kThemeTextColorBevelButtonPressed, 0 },			/* 127 */
    { "PopupButtonActiveText",		    0, kThemeTextColorPopupButtonActive, 0 },			/* 128 */
    { "PopupButtonInactiveText",	    0, kThemeTextColorPopupButtonInactive, 0 },			/* 129 */
    { "PopupButtonPressedText",		    0, kThemeTextColorPopupButtonPressed, 0 },			/* 130 */
    { "IconLabelText",			    0, kThemeTextColorIconLabel, 0 },				/* 131 */
    { "ListViewText",			    0, kThemeTextColorListView, 0 },				/* 132 */
    { "DocumentWindowTitleActiveText",	    0, kThemeTextColorDocumentWindowTitleActive, 0 },		/* 133 */
    { "DocumentWindowTitleInactiveText",    0, kThemeTextColorDocumentWindowTitleInactive, 0 },		/* 134 */
    { "MovableModalWindowTitleActiveText",  0, kThemeTextColorMovableModalWindowTitleActive, 0 },	/* 135 */
    { "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0 },	/* 136 */
    { "UtilityWindowTitleActiveText",	    0, kThemeTextColorUtilityWindowTitleActive, 0 },		/* 137 */
    { "UtilityWindowTitleInactiveText",	    0, kThemeTextColorUtilityWindowTitleInactive, 0 },		/* 138 */
    { "PopupWindowTitleActiveText",	    0, kThemeTextColorPopupWindowTitleActive, 0 },		/* 139 */
    { "PopupWindowTitleInactiveText",	    0, kThemeTextColorPopupWindowTitleInactive, 0 },		/* 140 */
    { "RootMenuActiveText",		    0, kThemeTextColorRootMenuActive, 0 },			/* 141 */
    { "RootMenuSelectedText",		    0, kThemeTextColorRootMenuSelected, 0 },			/* 142 */
    { "RootMenuDisabledText",		    0, kThemeTextColorRootMenuDisabled, 0 },			/* 143 */
    { "MenuItemActiveText",		    0, kThemeTextColorMenuItemActive, 0 },			/* 144 */
    { "MenuItemSelectedText",		    0, kThemeTextColorMenuItemSelected, 0 },			/* 145 */
    { "MenuItemDisabledText",		    0, kThemeTextColorMenuItemDisabled, 0 },			/* 146 */
    { "PopupLabelActiveText",		    0, kThemeTextColorPopupLabelActive, 0 },			/* 147 */
    { "PopupLabelInactiveText",		    0, kThemeTextColorPopupLabelInactive, 0 },			/* 148 */
    { "TabFrontActiveText",		    0, kThemeTextColorTabFrontActive, 0 },			/* 149 */
    { "TabNonFrontActiveText",		    0, kThemeTextColorTabNonFrontActive, 0 },			/* 150 */
    { "TabNonFrontPressedText",		    0, kThemeTextColorTabNonFrontPressed, 0 },			/* 151 */
    { "TabFrontInactiveText",		    0, kThemeTextColorTabFrontInactive, 0 },			/* 152 */
    { "TabNonFrontInactiveText",	    0, kThemeTextColorTabNonFrontInactive, 0 },			/* 153 */
    { "IconLabelSelectedText",		    0, kThemeTextColorIconLabelSelected, 0 },			/* 154 */
    { "BevelButtonStickyActiveText",	    0, kThemeTextColorBevelButtonStickyActive, 0 },		/* 155 */
    { "BevelButtonStickyInactiveText",	    0, kThemeTextColorBevelButtonStickyInactive, 0 },		/* 156 */
    { "NotificationText",		    0, kThemeTextColorNotification, 0 },			/* 157 */
    { "SystemDetailText",		    0, kThemeTextColorSystemDetail, 0 },			/* 158 */
    { "WhiteText",			    0, kThemeTextColorWhite, 0 },				/* 159 */
    { "TabPaneBackground",		    0, 0, kThemeBackgroundTabPane },				/* 160 */
    { "PlacardBackground",		    0, 0, kThemeBackgroundPlacard },				/* 161 */
    { "WindowHeaderBackground",		    0, 0, kThemeBackgroundWindowHeader },			/* 162 */
    { "ListViewWindowHeaderBackground",	    0, 0, kThemeBackgroundListViewWindowHeader },		/* 163 */
    { "SecondaryGroupBoxBackground",	    0, 0, kThemeBackgroundSecondaryGroupBox },			/* 164 */
    { "MetalBackground",		    0, 0, kThemeBackgroundMetal },				/* 165 */
    { NULL,				    0, 0, 0 }
};
#define MAX_PIXELCODE 165

/*
 *----------------------------------------------------------------------
 *
 * GetThemeFromPixelCode --
 *
 *	When given a pixel code corresponding to a theme system color,
 *	set one of brush, textColor or background to the corresponding
 *	Appearance Mgr theme constant.
 *
 * Results:
 *	Returns false if not a real pixel, true otherwise.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static int
GetThemeFromPixelCode(
    unsigned char code,
    ThemeBrush *brush,
    ThemeTextColor *textColor,
    ThemeBackgroundKind *background)
{
    if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) {
	*brush = systemColorMap[code - MIN_PIXELCODE].brush;
	*textColor = systemColorMap[code - MIN_PIXELCODE].textColor;
	*background = systemColorMap[code - MIN_PIXELCODE].background;
    } else {
	*brush = 0;
	*textColor = 0;
	*background = 0;
    }
    if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC &&
	    code != TRANSPARENT_PIXEL) {
	return false;
    } else {
	return true;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * GetThemeColor --
 *
 *	Get RGB color for a given system color or pixel value.
 *
 * Results:
 *	OSStatus
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static OSStatus
GetThemeColor(
    unsigned long pixel,
    ThemeBrush brush,
    ThemeTextColor textColor,
    ThemeBackgroundKind background,
    CGColorRef *c)
{
    OSStatus err = noErr;

    if (brush) {
	err = ChkErr(HIThemeBrushCreateCGColor, brush, c);
    /*} else if (textColor) {
	err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/
    } else {
	CGFloat rgba[4] = {0, 0, 0, 1};

	switch ((pixel >> 24) & 0xff) {
	case PIXEL_MAGIC: {
	    unsigned short red, green, blue;
	    red		= (pixel >> 16) & 0xff;
	    green	= (pixel >>  8) & 0xff;
	    blue	= (pixel      ) & 0xff;
	    red		|= red   << 8;
	    green	|= green << 8;
	    blue	|= blue  << 8;
	    rgba[0]	= red	/ 65535.0;
	    rgba[1]	= green / 65535.0;
	    rgba[2]	= blue  / 65535.0;
	    break;
	    }
	case TRANSPARENT_PIXEL:
	    rgba[3]	= 0.0;
	    break;
	}

	*c = CGColorCreateGenericRGB(rgba[0], rgba[1], rgba[2], rgba[3]);

	/*static CGColorSpaceRef deviceRGBSpace = NULL;
	if (!deviceRGBSpace) {
	    deviceRGBSpace = CGDisplayCopyColorSpace(CGMainDisplayID());
	}
	*c = CGColorCreate(deviceRGBSpace, rgba );*/
    }
    return err;
}

/*
 *----------------------------------------------------------------------
 *
 * TkSetMacColor --
 *
 *	Creates a CGColorRef from a X style pixel value.
 *
 * Results:
 *	Returns false if not a real pixel, true otherwise.
 *
 * Side effects:
 *	The variable macColor is set to a new CGColorRef, the caller is
 *	responsible for releasing it!
 *
 *----------------------------------------------------------------------
 */

int
TkSetMacColor(
    unsigned long pixel,		/* Pixel value to convert. */
    void *macColor)			/* CGColorRef to modify. */
{
    CGColorRef *color = (CGColorRef*)macColor;
    OSStatus err = -1;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;

    if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
	    &background)) {
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
		color);
    }
    return (err == noErr);
}

/*
 *----------------------------------------------------------------------
 *
 * TkpInitGCCache, TkpFreeGCCache, CopyCachedColor, SetCachedColor --
 *
 *	Maintain a per-GC cache of previously converted CGColorRefs
 *
 * Results:
 *	None resp. retained CGColorRef for CopyCachedColor()
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

void
TkpInitGCCache(
    GC gc)
{
    bzero(TkpGetGCCache(gc), sizeof(TkpGCCache));
}

void
TkpFreeGCCache(
    GC gc)
{
    TkpGCCache *gcCache = TkpGetGCCache(gc);

    if (gcCache->cachedForegroundColor) {
	CFRelease(gcCache->cachedForegroundColor);
    }
    if (gcCache->cachedBackgroundColor) {
	CFRelease(gcCache->cachedBackgroundColor);
    }
}

static CGColorRef
CopyCachedColor(
    GC gc,
    unsigned long pixel)
{
    TkpGCCache *gcCache = TkpGetGCCache(gc);
    CGColorRef cgColor = NULL;

    if (gcCache) {
	if (gcCache->cachedForeground == pixel) {
	    cgColor = gcCache->cachedForegroundColor;
	} else if (gcCache->cachedBackground == pixel) {
	    cgColor = gcCache->cachedBackgroundColor;
	}
	if (cgColor) {
	    CFRetain(cgColor);
	}
    }
    return cgColor;
}

static void
SetCachedColor(
    GC gc,
    unsigned long pixel,
    CGColorRef cgColor)
{
    TkpGCCache *gcCache = TkpGetGCCache(gc);

    if (gcCache && cgColor) {
	if (gc->foreground == pixel) {
	    if (gcCache->cachedForegroundColor) {
		CFRelease(gcCache->cachedForegroundColor);
	    }
	    gcCache->cachedForegroundColor = (CGColorRef) CFRetain(cgColor);
	    gcCache->cachedForeground = pixel;
	} else if (gc->background == pixel) {
	    if (gcCache->cachedBackgroundColor) {
		CFRelease(gcCache->cachedBackgroundColor);
	    }
	    gcCache->cachedBackgroundColor = (CGColorRef) CFRetain(cgColor);
	    gcCache->cachedBackground = pixel;
	}
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXCreateCGColor --
 *
 *	Creates a CGColorRef from a X style pixel value.
 *
 * Results:
 *	Returns NULL if not a real pixel, CGColorRef otherwise.
 *
 * Side effects:
 *	None
 *
 *----------------------------------------------------------------------
 */

CGColorRef
TkMacOSXCreateCGColor(
    GC gc,
    unsigned long pixel)		/* Pixel value to convert. */
{
    CGColorRef cgColor = CopyCachedColor(gc, pixel);

    if (!cgColor && TkSetMacColor(pixel, &cgColor)) {
	SetCachedColor(gc, pixel, cgColor);
    }
    return cgColor;
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXGetNSColor --
 *
 *	Creates an autoreleased NSColor from a X style pixel value.
 *
 * Results:
 *	Returns nil if not a real pixel, NSColor* otherwise.
 *
 * Side effects:
 *	None
 *
 *----------------------------------------------------------------------
 */

NSColor*
TkMacOSXGetNSColor(
    GC gc,
    unsigned long pixel)		/* Pixel value to convert. */
{
    CGColorRef cgColor = TkMacOSXCreateCGColor(gc, pixel);
    NSColor *nsColor = nil;

    if (cgColor) {
	NSColorSpace *colorSpace = [[NSColorSpace alloc]
		initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
	nsColor = [NSColor colorWithColorSpace:colorSpace
		components:CGColorGetComponents(cgColor)
		count:CGColorGetNumberOfComponents(cgColor)];
	[colorSpace release];
	CFRelease(cgColor);
    }
    return nsColor;
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetColorInContext --
 *
 *	Sets fill and stroke color in the given CG context from an X
 *	pixel value, or if the pixel code indicates a system color,
 *	sets the corresponding brush, textColor or background via
 *	HITheme APIs if available or Appearance mgr APIs.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

void
TkMacOSXSetColorInContext(
    GC gc,
    unsigned long pixel,
    CGContextRef context)
{
    OSStatus err = -1;
    CGColorRef cgColor = CopyCachedColor(gc, pixel);
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;

    if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush,
	    &textColor, &background)) {
	if (brush) {
	    err = ChkErr(HIThemeSetFill, brush, NULL, context,
		    kHIThemeOrientationNormal);
	    if (err == noErr) {
		err = ChkErr(HIThemeSetStroke, brush, NULL, context,
			kHIThemeOrientationNormal);
	    }
	} else if (textColor) {
	    err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
		    kHIThemeOrientationNormal);
	} else if (background) {
	    CGRect rect = CGContextGetClipBoundingBox(context);
	    HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
		    background };

	    err = ChkErr(HIThemeApplyBackground, &rect, &info,
		    context, kHIThemeOrientationNormal);
	}
	if (err == noErr) {
	    return;
	}
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
		&cgColor);
	if (err == noErr) {
	    SetCachedColor(gc, pixel, cgColor);
	}
    } else if (!cgColor) {
	TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
    }
    if (cgColor) {
	CGContextSetFillColorWithColor(context, cgColor);
	CGContextSetStrokeColorWithColor(context, cgColor);
	CGColorRelease(cgColor);
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TkpGetColor --
 *
 *	Allocate a new TkColor for the color with the given name.
 *
 * Results:
 *	Returns a newly allocated TkColor, or NULL on failure.
 *
 * Side effects:
 *	May invalidate the colormap cache associated with tkwin upon
 *	allocating a new colormap entry. Allocates a new TkColor
 *	structure.
 *
 *----------------------------------------------------------------------
 */

TkColor *
TkpGetColor(
    Tk_Window tkwin,		/* Window in which color will be used. */
    Tk_Uid name)		/* Name of color to allocated (in form
				 * suitable for passing to XParseColor). */
{
    Display *display = tkwin != None ? Tk_Display(tkwin) : NULL;
    Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None;
    TkColor *tkColPtr;
    XColor color;

    /*
     * Check to see if this is a system color. Otherwise, XParseColor
     * will do all the work.
     */
    if (strncasecmp(name, "system", 6) == 0) {
	Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1);
	int idx, result;

	result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap,
		    sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
	Tcl_DecrRefCount(strPtr);
	if (result == TCL_OK) {
	    OSStatus err;
	    CGColorRef c;
	    unsigned char pixelCode = idx + MIN_PIXELCODE;
	    ThemeBrush brush = systemColorMap[idx].brush;
	    ThemeTextColor textColor = systemColorMap[idx].textColor;
	    ThemeBackgroundKind background = systemColorMap[idx].background;

	    err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c);
	    if (err == noErr) {
		const size_t n = CGColorGetNumberOfComponents(c);
		const CGFloat *rgba = CGColorGetComponents(c);

		switch (n) {
		case 4:
		    color.red   = rgba[0] * 65535.0;
		    color.green = rgba[1] * 65535.0;
		    color.blue  = rgba[2] * 65535.0;
		    break;
		case 2:
		    color.red = color.green = color.blue = rgba[0] * 65535.0;
		    break;
		default:
		    Tcl_Panic("CGColor with %d components", n);
		}
		color.pixel = ((((((pixelCode << 8)
		    | ((color.red   >> 8) & 0xff)) << 8)
		    | ((color.green >> 8) & 0xff)) << 8)
		    | ((color.blue  >> 8) & 0xff));
		CGColorRelease(c);
		goto validXColor;
	    }
	    CGColorRelease(c);
	}
    }

    if (XParseColor(display, colormap, name, &color) == 0) {
	return (TkColor *) NULL;
    }

validXColor:
    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
    tkColPtr->color = color;

    return tkColPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * TkpGetColorByValue --
 *
 *	Given a desired set of red-green-blue intensities for a color,
 *	locate a pixel value to use to draw that color in a given
 *	window.
 *
 * Results:
 *	The return value is a pointer to an TkColor structure that
 *	indicates the closest red, blue, and green intensities available
 *	to those specified in colorPtr, and also specifies a pixel
 *	value to use to draw in that color.
 *
 * Side effects:
 *	May invalidate the colormap cache for the specified window.
 *	Allocates a new TkColor structure.
 *
 *----------------------------------------------------------------------
 */

TkColor *
TkpGetColorByValue(
    Tk_Window tkwin,		/* Window in which color will be used. */
    XColor *colorPtr)		/* Red, green, and blue fields indicate
				 * desired color. */
{
    TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));

    tkColPtr->color.red = colorPtr->red;
    tkColPtr->color.green = colorPtr->green;
    tkColPtr->color.blue = colorPtr->blue;
    tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color);
    return tkColPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * Stub functions --
 *
 *	These functions are just stubs for functions that either
 *	don't make sense on the Mac or have yet to be implemented.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	These calls do nothing - which may not be expected.
 *
 *----------------------------------------------------------------------
 */

Status
XAllocColor(
    Display *display,		/* Display. */
    Colormap map,		/* Not used. */
    XColor *colorPtr)		/* XColor struct to modify. */
{
    display->request++;
    colorPtr->pixel = TkpGetPixel(colorPtr);
    return 1;
}

Colormap
XCreateColormap(
    Display *display,		/* Display. */
    Window window,		/* X window. */
    Visual *visual,		/* Not used. */
    int alloc)			/* Not used. */
{
    static Colormap index = 1;

    /*
     * Just return a new value each time.
     */
    return index++;
}

void
XFreeColormap(
    Display* display,		/* Display. */
    Colormap colormap)		/* Colormap. */
{
}

void
XFreeColors(
    Display* display,		/* Display. */
    Colormap colormap,		/* Colormap. */
    unsigned long* pixels,	/* Array of pixels. */
    int npixels,		/* Number of pixels. */
    unsigned long planes)	/* Number of pixel planes. */
{
    /*
     * The Macintosh version of Tk uses TrueColor. Nothing
     * needs to be done to release colors as there really is
     * no colormap in the Tk sense.
     */
}

/*
 * Local Variables:
 * mode: objc
 * c-basic-offset: 4
 * fill-column: 79
 * coding: utf-8
 * End:
 */
@


1.16
log
@Merge of TkAqua Cocoa port
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.15 2007/12/13 15:27:08 dgp Exp $
d726 1
a726 1
 * mode: c
@


1.15
log
@merge stable branch onto HEAD
@
text
@d10 2
a11 2
 * Copyright 2001, Apple Computer, Inc.
 * Copyright (c) 2006-2007 Daniel A. Steffen <das@@users.sourceforge.net>
d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.8.2.5 2007/11/01 16:37:23 dgp Exp $
a21 5
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
/* Undocumented CG API for creating CGPattern from CGImage */
extern CGPatternRef CGPatternCreateWithImage(CGImageRef img, int i) WEAK_IMPORT_ATTRIBUTE;
#endif

d176 1
a176 1

d202 1
a202 1
    if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE && code != PIXEL_MAGIC) {
d211 2
a212 1
    if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC) {
d241 1
a241 1
    RGBColor *c)
d246 3
a248 5
	err = ChkErr(GetThemeBrushAsColor,
		brush == kThemeBrushMenuBackgroundSelected ?
		kThemeBrushFocusHighlight : brush, 32, true, c);
    } else if (textColor) {
	err = ChkErr(GetThemeTextColor, textColor, 32, true, c);
d250 28
a277 6
	c->red	  = (pixel >> 16) & 0xff;
	c->green  = (pixel >>  8) & 0xff;
	c->blue	  = (pixel	) & 0xff;
	c->red	 |= c->red   << 8;
	c->green |= c->green << 8;
	c->blue	 |= c->blue  << 8;
d287 1
a287 2
 *	Populates a Macintosh RGBColor structure from a X style
 *	pixel value.
d293 2
a294 1
 *	The variable macColor is updated to the pixels value.
d302 1
a302 1
    RGBColor *macColor)			/* Mac color struct to modify. */
d304 1
d313 1
a313 1
		macColor);
d321 1
a321 1
 * TkMacOSXSetColorInPort --
d323 1
a323 4
 *	Sets fore or back color in the given QD port from an X pixel
 *	value, and if the pixel code indicates a system color, sets
 *	the corresponding brush, textColor or background via
 *	Appearance mgr APIs.
d326 1
a326 1
 *	None.
d329 1
a329 1
 *	If penPat is non-NULL it is set to the forground color/pattern.
d335 2
a336 5
TkMacOSXSetColorInPort(
    unsigned long pixel,
    int fg,
    PixPatHandle penPat,
    CGrafPtr port)
d338 2
a339 6
    OSStatus err;
    RGBColor c;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;
    int setPenPat = 0;
d341 5
a345 4
    if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
	    &background)) {
	CGrafPtr savePort;
	Boolean portChanged;
d347 7
a353 22
	portChanged = QDSwapPort(port, &savePort);
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c);
	if (err == noErr) {
	    if (fg) {
		RGBForeColor(&c);
		if (penPat) {
		    MakeRGBPat(penPat, &c);
		    setPenPat = 1;
		}
	    } else {
		RGBBackColor(&c);
	    }
	}
	err = -1;
	if (brush) {
	    err = ChkErr(SetThemeBackground,
		    brush == kThemeBrushMenuBackgroundSelected ?
		    kThemeBrushFocusHighlight : brush, 32, true);
	} else if (textColor && fg) {
	    err = ChkErr(SetThemeTextColor, textColor, 32, true);
	} else if (background) {
	    Rect bounds;
d355 13
a367 3
	    GetPortBounds(port, &bounds);
	    err = ChkErr(ApplyThemeBackground, background, &bounds,
		    kThemeStateActive, 32, true);
d369 2
a370 3
	if (penPat && err == noErr && (brush || background)) {
	    GetPortBackPixPat(port, penPat);
	    setPenPat = 1;
d372 25
a396 2
	if (portChanged) {
	    QDSwapPort(savePort, NULL);
a397 2
    } else {
	TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
d399 63
a461 2
    if (penPat && !setPenPat) {
	GetPortBackPixPat(port, penPat);
d463 1
d487 1
d492 1
a492 1
    RGBColor c;
d497 2
a498 2
    if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
	    &background)) {
d500 4
a503 2
	    TK_IF_MAC_OS_X_API (4, HIThemeSetFill,
		err = ChkErr(HIThemeSetFill, brush, NULL, context,
d505 1
a505 5
		TK_IF_MAC_OS_X_API_COND (4, HIThemeSetFill, err == noErr,
		    err = ChkErr(HIThemeSetStroke, brush, NULL, context,
			    kHIThemeOrientationNormal);
		) TK_ENDIF
	    ) TK_ENDIF
d507 2
a508 4
	    TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill,
		err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
			kHIThemeOrientationNormal);
	    ) TK_ENDIF
d510 6
a515 12
	    TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
		CGRect rect = CGContextGetClipBoundingBox(context);
		HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
			background };

		TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground,
		    TK_IF_HI_TOOLBOX (3, /* c.f. QA1377 */
			err = ChkErr(HIThemeApplyBackground, &rect, &info,
				context, kHIThemeOrientationNormal);
		    ) TK_ENDIF
		) TK_ENDIF
	    ) TK_ENDIF
d520 2
a521 74
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
	/*
	 * Convert Appearance theme pattern to CGPattern:
	 */
	if ((brush || background) && CGPatternCreateWithImage != NULL) {
	    static PixPatHandle pixpat = NULL;
	    static GWorldPtr patGWorld = NULL;
	    static uint32_t bitmapInfo = 0;
	    const short patDim = 16;
	    const Rect bounds = {0, 0, patDim, patDim};
	    CGrafPtr savePort;
	    Boolean portChanged;
	    PixMapHandle pixmap;
	    long rowbytes;
	    CGImageRef img;
	    CGColorSpaceRef rgbCspace;
	    CGDataProviderRef provider;

	    if (!pixpat) {
		pixpat = NewPixPat();
		err = ChkErr(NewGWorld, &patGWorld, 32, &bounds, NULL, NULL, 0
#ifdef __LITTLE_ENDIAN__
			| kNativeEndianPixMap
#endif
			);
		if (!pixpat || err != noErr || !patGWorld) {
		    Tcl_Panic("TkMacOSXSetColorInContext(): "
			"pattern initialization failed !");
		}
		TK_IF_HI_TOOLBOX (4,
		    bitmapInfo = kCGBitmapByteOrder32Host;
		) TK_ENDIF
	    }
	    portChanged = QDSwapPort(patGWorld, &savePort);
	    TkMacOSXSetColorInPort(pixel, 1, pixpat, patGWorld);
#ifdef TK_MAC_DEBUG
	    Rect patBounds;
	    GetPixBounds((**pixpat).patMap, &patBounds);
	    if (patBounds.right > patDim || patBounds.bottom > patDim) {
		Tcl_Panic("TkMacOSXSetColorInContext(): "
		    "pattern larger than expected !");
	    }
#endif /* TK_MAC_DEBUG */
	    FillCRect(&bounds, pixpat);
	    if (portChanged) {
		QDSwapPort(savePort, NULL);
	    }
	    pixmap = GetPortPixMap(patGWorld);
	    rowbytes = GetPixRowBytes(pixmap);
	    provider = CGDataProviderCreateWithData(&patGWorld,
		    GetPixBaseAddr(pixmap), rowbytes * patDim, NULL);
	    rgbCspace = CGColorSpaceCreateDeviceRGB();
	    img = CGImageCreate(patDim, patDim, 8, 32,
		    rowbytes, rgbCspace, kCGImageAlphaFirst | bitmapInfo,
		    provider, NULL, 0, kCGRenderingIntentDefault);
	    CGColorSpaceRelease(rgbCspace);
	    CGDataProviderRelease(provider);
	    if (img) {
		CGPatternRef pat = CGPatternCreateWithImage(img, 2);
		CGColorSpaceRef patCSpace = CGColorSpaceCreatePattern(NULL);
		const float alpha = 1;

		CGContextSetFillColorSpace(context, patCSpace);
		CGContextSetFillPattern(context, pat, &alpha);
		CGContextSetStrokeColorSpace(context, patCSpace);
		CGContextSetStrokePattern(context, pat, &alpha);
		CGColorSpaceRelease(patCSpace);
		CGPatternRelease(pat);
		CGImageRelease(img);
		return;
	    }
	}
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1040 */
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c);
d523 1
a523 6
	    double r = c.red   / 65535.0;
	    double g = c.green / 65535.0;
	    double b = c.blue  / 65535.0;

	    CGContextSetRGBFillColor(context, r, g, b, 1.0);
	    CGContextSetRGBStrokeColor(context, r, g, b, 1.0);
d525 1
a525 4
    } else if (((pixel >> 24) & 0xff) == TRANSPARENT_PIXEL) {
	CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.0);
	CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.0);
    } else {
d528 5
d559 2
a560 2
    Display *display = Tk_Display(tkwin);
    Colormap colormap = Tk_Colormap(tkwin);
d577 1
a577 1
	    RGBColor c;
d585 15
a599 3
		color.red   = c.red;
		color.green = c.green;
		color.blue  = c.blue;
d604 1
d607 1
a658 31
#if !TK_DRAW_IN_CONTEXT
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXCompareColors --
 *
 *	On Mac, color codes may specify symbolic values like "highlight
 *	foreground", but we really need the actual values to compare.
 *	Maybe see also: "TIP #154: Add Named Colors to Tk".
 *
 * Results:
 *	Returns true if both colors are the same, false otherwise.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

int
TkMacOSXCompareColors(
    unsigned long c1,
    unsigned long c2)
{
    RGBColor col1, col2;
    return  TkSetMacColor(c1,&col1) &&
	    TkSetMacColor(c1,&col2) &&
	    !memcmp(&col1,&col2,sizeof(col1));
}
#endif /* !TK_DRAW_IN_CONTEXT */

d723 9
@


1.14
log
@	* macosx/tkMacOSXColor.c (GetThemeColor): improve translation of RGB
				pixel values into RGBColor.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.13 2007/07/02 13:05:14 das Exp $
@


1.13
log
@	*  macosx/tkMacOSXDraw.c (TkMacOSXRestoreDrawingContext): don't restore
	port state if it wasn't altered by TkMacOSXSetupDrawingContext().
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.12 2007/06/29 03:20:00 das Exp $
d256 6
a261 3
	c->red	 = ((pixel >> 16) & 0xff) << 8;
	c->green = ((pixel >>  8) & 0xff) << 8;
	c->blue	 = ((pixel	) & 0xff) << 8;
@


1.12
log
@	* macosx/tkMacOSXScrlbr.c: correct int <-> dobule conversion issues
	that could lead to Carbon getting confused about scrollbar thumb size.

	* macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) use
	TkMacOSX{Setup,Restore}DrawingContext() to setup/restore clip & colors.
	(TkMacOSXSetupDrawingContext, TkMacOSXRestoreDrawingContext): add save
	and restore of QD port clip region; factor out clip region code common
	to CG and QD branches; check for port and context validity; handle
	tkPictureIsOpen flag during QD port setup.
	(TkScrollWindow): remove unnecessary scroll region manipulation

	* macosx/tkMacOSXDraw.c:	remove second global QD temp region
	* macosx/tkMacOSXInt.h:		(no longer necessary) and rename
	* macosx/tkMacOSXRegion.c:	remaining global QD temp region.
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:

	* macosx/tkMacOSXDraw.c:	make useCGDrawing variable MODULE_SCOPE
	* macosx/tkMacOSXFont.c:	and respect it for ATSUI font drawing.

	* macosx/tkMacOSXButton.c:	reduce reliance on current QD port
	* macosx/tkMacOSXColor.c:	setting and remove unnecessary
	* macosx/tkMacOSXDebug.c:	references to a drawable's QD port,
	* macosx/tkMacOSXDebug.h:	notably replace GetWindowFromPort(
	* macosx/tkMacOSXDialog.c:	TkMacOSXGetDrawablePort()) idiom by new
	* macosx/tkMacOSXDraw.c:	TkMacOSXDrawableWindow() and change
	* macosx/tkMacOSXKeyEvent.c:	TkMacOSXSetColorInPort() to take a port
	* macosx/tkMacOSXMenu.c:	argument.
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXInt.h:			factor out macros, declarations
	* macosx/tkMacOSXPrivate.h (new):	and prototypes that are purely
	internal and private to the 'macosx' sources into a new internal header
	file that does _not_ get installed into Tk.framework/PrivateHeaders.

	* macosx/tkMacOSXButton.c:		#include new tkMacOSXPrivate.h
	* macosx/tkMacOSXCarbonEvents.c:	instead of tkMacOSXInt.h.
	* macosx/tkMacOSXClipboard.c:
	* macosx/tkMacOSXColor.c:
	* macosx/tkMacOSXCursor.c:
	* macosx/tkMacOSXDebug.c:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXHLEvents.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXNotify.c:
	* macosx/tkMacOSXRegion.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:
	* macosx/ttkMacOSXTheme.c:
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.11 2007/06/09 17:09:39 das Exp $
d303 1
a303 1
 *	Sets fore or back color in the current QD port from an X pixel
d370 2
d526 2
@


1.11
log
@	* macosx/tkMacOSXColor.c: fix issues with TK_{IF,ELSE,ENDIF} macros;
	* macosx/tkMacOSXDraw.c:  implement Jaguar equivalent of unavailable
	* macosx/tkMacOSXEntry.c: kHIToolboxVersion global; panic at startup
	* macosx/tkMacOSXEvent.c: if MAC_OS_X_VERSION_MIN_REQUIRED constraint
	* macosx/tkMacOSXInit.c:  is not satisfied.
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage)
	(TkMacOSXSetupDrawingContext): factor out common code and standardize
	setup/restore of port, context and clipping; formatting cleanup.

	* macosx/tkMacOSXWindowEvent.c:	add error checking.
	* macosx/tkMacOSXMenu.c:	fix gcc3 warning.
	* macosx/tkMacOSXScrlbr.c:	fix testsuite crash.
	* macosx/tkMacOSXSubwindows.c:	formatting cleanup.
	* macosx/tkMacOSXRegion.c:	fix typos.
	* macosx/tkMacOSXScale.c:

	* macosx/tkMacOSXXStubs.c (Tk_GetUserInactiveTime): remove superfluous
							    CFRetain/CFRelease.

	* macosx/Wish-Release.xcconfig: disable tktest release build stripping.

	* macosx/Wish.xcodeproj/project.pbxproj: add new Tclsh-Info.plist.in.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.10 2007/06/06 09:55:52 das Exp $
d19 1
a19 1
#include "tkMacOSXInt.h"
d201 5
a205 2
GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush,
	ThemeTextColor *textColor, ThemeBackgroundKind *background)
d240 6
a245 2
GetThemeColor(unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor,
	ThemeBackgroundKind background, RGBColor *c)
d318 5
a322 1
TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat)
d329 1
d333 2
a334 1
	CGrafPtr port;
d336 1
a336 1
	GetPort(&port);
d343 1
d363 1
a363 1
	if (penPat && err == noErr && !textColor) {
d365 1
d367 6
d396 3
a398 1
TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context)
d473 1
a473 1
	    TkMacOSXSetColorInPort(pixel, 1, pixpat);
@


1.10
log
@	* macosx/tkMacOSXMouseEvent.c (GenerateMouseWheelEvent): enable
	processing of mousewheel events in background windows.

	* macosx/tkMacOSXScrlbr.c: modernize checks for active/front window.
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXColor.c: factor out verbose #ifdef checks of
	* macosx/tkMacOSXDraw.c:  MAC_OS_X_VERSION_{MAX_ALLOWED,MIN_REQUIRED}
	* macosx/tkMacOSXEntry.c: and runtime checks of kHIToolboxVersion into
	* macosx/tkMacOSXEvent.c: new TK_{IF,ELSE,ENDIF}_MAC_OS_X macros.
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDraw.c:  factor out clip clearing in QD ports;
	* macosx/tkMacOSXEntry.c: formatting cleanup.

	* macosx/Wish.xcodeproj/project.pbxproj: add settings for Fix&Continue.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.9 2007/05/31 13:38:13 das Exp $
d389 1
a389 1
		TK_IF_MAC_OS_X_API_COND (4, err == noErr, HIThemeSetFill,
d392 2
a393 2
		) TK_ENDIF_MAC_OS_X
	    ) TK_ENDIF_MAC_OS_X
d398 1
a398 1
	    ) TK_ENDIF_MAC_OS_X
d406 1
a406 1
		    TK_IF_MAC_OS_X_HI_TOOLBOX (3, /* c.f. QA1377 */
d409 3
a411 3
		    ) TK_ENDIF_MAC_OS_X
		) TK_ENDIF_MAC_OS_X
	    ) TK_ENDIF_MAC_OS_X
d445 1
a445 1
		TK_IF_MAC_OS_X_HI_TOOLBOX (4,
d447 1
a447 1
		) TK_ENDIF_MAC_OS_X
@


1.9
log
@	* macosx/tkMacOSXWindowEvent.c (GenerateUpdateEvent): complete all
	pending idle-time redraws before newly posted Expose events are
	processed; add bounds of redrawn windows to update region to ensure all
	child windows overdrawn by parents are redrawn.

	* macosx/tkMacOSXWindowEvent.c:	centralize clip and window invalidation
	* macosx/tkMacOSXSubwindows.c:	after location/size changes in the
	* macosx/tkMacOSXWm.c:		BoundsChanged carbon event handler;
	correct/add window invalidation after window attribute changes.

	* macosx/tkMacOSXSubwindows.c (XResizeWindow, XMoveResizeWindow,
	XMoveWindow): factor out common code dealing with embedded and
	non-toplevel windows; remove unnecessary clip and window invalidation.

	* macosx/tkMacOSXButton.c (TkpDisplayButton): move clip setup closer to
	native button drawing calls.

	* macosx/tkMacOSXWm.c (TkMacOSXIsWindowZoomed, TkMacOSXZoomToplevel):
	correct handle gridded windows in max size calculations.

	* macosx/tkMacOSXEvent.c (TkMacOSXFlushWindows): use HIWindowFlush API
	when available.

	* macosx/tkMacOSXColor.c:	cleanup whitespace and formatting.
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWm.c:
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.8 2007/04/23 21:24:33 das Exp $
a384 1
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
d386 1
a386 5
	    if (1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
		    && HIThemeSetFill != NULL && HIThemeSetStroke != NULL
#endif
	    ) {
d389 1
a389 1
		if (err == noErr) {
d392 2
a393 2
		}
	    }
d395 1
a395 5
	    if (1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
		    && HIThemeSetTextFill != NULL
#endif
	    ) {
d398 3
a400 13
	    }
	} else
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
	if (background) {
	    if (1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
		    && CGContextGetClipBoundingBox != NULL
		    && HIThemeApplyBackground != NULL
		    && &kHIToolboxVersionNumber != NULL /* c.f. QA1377 */
		    && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3
#endif
	    ) {
d405 7
a411 3
		err = ChkErr(HIThemeApplyBackground, &rect, &info, context,
			kHIThemeOrientationNormal);
	    }
a412 1
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
d445 3
a447 11
		bitmapInfo =
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
			(1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
			&& &kHIToolboxVersionNumber != NULL
			&& kHIToolboxVersionNumber >=
				kHIToolboxVersionNumber10_4
#endif
			) ? kCGBitmapByteOrder32Host :
#endif
			0;
@


1.8
log
@	* macosx/tkMacOSXCarbonEvents.c: add window event target carbon event
	* macosx/tkMacOSXEvent.c:	 handler for all kEventClassWindow and
	* macosx/tkMacOSXEvent.h:	 kEventClassMouse events;
	* macosx/tkMacOSXNotify.c:	 move all remaining events except for
	* macosx/tkMacOSXWindowEvent.c:	 kEventClassKeyboard from dispatcher to
	application event handler; pass event handler callRef downstream; fix
	debug event tracing; process all tcl event types in carbon event timer;
	delay carbon event timer first fire; add TkMacOSXTrackingLoop() to mark
	enter/exit of event tracking loop during which all tcl events but only
	carbon update events should be processed by the timer (replaces various
	calls to Tcl_SetServiceMode()); rename TkMacOSXReceiveAndProcessEvent()
	to TkMacOSXReceiveAndDispatchEvent(), move it from tkMacOSXEvent.c to
	tkMacOSXCarbonEvents.c and modify it to dequeue only update events
	during a tracking loop; add TkMacOSXRunTclEventLoop() to standardize
	the various ways in use to run the tcl event loop; add handling of
	kEventClassAppearance events (for ScrollBarVariantChanged event).

	* macosx/tkMacOSXDialog.c:	use new TkMacOSXTrackingLoop() around
	* macosx/tkMacOSXEvent.c:	blocking API that puts up modal dialogs
	* macosx/tkMacOSXMenu.c:	or when entering/exiting menu/control
	* macosx/tkMacOSXMouseEvent.c:	tracking, window dragging and other
	* macosx/tkMacOSXScale.c:	mouse tracking loops.
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDialog.c:	use new TkMacOSXRunTclEventLoop()
	* macosx/tkMacOSXScale.c:	instead of Tcl_DoOneEvent(),
	* macosx/tkMacOSXScrlbr.c:	Tcl_ServiceAll(), TclServiceIdle()
	* macosx/tkMacOSXWindowEvent.c:	and Tcl_GlobalEval("update idletasks").

	* macosx/tkMacOSXColor.c: make available as Tk system colors all
	* macosx/tkMacOSXPort.h:  appearance manager brushes, text colors and
	backgrounds with new and legacy names, as well as the fully transparent
	color "systemTransparent"; add TkMacOSXSetColorIn{Port,Context}() to
	directly set an X pixel color value in the current QD port resp. the
	given CG context without requiring passage through rgb representation
	(lossy for most system colors); modernize/remove Classic-era code;
	replace crufty strcmp() elseifs by Tcl_GetIndexFromObjStruct().

	* macosx/tkMacOSXButton.c:	use new TkMacOSXSetColorInPort()
	* macosx/tkMacOSXDraw.c:	instead of setting rgb color directly
	* macosx/tkMacOSXMenubutton.c:	to allow for non-rgb system colors.

	* macosx/tkMacOSXCursor.c: implement "none" cursor as on other
	platforms [Patch 1615427]; add all missing appearance manager cursors.

	* macosx/tkMacOSXDefault.h: set SELECT_FG_COLORs to None to match aqua
	L&F; use standard system color names; use new 'menu' system font;
	correct default scrollbar width.

	* macosx/tkMacOSXDraw.c:	standardize initialization, use and
	* macosx/tkMacOSXInt.h:		emptying of various static temp rgns
	* macosx/tkMacOSXRegion.c:	onto two global RgnHandles; in debug
	* macosx/tkMacOSXSubwindows.c:	builds, verify emptiness of these temp
	* macosx/tkMacOSXWindowEvent.c:	rgns before use.

	* macosx/tkMacOSXDraw.c: add TkMacOSX{Setup,Restore}DrawingContext() to
	* macosx/tkMacOSXInt.h:  abstract common setup & teardown of drawing
	environment (for both CG and QD); save/restore QD theme drawing state;
	handle GC clip region; add TkpClipDrawableToRect() to allow clipped
	drawing into drawable regardless of GC used; use new system color
	"systemWindowHeaderBackground" to setup background in themed toplevels;
	correct implementation of TkMacOSXMakeStippleMap().

	* macosx/tkMacOSXEntry.c:  use new TkMacOSXSetupDrawingContext() and
	* macosx/tkMacOSXFont.c:   TkMacOSXRestoreDrawingContext() instead of
	* macosx/ttkMacOSXTheme.c: various setup/teardown procs like
	TkMacOSX{SetUp,Release}CGContext(), TkMacOSXQuarz{Start,End}Draw(),
	TkMacOSXSetUpGraphicsPort() etc.

	* macosx/tkMacOSXEmbed.c: add CG context and drawable clip rgn fields
	* macosx/tkMacOSXInt.h:   to MacDrawable struct.
	* macosx/tkMacOSXSubwindows.c:

	* macosx/tkMacOSXDialog.c: make -parent option of tk_getOpenFile et al.
	use the sheet version of NavServices dialogs; ensure native parent win
	exists before using StandardSheet API for tk_messageBox [Bug 1677611];
	force sheets to behave like app-modal dialogs via WindowModality() API;
	use more modern ColorPicker API.

	* macosx/tkAboutDlg.r: use themed movable modal dialog, fix (c) year.

	* macosx/tkMacOSXEntry.c:  take xOff/yOff of MacDrawable into account
	* macosx/ttkMacOSXTheme.c: when computing locations/bounds to ensure
	correct posititioning when not drawing into intermediate pixmap.

	* macosx/tkMacOSXFont.c: use appearance manager API to map system font
	* macosx/tkMacOSXFont.h: names to TkFonts; add "menu" system font for
	menu item text drawing from MDEF; always draw with CG; remove QD
	dependent stippling algorithm; move most header declarations into the
	source file (as they were not used anywhere else).

	* macosx/tkMacOSXMenu.c:		 large-scale rewrite of custom
	* macosx/tkMacOSXMenu.r (removed):	 MDEF and related code that
	* macosx/Wish.xcode/project.pbxproj:	 restores many longtime-MIA
	* macosx/Wish.xcodeproj/project.pbxproj: features to working order
	* unix/Makefile.in:			 (e.g. images, custom colors &
	fonts in menus etc); implement compound menu items; use Appearance Mgr
	and ThemeText APIs to mimic native MDEF as closely as possible when
	default "menu" system font is used; remove now obsolete SICN drawing
	code and resources.

	* macosx/tkMacOSXCarbonEvents.c: handle additional menu carbon events
	* macosx/tkMacOSXEvent.c:	 in order to support <<MenuSelect>> in
	* macosx/tkMacOSXMenu.c:	 the menubar and in menus that are not
	* macosx/tkMacOSXMenus.c:	 using the custom MDEF [Bug 1620826];
	fix early and missing clearing of current Tk active menu entry; fix
	extraneous sending of <<MenuSelect>> during active menu entry clearing.

	* macosx/tkMacOSXMouseEvent.c: add support for async window dragging by
	the window server; set the corresponding window attribute by default.

	* macosx/tkMacOSXMouseEvent.c: rationalized handling order of
	non-mousedown events; add TkMacOSXModifierState() to retrieve the
	current key modifiers in carbon format.

	* macosx/tkMacOSXScrlbr.c: use appearance manager API to retrieve
	scrollbar component metrics; add awareness of multiple possibilites for
	scrollbar arrow position in aqua and handle user changes to arrow
	position pref; handle difference in metrics of small & large scrollbar
	variants; handle aqua "jump to here" scrollbar behaviour; correct
	computation of scroll view size and position; enforce min scrollbar
	height to avoid scrollbar component overlap; erase scrollbar area
	outside of standard width; remove broken auto-adjust code; account for
	window class when leaving space for grow box; remove code to manually
	draw grow box; use modern API for thumb scroll proc; replace
	HiliteControl() by modern API; replace control mgr constants with
	appearance mgr equivalents.

	* macosx/tkMacOSXSubwindows.c: use SetWindowBounds() API instead of
	SizeWindow(); invalidate clip regions after X{Map,Unmap}Window as fix
	for [Bug 940117] made them dependent on mapping state; remove unneeded
	calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD port;
	use native-endian pixmap on intel; remove obsolete pixmap pix locking.

	* macosx/tkMacOSXWindowEvent.c: handle only the first of a batch of
	kEventAppAvailableWindowBoundsChanged events sent per transaction;
	handle kEventWindowBoundsChanged event to support live window resizing
	and centralized sending of location/size changed ConfigureNotify
	events; ensure HIGrowBox is redrawn after bounds change; constrain
	window after dragging to ensure titlebar is not inacessible
	offscreen or under dock/menubar; handle kEventWindowGetRegion and
	kEventWindowDrawContent for transparent windows to mark resp. paint
	content region as transparent; handle kEventWindowConstrain for
	fullscreen windows to ensure bounds match new screen size; enter/exit
	fullscreen UIMode upon activation/deactivation of fullscreen window.

	* macosx/tkMacOSXWm.c: use live-resize and async-drag carbon window
	* macosx/tkMacOSXWm.h: attributes for toplevels by default; implement
	new [wm attributes] -topmost, -transparent and -fullscreen; refactor
	WmAttributesCmd() parallelling the tkUnixWm.c implementation, use thus
	factored proc to set proxy icon from [wm iconbitmap]; dynamically
	determine default values for toplevel min and max sizes (similar to
	tkWinWm.c impl): min sizes depend on window class & attributes to
	ensure visibility of all titlebar widgets and grow box, max sizes
	depend on maximal window bounds for all active displays; factor out
	code that puts into effect changes to master or override_redirect; use
	RepositionWindow() API to determine staggered initial window bounds;
	correct resize limit calculations, handle gridding and use modern
	resize API in TkMacOSXGrowToplevel(); remove sending of ConfigureNotify
	after resize or zoom (now handled by BoundsChanged handler); correct
	composite carbon window attribute handling, remove currently unusable
	attributes and add new attributes in [tk::unsupported::MacWindowStyle];
	ensure validity of window class and attributes before use; apply
	changes to window class when handling carbon window attribute changes
	(if HIWindowChangeClass() API available); add debug build warning
	message when deprecated window style is used instead of window class;
	use transparent HIGrowBox for resizable windows; avoid unnecessary
	calls to window structure width API; use tcl time API in TkpGetMS();
	add TkMacOSXEnterExitFullscreen() to enter/exit UIMode with dock and
	menubar hidden; restrict wmTracing output to debug builds; remove
	unneeded calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD
	port; workaround GetWindowStructureWidths() Carbon bug (bogus results
	for never-mapped floating windows).

	* macosx/tkMacOSXXStubs.c (TkMacOSXDisplayChanged): add maximal window
	bounds field to Screen record (in ext_data), computed as the union of
	available window positioning bounds of all graphics devices (displays).

	* macosx/tkMacOSXBitmap.c: fix macRoman encoding leak.
	* macosx/tkMacOSXCursor.c:

	* macosx/tkMacOSXDebug.c (TkMacOSXCarbonEventToAscii): use static
	* macosx/tkMacOSXDebug.h: buffer to simplify callers; const fixes.

	* macosx/tkMacOSXBitmap.c: use more efficient QDSwapPort() instead of
	* macosx/tkMacOSXButton.c: GetPort()/SetPort()/GetGWorld()/SetGWorld().
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXXStubs.c:

	* macosx/tkMacOSXColor.c: use kHIToolboxVersionNumber for runtime OS
	* macosx/tkMacOSXEntry.c: version check rather than Gestalt() etc.
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDraw.c: remove obsolete and now incorrect
	* macosx/tkMacOSXInt.h:  tkMenuCascadeRgn clipping code.
	* macosx/tkMacOSXMenu.c:

	* macosx/tkMacOSXHLEvents.c: replace Tcl_GlobalEval() resp. Tcl_Eval()
	* macosx/tkMacOSXScrlbr.c:   by Tcl_EvalEx().
	* macosx/tkMacOSXInit.c:

	* macosx/tkMacOSXInit.c (TkpInit): reorder initialization steps.

	* macosx/tkMacOSXKeyEvent.c: remove pre-10.2 support.

	* macosx/tkMacOSXMenus.c: remove now useless call to
	TkMacOSXHandleTearoffMenu(); use \x.. quoting for non-latin1 macroman
	literar chars to allow file to be edited as utf-8.

	* macosx/tkMacOSXScale.c: replace TrackControl() by modern
	* macosx/tkMacOSXScrlbr.c: HandleControlClick() API (using new
	TkMacOSXModifierState()).

	* macosx/tkMacOSXInt.h:		move all constant #defines needed to
	* macosx/tkMacOSXColor.c:	support building on older OS X releases
	* macosx/tkMacOSXEvent.h:	to a central location in tkMacOSXInt.h.
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/ttkMacOSXTheme.c:

	* macosx/tkMacOSXInt.h:		 add ChkErr() macro to factor out
	* macosx/tkMacOSXButton.c:	 Carbon OSStatus return value checking
	* macosx/tkMacOSXCarbonEvents.c: and TkMacOSXDbgMsg() macro to factour
	* macosx/tkMacOSXClipboard.c:	 out debug message output; use these
	* macosx/tkMacOSXColor.c:	 macros to replace #ifdef TK_MAC_DEBUG
	* macosx/tkMacOSXCursor.c:	 blocks & direct printing to stderr,
	* macosx/tkMacOSXDebug.c:	 and to do additional OSStatus return
	* macosx/tkMacOSXDialog.c:	 checking, and to standardize OSStatus
	* macosx/tkMacOSXDraw.c:	 usage.
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXHLEvents.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:

	* macosx/tkMacOSXSend.c:	remove duplicate/unused declarations
	* macosx/tkMacOSXXStubs.c:

	* macosx/tkMacOSXDebug.c:	const fixes.
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXTest.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:

	* macosx/Wish-Info.plist.in: add tcl document extensions/mime types and
	LSMinimumSystemVersion, LSRequiresCarbon & NSAppleScriptEnabled keys.

	* macosx/Wish-Common.xcconfig: add Wish's Info.plist as __info_plist
	section to tktest; enable more warnings.

	* macosx/Wish.xcodeproj/project.pbxproj: add 'DebugMemCompile' build
	configuration that calls configure with --enable-symbols=all; disable
	configure check for __attribute__((__visibility__("hidden"))) in Debug
	configuration to restore availability of ZeroLink.

	* macosx/Wish-Common.xcconfig:	fix whitespace.
	* macosx/Wish-Debug.xcconfig:
	* macosx/Wish-Release.xcconfig:
	* macosx/tkMacOSXAETE.r:
	* macosx/tkMacOSXConfig.c:
	* macosx/tkMacOSXCursors.r:
	* macosx/tkMacOSXKeyboard.c:
	* macosx/tkMacOSXSend.c:
	* macosx/ttkMacOSXTheme.c:
	* macosx/tkMacOSXXCursors.r:
	* macosx/README:

	* macosx/GNUmakefile:		fix/add copyright and license refs.
	* macosx/Tk-Info.plist.in:
	* macosx/Wish-Info.plist.in:
	* macosx/Wish.xcode/project.pbxproj:
	* macosx/Wish.xcodeproj/project.pbxproj:
	* macosx/tkMacOSX.h:
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.7 2006/11/03 03:05:03 das Exp $
d465 3
a467 2
		    && &kHIToolboxVersionNumber != NULL
		    && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_4
d469 1
a469 1
		    ) ? kCGBitmapByteOrder32Host :
d471 1
a471 1
		    0;
@


1.8.2.1
log
@merge updates from HEAD
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.8 2007/04/23 21:24:33 das Exp $
d465 2
a466 3
			&& &kHIToolboxVersionNumber != NULL
			&& kHIToolboxVersionNumber >=
				kHIToolboxVersionNumber10_4
d468 1
a468 1
			) ? kCGBitmapByteOrder32Host :
d470 1
a470 1
			0;
@


1.8.2.2
log
@merge updates from HEAD
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.8.2.1 2007/06/01 04:01:32 dgp Exp $
d385 1
d387 5
a391 1
	    TK_IF_MAC_OS_X_API (4, HIThemeSetFill,
d394 1
a394 1
		TK_IF_MAC_OS_X_API_COND (4, HIThemeSetFill, err == noErr,
d397 2
a398 2
		) TK_ENDIF
	    ) TK_ENDIF
d400 5
a404 1
	    TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill,
d407 13
a419 3
	    ) TK_ENDIF
	} else if (background) {
	    TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
d424 3
a426 7
		TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground,
		    TK_IF_HI_TOOLBOX (3, /* c.f. QA1377 */
			err = ChkErr(HIThemeApplyBackground, &rect, &info,
				context, kHIThemeOrientationNormal);
		    ) TK_ENDIF
		) TK_ENDIF
	    ) TK_ENDIF
d428 1
d461 11
a471 3
		TK_IF_HI_TOOLBOX (4,
		    bitmapInfo = kCGBitmapByteOrder32Host;
		) TK_ENDIF
@


1.8.2.3
log
@merge updates from HEAD
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id$
d19 1
a19 1
#include "tkMacOSXPrivate.h"
d201 2
a202 5
GetThemeFromPixelCode(
    unsigned char code,
    ThemeBrush *brush,
    ThemeTextColor *textColor,
    ThemeBackgroundKind *background)
d237 2
a238 6
GetThemeColor(
    unsigned long pixel,
    ThemeBrush brush,
    ThemeTextColor textColor,
    ThemeBackgroundKind background,
    RGBColor *c)
d311 1
a311 5
TkMacOSXSetColorInPort(
    unsigned long pixel,
    int fg,
    PixPatHandle penPat,
    CGrafPtr port)
a317 1
    int setPenPat = 0;
d321 1
a321 2
	CGrafPtr savePort;
	Boolean portChanged;
d323 1
a323 1
	portChanged = QDSwapPort(port, &savePort);
a329 1
		    setPenPat = 1;
d349 1
a349 1
	if (penPat && err == noErr && (brush || background)) {
a350 1
	    setPenPat = 1;
a351 6
	if (portChanged) {
	    QDSwapPort(savePort, NULL);
	}
    }
    if (penPat && !setPenPat) {
	GetPortBackPixPat(port, penPat);
d375 1
a375 3
TkMacOSXSetColorInContext(
    unsigned long pixel,
    CGContextRef context)
d450 1
a450 1
	    TkMacOSXSetColorInPort(pixel, 1, pixpat, patGWorld);
@


1.8.2.4
log
@merge updates from HEAD
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.8.2.3 2007/07/01 17:31:32 dgp Exp $
d303 1
a303 1
 *	Sets fore or back color in the given QD port from an X pixel
a369 2
    } else {
	TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
a523 2
    } else {
	TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
@


1.8.2.5
log
@merge updates from HEAD
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.8.2.4 2007/07/03 02:28:13 dgp Exp $
d256 3
a258 6
	c->red	  = (pixel >> 16) & 0xff;
	c->green  = (pixel >>  8) & 0xff;
	c->blue	  = (pixel	) & 0xff;
	c->red	 |= c->red   << 8;
	c->green |= c->green << 8;
	c->blue	 |= c->blue  << 8;
@


1.7
log
@	* macosx/tkMacOSXColor.c (TkMacOSXCompareColors): ifdef out when unused.
@
text
@d1 1
a1 1
/* 
d4 3
a6 3
 *        This file maintains a database of color values for the Tk
 *        toolkit, in order to avoid round-trips to the server to
 *        map color names to pixel values.
d11 1
d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.6 2006/09/11 14:41:04 das Exp $
d22 3
a24 3
/* Define constants only available on Mac OS X 10.3 or later */
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
    #define kThemeBrushAlternatePrimaryHighlightColor -5
d27 171
a197 4
/*
 * Default Auxillary Control Record for all controls.  This is cached once
 * and is updated by the system.  We use this to get the default system
 * colors used by controls.
a198 4
/*
 * Stubbed out for OS X
static AuxCtlHandle defaultAuxCtlHandle = NULL;
*/
d200 20
d221 13
a233 1
 * Forward declarations for procedures defined later in this file:
d236 19
a254 3
static int        GetControlPartColor _ANSI_ARGS_((short part, RGBColor *macColor));
static int        GetMenuPartColor _ANSI_ARGS_((int part, RGBColor *macColor));
static int        GetWindowPartColor _ANSI_ARGS_((short part, RGBColor *macColor));
d261 2
a262 2
 *        Populates a Macintosh RGBColor structure from a X style
 *        pixel value.
d265 1
a265 1
 *        Returns false if not a real pixel, true otherwise.
d268 1
a268 1
 *        The variable macColor is updated to the pixels value.
d275 2
a276 2
    unsigned long pixel,        /* Pixel value to convert. */
    RGBColor *macColor)                /* Mac color struct to modify. */
d278 9
a286 63
    OSStatus err;

    switch (pixel >> 24) {
        case HIGHLIGHT_PIXEL:
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
            return true;
        case HIGHLIGHT_SECONDARY_PIXEL:
            err = GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
            return true;
        case HIGHLIGHT_ALTERNATE_PIXEL:
            err = GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
            return true;
        case HIGHLIGHT_TEXT_PIXEL:
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
            if ((macColor->red == 0) && (macColor->green == 0)
                    && (macColor->blue == 0)) {
                macColor->red = macColor->green = macColor->blue = 0xFFFF;
            } else {
                macColor->red = macColor->green = macColor->blue = 0;
            }
            return true;
        case CONTROL_TEXT_PIXEL:
            GetControlPartColor(cTextColor, macColor);
            return true;
        case CONTROL_BODY_PIXEL:
            GetControlPartColor(cBodyColor, macColor);
            return true;
        case CONTROL_FRAME_PIXEL:
            GetControlPartColor(cFrameColor, macColor);
            return true;
        case WINDOW_BODY_PIXEL:
            GetWindowPartColor(wContentColor, macColor);
            return true;
        case MENU_ACTIVE_PIXEL:
        case MENU_ACTIVE_TEXT_PIXEL:
        case MENU_BACKGROUND_PIXEL:
        case MENU_DISABLED_PIXEL:
        case MENU_TEXT_PIXEL:
            return GetMenuPartColor((pixel >> 24), macColor);
        case APPEARANCE_PIXEL:
            return false;
        case PIXEL_MAGIC:
        default:
            macColor->blue = (unsigned short) ((pixel & 0xFF) << 8);
            macColor->green = (unsigned short) (((pixel >> 8) & 0xFF) << 8);
            macColor->red = (unsigned short) (((pixel >> 16) & 0xFF) << 8);
            return true;
d288 1
a290 1
#if !TK_DRAW_IN_CONTEXT
d294 1
a294 1
 * TkMacOSXCompareColors --
d296 4
a299 3
 *        On Mac, color codes may specify symbolic values like "highlight
 *        foreground", but we really need the actual values to compare.
 *        Maybe see also: "TIP #154: Add Named Colors to Tk".
d302 1
a302 1
 *        Returns true if both colors are the same, false otherwise.
d305 1
a305 1
 *        None.
d310 2
a311 4
int
TkMacOSXCompareColors(
    unsigned long c1,
    unsigned long c2)
d313 40
a352 4
    RGBColor col1, col2;
    return  TkSetMacColor(c1,&col1) && 
	    TkSetMacColor(c1,&col2) &&
	    !memcmp(&col1,&col2,sizeof(col1));
a353 1
#endif /* !TK_DRAW_IN_CONTEXT */
d358 1
a358 1
 * Stub functions --
d360 4
a363 2
 *        These functions are just stubs for functions that either
 *        don't make sense on the Mac or have yet to be implemented.
d366 1
a366 1
 *        None.
d369 1
a369 1
 *        These calls do nothing - which may not be expected.
a373 26
Status
XAllocColor(
    Display *display,                /* Display. */
    Colormap map,                /* Not used. */
    XColor *colorPtr)                /* XColor struct to modify. */
{
    display->request++;
    colorPtr->pixel = TkpGetPixel(colorPtr);
    return 1;
}

Colormap
XCreateColormap(
    Display *display,                /* Display. */
    Window window,                /* X window. */
    Visual *visual,                /* Not used. */
    int alloc)                        /* Not used. */
{
    static Colormap index = 1;
    
    /*
     * Just return a new value each time.
     */
    return index++;
}

d375 1
a375 3
XFreeColormap(
    Display* display,                /* Display. */
    Colormap colormap)                /* Colormap. */
d377 46
a422 1
}
d424 101
a524 13
void
XFreeColors(
    Display* display,                /* Display. */
    Colormap colormap,                /* Colormap. */
    unsigned long* pixels,        /* Array of pixels. */
    int npixels,                /* Number of pixels. */
    unsigned long planes)        /* Number of pixel planes. */
{
    /*
     * The Macintosh version of Tk uses TrueColor.  Nothing
     * needs to be done to release colors as there really is
     * no colormap in the Tk sense.
     */
d532 1
a532 1
 *        Allocate a new TkColor for the color with the given name.
d535 1
a535 1
 *        Returns a newly allocated TkColor, or NULL on failure.
d538 3
a540 3
 *        May invalidate the colormap cache associated with tkwin upon
 *        allocating a new colormap entry.  Allocates a new TkColor
 *        structure.
d547 3
a549 3
    Tk_Window tkwin,                /* Window in which color will be used. */
    Tk_Uid name)                /* Name of color to allocated (in form
                                 * suitable for passing to XParseColor). */
d557 1
a557 1
     * Check to see if this is a system color.  Otherwise, XParseColor
d561 24
a584 10
        OSStatus err;
	int foundSystemColor = false;
        RGBColor rgbValue;
        char pixelCode = 0;
        
        if (!strcasecmp(name+6, "Highlight")) {
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
d586 1
a586 89
            pixelCode = HIGHLIGHT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "HighlightSecondary")) {
            err = GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
            pixelCode = HIGHLIGHT_SECONDARY_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "HighlightAlternate")) {
            err = GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
            pixelCode = HIGHLIGHT_ALTERNATE_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "HighlightText")) {
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
            if ((rgbValue.red == 0) && (rgbValue.green == 0)
                    && (rgbValue.blue == 0)) {
                rgbValue.red = rgbValue.green = rgbValue.blue = 0xFFFF;
            } else {
                rgbValue.red = rgbValue.green = rgbValue.blue = 0;
            }
            pixelCode = HIGHLIGHT_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "ButtonText")) {
            GetControlPartColor(cTextColor, &rgbValue);
            pixelCode = CONTROL_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "ButtonFace")) {
            GetControlPartColor(cBodyColor, &rgbValue);
            pixelCode = CONTROL_BODY_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "ButtonFrame")) {
            GetControlPartColor(cFrameColor, &rgbValue);
            pixelCode = CONTROL_FRAME_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "WindowBody")) {
            GetWindowPartColor(wContentColor, &rgbValue);
            pixelCode = WINDOW_BODY_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuActive")) {
            GetMenuPartColor(MENU_ACTIVE_PIXEL, &rgbValue);
            pixelCode = MENU_ACTIVE_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuActiveText")) {
            GetMenuPartColor(MENU_ACTIVE_TEXT_PIXEL, &rgbValue);
            pixelCode = MENU_ACTIVE_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "Menu")) {
            GetMenuPartColor(MENU_BACKGROUND_PIXEL, &rgbValue);
            pixelCode = MENU_BACKGROUND_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuDisabled")) {
            GetMenuPartColor(MENU_DISABLED_PIXEL, &rgbValue);
            pixelCode = MENU_DISABLED_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuText")) {
            GetMenuPartColor(MENU_TEXT_PIXEL, &rgbValue);
            pixelCode = MENU_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "AppearanceColor")) {
            color.red = 0;
            color.green = 0;
            color.blue = 0;
            pixelCode = APPEARANCE_PIXEL;
            foundSystemColor = true;
        }
        
        if (foundSystemColor) {
            color.red = rgbValue.red;
            color.green = rgbValue.green;
            color.blue = rgbValue.blue;
            color.pixel = ((((((pixelCode << 8)
                | ((color.red >> 8) & 0xff)) << 8)
                | ((color.green >> 8) & 0xff)) << 8)
                | ((color.blue >> 8) & 0xff));
            
            tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
            tkColPtr->color = color;
            return tkColPtr;
        }
d588 1
a588 1
    
d590 1
a590 1
        return (TkColor *) NULL;
d592 2
a593 1
    
d605 3
a607 3
 *        Given a desired set of red-green-blue intensities for a color,
 *        locate a pixel value to use to draw that color in a given
 *        window.
d610 4
a613 4
 *        The return value is a pointer to an TkColor structure that
 *        indicates the closest red, blue, and green intensities available
 *        to those specified in colorPtr, and also specifies a pixel
 *        value to use to draw in that color.
d616 2
a617 2
 *        May invalidate the colormap cache for the specified window.
 *        Allocates a new TkColor structure.
d624 3
a626 3
    Tk_Window tkwin,                /* Window in which color will be used. */
    XColor *colorPtr)                /* Red, green, and blue fields indicate
                                 * desired color. */
d637 1
d641 1
a641 1
 * GetControlPartColor --
d643 3
a645 4
 *        Given a part number this function will return the standard
 *        system default color for that part.  On MacOS X this uses the
 *        Theme Brushes to find the active color, though for now, only
 *        the "Text Color" is supported.
d648 1
a648 1
 *        True if a color is found, false otherwise.
d651 1
a651 2
 *        If a color is found then the RGB variable will be changed to
 *        the parts color.
d656 9
a664 20
static int 
GetControlPartColor(
    short part,                 /* Part code. */
    RGBColor *macColor)                /* Pointer to Mac color. */
{
    int retVal = false;
    OSErr err; 
    
    switch (part) {
        case cTextColor:
            err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32, 
                    true, macColor);
            if (err == noErr) {
                retVal = true;
            }
            break;
        default:
            retVal = false;
    }
    return retVal;
d666 1
d671 1
a671 1
 * GetWindowPartColor --
d673 2
a674 3
 *      Given a part number this function will return the standard
 *      system default color for that part.  It does this by looking
 *      in the system's 'wctb' resource.
d677 1
a677 1
 *      True if a color is found, false otherwise.
d680 1
a680 2
 *      If a color is found then the RGB variable will be changed to
 *      the parts color.
d685 31
a715 24
static int
GetWindowPartColor(
    short part,                 /* Part code. */
    RGBColor *macColor)         /* Pointer to Mac color. */
{
    short index;
    WCTabHandle wcTab;

    if (part == wContentColor) {
        GetThemeBrushAsColor(kThemeBrushDocumentWindowBackground,
                0xFFFF, true, macColor);
        return true;
    } else {
        wcTab = (WCTabHandle) GetResource('wctb', 0);
        if(wcTab && (ResError() == noErr)) {
            for(index = 0; index <= (**wcTab).ctSize; index++) {
                if((**wcTab).ctTable[index].value == part) {
                    *macColor = (**wcTab).ctTable[index].rgb;
                    return true;
                }
            }
        }
        return false;
    }
a716 18

/*
 *----------------------------------------------------------------------
 *
 * GetMenuPartColor --
 *
 *        Given a magic pixel value, returns the RGB color associated
 *        with it by looking the value up in the system's 'mctb' resource.
 *
 * Results:
 *        True if a color is found, false otherwise.
 *
 * Side effects:
 *        If a color is found then the RGB variable will be changed to
 *        the parts color.
 *
 *----------------------------------------------------------------------
 */
d718 13
a730 14
static int
GetMenuPartColor(
    int pixel,                        /* The magic pixel value */
    RGBColor *macColor)                /* Pointer to Mac color */
{
    
    /* Under Appearance, we don't want to set any menu colors when we
       are asked for the standard menu colors.  So we return false (which
       means don't use this color... */
       
        macColor->red = 0xFFFF;
        macColor->green = 0;
        macColor->blue = 0;
        return false;
@


1.6
log
@	* macosx/tkMacOSXWm.c (TkMacOSXMakeRealWindowExist): revert part of
	2006-05-16 change that had set overrideredirect windows to not become
	activated by the window manager, as this prevented interaction with
	native widgets in such windows [Bug 1472624]; apply changes to carbon
	window attributes even if native window has already been created.

	* macosx/tkMacOSXKeyEvent.c (TkMacOSXProcessKeyboardEvent): fix app
	* macosx/tkMacOSXMenu.c (DrawMenuBarWhenIdle): menu item key shortcuts
	* macosx/tkMacOSXInt.h: when custom ".apple" menu is installed.

	* library/demos/widget: on TkAqua, don't install file menu with single
	quit menu item, as the application menu already has a quit item.

	* macosx/tkMacOSXColor.c: fix building on Mac OS X 10.2.
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.5 2006/09/10 17:06:32 das Exp $
d132 1
d161 1
@


1.5
log
@	* macosx/tkMacOSXColor.c (TkSetMacColor, TkpGetColor): use AppearanceMgr
	* macosx/tkMacOSXDefault.h: to retrieve platform std colors for text
	* macosx/tkMacOSXPort.h:    selections, add "systemHighlightSecondary"
	color name for standard color of inactive selections, use this color as
	default for text widget -inactiveselectbackground to implement platform
	standard look for inactive text selections.

	* library/text.tcl (aqua): remove focus bindings to set selection color.

	* generic/tkTextBTree.c (TkTextIsElided): on TkAqua, don't show inactive
	* generic/tkTextDisp.c (GetStyle):        text selection when text
	                                          widget is in disabled state.

	* generic/tkEntry.c (DisplayEntry): change default TkAqua selection
	* macosx/tkMacOSXDefault.h:         relief to "flat" (platform std).

	* generic/tkText.c (CreateWidget): fix bug leading to default text
	selection relief string DEF_TEXT_SELECT_RELIEF being ignored.

	* macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): allow mouse
	event delivery to background windows with kWindowNoActivatesAttribute
	(e.g. overrideredirect windows), as these never come to the foreground
	they would not receive any mouse events otherwise. [Bug 1472624]

	* macosx/tkMacOSXWindowEvent.c (TkMacOSXGenerateFocusEvent): do not
	send focus events to any windows with kWindowNoActivatesAttribute.

	* macosx/tkMacOSXXStubs.c (XQueryColor, XQueryColors): implement basic
	XColor computation from pixel values, enough to make tkImg's window.c
	happy, fixes img::window failures reported on tcl-mac.

	* macosx/tkMacOSXMenu.c (DrawMenuEntryLabel): fix leak. [Bug 1554672]

	* macosx/GNUmakefile: workaround bug in 'cp -pRH' on Darwin 6 and
	earlier, fixes 'make embedded' failure reported on tcl-mac; fix error
	from 'make deploy' with same build tree as previous 'make embedded'.

	* macosx/Wish.xcodeproj/project.pbxproj: add new tclUnixCompat.c file.

	* macosx/tkMacOSXEntry.c (TkpDrawEntryBorderAndFocus): fix typo.

	* unix/tcl.m4: sync with tcl/unix/tcl.m4.
	* unix/configure: autoconf-2.59
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.4 2006/03/24 14:58:01 das Exp $
d21 5
@


1.4
log
@	* generic/tkTextDisp.c:   moved #ifdef MAC_OSX_TK code added by
	* macosx/tkMacOSXColor.c: Patch #638966 into platform specific
	* macosx/tkMacOSXInt.h:   files.

	* macosx/tkMacOSX.h:             cleaned up & rationalized order of
	* macosx/tkMacOSXBitmap.c:       #includes of tk and carbon headers.
	* macosx/tkMacOSXButton.c:
	* macosx/tkMacOSXCarbonEvents.c:
	* macosx/tkMacOSXClipboard.c:
	* macosx/tkMacOSXColor.c:
	* macosx/tkMacOSXConfig.c:
	* macosx/tkMacOSXCursor.c:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXEmbed.c:
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXEvent.h:
	* macosx/tkMacOSXFont.h:
	* macosx/tkMacOSXHLEvents.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXKeyboard.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXRegion.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSend.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXWm.h:
	* macosx/tkMacOSXXStubs.c:
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.3 2003/07/03 18:47:03 wolfsuit Exp $
d61 2
d65 19
a83 1
            LMGetHiliteRGB(macColor);
d86 5
a90 1
            LMGetHiliteRGB(macColor);
d255 2
a256 1
        int foundSystemColor = false;
d261 5
a265 1
            LMGetHiliteRGB(&rgbValue);
d268 16
d285 5
a289 1
            LMGetHiliteRGB(&rgbValue);
@


1.3
log
@Prime the systemButtonText from the theme brush.  This is really only the first
stage of actually using the theme brushes to track active colors, but it gets
the labelframe color working at least.
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id$
a17 1
#include <tkColor.h>
d19 1
a19 1
#include <Carbon/Carbon.h>
d106 29
@


1.2
log
@	*** macosx-8-4-branch merged into the mainline [tcl patch #602770] ***

	* generic/tk.decls:
	* generic/tkInt.decls: added new "aqua" specific entries to the
	stubs tables. Changed all "unix" entries to "x11" to allow us to
	distinguish and build both "aqua" on MacOSX and "x11" on MacOSX.

	* generic/tk.h: added a #ifnded RESOURCE_INCLUDED so that tk.h can
	be passed to the resource compiler.

	* generic/tkCmds.c (Tk_TkObjCmd): added [tk windowingsystem]
	subcommand: returns "x11" when running on X11, "win32" on Windows,
	"classic" on MacOS9 and "aqua" on MacOSX Aqua (i.e. Carbon)

	* generic/tkFont.c (TkFontGetFirstTextLayout): new private function
	returning the first chunk of a Tk_TextLayout, i.e. until the first
	font change on the first line (or the whole first line if there is
	no such font change).

	* generic/tkMain.c: made Tcl_ThreadDataKey static

	* library/demos/puzzle.tcl: fixed button metrics for aqua

	* tests/cursor.test: check for presence of arrow cursor instead of
	heart cursor

	* xlib/xcolors.c: changed xColors static initialization to more
	standard C

	* macosx/Wish.pbproj/jingham.pbxuser (new):
	* macosx/Wish.pbproj/project.pbxproj (new): project for Apple's
	ProjectBuilder IDE.

	* macosx/Makefile (new): simple makefile for building the project
	from the command line via the ProjectBuilder tool 'pbxbuild'.

	* macosx/tkMacOSXAppInit.c (new): macosx specific AppInit looking
	for a AppMain.tcl file in its bundled Resources/Scripts folder. If
	present, argv[1] is set to that file and the Scripts folder is
	added to the auto_path. This allows tk apps to embed scripts within
	their bundle directory structure.

	* macosx/tkMacOSXInit.c (new): macosx adapted version of
	tkUnixInit.c: we initialize & cache the Carbon native encoding
	(e.g. 'macRoman') and try to find the tk script library files
	inside Tk packaged as a framework.

	* macosx/tkMacOSXNotify.c (new): new macosx specific merged
	Carbon/select-based notifier.

	* macosx/tkMacOSXEvent.c (new):
	* macosx/tkMacOSXEvent.h (new):
	* macosx/tkMacOSXKeyEvent.c (new):
	* macosx/tkMacOSXMouseEvent.c (new):
	* macosx/tkMacOSXWindowEvent.c (new): new macosx specific event
	handling functionality.

	* macosx/tkMacOSX.h (new):
	* macosx/tkMacOSXBitmap.c (new):
	* macosx/tkMacOSXButton.c (new):
	* macosx/tkMacOSXClipboard.c (new):
	* macosx/tkMacOSXColor.c (new):
	* macosx/tkMacOSXConfig.c (new):
	* macosx/tkMacOSXCursor.c (new):
	* macosx/tkMacOSXDefault.h (new):
	* macosx/tkMacOSXDialog.c (new):
	* macosx/tkMacOSXDraw.c (new):
	* macosx/tkMacOSXEmbed.c (new):
	* macosx/tkMacOSXFont.c (new):
	* macosx/tkMacOSXHLEvents.c (new):
	* macosx/tkMacOSXInt.h (new):
	* macosx/tkMacOSXKeyboard.c (new):
	* macosx/tkMacOSXMenu.c (new):
	* macosx/tkMacOSXMenubutton.c (new):
	* macosx/tkMacOSXMenus.c (new):
	* macosx/tkMacOSXPort.h (new):
	* macosx/tkMacOSXRegion.c (new):
	* macosx/tkMacOSXScale.c (new):
	* macosx/tkMacOSXScrlbr.c (new):
	* macosx/tkMacOSXSubwindows.c (new):
	* macosx/tkMacOSXTest.c (new):
	* macosx/tkMacOSXUtil.c (new):
	* macosx/tkMacOSXUtil.h (new):
	* macosx/tkMacOSXWm.c (new):
	* macosx/tkMacOSXWm.h (new):
	* macosx/tkMacOSXXStubs.c (new): macosx ports of classic mac Tk
	implementation in tk/mac.

	* macosx/tkMacOSXSend.c (new): only send to local interp
	implemented currently.

	* macosx/tkMacOSXDebug.h (new):
	* macosx/tkMacOSXDebug.c (new): new macosx specific functions for
	debugging MacOS events, regions, etc.

	* macosx/tkAboutDlg.r (new):
	* macosx/tkMacOSXApplication.r (new):
	* macosx/tkMacOSXCursors.r (new):
	* macosx/tkMacOSXLibrary.r (new):
	* macosx/tkMacOSXMenu.r (new):
	* macosx/tkMacOSXResource.r (new):
	* macosx/tkMacOSXXCursors.r (new):
	* macosx/tclets.r (new): sources for Rez resource compiler.

	* macosx/Wish.icns (new): Wish application icon.

	* generic/tk.h:
	* generic/default.h:
	* generic/tkBind.c:
	* generic/tkCmds.c:
	* generic/tkGrab.c:
	* generic/tkPointer.c:
	* generic/tkPort.h:
	* generic/tkSelect.c:
	* generic/tkStubLib.c:
	* generic/tkTest.c:
	* generic/tkText.c:
	* generic/tkWindow.c:
	* unix/tkUnix3d.c:
	* xlib/xgc.c:
	* xlib/X11/X.h:
	* xlib/X11/Xlib.h:
	* xlib/X11/Xutil.h: added #includes and #ifdefs for macosx

	* library/bgerror.tcl:
	* library/button.tcl:
	* library/console.tcl:
	* library/dialog.tcl:
	* library/entry.tcl:
	* library/listbox.tcl:
	* library/menu.tcl:
	* library/msgbox.tcl:
	* library/scrlbar.tcl:
	* library/spinbox.tcl:
	* library/text.tcl:
	* library/tk.tcl:
	* library/demos/menu.tcl:
	* library/demos/menubu.tcl:
	* library/demos/widget: check [tk windowingsystem] instead of
	and/or in addition to $tcl_platform(platform).

	* generic/tkInt.h:
	* mac/tkMacBitmap.c:
	* mac/tkMacWm.c: added missing CONSTification

	* generic/tkIntDecls.h:
	* generic/tkIntPlatDecls.h:
	* generic/tkIntXlibDecls.h:
	* generic/tkPlatDecls.h:
	* generic/tkStubInit.c: regen
@
text
@d333 3
a335 2
 *        system default color for that part.  It does this by looking
 *        in the system's 'cctb' resource.
d352 9
a360 13
/* Stubbed out for OS X
    short index;
    CCTabHandle ccTab;

    if (defaultAuxCtlHandle == NULL) {
        GetAuxiliaryControlRecord(NULL, &defaultAuxCtlHandle);
    }
    ccTab = (**defaultAuxCtlHandle).acCTable;
    if(ccTab && (ResError() == noErr)) {
        for(index = 0; index <= (**ccTab).ctSize; index++) {
            if((**ccTab).ctTable[index].value == part) {
                *macColor = (**ccTab).ctTable[index].rgb;
                return true;
d362 3
a364 1
        }
d366 1
a366 2
*/
    return false;
@


1.2.2.1
log
@Backport Mac OS X specific fixes from TOT. See ChangeLog for details.

In tk_getOpenFile filters, handle the case where you have a Macintosh
file type and the files have no filetype.

Fix various formatting nits.
@
text
@d333 2
a334 3
 *        system default color for that part.  On MacOS X this uses the
 *        Theme Brushes to find the active color, though for now, only
 *        the "Text Color" is supported.
d351 13
a363 9
    int retVal = false;
    OSErr err; 
    
    switch (part) {
        case cTextColor:
            err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32, 
                    true, macColor);
            if (err == noErr) {
                retVal = true;
d365 1
a365 3
            break;
        default:
            retVal = false;
d367 2
a368 1
    return retVal;
@


1.2.2.2
log
@	* macosx/tkMacOSX.h:             Cleaned up & rationalized order of
	* macosx/tkMacOSXBitmap.c:       #includes of tk and carbon headers;
	* macosx/tkMacOSXButton.c:       sync whitespace, comments & minor
	* macosx/tkMacOSXCarbonEvents.c: changes with HEAD.
	* macosx/tkMacOSXClipboard.c:
	* macosx/tkMacOSXColor.c:
	* macosx/tkMacOSXConfig.c:
	* macosx/tkMacOSXCursor.c:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXEmbed.c:
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXEvent.h:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXFont.h (new file):
	* macosx/tkMacOSXHLEvents.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXKeyboard.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXNotify.c:
	* macosx/tkMacOSXRegion.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSend.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXTest.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXWm.h:
	* macosx/tkMacOSXXStubs.c:
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.1 2004/02/16 00:42:34 wolfsuit Exp $
d18 1
d20 1
a20 1
#include "tkColor.h"
@


1.2.2.3
log
@	* macosx/tkMacOSXColor.c (TkSetMacColor, TkpGetColor): use AppearanceMgr
	* macosx/tkMacOSXDefault.h: to retrieve platform std colors for text
	* macosx/tkMacOSXPort.h:    selections, add "systemHighlightSecondary"
	color name for standard color of inactive selections.

	* library/text.tcl (aqua): change focus bindings to implement platform
	standard look for inactive text selections using this new color.

	* generic/tkTextBTree.c (TkTextIsElided): on TkAqua, don't show text
	* generic/tkTextDisp.c (GetStyle):        selection when text widget
	* generic/tkText.c (TextEventProc):       is in disabled state.

	* generic/tkEntry.c (DisplayEntry): change default TkAqua selection
	* macosx/tkMacOSXDefault.h:         relief to "flat" (platform std).

	* generic/tkText.c (Tk_TextCmd): fix bug leading to default text
	selection relief string DEF_TEXT_SELECT_RELIEF being ignored.

	* macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): allow mouse
	event delivery to background windows with kWindowNoActivatesAttribute
	(e.g. overrideredirect windows), as these never come to the foreground
	they would not receive any mouse events otherwise. [Bug 1472624]

	* macosx/tkMacOSXWindowEvent.c (TkMacOSXGenerateFocusEvent): do not
	send focus events to any windows with kWindowNoActivatesAttribute.

	* macosx/tkMacOSXXStubs.c (XQueryColor, XQueryColors): implement basic
	XColor computation from pixel values, enough to make tkImg's window.c
	happy, fixes img::window failures reported on tcl-mac.

	* macosx/tkMacOSXMenu.c (DrawMenuEntryLabel): fix leak. [Bug 1554672]

	* macosx/Makefile: workaround bug in 'cp -pRH' on Darwin 6 and earlier,
	fixes 'make embedded' failure reported on tcl-mac; fix error from 'make
	deploy' with same build tree as previous 'make embedded'.

	* macosx/tkMacOSXEntry.c (TkpDrawEntryBorderAndFocus): fix typo.

	* unix/tcl.m4: sync with tcl/unix/tcl.m4.
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.2 2006/03/28 02:44:13 das Exp $
a60 2
    OSStatus err;

d63 1
a63 19
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
            return true;
        case HIGHLIGHT_SECONDARY_PIXEL:
            err = GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
            return true;
        case HIGHLIGHT_ALTERNATE_PIXEL:
            err = GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
d66 1
a66 5
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, macColor);
	    if (err != noErr) {
		LMGetHiliteRGB(macColor);
	    }
d202 1
a202 2
        OSStatus err;
	int foundSystemColor = false;
d207 1
a207 5
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
a209 16
        } else if (!strcasecmp(name+6, "HighlightSecondary")) {
            err = GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
            pixelCode = HIGHLIGHT_SECONDARY_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "HighlightAlternate")) {
            err = GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
            pixelCode = HIGHLIGHT_ALTERNATE_PIXEL;
            foundSystemColor = true;
d211 1
a211 5
            err = GetThemeBrushAsColor(kThemeBrushPrimaryHighlightColor,
		    32, true, &rgbValue);
	    if (err != noErr) {
		LMGetHiliteRGB(&rgbValue);
	    }
@


1.2.2.4
log
@	* macosx/tkMacOSXWm.c (TkMacOSXMakeRealWindowExist): revert part of
	2006-05-16 change that had set overrideredirect windows to not become
	activated by the window manager, as this prevented interaction with
	native widgets in such windows [Bug 1472624]; apply changes to carbon
	window attributes even if native window has already been created.

	* macosx/tkMacOSXKeyEvent.c (TkMacOSXProcessKeyboardEvent): fix app
	* macosx/tkMacOSXMenu.c (DrawMenuBarWhenIdle): menu item key shortcuts
	* macosx/tkMacOSXInt.h: when custom ".apple" menu is installed.

	* library/demos/widget: on TkAqua, don't install file menu with single
	quit menu item, as the application menu already has a quit item.

	* macosx/tkMacOSXColor.c: fix building on Mac OS X 10.2.
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.3 2006/09/10 17:07:36 das Exp $
a20 5
/* Define constants only available on Mac OS X 10.3 or later */
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
    #define kThemeBrushAlternatePrimaryHighlightColor -5
#endif

@


1.2.2.5
log
@	* macosx/tkMacOSXCarbonEvents.c: add window event target carbon event
	* macosx/tkMacOSXEvent.c:	 handler for all kEventClassWindow and
	* macosx/tkMacOSXEvent.h:	 kEventClassMouse events; move all
	* macosx/tkMacOSXNotify.c:	 remaining events except for
	* macosx/tkMacOSXWindowEvent.c:	 kEventClassKeyboard from dispatcher to
	application event handler; pass event handler callRef downstream; fix
	debug event tracing; process all tcl event types in carbon event timer;
	delay carbon event timer first fire; add TkMacOSXTrackingLoop() to mark
	enter/exit of event tracking loop during which all tcl events but only
	carbon update events should be processed by the timer (replaces various
	calls to Tcl_SetServiceMode()); rename TkMacOSXReceiveAndProcessEvent()
	to TkMacOSXReceiveAndDispatchEvent(), move it from tkMacOSXEvent.c to
	tkMacOSXCarbonEvents.c and modify it to dequeue only update events
	during a tracking loop; add TkMacOSXRunTclEventLoop() to standardize
	the various ways in use to run the tcl event loop; add handling of
	kEventClassAppearance events (for ScrollBarVariantChanged event).

	* macosx/tkMacOSXDialog.c:	use new TkMacOSXTrackingLoop() around
	* macosx/tkMacOSXEvent.c:	blocking API that puts up modal dialogs
	* macosx/tkMacOSXMenu.c:	or when entering/exiting menu/control
	* macosx/tkMacOSXMouseEvent.c:	tracking, window dragging and other
	* macosx/tkMacOSXScale.c:	mouse tracking loops.
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDialog.c:	use new TkMacOSXRunTclEventLoop()
	* macosx/tkMacOSXScale.c:	instead of Tcl_DoOneEvent(),
	* macosx/tkMacOSXScrlbr.c:	Tcl_ServiceAll(), TclServiceIdle()
	* macosx/tkMacOSXWindowEvent.c:	and Tcl_GlobalEval("update idletasks").

	* macosx/tkMacOSXColor.c: make available as Tk system colors all
	* macosx/tkMacOSXPort.h:  appearance manager brushes, text colors and
	backgrounds with new and legacy names, as well as the fully transparent
	color "systemTransparent"; add TkMacOSXSetColorIn{Port,Context}() to
	directly set an X pixel color value in the current QD port resp. the
	given CG context without requiring passage through rgb representation
	(lossy for most system colors); modernize/remove Classic-era code;
	replace crufty strcmp() elseifs by Tcl_GetIndexFromObjStruct().

	* macosx/tkMacOSXButton.c:	use new TkMacOSXSetColorInPort()
	* macosx/tkMacOSXDraw.c:	instead of setting rgb color directly
	* macosx/tkMacOSXMenubutton.c:	to allow for non-rgb system colors.

	* macosx/tkMacOSXCursor.c: implement "none" cursor as on other
	platforms [Patch 1615427]; add all missing appearance manager cursors.

	* macosx/tkMacOSXDefault.h: set SELECT_FG_COLORs to None to match aqua
	L&F; use standard system color names; use new 'menu' system font;
	correct default scrollbar width.

	* macosx/tkMacOSXDraw.c:	standardize initialization, use and
	* macosx/tkMacOSXInt.h:		emptying of various static temp rgns
	* macosx/tkMacOSXRegion.c:	onto two global RgnHandles; in debug
	* macosx/tkMacOSXSubwindows.c:	builds, verify emptiness of these temp
	* macosx/tkMacOSXWindowEvent.c:	rgns before use.

	* macosx/tkMacOSXDraw.c: add TkMacOSX{Setup,Restore}DrawingContext() to
	* macosx/tkMacOSXInt.h:  abstract common setup & teardown of drawing
	environment (for both CG and QD); save/restore QD theme drawing state;
	handle GC clip region; add TkpClipDrawableToRect() to allow clipped
	drawing into drawable regardless of GC used; use new system color
	"systemWindowHeaderBackground" to setup background in themed toplevels;
	correct implementation of TkMacOSXMakeStippleMap().

	* macosx/tkMacOSXEntry.c: use new TkMacOSXSetupDrawingContext() and
	* macosx/tkMacOSXFont.c:  TkMacOSXRestoreDrawingContext() instead of
	various setup/teardown procs like TkMacOSX{SetUp,Release}CGContext(),
	TkMacOSXQuarz{Start,End}Draw(), TkMacOSXSetUpGraphicsPort() etc.

	* macosx/tkMacOSXEmbed.c: add CG context and drawable clip rgn fields
	* macosx/tkMacOSXInt.h:   to MacDrawable struct.
	* macosx/tkMacOSXSubwindows.c:

	* macosx/tkMacOSXDialog.c: make -parent option of tk_getOpenFile et al.
	use the sheet version of NavServices dialogs; ensure native parent win
	exists before using StandardSheet API for tk_messageBox [Bug 1677611];
	force sheets to behave like app-modal dialogs via WindowModality() API;
	use more modern ColorPicker API.

	* macosx/tkAboutDlg.r: use themed movable modal dialog, fix (c) year.

	* macosx/tkMacOSXEntry.c:  take xOff/yOff of MacDrawable into account
	when computing locations/bounds to ensure correct posititioning when
	not drawing into intermediate pixmap.

	* macosx/tkMacOSXFont.c: use appearance manager API to map system font
	* macosx/tkMacOSXFont.h: names to TkFonts; add "menu" system font for
	menu item text drawing from MDEF; disable broken QD stippling.

	* macosx/tkMacOSXMenu.c:		large-scale rewrite of custom
	* macosx/tkMacOSXMenu.r (removed):	MDEF and related code that
	* unix/Makefile.in:			restores many longtime-MIA
	features to working order (e.g. images, custom colors & fonts in menus
	etc); implement compound menu items; use Appearance Mgr and ThemeText
	APIs to mimic native MDEF as closely as possible when default "menu"
	system font is used; remove now obsolete SICN drawing code and
	resources.

	* macosx/tkMacOSXCarbonEvents.c: handle additional menu carbon events
	* macosx/tkMacOSXEvent.c:	 in order to support <<MenuSelect>> in
	* macosx/tkMacOSXMenu.c:	 the menubar and in menus that are not
	* macosx/tkMacOSXMenus.c:	 using the custom MDEF [Bug 1620826];
	fix early and missing clearing of current Tk active menu entry; fix
	extraneous sending of <<MenuSelect>> during active menu entry clearing.

	* macosx/tkMacOSXMouseEvent.c: add support for async window dragging by
	the window server; set the corresponding window attribute by default.

	* macosx/tkMacOSXMouseEvent.c: rationalized handling order of
	non-mousedown events; add TkMacOSXModifierState() to retrieve the
	current key modifiers in carbon format.

	* macosx/tkMacOSXScrlbr.c: use appearance manager API to retrieve
	scrollbar component metrics; add awareness of multiple possibilites for
	scrollbar arrow position in aqua and handle user changes to arrow
	position pref; handle difference in metrics of small & large scrollbar
	variants; handle aqua "jump to here" scrollbar behaviour; correct
	computation of scroll view size and position; enforce min scrollbar
	height to avoid scrollbar component overlap; erase scrollbar area
	outside of standard width; remove broken auto-adjust code; account for
	window class when leaving space for grow box; remove code to manually
	draw grow box; use modern API for thumb scroll proc; replace
	HiliteControl() by modern API; replace control mgr constants with
	appearance mgr equivalents.

	* macosx/tkMacOSXSubwindows.c: use SetWindowBounds() API instead of
	SizeWindow(); invalidate clip regions after X{Map,Unmap}Window as fix
	for [Bug 940117] made them dependent on mapping state; remove unneeded
	calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD port;
	use native-endian pixmap on intel; remove obsolete pixmap pix locking.

	* macosx/tkMacOSXWindowEvent.c: handle only the first of a batch of
	kEventAppAvailableWindowBoundsChanged events sent per transaction;
	handle kEventWindowBoundsChanged event to support live window resizing
	and centralized sending of location/size changed ConfigureNotify
	events; ensure HIGrowBox is redrawn after bounds change; constrain
	window after dragging to ensure titlebar is not inacessible
	offscreen or under dock/menubar; handle kEventWindowGetRegion and
	kEventWindowDrawContent for transparent windows to mark resp. paint
	content region as transparent; handle kEventWindowConstrain for
	fullscreen windows to ensure bounds match new screen size; enter/exit
	fullscreen UIMode upon activation/deactivation of fullscreen window.

	* macosx/tkMacOSXWm.c: use live-resize and async-drag carbon window
	* macosx/tkMacOSXWm.h: attributes for toplevels by default; implement
	new [wm attributes] -topmost, -transparent and -fullscreen; refactor
	WmAttributesCmd() parallelling the tkUnixWm.c implementation, use thus
	factored proc to set proxy icon from [wm iconbitmap]; dynamically
	determine default values for toplevel min and max sizes (similar to
	tkWinWm.c impl): min sizes depend on window class & attributes to
	ensure visibility of all titlebar widgets and grow box, max sizes
	depend on maximal window bounds for all active displays; factor out
	code that puts into effect changes to master or override_redirect; use
	RepositionWindow() API to determine staggered initial window bounds;
	correct resize limit calculations, handle gridding and use modern
	resize API in TkMacOSXGrowToplevel(); remove sending of ConfigureNotify
	after resize or zoom (now handled by BoundsChanged handler); correct
	composite carbon window attribute handling, remove currently unusable
	attributes and add new attributes in [tk::unsupported::MacWindowStyle];
	ensure validity of window class and attributes before use; apply
	changes to window class when handling carbon window attribute changes
	(if HIWindowChangeClass() API available); add debug build warning
	message when deprecated window style is used instead of window class;
	use transparent HIGrowBox for resizable windows; avoid unnecessary
	calls to window structure width API; use tcl time API in TkpGetMS();
	add TkMacOSXEnterExitFullscreen() to enter/exit UIMode with dock and
	menubar hidden; restrict wmTracing output to debug builds; remove
	unneeded calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD
	port; workaround GetWindowStructureWidths() Carbon bug (bogus results
	for never-mapped floating windows).

	* macosx/tkMacOSXXStubs.c (TkMacOSXDisplayChanged): add maximal window
	bounds field to Screen record (in ext_data), computed as the union of
	available window positioning bounds of all graphics devices (displays).

	* macosx/tkMacOSXBitmap.c: fix macRoman encoding leak.
	* macosx/tkMacOSXCursor.c:

	* macosx/tkMacOSXDebug.c (TkMacOSXCarbonEventToAscii): use static
	* macosx/tkMacOSXDebug.h: buffer to simplify callers; const fixes.

	* macosx/tkMacOSXBitmap.c: use more efficient QDSwapPort() instead of
	* macosx/tkMacOSXButton.c: GetPort()/SetPort()/GetGWorld()/SetGWorld().
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXXStubs.c:

	* macosx/tkMacOSXColor.c: use kHIToolboxVersionNumber for runtime OS
	* macosx/tkMacOSXEntry.c: version check rather than Gestalt() etc.
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDraw.c: remove obsolete and now incorrect
	* macosx/tkMacOSXInt.h:  tkMenuCascadeRgn clipping code.
	* macosx/tkMacOSXMenu.c:

	* macosx/tkMacOSXHLEvents.c: replace Tcl_GlobalEval() resp. Tcl_Eval()
	* macosx/tkMacOSXScrlbr.c:   by Tcl_EvalEx().
	* macosx/tkMacOSXInit.c:

	* macosx/tkMacOSXInit.c (TkpInit): reorder initialization steps.

	* macosx/tkMacOSXKeyEvent.c: remove pre-10.2 support.

	* macosx/tkMacOSXMenus.c: remove now useless call to
	TkMacOSXHandleTearoffMenu(); use \x.. quoting for non-latin1 macroman
	literar chars to allow file to be edited as utf-8.

	* macosx/tkMacOSXScale.c: replace TrackControl() by modern
	* macosx/tkMacOSXScrlbr.c: HandleControlClick() API (using new
	TkMacOSXModifierState()).

	* macosx/tkMacOSXInt.h:		move all constant #defines needed to
	* macosx/tkMacOSXColor.c:	support building on older OS X releases
	* macosx/tkMacOSXEvent.h:	to a central location in tkMacOSXInt.h.
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXInt.h:		 add ChkErr() macro to factor out
	* macosx/tkMacOSXButton.c:	 Carbon OSStatus return value checking
	* macosx/tkMacOSXCarbonEvents.c: and TkMacOSXDbgMsg() macro to factour
	* macosx/tkMacOSXClipboard.c:	 out debug message output; use these
	* macosx/tkMacOSXColor.c:	 macros to replace #ifdef TK_MAC_DEBUG
	* macosx/tkMacOSXCursor.c:	 blocks & direct printing to stderr,
	* macosx/tkMacOSXDebug.c:	 and to do additional OSStatus return
	* macosx/tkMacOSXDialog.c:	 checking, and to standardize OSStatus
	* macosx/tkMacOSXDraw.c:	 usage.
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXHLEvents.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:

	* macosx/tkMacOSXSend.c:	remove duplicate/unused declarations.
	* macosx/tkMacOSXXStubs.c:

	* macosx/tkMacOSXDebug.c:	const fixes.
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXTest.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:

	* macosx/Wish-Info.plist.in: add tcl document extensions/mime types and
	LSMinimumSystemVersion, LSRequiresCarbon & NSAppleScriptEnabled keys.

	* macosx/tkMacOSXAETE.r:	fix whitespace.
	* macosx/tkMacOSXConfig.c:
	* macosx/tkMacOSXCursors.r:
	* macosx/tkMacOSXKeyboard.c:
	* macosx/tkMacOSXSend.c:
	* macosx/tkMacOSXXCursors.r:
	* macosx/README:

	* macosx/Makefile:		fix/add copyright and license refs.
	* macosx/Tk-Info.plist.in:
	* macosx/Wish-Info.plist.in:
	* macosx/tkMacOSX.h:
@
text
@d1 1
a1 1
/*
d4 3
a6 3
 *	This file maintains a database of color values for the Tk
 *	toolkit, in order to avoid round-trips to the server to
 *	map color names to pixel values.
a10 1
 * Copyright (c) 2006-2007 Daniel A. Steffen <das@@users.sourceforge.net>
d15 1
a15 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.4 2006/09/11 14:41:16 das Exp $
d21 3
a23 3
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
/* Undocumented CG API for creating CGPattern from CGImage */
extern CGPatternRef CGPatternCreateWithImage(CGImageRef img, int i) WEAK_IMPORT_ATTRIBUTE;
a25 7
struct SystemColorMapEntry {
    const char *name;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;
};  /* unsigned char pixelCode; */

d27 3
a29 3
 * Array of system color definitions: the array index is required to equal the
 * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept
 * in sync with the public pixel code values in tkMacOSXPort.h !
d31 4
a34 142

#define MIN_PIXELCODE  30
static const struct SystemColorMapEntry systemColorMap[] = {
    { "Transparent",			    0, 0, 0 },							/*  30: TRANSPARENT_PIXEL */
    { "Highlight",			    kThemeBrushPrimaryHighlightColor, 0, 0 },			/*  31: HIGHLIGHT_PIXEL */
    { "HighlightSecondary",		    kThemeBrushSecondaryHighlightColor, 0, 0 },			/*  32: HIGHLIGHT_SECONDARY_PIXEL */
    { "HighlightText",			    kThemeBrushBlack, 0, 0 },					/*  33: HIGHLIGHT_TEXT_PIXEL */
    { "HighlightAlternate",		    kThemeBrushAlternatePrimaryHighlightColor, 0, 0 },		/*  34: HIGHLIGHT_ALTERNATE_PIXEL */
    { "ButtonText",			    0, kThemeTextColorPushButtonActive, 0 },			/*  35: CONTROL_TEXT_PIXEL */
    { "PrimaryHighlightColor",		    kThemeBrushPrimaryHighlightColor, 0, 0 },			/*  36 */
    { "ButtonFace",			    kThemeBrushButtonFaceActive, 0, 0 },			/*  37: CONTROL_BODY_PIXEL */
    { "SecondaryHighlightColor",	    kThemeBrushSecondaryHighlightColor, 0, 0 },			/*  38 */
    { "ButtonFrame",			    kThemeBrushButtonFrameActive, 0, 0 },			/*  39: CONTROL_FRAME_PIXEL */
    { "AlternatePrimaryHighlightColor",	    kThemeBrushAlternatePrimaryHighlightColor, 0, 0 },		/*  40 */
    { "WindowBody",			    kThemeBrushDocumentWindowBackground, 0, 0 },		/*  41: WINDOW_BODY_PIXEL */
    { "SheetBackground",		    kThemeBrushSheetBackground, 0, 0 },				/*  42 */
    { "MenuActive",			    kThemeBrushMenuBackgroundSelected, 0, 0 },			/*  43: MENU_ACTIVE_PIXEL */
    { "Black",				    kThemeBrushBlack, 0, 0 },					/*  44 */
    { "MenuActiveText",			    0, kThemeTextColorMenuItemSelected, 0 },			/*  45: MENU_ACTIVE_TEXT_PIXEL */
    { "White",				    kThemeBrushWhite, 0, 0 },					/*  46 */
    { "Menu",				    kThemeBrushMenuBackground, 0, 0 },				/*  47: MENU_BACKGROUND_PIXEL */
    { "DialogBackgroundActive",		    kThemeBrushDialogBackgroundActive, 0, 0 },			/*  48 */
    { "MenuDisabled",			    0, kThemeTextColorMenuItemDisabled, 0 },			/*  49: MENU_DISABLED_PIXEL */
    { "DialogBackgroundInactive",	    kThemeBrushDialogBackgroundInactive, 0, 0 },		/*  50 */
    { "MenuText",			    0, kThemeTextColorMenuItemActive, 0 },			/*  51: MENU_TEXT_PIXEL */
    { "AppearanceColor",		    0, 0, 0 },							/*  52: APPEARANCE_PIXEL */
    { "AlertBackgroundActive",		    kThemeBrushAlertBackgroundActive, 0, 0 },			/*  53 */
    { "AlertBackgroundInactive",	    kThemeBrushAlertBackgroundInactive, 0, 0 },			/*  54 */
    { "ModelessDialogBackgroundActive",	    kThemeBrushModelessDialogBackgroundActive, 0, 0 },		/*  55 */
    { "ModelessDialogBackgroundInactive",   kThemeBrushModelessDialogBackgroundInactive, 0, 0 },	/*  56 */
    { "UtilityWindowBackgroundActive",	    kThemeBrushUtilityWindowBackgroundActive, 0, 0 },		/*  57 */
    { "UtilityWindowBackgroundInactive",    kThemeBrushUtilityWindowBackgroundInactive, 0, 0 },		/*  58 */
    { "ListViewSortColumnBackground",	    kThemeBrushListViewSortColumnBackground, 0, 0 },		/*  59 */
    { "ListViewBackground",		    kThemeBrushListViewBackground, 0, 0 },			/*  60 */
    { "IconLabelBackground",		    kThemeBrushIconLabelBackground, 0, 0 },			/*  61 */
    { "ListViewSeparator",		    kThemeBrushListViewSeparator, 0, 0 },			/*  62 */
    { "ChasingArrows",			    kThemeBrushChasingArrows, 0, 0 },				/*  63 */
    { "DragHilite",			    kThemeBrushDragHilite, 0, 0 },				/*  64 */
    { "DocumentWindowBackground",	    kThemeBrushDocumentWindowBackground, 0, 0 },		/*  65 */
    { "FinderWindowBackground",		    kThemeBrushFinderWindowBackground, 0, 0 },			/*  66 */
    { "ScrollBarDelimiterActive",	    kThemeBrushScrollBarDelimiterActive, 0, 0 },		/*  67 */
    { "ScrollBarDelimiterInactive",	    kThemeBrushScrollBarDelimiterInactive, 0, 0 },		/*  68 */
    { "FocusHighlight",			    kThemeBrushFocusHighlight, 0, 0 },				/*  69 */
    { "PopupArrowActive",		    kThemeBrushPopupArrowActive, 0, 0 },			/*  70 */
    { "PopupArrowPressed",		    kThemeBrushPopupArrowPressed, 0, 0 },			/*  71 */
    { "PopupArrowInactive",		    kThemeBrushPopupArrowInactive, 0, 0 },			/*  72 */
    { "AppleGuideCoachmark",		    kThemeBrushAppleGuideCoachmark, 0, 0 },			/*  73 */
    { "IconLabelBackgroundSelected",	    kThemeBrushIconLabelBackgroundSelected, 0, 0 },		/*  74 */
    { "StaticAreaFill",			    kThemeBrushStaticAreaFill, 0, 0 },				/*  75 */
    { "ActiveAreaFill",			    kThemeBrushActiveAreaFill, 0, 0 },				/*  76 */
    { "ButtonFrameActive",		    kThemeBrushButtonFrameActive, 0, 0 },			/*  77 */
    { "ButtonFrameInactive",		    kThemeBrushButtonFrameInactive, 0, 0 },			/*  78 */
    { "ButtonFaceActive",		    kThemeBrushButtonFaceActive, 0, 0 },			/*  79 */
    { "ButtonFaceInactive",		    kThemeBrushButtonFaceInactive, 0, 0 },			/*  80 */
    { "ButtonFacePressed",		    kThemeBrushButtonFacePressed, 0, 0 },			/*  81 */
    { "ButtonActiveDarkShadow",		    kThemeBrushButtonActiveDarkShadow, 0, 0 },			/*  82 */
    { "ButtonActiveDarkHighlight",	    kThemeBrushButtonActiveDarkHighlight, 0, 0 },		/*  83 */
    { "ButtonActiveLightShadow",	    kThemeBrushButtonActiveLightShadow, 0, 0 },			/*  84 */
    { "ButtonActiveLightHighlight",	    kThemeBrushButtonActiveLightHighlight, 0, 0 },		/*  85 */
    { "ButtonInactiveDarkShadow",	    kThemeBrushButtonInactiveDarkShadow, 0, 0 },		/*  86 */
    { "ButtonInactiveDarkHighlight",	    kThemeBrushButtonInactiveDarkHighlight, 0, 0 },		/*  87 */
    { "ButtonInactiveLightShadow",	    kThemeBrushButtonInactiveLightShadow, 0, 0 },		/*  88 */
    { "ButtonInactiveLightHighlight",	    kThemeBrushButtonInactiveLightHighlight, 0, 0 },		/*  89 */
    { "ButtonPressedDarkShadow",	    kThemeBrushButtonPressedDarkShadow, 0, 0 },			/*  90 */
    { "ButtonPressedDarkHighlight",	    kThemeBrushButtonPressedDarkHighlight, 0, 0 },		/*  91 */
    { "ButtonPressedLightShadow",	    kThemeBrushButtonPressedLightShadow, 0, 0 },		/*  92 */
    { "ButtonPressedLightHighlight",	    kThemeBrushButtonPressedLightHighlight, 0, 0 },		/*  93 */
    { "BevelActiveLight",		    kThemeBrushBevelActiveLight, 0, 0 },			/*  94 */
    { "BevelActiveDark",		    kThemeBrushBevelActiveDark, 0, 0 },				/*  95 */
    { "BevelInactiveLight",		    kThemeBrushBevelInactiveLight, 0, 0 },			/*  96 */
    { "BevelInactiveDark",		    kThemeBrushBevelInactiveDark, 0, 0 },			/*  97 */
    { "NotificationWindowBackground",	    kThemeBrushNotificationWindowBackground, 0, 0 },		/*  98 */
    { "MovableModalBackground",		    kThemeBrushMovableModalBackground, 0, 0 },			/*  99 */
    { "SheetBackgroundOpaque",		    kThemeBrushSheetBackgroundOpaque, 0, 0 },			/* 100 */
    { "DrawerBackground",		    kThemeBrushDrawerBackground, 0, 0 },			/* 101 */
    { "ToolbarBackground",		    kThemeBrushToolbarBackground, 0, 0 },			/* 102 */
    { "SheetBackgroundTransparent",	    kThemeBrushSheetBackgroundTransparent, 0, 0 },		/* 103 */
    { "MenuBackground",			    kThemeBrushMenuBackground, 0, 0 },				/* 104 */
    { "Pixel",				    0, 0, 0 },							/* 105: PIXEL_MAGIC */
    { "MenuBackgroundSelected",		    kThemeBrushMenuBackgroundSelected, 0, 0 },			/* 106 */
    { "ListViewOddRowBackground",	    kThemeBrushListViewOddRowBackground, 0, 0 },		/* 107 */
    { "ListViewEvenRowBackground",	    kThemeBrushListViewEvenRowBackground, 0, 0 },		/* 108 */
    { "ListViewColumnDivider",		    kThemeBrushListViewColumnDivider, 0, 0 },			/* 109 */
    { "BlackText",			    0, kThemeTextColorBlack, 0 },				/* 110 */
    { "DialogActiveText",		    0, kThemeTextColorDialogActive, 0 },			/* 111 */
    { "DialogInactiveText",		    0, kThemeTextColorDialogInactive, 0 },			/* 112 */
    { "AlertActiveText",		    0, kThemeTextColorAlertActive, 0 },				/* 113 */
    { "AlertInactiveText",		    0, kThemeTextColorAlertInactive, 0 },			/* 114 */
    { "ModelessDialogActiveText",	    0, kThemeTextColorModelessDialogActive, 0 },		/* 115 */
    { "ModelessDialogInactiveText",	    0, kThemeTextColorModelessDialogInactive, 0 },		/* 116 */
    { "WindowHeaderActiveText",		    0, kThemeTextColorWindowHeaderActive, 0 },			/* 117 */
    { "WindowHeaderInactiveText",	    0, kThemeTextColorWindowHeaderInactive, 0 },		/* 118 */
    { "PlacardActiveText",		    0, kThemeTextColorPlacardActive, 0 },			/* 119 */
    { "PlacardInactiveText",		    0, kThemeTextColorPlacardInactive, 0 },			/* 120 */
    { "PlacardPressedText",		    0, kThemeTextColorPlacardPressed, 0 },			/* 121 */
    { "PushButtonActiveText",		    0, kThemeTextColorPushButtonActive, 0 },			/* 122 */
    { "PushButtonInactiveText",		    0, kThemeTextColorPushButtonInactive, 0 },			/* 123 */
    { "PushButtonPressedText",		    0, kThemeTextColorPushButtonPressed, 0 },			/* 124 */
    { "BevelButtonActiveText",		    0, kThemeTextColorBevelButtonActive, 0 },			/* 125 */
    { "BevelButtonInactiveText",	    0, kThemeTextColorBevelButtonInactive, 0 },			/* 126 */
    { "BevelButtonPressedText",		    0, kThemeTextColorBevelButtonPressed, 0 },			/* 127 */
    { "PopupButtonActiveText",		    0, kThemeTextColorPopupButtonActive, 0 },			/* 128 */
    { "PopupButtonInactiveText",	    0, kThemeTextColorPopupButtonInactive, 0 },			/* 129 */
    { "PopupButtonPressedText",		    0, kThemeTextColorPopupButtonPressed, 0 },			/* 130 */
    { "IconLabelText",			    0, kThemeTextColorIconLabel, 0 },				/* 131 */
    { "ListViewText",			    0, kThemeTextColorListView, 0 },				/* 132 */
    { "DocumentWindowTitleActiveText",	    0, kThemeTextColorDocumentWindowTitleActive, 0 },		/* 133 */
    { "DocumentWindowTitleInactiveText",    0, kThemeTextColorDocumentWindowTitleInactive, 0 },		/* 134 */
    { "MovableModalWindowTitleActiveText",  0, kThemeTextColorMovableModalWindowTitleActive, 0 },	/* 135 */
    { "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0 },	/* 136 */
    { "UtilityWindowTitleActiveText",	    0, kThemeTextColorUtilityWindowTitleActive, 0 },		/* 137 */
    { "UtilityWindowTitleInactiveText",	    0, kThemeTextColorUtilityWindowTitleInactive, 0 },		/* 138 */
    { "PopupWindowTitleActiveText",	    0, kThemeTextColorPopupWindowTitleActive, 0 },		/* 139 */
    { "PopupWindowTitleInactiveText",	    0, kThemeTextColorPopupWindowTitleInactive, 0 },		/* 140 */
    { "RootMenuActiveText",		    0, kThemeTextColorRootMenuActive, 0 },			/* 141 */
    { "RootMenuSelectedText",		    0, kThemeTextColorRootMenuSelected, 0 },			/* 142 */
    { "RootMenuDisabledText",		    0, kThemeTextColorRootMenuDisabled, 0 },			/* 143 */
    { "MenuItemActiveText",		    0, kThemeTextColorMenuItemActive, 0 },			/* 144 */
    { "MenuItemSelectedText",		    0, kThemeTextColorMenuItemSelected, 0 },			/* 145 */
    { "MenuItemDisabledText",		    0, kThemeTextColorMenuItemDisabled, 0 },			/* 146 */
    { "PopupLabelActiveText",		    0, kThemeTextColorPopupLabelActive, 0 },			/* 147 */
    { "PopupLabelInactiveText",		    0, kThemeTextColorPopupLabelInactive, 0 },			/* 148 */
    { "TabFrontActiveText",		    0, kThemeTextColorTabFrontActive, 0 },			/* 149 */
    { "TabNonFrontActiveText",		    0, kThemeTextColorTabNonFrontActive, 0 },			/* 150 */
    { "TabNonFrontPressedText",		    0, kThemeTextColorTabNonFrontPressed, 0 },			/* 151 */
    { "TabFrontInactiveText",		    0, kThemeTextColorTabFrontInactive, 0 },			/* 152 */
    { "TabNonFrontInactiveText",	    0, kThemeTextColorTabNonFrontInactive, 0 },			/* 153 */
    { "IconLabelSelectedText",		    0, kThemeTextColorIconLabelSelected, 0 },			/* 154 */
    { "BevelButtonStickyActiveText",	    0, kThemeTextColorBevelButtonStickyActive, 0 },		/* 155 */
    { "BevelButtonStickyInactiveText",	    0, kThemeTextColorBevelButtonStickyInactive, 0 },		/* 156 */
    { "NotificationText",		    0, kThemeTextColorNotification, 0 },			/* 157 */
    { "SystemDetailText",		    0, kThemeTextColorSystemDetail, 0 },			/* 158 */
    { "WhiteText",			    0, kThemeTextColorWhite, 0 },				/* 159 */
    { "TabPaneBackground",		    0, 0, kThemeBackgroundTabPane },				/* 160 */
    { "PlacardBackground",		    0, 0, kThemeBackgroundPlacard },				/* 161 */
    { "WindowHeaderBackground",		    0, 0, kThemeBackgroundWindowHeader },			/* 162 */
    { "ListViewWindowHeaderBackground",	    0, 0, kThemeBackgroundListViewWindowHeader },		/* 163 */
    { "SecondaryGroupBoxBackground",	    0, 0, kThemeBackgroundSecondaryGroupBox },			/* 164 */
    { "MetalBackground",		    0, 0, kThemeBackgroundMetal },				/* 165 */
    { NULL,				    0, 0, 0 }
};
#define MAX_PIXELCODE 165
d37 1
a37 15
 *----------------------------------------------------------------------
 *
 * GetThemeFromPixelCode --
 *
 *	When given a pixel code corresponding to a theme system color,
 *	set one of brush, textColor or background to the corresponding
 *	Appearance Mgr theme constant.
 *
 * Results:
 *	Returns false if not a real pixel, true otherwise.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
d40 3
a42 19
static int
GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush,
	ThemeTextColor *textColor, ThemeBackgroundKind *background)
{
    if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE && code != PIXEL_MAGIC) {
	*brush = systemColorMap[code - MIN_PIXELCODE].brush;
	*textColor = systemColorMap[code - MIN_PIXELCODE].textColor;
	*background = systemColorMap[code - MIN_PIXELCODE].background;
    } else {
	*brush = 0;
	*textColor = 0;
	*background = 0;
    }
    if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC) {
	return false;
    } else {
	return true;
    }
}
d47 1
a47 1
 * GetThemeColor --
d49 2
a50 1
 *	Get RGB color for a given system color or pixel value.
d53 1
a53 1
 *	OSStatus
d56 1
a56 1
 *	None.
d61 4
a64 3
static OSStatus
GetThemeColor(unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor,
	ThemeBackgroundKind background, RGBColor *c)
d66 1
a66 1
    OSStatus err = noErr;
d68 61
a128 10
    if (brush) {
	err = ChkErr(GetThemeBrushAsColor,
		brush == kThemeBrushMenuBackgroundSelected ?
		kThemeBrushFocusHighlight : brush, 32, true, c);
    } else if (textColor) {
	err = ChkErr(GetThemeTextColor, textColor, 32, true, c);
    } else {
	c->red	 = ((pixel >> 16) & 0xff) << 8;
	c->green = ((pixel >>  8) & 0xff) << 8;
	c->blue	 = ((pixel	) & 0xff) << 8;
a129 1
    return err;
d135 1
a135 1
 * TkSetMacColor --
d137 2
a138 2
 *	Populates a Macintosh RGBColor structure from a X style
 *	pixel value.
d141 1
a141 1
 *	Returns false if not a real pixel, true otherwise.
d144 1
a144 1
 *	The variable macColor is updated to the pixels value.
d149 17
a165 4
int
TkSetMacColor(
    unsigned long pixel,		/* Pixel value to convert. */
    RGBColor *macColor)			/* Mac color struct to modify. */
d167 6
a172 11
    OSStatus err = -1;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;

    if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
	    &background)) {
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
		macColor);
    }
    return (err == noErr);
a173 19

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetColorInPort --
 *
 *	Sets fore or back color in the current QD port from an X pixel
 *	value, and if the pixel code indicates a system color, sets
 *	the corresponding brush, textColor or background via
 *	Appearance mgr APIs.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	If penPat is non-NULL it is set to the forground color/pattern.
 *
 *----------------------------------------------------------------------
 */
d176 3
a178 1
TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat)
a179 40
    OSStatus err;
    RGBColor c;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;

    if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
	    &background)) {
	CGrafPtr port;

	GetPort(&port);
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c);
	if (err == noErr) {
	    if (fg) {
		RGBForeColor(&c);
		if (penPat) {
		    MakeRGBPat(penPat, &c);
		}
	    } else {
		RGBBackColor(&c);
	    }
	}
	err = -1;
	if (brush) {
	    err = ChkErr(SetThemeBackground,
		    brush == kThemeBrushMenuBackgroundSelected ?
		    kThemeBrushFocusHighlight : brush, 32, true);
	} else if (textColor && fg) {
	    err = ChkErr(SetThemeTextColor, textColor, 32, true);
	} else if (background) {
	    Rect bounds;

	    GetPortBounds(port, &bounds);
	    err = ChkErr(ApplyThemeBackground, background, &bounds,
		    kThemeStateActive, 32, true);
	}
	if (penPat && err == noErr && !textColor) {
	    GetPortBackPixPat(port, penPat);
	}
    }
a180 19

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXSetColorInContext --
 *
 *	Sets fill and stroke color in the given CG context from an X
 *	pixel value, or if the pixel code indicates a system color,
 *	sets the corresponding brush, textColor or background via
 *	HITheme APIs if available or Appearance mgr APIs.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */
d183 6
a188 1
TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context)
d190 5
a194 148
    OSStatus err = -1;
    RGBColor c;
    ThemeBrush brush;
    ThemeTextColor textColor;
    ThemeBackgroundKind background;

    if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
	    &background)) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
	if (brush) {
	    if (1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
		    && HIThemeSetFill != NULL && HIThemeSetStroke != NULL
#endif
	    ) {
		err = ChkErr(HIThemeSetFill, brush, NULL, context,
			kHIThemeOrientationNormal);
		if (err == noErr) {
		    err = ChkErr(HIThemeSetStroke, brush, NULL, context,
			    kHIThemeOrientationNormal);
		}
	    }
	} else if (textColor) {
	    if (1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
		    && HIThemeSetTextFill != NULL
#endif
	    ) {
		err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
			kHIThemeOrientationNormal);
	    }
	} else
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
	if (background) {
	    if (1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030
		    && CGContextGetClipBoundingBox != NULL
		    && HIThemeApplyBackground != NULL
		    && &kHIToolboxVersionNumber != NULL /* c.f. QA1377 */
		    && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_3
#endif
	    ) {
		CGRect rect = CGContextGetClipBoundingBox(context);
		HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
			background };

		err = ChkErr(HIThemeApplyBackground, &rect, &info, context,
			kHIThemeOrientationNormal);
	    }
	}
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
	if (err == noErr) {
	    return;
	}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
	/*
	 * Convert Appearance theme pattern to CGPattern:
	 */
	if ((brush || background) && CGPatternCreateWithImage != NULL) {
	    static PixPatHandle pixpat = NULL;
	    static GWorldPtr patGWorld = NULL;
	    static uint32_t bitmapInfo = 0;
	    const short patDim = 16;
	    const Rect bounds = {0, 0, patDim, patDim};
	    CGrafPtr savePort;
	    Boolean portChanged;
	    PixMapHandle pixmap;
	    long rowbytes;
	    CGImageRef img;
	    CGColorSpaceRef rgbCspace;
	    CGDataProviderRef provider;

	    if (!pixpat) {
		pixpat = NewPixPat();
		err = ChkErr(NewGWorld, &patGWorld, 32, &bounds, NULL, NULL, 0
#ifdef __LITTLE_ENDIAN__
			| kNativeEndianPixMap
#endif
			);
		if (!pixpat || err != noErr || !patGWorld) {
		    Tcl_Panic("TkMacOSXSetColorInContext(): "
			"pattern initialization failed !");
		}
		bitmapInfo =
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
			(1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
		    && &kHIToolboxVersionNumber != NULL
		    && kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_4
#endif
		    ) ? kCGBitmapByteOrder32Host :
#endif
		    0;
	    }
	    portChanged = QDSwapPort(patGWorld, &savePort);
	    TkMacOSXSetColorInPort(pixel, 1, pixpat);
#ifdef TK_MAC_DEBUG
	    Rect patBounds;
	    GetPixBounds((**pixpat).patMap, &patBounds);
	    if (patBounds.right > patDim || patBounds.bottom > patDim) {
		Tcl_Panic("TkMacOSXSetColorInContext(): "
		    "pattern larger than expected !");
	    }
#endif /* TK_MAC_DEBUG */
	    FillCRect(&bounds, pixpat);
	    if (portChanged) {
		QDSwapPort(savePort, NULL);
	    }
	    pixmap = GetPortPixMap(patGWorld);
	    rowbytes = GetPixRowBytes(pixmap);
	    provider = CGDataProviderCreateWithData(&patGWorld,
		    GetPixBaseAddr(pixmap), rowbytes * patDim, NULL);
	    rgbCspace = CGColorSpaceCreateDeviceRGB();
	    img = CGImageCreate(patDim, patDim, 8, 32,
		    rowbytes, rgbCspace, kCGImageAlphaFirst | bitmapInfo,
		    provider, NULL, 0, kCGRenderingIntentDefault);
	    CGColorSpaceRelease(rgbCspace);
	    CGDataProviderRelease(provider);
	    if (img) {
		CGPatternRef pat = CGPatternCreateWithImage(img, 2);
		CGColorSpaceRef patCSpace = CGColorSpaceCreatePattern(NULL);
		const float alpha = 1;

		CGContextSetFillColorSpace(context, patCSpace);
		CGContextSetFillPattern(context, pat, &alpha);
		CGContextSetStrokeColorSpace(context, patCSpace);
		CGContextSetStrokePattern(context, pat, &alpha);
		CGColorSpaceRelease(patCSpace);
		CGPatternRelease(pat);
		CGImageRelease(img);
		return;
	    }
	}
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1040 */
	err = ChkErr(GetThemeColor, pixel, brush, textColor, background, &c);
	if (err == noErr) {
	    double r = c.red   / 65535.0;
	    double g = c.green / 65535.0;
	    double b = c.blue  / 65535.0;

	    CGContextSetRGBFillColor(context, r, g, b, 1.0);
	    CGContextSetRGBStrokeColor(context, r, g, b, 1.0);
	}
    } else if (((pixel >> 24) & 0xff) == TRANSPARENT_PIXEL) {
	CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.0);
	CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.0);
    }
d202 1
a202 1
 *	Allocate a new TkColor for the color with the given name.
d205 1
a205 1
 *	Returns a newly allocated TkColor, or NULL on failure.
d208 3
a210 3
 *	May invalidate the colormap cache associated with tkwin upon
 *	allocating a new colormap entry. Allocates a new TkColor
 *	structure.
d217 3
a219 3
    Tk_Window tkwin,		/* Window in which color will be used. */
    Tk_Uid name)		/* Name of color to allocated (in form
				 * suitable for passing to XParseColor). */
d227 1
a227 1
     * Check to see if this is a system color. Otherwise, XParseColor
d231 34
a264 24
	Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1);
	int idx, result;

	result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap,
		    sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
	Tcl_DecrRefCount(strPtr);
	if (result == TCL_OK) {
	    OSStatus err;
	    RGBColor c;
	    unsigned char pixelCode = idx + MIN_PIXELCODE;
	    ThemeBrush brush = systemColorMap[idx].brush;
	    ThemeTextColor textColor = systemColorMap[idx].textColor;
	    ThemeBackgroundKind background = systemColorMap[idx].background;

	    err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c);
	    if (err == noErr) {
		color.red   = c.red;
		color.green = c.green;
		color.blue  = c.blue;
		color.pixel = ((((((pixelCode << 8)
		    | ((color.red   >> 8) & 0xff)) << 8)
		    | ((color.green >> 8) & 0xff)) << 8)
		    | ((color.blue  >> 8) & 0xff));
		goto validXColor;
d266 65
a330 1
	}
d332 1
a332 1

d334 1
a334 1
	return (TkColor *) NULL;
d336 1
a336 2

validXColor:
d348 3
a350 3
 *	Given a desired set of red-green-blue intensities for a color,
 *	locate a pixel value to use to draw that color in a given
 *	window.
d353 4
a356 4
 *	The return value is a pointer to an TkColor structure that
 *	indicates the closest red, blue, and green intensities available
 *	to those specified in colorPtr, and also specifies a pixel
 *	value to use to draw in that color.
d359 2
a360 2
 *	May invalidate the colormap cache for the specified window.
 *	Allocates a new TkColor structure.
d367 3
a369 3
    Tk_Window tkwin,		/* Window in which color will be used. */
    XColor *colorPtr)		/* Red, green, and blue fields indicate
				 * desired color. */
d383 1
a383 1
 * Stub functions --
d385 4
a388 2
 *	These functions are just stubs for functions that either
 *	don't make sense on the Mac or have yet to be implemented.
d391 1
a391 1
 *	None.
d394 2
a395 1
 *	These calls do nothing - which may not be expected.
d400 20
a419 9
Status
XAllocColor(
    Display *display,		/* Display. */
    Colormap map,		/* Not used. */
    XColor *colorPtr)		/* XColor struct to modify. */
{
    display->request++;
    colorPtr->pixel = TkpGetPixel(colorPtr);
    return 1;
d421 19
d441 24
a464 13
Colormap
XCreateColormap(
    Display *display,		/* Display. */
    Window window,		/* X window. */
    Visual *visual,		/* Not used. */
    int alloc)			/* Not used. */
{
    static Colormap index = 1;

    /*
     * Just return a new value each time.
     */
    return index++;
d466 18
d485 14
a498 20
void
XFreeColormap(
    Display* display,		/* Display. */
    Colormap colormap)		/* Colormap. */
{
}

void
XFreeColors(
    Display* display,		/* Display. */
    Colormap colormap,		/* Colormap. */
    unsigned long* pixels,	/* Array of pixels. */
    int npixels,		/* Number of pixels. */
    unsigned long planes)	/* Number of pixel planes. */
{
    /*
     * The Macintosh version of Tk uses TrueColor. Nothing
     * needs to be done to release colors as there really is
     * no colormap in the Tk sense.
     */
@


1.2.2.6
log
@	* macosx/tkMacOSXWindowEvent.c (GenerateUpdateEvent): complete all
	pending idle-time redraws before newly posted Expose events are
	processed; add bounds of redrawn windows to update region to ensure all
	child windows overdrawn by parents are redrawn.

	* macosx/tkMacOSXWindowEvent.c:	centralize clip and window invalidation
	* macosx/tkMacOSXSubwindows.c:	after location/size changes in the
	* macosx/tkMacOSXWm.c:		BoundsChanged carbon event handler;
	correct/add window invalidation after window attribute changes.

	* macosx/tkMacOSXSubwindows.c (XResizeWindow, XMoveResizeWindow,
	XMoveWindow): factor out common code dealing with embedded and
	non-toplevel windows; remove unnecessary clip and window invalidation.

	* macosx/tkMacOSXButton.c (TkpDisplayButton): move clip setup closer to
	native button drawing calls.

	* macosx/tkMacOSXWm.c (TkMacOSXIsWindowZoomed, TkMacOSXZoomToplevel):
	correct handle gridded windows in max size calculations.

	* macosx/tkMacOSXEvent.c (TkMacOSXFlushWindows): use HIWindowFlush API
	when available.

	* macosx/tkMacOSXColor.c:	cleanup whitespace and formatting.
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWm.c:
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.5 2007/04/29 02:26:48 das Exp $
d465 2
a466 3
			&& &kHIToolboxVersionNumber != NULL
			&& kHIToolboxVersionNumber >=
				kHIToolboxVersionNumber10_4
d468 1
a468 1
			) ? kCGBitmapByteOrder32Host :
d470 1
a470 1
			0;
@


1.2.2.7
log
@	* macosx/tkMacOSXMouseEvent.c (GenerateMouseWheelEvent): enable
	processing of mousewheel events in background windows.

	* macosx/tkMacOSXScrlbr.c: modernize checks for active/front window.
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXColor.c: factor out verbose #ifdef checks of
	* macosx/tkMacOSXDraw.c:  MAC_OS_X_VERSION_{MAX_ALLOWED,MIN_REQUIRED}
	* macosx/tkMacOSXEntry.c: and runtime checks of kHIToolboxVersion into
	* macosx/tkMacOSXEvent.c: new TK_{IF,ELSE,ENDIF}_MAC_OS_X macros.
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDraw.c:  factor out clip clearing in QD ports;
	* macosx/tkMacOSXEntry.c: formatting cleanup.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.6 2007/05/31 13:42:12 das Exp $
d385 1
d387 5
a391 1
	    TK_IF_MAC_OS_X_API (4, HIThemeSetFill,
d394 1
a394 1
		TK_IF_MAC_OS_X_API_COND (4, err == noErr, HIThemeSetFill,
d397 2
a398 2
		) TK_ENDIF_MAC_OS_X
	    ) TK_ENDIF_MAC_OS_X
d400 5
a404 1
	    TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill,
d407 13
a419 3
	    ) TK_ENDIF_MAC_OS_X
	} else if (background) {
	    TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox,
d424 3
a426 7
		TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground,
		    TK_IF_MAC_OS_X_HI_TOOLBOX (3, /* c.f. QA1377 */
			err = ChkErr(HIThemeApplyBackground, &rect, &info,
				context, kHIThemeOrientationNormal);
		    ) TK_ENDIF_MAC_OS_X
		) TK_ENDIF_MAC_OS_X
	    ) TK_ENDIF_MAC_OS_X
d428 1
d461 11
a471 3
		TK_IF_MAC_OS_X_HI_TOOLBOX (4,
		    bitmapInfo = kCGBitmapByteOrder32Host;
		) TK_ENDIF_MAC_OS_X
@


1.2.2.8
log
@	* macosx/tkMacOSXColor.c: fix issues with TK_{IF,ELSE,ENDIF} macros;
	* macosx/tkMacOSXDraw.c:  implement Jaguar equivalent of unavailable
	* macosx/tkMacOSXEntry.c: kHIToolboxVersion global; panic at startup
	* macosx/tkMacOSXEvent.c: if MAC_OS_X_VERSION_MIN_REQUIRED constraint
	* macosx/tkMacOSXInit.c:  is not satisfied.
	* macosx/tkMacOSXInt.h:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage)
	(TkMacOSXSetupDrawingContext): factor out common code and standardize
	setup/restore of port, context and clipping; formatting cleanup.

	* macosx/tkMacOSXWindowEvent.c:	add error checking.
	* macosx/tkMacOSXMenu.c:	fix gcc3 warning.
	* macosx/tkMacOSXScrlbr.c:	fix testsuite crash.
	* macosx/tkMacOSXSubwindows.c:	formatting cleanup.
	* macosx/tkMacOSXRegion.c:	fix typos.
	* macosx/tkMacOSXScale.c:
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.7 2007/06/06 09:56:54 das Exp $
d389 1
a389 1
		TK_IF_MAC_OS_X_API_COND (4, HIThemeSetFill, err == noErr,
d392 2
a393 2
		) TK_ENDIF
	    ) TK_ENDIF
d398 1
a398 1
	    ) TK_ENDIF
d406 1
a406 1
		    TK_IF_HI_TOOLBOX (3, /* c.f. QA1377 */
d409 3
a411 3
		    ) TK_ENDIF
		) TK_ENDIF
	    ) TK_ENDIF
d445 1
a445 1
		TK_IF_HI_TOOLBOX (4,
d447 1
a447 1
		) TK_ENDIF
@


1.2.2.9
log
@	* macosx/tkMacOSXScrlbr.c: correct int <-> dobule conversion issues
	that could lead to Carbon getting confused about scrollbar thumb size.

	* macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) use
	TkMacOSX{Setup,Restore}DrawingContext() to setup/restore clip & colors.
	(TkMacOSXSetupDrawingContext, TkMacOSXRestoreDrawingContext): add save
	and restore of QD port clip region; factor out clip region code common
	to CG and QD branches; check for port and context validity; handle
	tkPictureIsOpen flag during QD port setup.
	(TkScrollWindow): remove unnecessary scroll region manipulation

	* macosx/tkMacOSXDraw.c:	remove second global QD temp region
	* macosx/tkMacOSXInt.h:		(no longer necessary) and rename
	* macosx/tkMacOSXRegion.c:	remaining global QD temp region.
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:

	* macosx/tkMacOSXDraw.c:	make useCGDrawing variable MODULE_SCOPE
	* macosx/tkMacOSXFont.c:	and sync formatting with HEAD.

	* macosx/tkMacOSXButton.c:	reduce reliance on current QD port
	* macosx/tkMacOSXColor.c:	setting and remove unnecessary
	* macosx/tkMacOSXDebug.c:	references to a drawable's QD port,
	* macosx/tkMacOSXDebug.h:	notably replace GetWindowFromPort(
	* macosx/tkMacOSXDialog.c:	TkMacOSXGetDrawablePort()) idiom by new
	* macosx/tkMacOSXDraw.c:	TkMacOSXDrawableWindow() and change
	* macosx/tkMacOSXKeyEvent.c:	TkMacOSXSetColorInPort() to take a port
	* macosx/tkMacOSXMenu.c:	argument.
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:

	* macosx/tkMacOSXInt.h:			factor out macros, declarations
	* macosx/tkMacOSXPrivate.h (new):	and prototypes that are purely
	internal and private to the 'macosx' sources into a new internal header
	file that does _not_ get installed into Tk.framework/PrivateHeaders.

	* macosx/tkMacOSXButton.c:		#include new tkMacOSXPrivate.h
	* macosx/tkMacOSXCarbonEvents.c:	instead of tkMacOSXInt.h.
	* macosx/tkMacOSXClipboard.c:
	* macosx/tkMacOSXColor.c:
	* macosx/tkMacOSXCursor.c:
	* macosx/tkMacOSXDebug.c:
	* macosx/tkMacOSXDialog.c:
	* macosx/tkMacOSXDraw.c:
	* macosx/tkMacOSXEntry.c:
	* macosx/tkMacOSXEvent.c:
	* macosx/tkMacOSXFont.c:
	* macosx/tkMacOSXHLEvents.c:
	* macosx/tkMacOSXInit.c:
	* macosx/tkMacOSXKeyEvent.c:
	* macosx/tkMacOSXMenu.c:
	* macosx/tkMacOSXMenubutton.c:
	* macosx/tkMacOSXMenus.c:
	* macosx/tkMacOSXMouseEvent.c:
	* macosx/tkMacOSXNotify.c:
	* macosx/tkMacOSXRegion.c:
	* macosx/tkMacOSXScale.c:
	* macosx/tkMacOSXScrlbr.c:
	* macosx/tkMacOSXSubwindows.c:
	* macosx/tkMacOSXWindowEvent.c:
	* macosx/tkMacOSXWm.c:
	* macosx/tkMacOSXXStubs.c:
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.8 2007/06/09 17:10:20 das Exp $
d19 1
a19 1
#include "tkMacOSXPrivate.h"
d201 2
a202 5
GetThemeFromPixelCode(
    unsigned char code,
    ThemeBrush *brush,
    ThemeTextColor *textColor,
    ThemeBackgroundKind *background)
d237 2
a238 6
GetThemeColor(
    unsigned long pixel,
    ThemeBrush brush,
    ThemeTextColor textColor,
    ThemeBackgroundKind background,
    RGBColor *c)
d311 1
a311 5
TkMacOSXSetColorInPort(
    unsigned long pixel,
    int fg,
    PixPatHandle penPat,
    CGrafPtr port)
a317 1
    int setPenPat = 0;
d321 1
a321 2
	CGrafPtr savePort;
	Boolean portChanged;
d323 1
a323 1
	portChanged = QDSwapPort(port, &savePort);
a329 1
		    setPenPat = 1;
d349 1
a349 1
	if (penPat && err == noErr && (brush || background)) {
a350 1
	    setPenPat = 1;
a351 6
	if (portChanged) {
	    QDSwapPort(savePort, NULL);
	}
    }
    if (penPat && !setPenPat) {
	GetPortBackPixPat(port, penPat);
d375 1
a375 3
TkMacOSXSetColorInContext(
    unsigned long pixel,
    CGContextRef context)
d450 1
a450 1
	    TkMacOSXSetColorInPort(pixel, 1, pixpat, patGWorld);
@


1.2.2.10
log
@	* macosx/tkMacOSXColor.c: add debug messages for unknown pixel values.

	*  macosx/tkMacOSXDraw.c (TkMacOSXRestoreDrawingContext): don't restore
	port state if it wasn't altered by TkMacOSXSetupDrawingContext().
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.9 2007/06/29 03:22:01 das Exp $
d303 1
a303 1
 *	Sets fore or back color in the given QD port from an X pixel
a369 2
    } else {
	TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
a523 2
    } else {
	TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
@


1.2.2.11
log
@	Backport from HEAD of Aqua changes from 2007-10-12 to 2007-11-09
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkMacOSXColor.c,v 1.2.2.10 2007/07/02 13:06:14 das Exp $
d256 3
a258 6
	c->red	  = (pixel >> 16) & 0xff;
	c->green  = (pixel >>  8) & 0xff;
	c->blue	  = (pixel	) & 0xff;
	c->red	 |= c->red   << 8;
	c->green |= c->green << 8;
	c->blue	 |= c->blue  << 8;
a640 31
#if 0
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXCompareColors --
 *
 *	On Mac, color codes may specify symbolic values like "highlight
 *	foreground", but we really need the actual values to compare.
 *	Maybe see also: "TIP #154: Add Named Colors to Tk".
 *
 * Results:
 *	Returns true if both colors are the same, false otherwise.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

int
TkMacOSXCompareColors(
    unsigned long c1,
    unsigned long c2)
{
    RGBColor col1, col2;
    return  TkSetMacColor(c1,&col1) &&
	    TkSetMacColor(c1,&col2) &&
	    !memcmp(&col1,&col2,sizeof(col1));
}
#endif /* !TK_DRAW_IN_CONTEXT */

@


1.1
log
@file tkMacOSXColor.c was initially added on branch macosx-8-4-branch.
@
text
@d1 448
@


1.1.2.1
log
@First checkin of support for Tk on Mac OS X.
@
text
@a0 448
/* 
 * tkMacOSXColor.c --
 *
 *        This file maintains a database of color values for the Tk
 *        toolkit, in order to avoid round-trips to the server to
 *        map color names to pixel values.
 *
 * Copyright (c) 1990-1994 The Regents of the University of California.
 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
 * Copyright 2001, Apple Computer, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @@(#) $Id$
 */

#include <tkColor.h>
#include "tkMacOSXInt.h"
#include <Carbon/Carbon.h>

/*
 * Default Auxillary Control Record for all controls.  This is cached once
 * and is updated by the system.  We use this to get the default system
 * colors used by controls.
 */
/*
 * Stubbed out for OS X
static AuxCtlHandle defaultAuxCtlHandle = NULL;
*/

/*
 * Forward declarations for procedures defined later in this file:
 */

static int        GetControlPartColor _ANSI_ARGS_((short part, RGBColor *macColor));
static int        GetMenuPartColor _ANSI_ARGS_((int part, RGBColor *macColor));
static int        GetWindowPartColor _ANSI_ARGS_((short part, RGBColor *macColor));

/*
 *----------------------------------------------------------------------
 *
 * TkSetMacColor --
 *
 *        Populates a Macintosh RGBColor structure from a X style
 *        pixel value.
 *
 * Results:
 *        Returns false if not a real pixel, true otherwise.
 *
 * Side effects:
 *        The variable macColor is updated to the pixels value.
 *
 *----------------------------------------------------------------------
 */

int
TkSetMacColor(
    unsigned long pixel,        /* Pixel value to convert. */
    RGBColor *macColor)                /* Mac color struct to modify. */
{
    switch (pixel >> 24) {
        case HIGHLIGHT_PIXEL:
            LMGetHiliteRGB(macColor);
            return true;
        case HIGHLIGHT_TEXT_PIXEL:
            LMGetHiliteRGB(macColor);
            if ((macColor->red == 0) && (macColor->green == 0)
                    && (macColor->blue == 0)) {
                macColor->red = macColor->green = macColor->blue = 0xFFFFFFFF;
            } else {
                macColor->red = macColor->green = macColor->blue = 0;
            }
            return true;
        case CONTROL_TEXT_PIXEL:
            GetControlPartColor(cTextColor, macColor);
            return true;
        case CONTROL_BODY_PIXEL:
            GetControlPartColor(cBodyColor, macColor);
            return true;
        case CONTROL_FRAME_PIXEL:
            GetControlPartColor(cFrameColor, macColor);
            return true;
        case WINDOW_BODY_PIXEL:
            GetWindowPartColor(wContentColor, macColor);
            return true;
        case MENU_ACTIVE_PIXEL:
        case MENU_ACTIVE_TEXT_PIXEL:
        case MENU_BACKGROUND_PIXEL:
        case MENU_DISABLED_PIXEL:
        case MENU_TEXT_PIXEL:
            return GetMenuPartColor((pixel >> 24), macColor);
        case APPEARANCE_PIXEL:
            return false;
        case PIXEL_MAGIC:
        default:
            macColor->blue = (unsigned short) ((pixel & 0xFF) << 8);
            macColor->green = (unsigned short) (((pixel >> 8) & 0xFF) << 8);
            macColor->red = (unsigned short) (((pixel >> 16) & 0xFF) << 8);
            return true;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * Stub functions --
 *
 *        These functions are just stubs for functions that either
 *        don't make sense on the Mac or have yet to be implemented.
 *
 * Results:
 *        None.
 *
 * Side effects:
 *        These calls do nothing - which may not be expected.
 *
 *----------------------------------------------------------------------
 */

Status
XAllocColor(
    Display *display,                /* Display. */
    Colormap map,                /* Not used. */
    XColor *colorPtr)                /* XColor struct to modify. */
{
    display->request++;
    colorPtr->pixel = TkpGetPixel(colorPtr);
    return 1;
}

Colormap
XCreateColormap(
    Display *display,                /* Display. */
    Window window,                /* X window. */
    Visual *visual,                /* Not used. */
    int alloc)                        /* Not used. */
{
    static Colormap index = 1;
    
    /*
     * Just return a new value each time.
     */
    return index++;
}

void
XFreeColormap(
    Display* display,                /* Display. */
    Colormap colormap)                /* Colormap. */
{
}

void
XFreeColors(
    Display* display,                /* Display. */
    Colormap colormap,                /* Colormap. */
    unsigned long* pixels,        /* Array of pixels. */
    int npixels,                /* Number of pixels. */
    unsigned long planes)        /* Number of pixel planes. */
{
    /*
     * The Macintosh version of Tk uses TrueColor.  Nothing
     * needs to be done to release colors as there really is
     * no colormap in the Tk sense.
     */
}

/*
 *----------------------------------------------------------------------
 *
 * TkpGetColor --
 *
 *        Allocate a new TkColor for the color with the given name.
 *
 * Results:
 *        Returns a newly allocated TkColor, or NULL on failure.
 *
 * Side effects:
 *        May invalidate the colormap cache associated with tkwin upon
 *        allocating a new colormap entry.  Allocates a new TkColor
 *        structure.
 *
 *----------------------------------------------------------------------
 */

TkColor *
TkpGetColor(
    Tk_Window tkwin,                /* Window in which color will be used. */
    Tk_Uid name)                /* Name of color to allocated (in form
                                 * suitable for passing to XParseColor). */
{
    Display *display = Tk_Display(tkwin);
    Colormap colormap = Tk_Colormap(tkwin);
    TkColor *tkColPtr;
    XColor color;

    /*
     * Check to see if this is a system color.  Otherwise, XParseColor
     * will do all the work.
     */
    if (strncasecmp(name, "system", 6) == 0) {
        int foundSystemColor = false;
        RGBColor rgbValue;
        char pixelCode;
        
        if (!strcasecmp(name+6, "Highlight")) {
            LMGetHiliteRGB(&rgbValue);
            pixelCode = HIGHLIGHT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "HighlightText")) {
            LMGetHiliteRGB(&rgbValue);
            if ((rgbValue.red == 0) && (rgbValue.green == 0)
                    && (rgbValue.blue == 0)) {
                rgbValue.red = rgbValue.green = rgbValue.blue = 0xFFFFFFFF;
            } else {
                rgbValue.red = rgbValue.green = rgbValue.blue = 0;
            }
            pixelCode = HIGHLIGHT_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "ButtonText")) {
            GetControlPartColor(cTextColor, &rgbValue);
            pixelCode = CONTROL_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "ButtonFace")) {
            GetControlPartColor(cBodyColor, &rgbValue);
            pixelCode = CONTROL_BODY_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "ButtonFrame")) {
            GetControlPartColor(cFrameColor, &rgbValue);
            pixelCode = CONTROL_FRAME_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "WindowBody")) {
            GetWindowPartColor(wContentColor, &rgbValue);
            pixelCode = WINDOW_BODY_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuActive")) {
            GetMenuPartColor(MENU_ACTIVE_PIXEL, &rgbValue);
            pixelCode = MENU_ACTIVE_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuActiveText")) {
            GetMenuPartColor(MENU_ACTIVE_TEXT_PIXEL, &rgbValue);
            pixelCode = MENU_ACTIVE_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "Menu")) {
            GetMenuPartColor(MENU_BACKGROUND_PIXEL, &rgbValue);
            pixelCode = MENU_BACKGROUND_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuDisabled")) {
            GetMenuPartColor(MENU_DISABLED_PIXEL, &rgbValue);
            pixelCode = MENU_DISABLED_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "MenuText")) {
            GetMenuPartColor(MENU_TEXT_PIXEL, &rgbValue);
            pixelCode = MENU_TEXT_PIXEL;
            foundSystemColor = true;
        } else if (!strcasecmp(name+6, "AppearanceColor")) {
            color.red = 0;
            color.green = 0;
            color.blue = 0;
            pixelCode = APPEARANCE_PIXEL;
            foundSystemColor = true;
        }
        
        if (foundSystemColor) {
            color.red = rgbValue.red;
            color.green = rgbValue.green;
            color.blue = rgbValue.blue;
            color.pixel = ((((((pixelCode << 8)
                | ((color.red >> 8) & 0xff)) << 8)
                | ((color.green >> 8) & 0xff)) << 8)
                | ((color.blue >> 8) & 0xff));
            
            tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
            tkColPtr->color = color;
            return tkColPtr;
        }
    }
    
    if (XParseColor(display, colormap, name, &color) == 0) {
        return (TkColor *) NULL;
    }
    
    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
    tkColPtr->color = color;

    return tkColPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * TkpGetColorByValue --
 *
 *        Given a desired set of red-green-blue intensities for a color,
 *        locate a pixel value to use to draw that color in a given
 *        window.
 *
 * Results:
 *        The return value is a pointer to an TkColor structure that
 *        indicates the closest red, blue, and green intensities available
 *        to those specified in colorPtr, and also specifies a pixel
 *        value to use to draw in that color.
 *
 * Side effects:
 *        May invalidate the colormap cache for the specified window.
 *        Allocates a new TkColor structure.
 *
 *----------------------------------------------------------------------
 */

TkColor *
TkpGetColorByValue(
    Tk_Window tkwin,                /* Window in which color will be used. */
    XColor *colorPtr)                /* Red, green, and blue fields indicate
                                 * desired color. */
{
    TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));

    tkColPtr->color.red = colorPtr->red;
    tkColPtr->color.green = colorPtr->green;
    tkColPtr->color.blue = colorPtr->blue;
    tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color);
    return tkColPtr;
}

/*
 *----------------------------------------------------------------------
 *
 * GetControlPartColor --
 *
 *        Given a part number this function will return the standard
 *        system default color for that part.  It does this by looking
 *        in the system's 'cctb' resource.
 *
 * Results:
 *        True if a color is found, false otherwise.
 *
 * Side effects:
 *        If a color is found then the RGB variable will be changed to
 *        the parts color.
 *
 *----------------------------------------------------------------------
 */

static int 
GetControlPartColor(
    short part,                 /* Part code. */
    RGBColor *macColor)                /* Pointer to Mac color. */
{
/* Stubbed out for OS X
    short index;
    CCTabHandle ccTab;

    if (defaultAuxCtlHandle == NULL) {
        GetAuxiliaryControlRecord(NULL, &defaultAuxCtlHandle);
    }
    ccTab = (**defaultAuxCtlHandle).acCTable;
    if(ccTab && (ResError() == noErr)) {
        for(index = 0; index <= (**ccTab).ctSize; index++) {
            if((**ccTab).ctTable[index].value == part) {
                *macColor = (**ccTab).ctTable[index].rgb;
                return true;
            }
        }
    }
*/
    return false;
}

/*
 *----------------------------------------------------------------------
 *
 * GetWindowPartColor --
 *
 *      Given a part number this function will return the standard
 *      system default color for that part.  It does this by looking
 *      in the system's 'wctb' resource.
 *
 * Results:
 *      True if a color is found, false otherwise.
 *
 * Side effects:
 *      If a color is found then the RGB variable will be changed to
 *      the parts color.
 *
 *----------------------------------------------------------------------
 */

static int
GetWindowPartColor(
    short part,                 /* Part code. */
    RGBColor *macColor)         /* Pointer to Mac color. */
{
    short index;
    WCTabHandle wcTab;

    if (part == wContentColor) {
        GetThemeBrushAsColor(kThemeBrushDocumentWindowBackground,
                0xFFFF, true, macColor);
        return true;
    } else {
        wcTab = (WCTabHandle) GetResource('wctb', 0);
        if(wcTab && (ResError() == noErr)) {
            for(index = 0; index <= (**wcTab).ctSize; index++) {
                if((**wcTab).ctTable[index].value == part) {
                    *macColor = (**wcTab).ctTable[index].rgb;
                    return true;
                }
            }
        }
        return false;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * GetMenuPartColor --
 *
 *        Given a magic pixel value, returns the RGB color associated
 *        with it by looking the value up in the system's 'mctb' resource.
 *
 * Results:
 *        True if a color is found, false otherwise.
 *
 * Side effects:
 *        If a color is found then the RGB variable will be changed to
 *        the parts color.
 *
 *----------------------------------------------------------------------
 */

static int
GetMenuPartColor(
    int pixel,                        /* The magic pixel value */
    RGBColor *macColor)                /* Pointer to Mac color */
{
    
    /* Under Appearance, we don't want to set any menu colors when we
       are asked for the standard menu colors.  So we return false (which
       means don't use this color... */
       
        macColor->red = 0xFFFF;
        macColor->green = 0;
        macColor->blue = 0;
        return false;
}
@


1.1.2.2
log
@various project cleanups & enhancements
added macosx/Makefile to facilitate building from cli
added [tk windowingsystem] and removed $::tcl_plaform(windowingsystem)
changed all runtime library references to the above
removed duplicate entries in tk.decls & tkInt.decls
CONSTification and other small changes in macosx/ to remove compiler warnings
@
text
@d70 1
a70 1
                macColor->red = macColor->green = macColor->blue = 0xFFFF;
d205 1
a205 1
        char pixelCode = 0;
d215 1
a215 1
                rgbValue.red = rgbValue.green = rgbValue.blue = 0xFFFF;
@


