summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXColor.c
diff options
context:
space:
mode:
authordas <das>2007-06-29 03:20:00 (GMT)
committerdas <das>2007-06-29 03:20:00 (GMT)
commitfd6f23be1500b5efefed38ae033804ef95f66f1b (patch)
tree05f288d4eecbd4785ba86178ba73ebfc79a81895 /macosx/tkMacOSXColor.c
parentf6a5a5d57bfdc3aa6088dd2e9957652bdd9be70c (diff)
downloadtk-fd6f23be1500b5efefed38ae033804ef95f66f1b.zip
tk-fd6f23be1500b5efefed38ae033804ef95f66f1b.tar.gz
tk-fd6f23be1500b5efefed38ae033804ef95f66f1b.tar.bz2
* 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:
Diffstat (limited to 'macosx/tkMacOSXColor.c')
-rw-r--r--macosx/tkMacOSXColor.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 2194b7a..61403ab 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -13,10 +13,10 @@
* 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.11 2007/06/09 17:09:39 das Exp $
+ * RCS: @(#) $Id: tkMacOSXColor.c,v 1.12 2007/06/29 03:20:00 das Exp $
*/
-#include "tkMacOSXInt.h"
+#include "tkMacOSXPrivate.h"
#include "tkColor.h"
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040
@@ -198,8 +198,11 @@ static const struct SystemColorMapEntry systemColorMap[] = {
*/
static int
-GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush,
- ThemeTextColor *textColor, ThemeBackgroundKind *background)
+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;
@@ -234,8 +237,12 @@ GetThemeFromPixelCode(unsigned char code, ThemeBrush *brush,
*/
static OSStatus
-GetThemeColor(unsigned long pixel, ThemeBrush brush, ThemeTextColor textColor,
- ThemeBackgroundKind background, RGBColor *c)
+GetThemeColor(
+ unsigned long pixel,
+ ThemeBrush brush,
+ ThemeTextColor textColor,
+ ThemeBackgroundKind background,
+ RGBColor *c)
{
OSStatus err = noErr;
@@ -308,25 +315,32 @@ TkSetMacColor(
*/
void
-TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat)
+TkMacOSXSetColorInPort(
+ unsigned long pixel,
+ int fg,
+ PixPatHandle penPat,
+ CGrafPtr port)
{
OSStatus err;
RGBColor c;
ThemeBrush brush;
ThemeTextColor textColor;
ThemeBackgroundKind background;
+ int setPenPat = 0;
if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
&background)) {
- CGrafPtr port;
+ CGrafPtr savePort;
+ Boolean portChanged;
- GetPort(&port);
+ 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);
@@ -346,9 +360,16 @@ TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat)
err = ChkErr(ApplyThemeBackground, background, &bounds,
kThemeStateActive, 32, true);
}
- if (penPat && err == noErr && !textColor) {
+ if (penPat && err == noErr && (brush || background)) {
GetPortBackPixPat(port, penPat);
+ setPenPat = 1;
}
+ if (portChanged) {
+ QDSwapPort(savePort, NULL);
+ }
+ }
+ if (penPat && !setPenPat) {
+ GetPortBackPixPat(port, penPat);
}
}
@@ -372,7 +393,9 @@ TkMacOSXSetColorInPort(unsigned long pixel, int fg, PixPatHandle penPat)
*/
void
-TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context)
+TkMacOSXSetColorInContext(
+ unsigned long pixel,
+ CGContextRef context)
{
OSStatus err = -1;
RGBColor c;
@@ -447,7 +470,7 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context)
) TK_ENDIF
}
portChanged = QDSwapPort(patGWorld, &savePort);
- TkMacOSXSetColorInPort(pixel, 1, pixpat);
+ TkMacOSXSetColorInPort(pixel, 1, pixpat, patGWorld);
#ifdef TK_MAC_DEBUG
Rect patBounds;
GetPixBounds((**pixpat).patMap, &patBounds);