summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXScale.c
diff options
context:
space:
mode:
authorwolfsuit <wolfsuit>2005-03-24 07:16:12 (GMT)
committerwolfsuit <wolfsuit>2005-03-24 07:16:12 (GMT)
commitaaefb48ff561e7d947da1c4fe5e268f4b1732d09 (patch)
tree1ef5a377a38db2e2a7d98d05e17834cc81e8e33a /macosx/tkMacOSXScale.c
parent05963ced8e8d4dec5a58d5dfa865c1878806fa16 (diff)
downloadtk-aaefb48ff561e7d947da1c4fe5e268f4b1732d09.zip
tk-aaefb48ff561e7d947da1c4fe5e268f4b1732d09.tar.gz
tk-aaefb48ff561e7d947da1c4fe5e268f4b1732d09.tar.bz2
Get the Entry and Spinbox widgets to draw with the native look & feel on
Mac OS X. Also contains some more work on tkMacOSXScale.c, but this doesn't work all the way yet, so it's not currently built.
Diffstat (limited to 'macosx/tkMacOSXScale.c')
-rw-r--r--macosx/tkMacOSXScale.c85
1 files changed, 63 insertions, 22 deletions
diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c
index c271ec0..d0d8de8 100644
--- a/macosx/tkMacOSXScale.c
+++ b/macosx/tkMacOSXScale.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXScale.c,v 1.3 2004/02/16 00:19:42 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXScale.c,v 1.4 2005/03/24 07:16:13 wolfsuit Exp $
*/
#include "tkScale.h"
@@ -147,12 +147,11 @@ TkpDisplayScale(clientData)
CGrafPtr saveWorld;
GDHandle saveDevice;
MacDrawable *macDraw;
- SInt16 initialValue;
- SInt16 minValue;
- SInt16 maxValue;
- SInt16 procID;
- SInt32 controlReference;
- Boolean initiallyVisible = true;
+ SInt32 initialValue;
+ SInt32 minValue;
+ SInt32 maxValue;
+ UInt16 numTicks;
+
fprintf(stderr,"TkpDisplayScale\n");
scalePtr->flags &= ~REDRAW_PENDING;
@@ -215,21 +214,58 @@ TkpDisplayScale(clientData)
/*
* Create Macintosh control.
*/
- if (macScalePtr->scaleHandle == NULL) {
- fprintf(stderr,"Initialising scale\n");
- r.left = macDraw->xOff;
- r.top = macDraw->yOff;
+
+#define MAC_OSX_SCROLL_WIDTH 10
+
+ if (scalePtr->orient == ORIENT_HORIZONTAL) {
+ int offset;
+ offset = (Tk_Height(tkwin) - MAC_OSX_SCROLL_WIDTH)/2;
+ if (offset < 0) {
+ offset = 0;
+ }
+
+ r.left = macDraw->xOff + scalePtr->inset;
+ r.top = macDraw->yOff + offset;
r.right = macDraw->xOff+Tk_Width(tkwin) - scalePtr->inset;
+ r.bottom = macDraw->yOff + offset + MAC_OSX_SCROLL_WIDTH/2;
+ } else {
+ int offset;
+
+ offset = (Tk_Width(tkwin) - MAC_OSX_SCROLL_WIDTH)/2;
+ if (offset < 0) {
+ offset = 0;
+ }
+
+ r.left = macDraw->xOff + offset;
+ r.top = macDraw->yOff + scalePtr->inset;
+ r.right = macDraw->xOff + offset + MAC_OSX_SCROLL_WIDTH/2;
r.bottom = macDraw->yOff+Tk_Height(tkwin) - scalePtr->inset;
+ }
+
+ if (macScalePtr->scaleHandle == NULL) {
+
+ fprintf(stderr,"Initialising scale\n");
initialValue = scalePtr->value;
- minValue = scalePtr->toValue;
- maxValue = scalePtr->fromValue;
- procID = kControlSliderProc;
- controlReference = (SInt32) macScalePtr;
- macScalePtr->scaleHandle = NewControl(windowRef,
- &r, "\p", initiallyVisible, initialValue,minValue,maxValue,
- procID, controlReference);
+ if (scalePtr->orient == ORIENT_HORIZONTAL) {
+ minValue = scalePtr->fromValue;
+ maxValue = scalePtr->toValue;
+ } else {
+ minValue = scalePtr->fromValue;
+ maxValue = scalePtr->toValue;
+ }
+
+ if (scalePtr->tickInterval == 0) {
+ numTicks = 0;
+ } else {
+ numTicks = (maxValue - minValue)/scalePtr->tickInterval;
+ }
+
+ CreateSliderControl(windowRef, &r, initialValue, minValue, maxValue,
+ kControlSliderPointsDownOrRight, numTicks,
+ 1, scaleActionProc,
+ &(macScalePtr->scaleHandle));
+ SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr);
/*
* If we are foremost than make us active.
@@ -237,6 +273,11 @@ TkpDisplayScale(clientData)
if (windowRef == FrontWindow()) {
macScalePtr->flags |= ACTIVE;
}
+ } else {
+ SetControlBounds(macScalePtr->scaleHandle, &r);
+ SetControl32BitValue(macScalePtr->scaleHandle, scalePtr->value);
+ SetControl32BitMinimum(macScalePtr->scaleHandle, scalePtr->fromValue);
+ SetControl32BitMaximum(macScalePtr->scaleHandle, scalePtr->toValue);
}
/*
@@ -375,7 +416,7 @@ MacScaleEventProc(clientData, eventPtr)
return;
}
- part = TrackControl(macScalePtr->scaleHandle, where, scaleActionProc);
+ part = TrackControl(macScalePtr->scaleHandle, where, (void *) -1);
/*
* Update the value for the widget.
@@ -414,9 +455,9 @@ MacScaleEventProc(clientData, eventPtr)
*/
static pascal void
-ScaleActionProc(ControlRef theControl, ControlPartCode partCode)
- /* ControlRef theControl; /* Handle to scrollbat control */
- /* ControlPartCode partCode; /* Part of scrollbar that was "hit" */
+ScaleActionProc(
+ ControlRef theControl, /* Handle to scrollbat control */
+ ControlPartCode partCode) /* Part of scrollbar that was "hit" */
{
int value;
TkScale *scalePtr = (TkScale *) GetControlReference(theControl);