head	1.22;
access;
symbols
	core-8-5-9:1.14.2.1
	core-8-5-8:1.14
	macosx-cocoa-merge:1.17
	macosx-cocoa-premerge:1.17
	macosx-carbon-freeze:1.17
	core-8-5-7:1.14
	core-8-5-6:1.14
	core-8-6-b1:1.17
	core-8-6-a3:1.16
	core-8-5-5:1.14
	core-8-6-a2:1.16
	core-8-5-4:1.14
	core-8-5-3:1.14
	core-8-6-a1:1.15
	core-8-5-branch:1.14.0.2
	core-8-5-2:1.14
	core-8-5-1:1.13
	core-8-5-0:1.13
	core-8-5-b3:1.11
	core-8-5-b2:1.11
	core-8-5-b1:1.11
	core-stablilizer-merge:1.11
	core-stabilizer-branch:1.9.0.2
	core-stabilizer-merge:1.14
	core-8-5-a6:1.9;
locks; strict;
comment	@ * @;


1.22
date	2010.02.05.21.33.14;	author jenglish;	state Exp;
branches;
next	1.21;

1.21
date	2010.02.05.17.42.21;	author nijtmans;	state Exp;
branches;
next	1.20;

1.20
date	2010.01.31.22.50.56;	author jenglish;	state Exp;
branches;
next	1.19;

1.19
date	2010.01.22.14.17.53;	author nijtmans;	state Exp;
branches;
next	1.18;

1.18
date	2009.11.01.18.12.44;	author jenglish;	state Exp;
branches;
next	1.17;

1.17
date	2008.11.09.23.53.09;	author jenglish;	state Exp;
branches;
next	1.16;

1.16
date	2008.07.23.23.24.45;	author nijtmans;	state Exp;
branches;
next	1.15;

1.15
date	2008.04.27.22.41.12;	author dkf;	state Exp;
branches;
next	1.14;

1.14
date	2008.02.23.17.35.28;	author jenglish;	state Exp;
branches
	1.14.2.1;
next	1.13;

1.13
date	2007.12.13.15.26.26;	author dgp;	state Exp;
branches;
next	1.12;

1.12
date	2007.11.25.18.11.12;	author jenglish;	state Exp;
branches;
next	1.11;

1.11
date	2007.06.10.03.25.32;	author jenglish;	state Exp;
branches;
next	1.10;

1.10
date	2007.06.09.21.45.45;	author jenglish;	state Exp;
branches;
next	1.9;

1.9
date	2007.01.11.14.49.47;	author jenglish;	state Exp;
branches
	1.9.2.1;
next	1.8;

1.8
date	2007.01.03.05.06.25;	author nijtmans;	state Exp;
branches;
next	1.7;

1.7
date	2006.12.14.19.51.04;	author jenglish;	state Exp;
branches;
next	1.6;

1.6
date	2006.12.13.20.40.32;	author hobbs;	state Exp;
branches;
next	1.5;

1.5
date	2006.11.27.06.53.55;	author jenglish;	state Exp;
branches;
next	1.4;

1.4
date	2006.11.24.18.04.14;	author jenglish;	state Exp;
branches;
next	1.3;

1.3
date	2006.11.07.03.45.28;	author jenglish;	state Exp;
branches;
next	1.2;

1.2
date	2006.11.03.03.06.22;	author das;	state Exp;
branches;
next	1.1;

1.1
date	2006.10.31.01.42.26;	author hobbs;	state Exp;
branches;
next	;

1.9.2.1
date	2007.06.12.16.22.41;	author dgp;	state Exp;
branches;
next	1.9.2.2;

1.9.2.2
date	2007.11.25.19.19.21;	author dgp;	state Exp;
branches;
next	1.9.2.3;

1.9.2.3
date	2008.03.07.22.03.49;	author dgp;	state Exp;
branches;
next	;

1.14.2.1
date	2010.08.26.02.06.09;	author hobbs;	state Exp;
branches;
next	;


desc
@@


1.22
log
@Laxative patch: Revert contravariant const qualifiers added by the
previous commit to keep codebase in sync with the Tile extension,
which must remain 8.4 compatible.
@
text
@/* $Id: ttkPanedwindow.c,v 1.21 2010/02/05 17:42:21 nijtmans Exp $
 *
 * Copyright (c) 2005, Joe English.  Freely redistributable.
 *
 * ttk::panedwindow widget implementation.
 *
 * TODO: track active/pressed sash.
 */

#include <string.h>
#include <tk.h>
#include "ttkManager.h"
#include "ttkTheme.h"
#include "ttkWidget.h"

/*------------------------------------------------------------------------
 * +++ Layout algorithm.
 *
 * (pos=x/y, size=width/height, depending on -orient=horizontal/vertical)
 *
 * Each pane carries two pieces of state: the request size and the
 * position of the following sash.  (The final pane has no sash,
 * its sash position is used as a sentinel value).
 *
 * Pane geometry is determined by the sash positions.
 * When resizing, sash positions are computed from the request sizes,
 * the available space, and pane weights (see PlaceSashes()).
 * This ensures continuous resize behavior (that is: changing
 * the size by X pixels then changing the size by Y pixels
 * gives the same result as changing the size by X+Y pixels
 * in one step).
 *
 * The request size is initially set to the slave window's requested size.
 * When the user drags a sash, each pane's request size is set to its
 * actual size.  This ensures that panes "stay put" on the next resize.
 *
 * If reqSize == 0, use 0 for the weight as well.  This ensures that
 * "collapsed" panes stay collapsed during a resize, regardless of
 * their nominal -weight.
 *
 * +++ Invariants.
 *
 * #sash 		=  #pane - 1
 * pos(pane[0]) 	=  0
 * pos(sash[i]) 	=  pos(pane[i]) + size(pane[i]), 0 <= i <= #sash
 * pos(pane[i+1]) 	=  pos(sash[i]) + size(sash[i]), 0 <= i <  #sash
 * pos(sash[#sash])	=  size(pw)   // sentinel value, constraint
 *
 * size(pw) 		=  sum(size(pane(0..#pane))) + sum(size(sash(0..#sash)))
 * size(pane[i]) 	>= 0,  for 0 <= i < #pane
 * size(sash[i]) 	>= 0,  for 0 <= i < #sash
 * ==> pos(pane[i]) <= pos(sash[i]) <= pos(pane[i+1]), for 0 <= i < #sash
 *
 * Assumption: all sashes are the same size.
 */

/*------------------------------------------------------------------------
 * +++ Widget record.
 */

typedef struct {
    Tcl_Obj	*orientObj;
    int 	orient;
    int 	width;
    int 	height;
    Ttk_Manager	*mgr;
    Tk_OptionTable paneOptionTable;
    Ttk_Layout	sashLayout;
    int 	sashThickness;
} PanedPart;

typedef struct {
    WidgetCore	core;
    PanedPart	paned;
} Paned;

/* @@@@@@ NOTE: -orient is readonly 'cause dynamic oriention changes NYI
 */
static Tk_OptionSpec PanedOptionSpecs[] = {
    {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
	Tk_Offset(Paned,paned.orientObj), Tk_Offset(Paned,paned.orient),
	0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED },
    {TK_OPTION_INT, "-width", "width", "Width", "0",
	-1,Tk_Offset(Paned,paned.width),
	0,0,GEOMETRY_CHANGED },
    {TK_OPTION_INT, "-height", "height", "Height", "0",
	-1,Tk_Offset(Paned,paned.height),
	0,0,GEOMETRY_CHANGED },

    WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};

/*------------------------------------------------------------------------
 * +++ Slave pane record.
 */
typedef struct {
    int 	reqSize;		/* Pane request size */
    int 	sashPos;		/* Folowing sash position */
    int 	weight; 		/* Pane -weight, for resizing */
} Pane;

static Tk_OptionSpec PaneOptionSpecs[] = {
    {TK_OPTION_INT, "-weight", "weight", "Weight", "0",
	-1,Tk_Offset(Pane,weight), 0,0,GEOMETRY_CHANGED },
    {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
};

/* CreatePane --
 * 	Create a new pane record.
 */
static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window slaveWindow)
{
    Tk_OptionTable optionTable = pw->paned.paneOptionTable;
    void *record = ckalloc(sizeof(Pane));
    Pane *pane = record;

    memset(record, 0, sizeof(Pane));
    if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
	ckfree(record);
	return NULL;
    }

    pane->reqSize
	= pw->paned.orient == TTK_ORIENT_HORIZONTAL
	? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow);

    return pane;
}

/* DestroyPane --
 * 	Free pane record.
 */
static void DestroyPane(Paned *pw, Pane *pane)
{
    void *record = pane;
    Tk_FreeConfigOptions(record, pw->paned.paneOptionTable, pw->core.tkwin);
    ckfree(record);
}

/* ConfigurePane --
 * 	Set pane options.
 */
static int ConfigurePane(
    Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window slaveWindow,
    int objc, Tcl_Obj *const objv[])
{
    Ttk_Manager *mgr = pw->paned.mgr;
    Tk_SavedOptions savedOptions;
    int mask = 0;

    if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable,
	    objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK)
    {
	return TCL_ERROR;
    }

    /* Sanity-check:
     */
    if (pane->weight < 0) {
	Tcl_AppendResult(interp, "-weight must be nonnegative", NULL);
	goto error;
    }

    /* Done.
     */
    Tk_FreeSavedOptions(&savedOptions);
    Ttk_ManagerSizeChanged(mgr);
    return TCL_OK;

error:
    Tk_RestoreSavedOptions(&savedOptions);
    return TCL_ERROR;
}


/*------------------------------------------------------------------------
 * +++ Sash adjustment.
 */

/* ShoveUp --
 * 	Place sash i at specified position, recursively shoving
 * 	previous sashes upwards as needed, until hitting the top
 * 	of the window.  If that happens, shove back down.
 *
 * 	Returns: final position of sash i.
 */

static int ShoveUp(Paned *pw, int i, int pos)
{
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
    int sashThickness = pw->paned.sashThickness;

    if (i == 0) {
	if (pos < 0)
	    pos = 0;
    } else {
	Pane *prevPane = Ttk_SlaveData(pw->paned.mgr, i-1);
	if (pos < prevPane->sashPos + sashThickness)
	    pos = ShoveUp(pw, i-1, pos - sashThickness) + sashThickness;
    }
    return pane->sashPos = pos;
}

/* ShoveDown --
 * 	Same as ShoveUp, but going in the opposite direction
 * 	and stopping at the sentinel sash.
 */
static int ShoveDown(Paned *pw, int i, int pos)
{
    Pane *pane = Ttk_SlaveData(pw->paned.mgr,i);
    int sashThickness = pw->paned.sashThickness;

    if (i == Ttk_NumberSlaves(pw->paned.mgr) - 1) {
	pos = pane->sashPos; /* Sentinel value == master window size */
    } else {
	Pane *nextPane = Ttk_SlaveData(pw->paned.mgr,i+1);
	if (pos + sashThickness > nextPane->sashPos)
	    pos = ShoveDown(pw, i+1, pos + sashThickness) - sashThickness;
    }
    return pane->sashPos = pos;
}

/* PanedSize --
 * 	Compute the requested size of the paned widget
 * 	from the individual pane request sizes.
 *
 * 	Used as the WidgetSpec sizeProc and the ManagerSpec sizeProc.
 */
static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
    Paned *pw = recordPtr;
    int nPanes = Ttk_NumberSlaves(pw->paned.mgr);
    int nSashes = nPanes - 1;
    int sashThickness = pw->paned.sashThickness;
    int width = 0, height = 0;
    int index;

    if (pw->paned.orient == TTK_ORIENT_HORIZONTAL) {
	for (index = 0; index < nPanes; ++index) {
	    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
	    Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);

	    if (height < Tk_ReqHeight(slaveWindow))
		height = Tk_ReqHeight(slaveWindow);
	    width += pane->reqSize;
	}
	width += nSashes * sashThickness;
    } else {
	for (index = 0; index < nPanes; ++index) {
	    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
	    Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);

	    if (width < Tk_ReqWidth(slaveWindow))
		width = Tk_ReqWidth(slaveWindow);
	    height += pane->reqSize;
	}
	height += nSashes * sashThickness;
    }

    *widthPtr = pw->paned.width > 0 ? pw->paned.width : width;
    *heightPtr = pw->paned.height > 0 ? pw->paned.height : height;
    return 1;
}

/* AdjustPanes --
 * 	Set pane request sizes from sash positions.
 *
 * NOTE:
 * 	AdjustPanes followed by PlaceSashes (called during relayout)
 * 	will leave the sashes in the same place, as long as available size
 * 	remains contant.
 */
static void AdjustPanes(Paned *pw)
{
    int sashThickness = pw->paned.sashThickness;
    int pos = 0;
    int index;

    for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
	Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
	int size = pane->sashPos - pos;
	pane->reqSize = size >= 0 ? size : 0;
	pos = pane->sashPos + sashThickness;
    }
}

/* PlaceSashes --
 *	Set sash positions from pane request sizes and available space.
 *	The sentinel sash position is set to the available space.
 *
 *	Allocate pane->reqSize pixels to each pane, and distribute
 *	the difference = available size - requested size according
 *	to pane->weight.
 *
 *	If there's still some left over, squeeze panes from the bottom up
 *	(This can happen if all weights are zero, or if one or more panes
 *	are too small to absorb the required shrinkage).
 *
 * Notes:
 * 	This doesn't distribute the remainder pixels as evenly as it could
 * 	when more than one pane has weight > 1.
 */
static void PlaceSashes(Paned *pw, int width, int height)
{
    Ttk_Manager *mgr = pw->paned.mgr;
    int nPanes = Ttk_NumberSlaves(mgr);
    int sashThickness = pw->paned.sashThickness;
    int available = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? width : height;
    int reqSize = 0, totalWeight = 0;
    int difference, delta, remainder, pos, i;

    if (nPanes == 0)
	return;

    /* Compute total required size and total available weight:
     */
    for (i = 0; i < nPanes; ++i) {
	Pane *pane = Ttk_SlaveData(mgr, i);
	reqSize += pane->reqSize;
	totalWeight += pane->weight * (pane->reqSize != 0);
    }

    /* Compute difference to be redistributed:
     */
    difference = available - reqSize - sashThickness*(nPanes-1);
    if (totalWeight != 0) {
	delta = difference / totalWeight;
	remainder = difference % totalWeight;
	if (remainder < 0) {
	    --delta;
	    remainder += totalWeight;
	}
    } else {
	delta = remainder = 0;
    }
    /* ASSERT: 0 <= remainder < totalWeight */

    /* Place sashes:
     */
    pos = 0;
    for (i = 0; i < nPanes; ++i) {
	Pane *pane = Ttk_SlaveData(mgr, i);
	int weight = pane->weight * (pane->reqSize != 0);
	int size = pane->reqSize + delta * weight;

	if (weight > remainder)
	    weight = remainder;
	remainder -= weight;
	size += weight;

	if (size < 0)
	    size = 0;

	pane->sashPos = (pos += size);
	pos += sashThickness;
    }

    /* Handle emergency shrink/emergency stretch:
     * Set sentinel sash position to end of widget,
     * shove preceding sashes up.
     */
    ShoveUp(pw, nPanes - 1, available);
}

/* PlacePanes --
 *	Places slave panes based on sash positions.
 */
static void PlacePanes(Paned *pw)
{
    int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
    int width = Tk_Width(pw->core.tkwin), height = Tk_Height(pw->core.tkwin);
    int sashThickness = pw->paned.sashThickness;
    int pos = 0;
    int index;

    for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
	Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
	int size = pane->sashPos - pos;

	if (size > 0) {
	    if (horizontal) {
		Ttk_PlaceSlave(pw->paned.mgr, index, pos, 0, size, height);
	    } else {
		Ttk_PlaceSlave(pw->paned.mgr, index, 0, pos, width, size);
	    }
	} else {
	    Ttk_UnmapSlave(pw->paned.mgr, index);
	}

	pos = pane->sashPos + sashThickness;
    }
}

/*------------------------------------------------------------------------
 * +++ Manager specification.
 */

static void PanedPlaceSlaves(void *managerData)
{
    Paned *pw = managerData;
    PlaceSashes(pw, Tk_Width(pw->core.tkwin), Tk_Height(pw->core.tkwin));
    PlacePanes(pw);
}

static void PaneRemoved(void *managerData, int index)
{
    Paned *pw = managerData;
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
    DestroyPane(pw, pane);
}

static int AddPane(
    Tcl_Interp *interp, Paned *pw,
    int destIndex, Tk_Window slaveWindow,
    int objc, Tcl_Obj *const objv[])
{
    Pane *pane;
    if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) {
	return TCL_ERROR;
    }
    if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) {
	Tcl_AppendResult(interp,
	    Tk_PathName(slaveWindow), " already added",
	    NULL);
	return TCL_ERROR;
    }

    pane = CreatePane(interp, pw, slaveWindow);
    if (!pane) {
	return TCL_ERROR;
    }
    if (ConfigurePane(interp, pw, pane, slaveWindow, objc, objv) != TCL_OK) {
	DestroyPane(pw, pane);
	return TCL_ERROR;
    }

    Ttk_InsertSlave(pw->paned.mgr, destIndex, slaveWindow, pane);
    return TCL_OK;
}

/* PaneRequest --
 * 	Only update pane request size if slave is currently unmapped.
 * 	Geometry requests from mapped slaves are not directly honored
 * 	in order to avoid unexpected pane resizes (esp. while the
 * 	user is dragging a sash [#1325286]).
 */
static int PaneRequest(void *managerData, int index, int width, int height)
{
    Paned *pw = managerData;
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
    Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
    int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;

    if (!Tk_IsMapped(slaveWindow)) {
	pane->reqSize = horizontal ? width : height;
    }
    return 1;
}

static Ttk_ManagerSpec PanedManagerSpec = {
    { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
    PanedSize,
    PanedPlaceSlaves,
    PaneRequest,
    PaneRemoved
};

/*------------------------------------------------------------------------
 * +++ Event handler.
 *
 * <<NOTE-PW-LEAVE-NOTIFYINFERIOR>>
 * Tk does not execute binding scripts for <Leave> events when
 * the pointer crosses from a parent to a child.  This widget
 * needs to know when that happens, though, so it can reset
 * the cursor.
 *
 * This event handler generates an <<EnteredChild>> virtual event
 * on LeaveNotify/NotifyInferior.
 */

static const unsigned PanedEventMask = LeaveWindowMask;
static void PanedEventProc(ClientData clientData, XEvent *eventPtr)
{
    WidgetCore *corePtr = clientData;
    if (   eventPtr->type == LeaveNotify
	&& eventPtr->xcrossing.detail == NotifyInferior)
    {
	TtkSendVirtualEvent(corePtr->tkwin, "EnteredChild");
    }
}

/*------------------------------------------------------------------------
 * +++ Initialization and cleanup hooks.
 */

static void PanedInitialize(Tcl_Interp *interp, void *recordPtr)
{
    Paned *pw = recordPtr;

    Tk_CreateEventHandler(pw->core.tkwin,
	PanedEventMask, PanedEventProc, recordPtr);
    pw->paned.mgr = Ttk_CreateManager(&PanedManagerSpec, pw, pw->core.tkwin);
    pw->paned.paneOptionTable = Tk_CreateOptionTable(interp,PaneOptionSpecs);
    pw->paned.sashLayout = 0;
    pw->paned.sashThickness = 1;
}

static void PanedCleanup(void *recordPtr)
{
    Paned *pw = recordPtr;

    if (pw->paned.sashLayout)
	Ttk_FreeLayout(pw->paned.sashLayout);
    Tk_DeleteEventHandler(pw->core.tkwin,
	PanedEventMask, PanedEventProc, recordPtr);
    Ttk_DeleteManager(pw->paned.mgr);
}

/* Post-configuration hook.
 */
static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
    Paned *pw = clientData;

    if (mask & GEOMETRY_CHANGED) {
	/* User has changed -width or -height.
	 * Recalculate sash positions based on requested size.
	 */
	Tk_Window tkwin = pw->core.tkwin;
	PlaceSashes(pw,
	    pw->paned.width > 0 ? pw->paned.width : Tk_Width(tkwin),
	    pw->paned.height > 0 ? pw->paned.height : Tk_Height(tkwin));
    }

    return TCL_OK;
}

/*------------------------------------------------------------------------
 * +++ Layout management hooks.
 */
static Ttk_Layout PanedGetLayout(
    Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
    Paned *pw = recordPtr;
    Ttk_Layout panedLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);

    if (panedLayout) {
	int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
	const char *layoutName =
	    horizontal ? ".Vertical.Sash" : ".Horizontal.Sash";
	Ttk_Layout sashLayout = Ttk_CreateSublayout(
	    interp, themePtr, panedLayout, layoutName, pw->core.optionTable);

	if (sashLayout) {
	    int sashWidth, sashHeight;

	    Ttk_LayoutSize(sashLayout, 0, &sashWidth, &sashHeight);
	    pw->paned.sashThickness = horizontal ? sashWidth : sashHeight;

	    if (pw->paned.sashLayout)
		Ttk_FreeLayout(pw->paned.sashLayout);
	    pw->paned.sashLayout = sashLayout;
	} else {
	    Ttk_FreeLayout(panedLayout);
	    return 0;
	}
    }

    return panedLayout;
}

/*------------------------------------------------------------------------
 * +++ Drawing routines.
 */

/* SashLayout --
 * 	Place the sash sublayout after the specified pane,
 * 	in preparation for drawing.
 */
static Ttk_Layout SashLayout(Paned *pw, int index)
{
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
    int thickness = pw->paned.sashThickness,
	height = Tk_Height(pw->core.tkwin),
	width = Tk_Width(pw->core.tkwin),
	sashPos = pane->sashPos;

    Ttk_PlaceLayout(
	pw->paned.sashLayout, pw->core.state,
	pw->paned.orient == TTK_ORIENT_HORIZONTAL
	    ? Ttk_MakeBox(sashPos, 0, thickness, height)
	    : Ttk_MakeBox(0, sashPos, width, thickness));

    return pw->paned.sashLayout;
}

static void DrawSash(Paned *pw, int index, Drawable d)
{
    Ttk_DrawLayout(SashLayout(pw, index), pw->core.state, d);
}

static void PanedDisplay(void *recordPtr, Drawable d)
{
    Paned *pw = recordPtr;
    int i, nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;

    TtkWidgetDisplay(recordPtr, d);
    for (i = 0; i < nSashes; ++i) {
	DrawSash(pw, i, d);
    }
}

/*------------------------------------------------------------------------
 * +++ Widget commands.
 */

/* $pw add window [ options ... ]
 */
static int PanedAddCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    Paned *pw = recordPtr;
    Tk_Window slaveWindow;

    if (objc < 3) {
	Tcl_WrongNumArgs(interp, 2, objv, "window");
	return TCL_ERROR;
    }

    slaveWindow = Tk_NameToWindow(
	interp, Tcl_GetString(objv[2]), pw->core.tkwin);

    if (!slaveWindow) {
	return TCL_ERROR;
    }

    return AddPane(interp, pw, Ttk_NumberSlaves(pw->paned.mgr), slaveWindow,
	    objc - 3, objv + 3);
}

/* $pw insert $index $slave ?-option value ...?
 * 	Insert new slave, or move existing one.
 */
static int PanedInsertCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    Paned *pw = recordPtr;
    int nSlaves = Ttk_NumberSlaves(pw->paned.mgr);
    int srcIndex, destIndex;
    Tk_Window slaveWindow;

    if (objc < 4) {
	Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?");
	return TCL_ERROR;
    }

    slaveWindow = Tk_NameToWindow(
	interp, Tcl_GetString(objv[3]), pw->core.tkwin);
    if (!slaveWindow) {
	return TCL_ERROR;
    }

    if (!strcmp(Tcl_GetString(objv[2]), "end")) {
	destIndex = Ttk_NumberSlaves(pw->paned.mgr);
    } else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
		interp,pw->paned.mgr,objv[2],&destIndex))
    {
	return TCL_ERROR;
    }

    srcIndex = Ttk_SlaveIndex(pw->paned.mgr, slaveWindow);
    if (srcIndex < 0) { /* New slave: */
	return AddPane(interp, pw, destIndex, slaveWindow, objc-4, objv+4);
    } /* else -- move existing slave: */

    if (destIndex >= nSlaves)
	destIndex  = nSlaves - 1;
    Ttk_ReorderSlave(pw->paned.mgr, srcIndex, destIndex);

    return objc == 4 ? TCL_OK :
	ConfigurePane(interp, pw,
		Ttk_SlaveData(pw->paned.mgr, destIndex),
		Ttk_SlaveWindow(pw->paned.mgr, destIndex),
		objc-4,objv+4);
}

/* $pw forget $pane
 */
static int PanedForgetCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    Paned *pw = recordPtr;
    int paneIndex;

    if (objc != 3) {
	Tcl_WrongNumArgs(interp, 2,objv, "pane");
	return TCL_ERROR;
    }

    if (TCL_OK != Ttk_GetSlaveIndexFromObj(
		    interp, pw->paned.mgr, objv[2], &paneIndex))
    {
	return TCL_ERROR;
    }
    Ttk_ForgetSlave(pw->paned.mgr, paneIndex);

    return TCL_OK;
}

/* $pw identify ?what? $x $y --
 * 	Return index of sash at $x,$y
 */
static int PanedIdentifyCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    const char *whatTable[] = { "element", "sash", NULL };
    enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
    int what = IDENTIFY_SASH;
    Paned *pw = recordPtr;
    int sashThickness = pw->paned.sashThickness;
    int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
    int x, y, pos;
    int index;

    if (objc < 4 || objc > 5) {
	Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
	return TCL_ERROR;
    }

    if (   Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
	|| Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK
	|| (objc == 5 &&
	    Tcl_GetIndexFromObj(interp, objv[2], whatTable, "option", 0, &what)
		!= TCL_OK)
    ) {
	return TCL_ERROR;
    }

    pos = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? x : y;
    for (index = 0; index < nSashes; ++index) {
	Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
	if (pane->sashPos <= pos && pos <= pane->sashPos + sashThickness) {
	    /* Found it. */
	    switch (what) {
		case IDENTIFY_SASH:
		    Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
		    return TCL_OK;
		case IDENTIFY_ELEMENT:
		{
		    Ttk_Element element =
			Ttk_IdentifyElement(SashLayout(pw, index), x, y);
		    if (element) {
			Tcl_SetObjResult(interp,
			    Tcl_NewStringObj(Ttk_ElementName(element), -1));
		    }
		    return TCL_OK;
		}
	    }
	}
    }

    return TCL_OK; /* nothing found - return empty string */
}

/* $pw pane $pane ?-option ?value -option value ...??
 * 	Query/modify pane options.
 */
static int PanedPaneCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    Paned *pw = recordPtr;
    int paneIndex;
    Tk_Window slaveWindow;
    Pane *pane;

    if (objc < 3) {
	Tcl_WrongNumArgs(interp, 2,objv, "pane ?-option value ...?");
	return TCL_ERROR;
    }

    if (TCL_OK != Ttk_GetSlaveIndexFromObj(
		    interp,pw->paned.mgr,objv[2],&paneIndex))
    {
	return TCL_ERROR;
    }

    pane = Ttk_SlaveData(pw->paned.mgr, paneIndex);
    slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, paneIndex);

    switch (objc) {
	case 3:
	    return TtkEnumerateOptions(interp, pane, PaneOptionSpecs,
			pw->paned.paneOptionTable, slaveWindow);
	case 4:
	    return TtkGetOptionValue(interp, pane, objv[3],
			pw->paned.paneOptionTable, slaveWindow);
	default:
	    return ConfigurePane(interp, pw, pane, slaveWindow, objc-3,objv+3);
    }
}

/* $pw panes --
 * 	Return list of managed panes.
 */
static int PanedPanesCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    Paned *pw = recordPtr;
    Ttk_Manager *mgr = pw->paned.mgr;
    Tcl_Obj *panes;
    int i;

    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 2, objv, "");
	return TCL_ERROR;
    }

    panes = Tcl_NewListObj(0, NULL);
    for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) {
	const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i));
	Tcl_ListObjAppendElement(interp, panes, Tcl_NewStringObj(pathName,-1));
    }
    Tcl_SetObjResult(interp, panes);

    return TCL_OK;
}


/* $pw sashpos $index ?$newpos?
 * 	Query or modify sash position.
 */
static int PanedSashposCommand(
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
    Paned *pw = recordPtr;
    int sashIndex, position = -1;
    Pane *pane;

    if (objc < 3 || objc > 4) {
	Tcl_WrongNumArgs(interp, 2,objv, "index ?newpos?");
	return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) {
	return TCL_ERROR;
    }
    if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) {
	Tcl_AppendResult(interp,
	    "sash index ", Tcl_GetString(objv[2]), " out of range",
	    NULL);
	return TCL_ERROR;
    }

    pane = Ttk_SlaveData(pw->paned.mgr, sashIndex);

    if (objc == 3) {
	Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
	return TCL_OK;
    }
    /* else -- set new sash position */

    if (Tcl_GetIntFromObj(interp, objv[3], &position) != TCL_OK) {
	return TCL_ERROR;
    }

    if (position < pane->sashPos) {
	ShoveUp(pw, sashIndex, position);
    } else {
	ShoveDown(pw, sashIndex, position);
    }

    AdjustPanes(pw);
    Ttk_ManagerLayoutChanged(pw->paned.mgr);

    Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
    return TCL_OK;
}

static const Ttk_Ensemble PanedCommands[] = {
    { "add", 		PanedAddCommand,0 },
    { "configure",	TtkWidgetConfigureCommand,0 },
    { "cget",		TtkWidgetCgetCommand,0 },
    { "forget", 	PanedForgetCommand,0 },
    { "identify", 	PanedIdentifyCommand,0 },
    { "insert", 	PanedInsertCommand,0 },
    { "instate",	TtkWidgetInstateCommand,0 },
    { "pane",   	PanedPaneCommand,0 },
    { "panes",   	PanedPanesCommand,0 },
    { "sashpos",  	PanedSashposCommand,0 },
    { "state",  	TtkWidgetStateCommand,0 },
    { 0,0,0 }
};

/*------------------------------------------------------------------------
 * +++ Widget specification.
 */

static WidgetSpec PanedWidgetSpec =
{
    "TPanedwindow",		/* className */
    sizeof(Paned),		/* recordSize */
    PanedOptionSpecs,		/* optionSpecs */
    PanedCommands,		/* subcommands */
    PanedInitialize,		/* initializeProc */
    PanedCleanup,		/* cleanupProc */
    TtkCoreConfigure,		/* configureProc */
    PanedPostConfigure, 	/* postConfigureProc */
    PanedGetLayout,		/* getLayoutProc */
    PanedSize, 			/* sizeProc */
    TtkWidgetDoLayout,		/* layoutProc */
    PanedDisplay		/* displayProc */
};

/*------------------------------------------------------------------------
 * +++ Elements and layouts.
 */

static const int DEFAULT_SASH_THICKNESS = 5;

typedef struct {
    Tcl_Obj *thicknessObj;
} SashElement;

static Ttk_ElementOptionSpec SashElementOptions[] = {
    { "-sashthickness", TK_OPTION_INT,
	    Tk_Offset(SashElement,thicknessObj), "5" },
    { NULL, 0, 0, NULL }
};

static void SashElementSize(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
    SashElement *sash = elementRecord;
    int thickness = DEFAULT_SASH_THICKNESS;
    Tcl_GetIntFromObj(NULL, sash->thicknessObj, &thickness);
    *widthPtr = *heightPtr = thickness;
}

static Ttk_ElementSpec SashElementSpec = {
    TK_STYLE_VERSION_2,
    sizeof(SashElement),
    SashElementOptions,
    SashElementSize,
    TtkNullElementDraw
};

TTK_BEGIN_LAYOUT(PanedLayout)
    TTK_NODE("Panedwindow.background", 0)/* @@@@@@ BUG: empty layouts don't work */
TTK_END_LAYOUT

TTK_BEGIN_LAYOUT(HorizontalSashLayout)
    TTK_NODE("Sash.hsash", TTK_FILL_X)
TTK_END_LAYOUT

TTK_BEGIN_LAYOUT(VerticalSashLayout)
    TTK_NODE("Sash.vsash", TTK_FILL_Y)
TTK_END_LAYOUT

/*------------------------------------------------------------------------
 * +++ Registration routine.
 */
MODULE_SCOPE
void TtkPanedwindow_Init(Tcl_Interp *interp)
{
    Ttk_Theme themePtr = Ttk_GetDefaultTheme(interp);
    RegisterWidget(interp, "ttk::panedwindow", &PanedWidgetSpec);

    Ttk_RegisterElement(interp, themePtr, "hsash", &SashElementSpec, 0);
    Ttk_RegisterElement(interp, themePtr, "vsash", &SashElementSpec, 0);

    Ttk_RegisterLayout(themePtr, "TPanedwindow", PanedLayout);
    Ttk_RegisterLayout(themePtr, "Horizontal.Sash", HorizontalSashLayout);
    Ttk_RegisterLayout(themePtr, "Vertical.Sash", VerticalSashLayout);
}

@


1.21
log
@Make the various stub tables and hook pointers const,
just as Tcl and Tk.
Make more internal tables "const"
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.20 2010/01/31 22:50:56 jenglish Exp $
d716 1
a716 1
    const char *const whatTable[] = { "element", "sash", NULL };
@


1.20
log
@Change signature of widget subcommand procedures to match Tcl_ObjCmdProc.
Merge now-redundant ensemble dispatch code.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.19 2010/01/22 14:17:53 nijtmans Exp $
d716 1
a716 1
    const char *whatTable[] = { "element", "sash", NULL };
@


1.19
log
@fix more gcc warnings: missing initializer
Eliminate use of __argc and __argv for CYGWIN
Make cygwin configuration error into
 a warning: CYGWIN compilation works
although there still are test failures.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.18 2009/11/01 18:12:44 jenglish Exp $
d620 1
a620 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d645 1
a645 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d690 1
a690 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d714 1
a714 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d769 1
a769 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d806 1
a806 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d833 1
a833 1
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr)
d878 13
a890 14
static WidgetCommandSpec PanedCommands[] =
{
    { "add", 		PanedAddCommand },
    { "configure",	TtkWidgetConfigureCommand },
    { "cget",		TtkWidgetCgetCommand },
    { "forget", 	PanedForgetCommand },
    { "identify", 	PanedIdentifyCommand },
    { "insert", 	PanedInsertCommand },
    { "instate",	TtkWidgetInstateCommand },
    { "pane",   	PanedPaneCommand },
    { "panes",   	PanedPanesCommand },
    { "sashpos",  	PanedSashposCommand },
    { "state",  	TtkWidgetStateCommand },
    { 0,0 }
@


1.18
log
@Uniform, extensible syntax for [$w identify] methods:
[$w identify $component $x $y].
All ttk::* widgets support [$w identify element $x $y];
widgets with other identifiable parts may have additional subcommands.
Notebook widgets support [$nb identify tab],
Panedwindow widgets support [$w identify sash].
Older 2-argument form [$w identify $x $y] still supported,
though it does different things depending on the widget.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.17 2008/11/09 23:53:09 jenglish Exp $
d927 1
a927 1
    {NULL}
@


1.17
log
@Ttk widget initializeProc()s now return void instead of
a status code, and are no longer allowed to fail.
(Fix for #2207435 in progress).
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.16 2008/07/23 23:24:45 nijtmans Exp $
d576 5
a580 1
static void DrawSash(Paned *pw, Drawable d, Ttk_Box b)
d582 11
a592 2
    Ttk_Layout sashLayout = pw->paned.sashLayout;
    Ttk_State state = pw->core.state;
d594 6
a599 2
    Ttk_PlaceLayout(sashLayout, state, b);
    Ttk_DrawLayout(sashLayout, state, d);
d605 1
a605 6
    int nPanes = Ttk_NumberSlaves(pw->paned.mgr),
	horizontal =  pw->paned.orient == TTK_ORIENT_HORIZONTAL,
	thickness = pw->paned.sashThickness,
	height = Tk_Height(pw->core.tkwin),
	width = Tk_Width(pw->core.tkwin);
    int i;
d608 2
a609 10

    /* Draw sashes:
     */
    for (i = 0; i < nPanes; ++i) {
	Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
	if (horizontal) {
	    DrawSash(pw, d, Ttk_MakeBox(pane->sashPos, 0, thickness, height));
	} else {
	    DrawSash(pw, d, Ttk_MakeBox(0, pane->sashPos, width, thickness));
	}
d710 1
a710 1
/* $pw identify $x $y --
d716 3
d725 2
a726 2
    if (objc != 4) {
	Tcl_WrongNumArgs(interp, 2,objv, "x y");
d729 6
a734 2
    if (   Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK
	|| Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK
d743 16
a758 2
	    Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
	    return TCL_OK;
d762 1
a762 1
    return TCL_OK;	/* return empty string */
@


1.16
log
@fix [2021443] inconsistant "wrong # args" messages (for Tk)
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.15 2008/04/27 22:41:12 dkf Exp $
d496 1
a496 1
static int PanedInitialize(Tcl_Interp *interp, void *recordPtr)
a505 2

    return TCL_OK;
@


1.15
log
@Get rid of pre-C89-isms (esp. CONST vs const).
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.14 2008/02/23 17:35:28 jenglish Exp $
d532 1
a532 1
	PlaceSashes(pw, 
d639 1
a639 1
/* $pw insert $index $slave ?options...?
d651 1
a651 1
	Tcl_WrongNumArgs(interp, 2,objv, "index slave ?options...?");
d664 1
a664 1
		interp,pw->paned.mgr,objv[2],&destIndex)) 
d699 1
a699 1
		    interp, pw->paned.mgr, objv[2], &paneIndex)) 
d754 1
a754 1
	Tcl_WrongNumArgs(interp, 2,objv, "pane ?-option value...?");
d940 1
a940 1
MODULE_SCOPE 
@


1.14
log
@Don't enforce minimum sash thickness of 5 pixels, just use 5 as a default
[FR 1898288]
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.13 2007/12/13 15:26:26 dgp Exp $
d145 1
a145 1
    int objc, Tcl_Obj *CONST objv[])
d618 1
a618 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
d643 1
a643 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
d688 1
a688 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
d712 1
a712 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
d746 1
a746 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
d783 1
a783 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
d810 1
a810 1
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
@


1.14.2.1
log
@        Major backport of 8.6 Ttk for 8.5.9.  Most changes were only being
        committed to head (8.6), although they could apply for 8.5 as well.
        This re-sync makes future work easier to maintain and adds some
        useful work for 8.5 users. Notable changes:
        - Lots of code cleanup
        - Some bug fixes never backported
        - Addition of ttk::spinbox
        - minor color changes
        - Improved Vista/7 styling
        - Move to tile version 0.8.6 (pseudo-package)
        - ABI and API compatible (even $w identify)
        - minor new features (extended $w identify)
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.22 2010/02/05 21:33:14 jenglish Exp $
d145 1
a145 1
    int objc, Tcl_Obj *const objv[])
d496 1
a496 1
static void PanedInitialize(Tcl_Interp *interp, void *recordPtr)
d506 2
d532 1
a532 1
	PlaceSashes(pw,
d578 1
a578 5
/* SashLayout --
 * 	Place the sash sublayout after the specified pane,
 * 	in preparation for drawing.
 */
static Ttk_Layout SashLayout(Paned *pw, int index)
d580 2
a581 11
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
    int thickness = pw->paned.sashThickness,
	height = Tk_Height(pw->core.tkwin),
	width = Tk_Width(pw->core.tkwin),
	sashPos = pane->sashPos;

    Ttk_PlaceLayout(
	pw->paned.sashLayout, pw->core.state,
	pw->paned.orient == TTK_ORIENT_HORIZONTAL
	    ? Ttk_MakeBox(sashPos, 0, thickness, height)
	    : Ttk_MakeBox(0, sashPos, width, thickness));
d583 2
a584 6
    return pw->paned.sashLayout;
}

static void DrawSash(Paned *pw, int index, Drawable d)
{
    Ttk_DrawLayout(SashLayout(pw, index), pw->core.state, d);
d590 6
a595 1
    int i, nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
d598 10
a607 2
    for (i = 0; i < nSashes; ++i) {
	DrawSash(pw, i, d);
d618 1
a618 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
d639 1
a639 1
/* $pw insert $index $slave ?-option value ...?
d643 1
a643 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
d651 1
a651 1
	Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?");
d664 1
a664 1
		interp,pw->paned.mgr,objv[2],&destIndex))
d688 1
a688 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
d699 1
a699 1
		    interp, pw->paned.mgr, objv[2], &paneIndex))
d708 1
a708 1
/* $pw identify ?what? $x $y --
d712 1
a712 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
a713 3
    const char *whatTable[] = { "element", "sash", NULL };
    enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
    int what = IDENTIFY_SASH;
d720 2
a721 2
    if (objc < 4 || objc > 5) {
	Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
d724 2
a725 6

    if (   Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
	|| Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK
	|| (objc == 5 &&
	    Tcl_GetIndexFromObj(interp, objv[2], whatTable, "option", 0, &what)
		!= TCL_OK)
d734 2
a735 16
	    /* Found it. */
	    switch (what) {
		case IDENTIFY_SASH:
		    Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
		    return TCL_OK;
		case IDENTIFY_ELEMENT:
		{
		    Ttk_Element element =
			Ttk_IdentifyElement(SashLayout(pw, index), x, y);
		    if (element) {
			Tcl_SetObjResult(interp,
			    Tcl_NewStringObj(Ttk_ElementName(element), -1));
		    }
		    return TCL_OK;
		}
	    }
d739 1
a739 1
    return TCL_OK; /* nothing found - return empty string */
d746 1
a746 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
d754 1
a754 1
	Tcl_WrongNumArgs(interp, 2,objv, "pane ?-option value ...?");
d783 1
a783 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
d810 1
a810 1
    void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
d855 14
a868 13
static const Ttk_Ensemble PanedCommands[] = {
    { "add", 		PanedAddCommand,0 },
    { "configure",	TtkWidgetConfigureCommand,0 },
    { "cget",		TtkWidgetCgetCommand,0 },
    { "forget", 	PanedForgetCommand,0 },
    { "identify", 	PanedIdentifyCommand,0 },
    { "insert", 	PanedInsertCommand,0 },
    { "instate",	TtkWidgetInstateCommand,0 },
    { "pane",   	PanedPaneCommand,0 },
    { "panes",   	PanedPanesCommand,0 },
    { "sashpos",  	PanedSashposCommand,0 },
    { "state",  	TtkWidgetStateCommand,0 },
    { 0,0,0 }
d904 1
a904 1
    { NULL, 0, 0, NULL }
d940 1
a940 1
MODULE_SCOPE
@


1.13
log
@merge stable branch onto HEAD
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.9.2.2 2007/11/25 19:19:21 dgp Exp $
a15 2
#define MIN_SASH_THICKNESS 5

a570 5
    /* Sanity-check:
     */
    if (pw->paned.sashThickness < MIN_SASH_THICKNESS)
	pw->paned.sashThickness = MIN_SASH_THICKNESS;

d895 2
d912 1
a912 1
    int thickness = MIN_SASH_THICKNESS;
@


1.12
log
@Internal Ttk_Manager API updates; Fixed [Bug 1343984];
Added [$nb hide] method; [$nb add] on already-managed windows
no longer throws an error, can be used to re-add a hidden tab.
Updated docs and test suite.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.11 2007/06/10 03:25:32 jenglish Exp $
@


1.11
log
@Added -width and -height options.
Added 'panes' method, return list of managed windows.
'sashpos' method is now documented as part of the public interface,
and details clarified.
Should be easier to set initial sash positions now [Alleviates #1659067].
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.10 2007/06/09 21:45:45 jenglish Exp $
d407 1
a407 1
static void PaneRemoved(Ttk_Manager *mgr, int index)
d409 2
a410 2
    Paned *pw = Ttk_ManagerData(mgr);
    Pane *pane = Ttk_SlaveData(mgr, index);
d443 3
a445 3
/* PanedGeometryRequestProc --
 * 	Update pane request size, but only if slave is currently unmapped.
 * 	Geometry requests from mapped slaves are not directly honored,
d449 1
a449 2
static void PanedGeometryRequestProc(
    ClientData clientData, Tk_Window slaveWindow)
d451 4
a454 2
    Ttk_Manager *mgr = clientData;
    Paned *pw = Ttk_ManagerData(mgr);
d457 1
a457 5
	int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow); /* ASSERT: != -1 */
	Pane *pane = Ttk_SlaveData(mgr, slaveIndex);
	pane->reqSize
	    = pw->paned.orient == TTK_ORIENT_HORIZONTAL
	    ? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow);
d459 1
a459 4

    /* Continue with default GeometryRequestProc:
     */
    Ttk_GeometryRequestProc(clientData, slaveWindow);
d463 1
a463 1
    { "panedwindow", PanedGeometryRequestProc, Ttk_LostSlaveProc },
d466 1
@


1.10
log
@Ttk_Manager API overhaul:
    + Ttk_Manager no longer responsible for managing slave records
    + Ttk_Manager structure now opaque
    + Ttk_Slave structure now private
    + Pass Ttk_Manager * to Tk_GeomMgr hooks instead of Ttk_Slave *
ttk::labelframe: Simplified -labelwidget management.
ttk::noteboook 'insert' command didn't correctly maintain current tab.
Changed documentation of ttk::panedwindow 'identify' command to
match implementation.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.9 2007/01/11 14:49:47 jenglish Exp $
d29 1
a29 1
 * the available space, and pane weights (see ComputePositions()).
d64 1
a64 1
    Tcl_Obj 	*orientObj;
d66 2
d85 6
d179 1
a179 1
 * +++ Layout algorithm.
d226 1
a226 1
 * 	Compute the requested size of the paned widget 
d262 2
a263 2
    *widthPtr = width;
    *heightPtr = height;
d271 1
a271 1
 * 	AdjustPanes followed by ComputePositions (called during relayout)
d289 1
a289 1
/* ComputePositions --
d291 1
d305 1
a305 1
static void ComputePositions(Paned *pw)
d310 1
a310 3
    int available
	= pw->paned.orient == TTK_ORIENT_HORIZONTAL
	? Tk_Width(pw->core.tkwin) : Tk_Height(pw->core.tkwin);
d403 1
a403 1
    ComputePositions(pw);
d528 19
d791 27
d877 1
d896 1
a896 1
    TtkNullPostConfigure,	/* postConfigureProc */
@


1.9
log
@Revert addition of contravariant 'const' qualifiers,
to keep in sync with Tile codebase (which must remain
compatible with Tk 8.4).
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.8 2007/01/03 05:06:25 nijtmans Exp $
d67 1
d102 68
d207 1
a207 1
    if (i == pw->paned.mgr->nSlaves - 1) {
d218 4
a221 2
 * 	Compute the requested size of the paned widget.
 * 	Used as both the WidgetSpec sizeProc and the ManagerSpec sizeProc.
d400 1
a400 1
static void PaneAdded(Ttk_Manager *mgr, int index)
d402 1
d404 1
a404 7
    Tk_Window slaveWindow = Ttk_SlaveWindow(mgr, index);
    Paned *pw = mgr->managerData;

    /* See also: PanedGeometryRequestProc */
    pane->reqSize
	= pw->paned.orient == TTK_ORIENT_HORIZONTAL
	? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow);
d407 15
a421 1
static void PaneRemoved(Ttk_Manager *mgr, int i) { /*no-op*/ }
d423 6
a428 7
static int PaneConfigured(
    Tcl_Interp *interp, Ttk_Manager *mgr, Ttk_Slave *slave, unsigned mask)
{
    Pane *pane = slave->slaveData;
    if (pane->weight < 0) {
	Tcl_AppendResult(interp, "-weight must be nonnegative", NULL);
	pane->weight = 0;
d431 2
a441 1

d445 2
a446 3
    Ttk_Slave *slave = clientData;
    Pane *pane = slave->slaveData;
    Paned *pw = slave->manager->managerData;
d449 2
a462 1
    PaneOptionSpecs, sizeof(Pane),
d465 1
a465 3
    PaneAdded,
    PaneRemoved,
    PaneConfigured,
d503 1
d532 1
a532 1
	const char *layoutName = 
d560 13
d576 5
a580 5
    int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
    Ttk_Layout sashLayout = pw->paned.sashLayout;
    int sashThickness = pw->paned.sashThickness;
    Ttk_State state = pw->core.state;
    int nPanes = Ttk_NumberSlaves(pw->paned.mgr);
d587 6
a592 15
    if (horizontal) {
	int height = Tk_Height(pw->core.tkwin);
	for (i = 0; i < nPanes; ++i) {
	    Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
	    Ttk_PlaceLayout(sashLayout, state,
		Ttk_MakeBox(pane->sashPos, 0, sashThickness, height));
	    Ttk_DrawLayout(sashLayout, state, d);
	}
    } else {
	int width = Tk_Width(pw->core.tkwin);
	for (i = 0; i < nPanes; ++i) {
	    Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
	    Ttk_PlaceLayout(sashLayout, state,
		Ttk_MakeBox(0, pane->sashPos, width, sashThickness));
	    Ttk_DrawLayout(sashLayout, state, d);
d621 2
a622 2
    return Ttk_AddSlave(interp, pw->paned.mgr, slaveWindow,
	    Ttk_NumberSlaves(pw->paned.mgr), objc - 3, objv + 3);
d632 1
d649 3
a651 1
    } else if (!Ttk_GetSlaveFromObj(interp,pw->paned.mgr,objv[2],&destIndex)) {
d657 1
a657 2
	return Ttk_AddSlave(interp, pw->paned.mgr, slaveWindow,
		destIndex, objc - 4, objv + 4);
d660 2
a661 2
    if (destIndex >= pw->paned.mgr->nSlaves)
	destIndex  = pw->paned.mgr->nSlaves - 1;
d665 4
a668 2
	Ttk_ConfigureSlave(interp, pw->paned.mgr,
	     pw->paned.mgr->slaves[destIndex], objc-4,objv+4);
d684 3
a686 1
    if (!Ttk_GetSlaveFromObj(interp, pw->paned.mgr, objv[2], &paneIndex)) {
d694 2
a695 2
/* $pw identify $x $y
 * @@@@@@ TODO: implement as documented, or change documentation.
d702 1
d717 1
a717 1
    for (index = 0; index < pw->paned.mgr->nSlaves - 1; ++index) {
d725 1
a725 1
    return TCL_OK;	/* empty list */
d736 2
a737 1
    Ttk_Slave *slave;
d744 3
a746 2
    slave = Ttk_GetSlaveFromObj(interp,pw->paned.mgr,objv[2],&paneIndex);
    if (!slave) {
d750 3
d755 2
a756 2
	    return TtkEnumerateOptions(interp, slave->slaveData, PaneOptionSpecs,
			pw->paned.mgr->slaveOptionTable, slave->slaveWindow);
d758 2
a759 2
	    return TtkGetOptionValue(interp, slave->slaveData,objv[3],
			pw->paned.mgr->slaveOptionTable, slave->slaveWindow);
d761 1
a761 2
	    return Ttk_ConfigureSlave(
		    interp, pw->paned.mgr, slave, objc-3,objv+3);
d842 1
a842 1
    TtkNullPostConfigure,		/* postConfigureProc */
@


1.9.2.1
log
@merge updates from HEAD
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.9 2007/01/11 14:49:47 jenglish Exp $
d29 1
a29 1
 * the available space, and pane weights (see PlaceSashes()).
d64 1
a64 1
    Tcl_Obj	*orientObj;
a65 2
    int 	width;
    int 	height;
a66 1
    Tk_OptionTable paneOptionTable;
a81 6
    {TK_OPTION_INT, "-width", "width", "Width", "0",
	-1,Tk_Offset(Paned,paned.width),
	0,0,GEOMETRY_CHANGED },
    {TK_OPTION_INT, "-height", "height", "Height", "0",
	-1,Tk_Offset(Paned,paned.height),
	0,0,GEOMETRY_CHANGED },
a100 68
/* CreatePane --
 * 	Create a new pane record.
 */
static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window slaveWindow)
{
    Tk_OptionTable optionTable = pw->paned.paneOptionTable;
    void *record = ckalloc(sizeof(Pane));
    Pane *pane = record;

    memset(record, 0, sizeof(Pane));
    if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
	ckfree(record);
	return NULL;
    }

    pane->reqSize
	= pw->paned.orient == TTK_ORIENT_HORIZONTAL
	? Tk_ReqWidth(slaveWindow) : Tk_ReqHeight(slaveWindow);

    return pane;
}

/* DestroyPane --
 * 	Free pane record.
 */
static void DestroyPane(Paned *pw, Pane *pane)
{
    void *record = pane;
    Tk_FreeConfigOptions(record, pw->paned.paneOptionTable, pw->core.tkwin);
    ckfree(record);
}

/* ConfigurePane --
 * 	Set pane options.
 */
static int ConfigurePane(
    Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window slaveWindow,
    int objc, Tcl_Obj *CONST objv[])
{
    Ttk_Manager *mgr = pw->paned.mgr;
    Tk_SavedOptions savedOptions;
    int mask = 0;

    if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable,
	    objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK)
    {
	return TCL_ERROR;
    }

    /* Sanity-check:
     */
    if (pane->weight < 0) {
	Tcl_AppendResult(interp, "-weight must be nonnegative", NULL);
	goto error;
    }

    /* Done.
     */
    Tk_FreeSavedOptions(&savedOptions);
    Ttk_ManagerSizeChanged(mgr);
    return TCL_OK;

error:
    Tk_RestoreSavedOptions(&savedOptions);
    return TCL_ERROR;
}


d102 1
a102 1
 * +++ Sash adjustment.
d138 1
a138 1
    if (i == Ttk_NumberSlaves(pw->paned.mgr) - 1) {
d149 2
a150 4
 * 	Compute the requested size of the paned widget
 * 	from the individual pane request sizes.
 *
 * 	Used as the WidgetSpec sizeProc and the ManagerSpec sizeProc.
d183 2
a184 2
    *widthPtr = pw->paned.width > 0 ? pw->paned.width : width;
    *heightPtr = pw->paned.height > 0 ? pw->paned.height : height;
d192 1
a192 1
 * 	AdjustPanes followed by PlaceSashes (called during relayout)
d210 1
a210 1
/* PlaceSashes --
a211 1
 *	The sentinel sash position is set to the available space.
d225 1
a225 1
static void PlaceSashes(Paned *pw, int width, int height)
d230 3
a232 1
    int available = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? width : height;
d325 1
a325 1
    PlaceSashes(pw, Tk_Width(pw->core.tkwin), Tk_Height(pw->core.tkwin));
d329 1
a329 1
static void PaneRemoved(Ttk_Manager *mgr, int index)
a330 1
    Paned *pw = Ttk_ManagerData(mgr);
d332 7
a338 1
    DestroyPane(pw, pane);
d341 4
a344 4
static int AddPane(
    Tcl_Interp *interp, Paned *pw,
    int destIndex, Tk_Window slaveWindow,
    int objc, Tcl_Obj *const objv[])
d346 4
a349 13
    Pane *pane;
    if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) {
	return TCL_ERROR;
    }
    if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) {
	Tcl_AppendResult(interp,
	    Tk_PathName(slaveWindow), " already added",
	    NULL);
	return TCL_ERROR;
    }

    pane = CreatePane(interp, pw, slaveWindow);
    if (!pane) {
a351 6
    if (ConfigurePane(interp, pw, pane, slaveWindow, objc, objv) != TCL_OK) {
	DestroyPane(pw, pane);
	return TCL_ERROR;
    }

    Ttk_InsertSlave(pw->paned.mgr, destIndex, slaveWindow, pane);
d361 1
d365 3
a367 2
    Ttk_Manager *mgr = clientData;
    Paned *pw = Ttk_ManagerData(mgr);
a369 2
	int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow); /* ASSERT: != -1 */
	Pane *pane = Ttk_SlaveData(mgr, slaveIndex);
d382 1
d385 3
a387 1
    PaneRemoved
a424 1
    pw->paned.paneOptionTable = Tk_CreateOptionTable(interp,PaneOptionSpecs);
a441 19
/* Post-configuration hook.
 */
static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
    Paned *pw = clientData;

    if (mask & GEOMETRY_CHANGED) {
	/* User has changed -width or -height.
	 * Recalculate sash positions based on requested size.
	 */
	Tk_Window tkwin = pw->core.tkwin;
	PlaceSashes(pw, 
	    pw->paned.width > 0 ? pw->paned.width : Tk_Width(tkwin),
	    pw->paned.height > 0 ? pw->paned.height : Tk_Height(tkwin));
    }

    return TCL_OK;
}

d453 1
a453 1
	const char *layoutName =
d481 1
a481 5
/*------------------------------------------------------------------------
 * +++ Drawing routines.
 */

static void DrawSash(Paned *pw, Drawable d, Ttk_Box b)
d483 2
d486 1
d488 1
a488 13

    Ttk_PlaceLayout(sashLayout, state, b);
    Ttk_DrawLayout(sashLayout, state, d);
}

static void PanedDisplay(void *recordPtr, Drawable d)
{
    Paned *pw = recordPtr;
    int nPanes = Ttk_NumberSlaves(pw->paned.mgr),
	horizontal =  pw->paned.orient == TTK_ORIENT_HORIZONTAL,
	thickness = pw->paned.sashThickness,
	height = Tk_Height(pw->core.tkwin),
	width = Tk_Width(pw->core.tkwin);
d495 15
a509 6
    for (i = 0; i < nPanes; ++i) {
	Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
	if (horizontal) {
	    DrawSash(pw, d, Ttk_MakeBox(pane->sashPos, 0, thickness, height));
	} else {
	    DrawSash(pw, d, Ttk_MakeBox(0, pane->sashPos, width, thickness));
d538 2
a539 2
    return AddPane(interp, pw, Ttk_NumberSlaves(pw->paned.mgr), slaveWindow,
	    objc - 3, objv + 3);
a548 1
    int nSlaves = Ttk_NumberSlaves(pw->paned.mgr);
d565 1
a565 3
    } else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
		interp,pw->paned.mgr,objv[2],&destIndex)) 
    {
d571 2
a572 1
	return AddPane(interp, pw, destIndex, slaveWindow, objc-4, objv+4);
d575 2
a576 2
    if (destIndex >= nSlaves)
	destIndex  = nSlaves - 1;
d580 2
a581 4
	ConfigurePane(interp, pw,
		Ttk_SlaveData(pw->paned.mgr, destIndex),
		Ttk_SlaveWindow(pw->paned.mgr, destIndex),
		objc-4,objv+4);
d597 1
a597 3
    if (TCL_OK != Ttk_GetSlaveIndexFromObj(
		    interp, pw->paned.mgr, objv[2], &paneIndex)) 
    {
d605 2
a606 2
/* $pw identify $x $y --
 * 	Return index of sash at $x,$y
a612 1
    int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
d627 1
a627 1
    for (index = 0; index < nSashes; ++index) {
d635 1
a635 1
    return TCL_OK;	/* return empty string */
d646 1
a646 2
    Tk_Window slaveWindow;
    Pane *pane;
d653 2
a654 3
    if (TCL_OK != Ttk_GetSlaveIndexFromObj(
		    interp,pw->paned.mgr,objv[2],&paneIndex))
    {
a657 3
    pane = Ttk_SlaveData(pw->paned.mgr, paneIndex);
    slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, paneIndex);

d660 2
a661 2
	    return TtkEnumerateOptions(interp, pane, PaneOptionSpecs,
			pw->paned.paneOptionTable, slaveWindow);
d663 2
a664 2
	    return TtkGetOptionValue(interp, pane, objv[3],
			pw->paned.paneOptionTable, slaveWindow);
d666 2
a667 24
	    return ConfigurePane(interp, pw, pane, slaveWindow, objc-3,objv+3);
    }
}

/* $pw panes --
 * 	Return list of managed panes.
 */
static int PanedPanesCommand(
    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
{
    Paned *pw = recordPtr;
    Ttk_Manager *mgr = pw->paned.mgr;
    Tcl_Obj *panes;
    int i;

    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 2, objv, "");
	return TCL_ERROR;
    }

    panes = Tcl_NewListObj(0, NULL);
    for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) {
	const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i));
	Tcl_ListObjAppendElement(interp, panes, Tcl_NewStringObj(pathName,-1));
a668 3
    Tcl_SetObjResult(interp, panes);

    return TCL_OK;
a670 1

a729 1
    { "panes",   	PanedPanesCommand },
d748 1
a748 1
    PanedPostConfigure, 	/* postConfigureProc */
@


1.9.2.2
log
@merge updates from HEAD
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.9.2.1 2007/06/12 16:22:41 dgp Exp $
d407 1
a407 1
static void PaneRemoved(void *managerData, int index)
d409 2
a410 2
    Paned *pw = managerData;
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
d443 3
a445 3
/* PaneRequest --
 * 	Only update pane request size if slave is currently unmapped.
 * 	Geometry requests from mapped slaves are not directly honored
d449 2
a450 1
static int PaneRequest(void *managerData, int index, int width, int height)
d452 2
a453 4
    Paned *pw = managerData;
    Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
    Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
    int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
d456 5
a460 1
	pane->reqSize = horizontal ? width : height;
d462 4
a465 1
    return 1;
d469 1
a469 1
    { "panedwindow", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
a471 1
    PaneRequest,
@


1.9.2.3
log
@merge updates from HEAD
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.9.2.2 2007/11/25 19:19:21 dgp Exp $
d16 2
d573 5
a901 2
static const int DEFAULT_SASH_THICKNESS = 5;

d917 1
a917 1
    int thickness = DEFAULT_SASH_THICKNESS;
@


1.8
log
@various "const" additions, in line with TIP #27
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.7 2006/12/14 19:51:04 jenglish Exp $
d78 1
a78 1
static const Tk_OptionSpec PanedOptionSpecs[] = {
d95 1
a95 1
static const Tk_OptionSpec PaneOptionSpecs[] = {
@


1.7
log
@Global reduction: use per-file *_Init() routines to reduce
the number of globally-visible initialization records.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.6 2006/12/13 20:40:32 hobbs Exp $
d78 1
a78 1
static Tk_OptionSpec PanedOptionSpecs[] = {
d95 1
a95 1
static Tk_OptionSpec PaneOptionSpecs[] = {
@


1.6
log
@	* generic/ttk/ttkInit.c:
	* generic/ttk/ttkTreeview.c: make treeview exist by default
	* generic/ttk/ttkPanedwindow.c: s/TtkPaned_Init/TtkPanedwindow_Init/
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.5 2006/11/27 06:53:55 jenglish Exp $
d802 2
a803 1
MODULE_SCOPE int TtkPanedwindow_Init(Tcl_Interp *interp)
a813 2
    
    return TCL_OK;
@


1.5
log
@* generic/ttk/ttkWidget.c, generic/ttk/ttkPaned.c Fix for #1603506
* library/ttk/button.tcl, library/ttk/combobox.tcl,
library/ttk/utils.tcl: Rename ttk::CopyBindings to ttk::copyBindings
* generic/ttk/ttkTreeview.c, doc/ttk_treeview.n:
-displaycolumns {} now means "no columns" instead of "all columns".
Use -displaycolumns #all for "all columns" [Fixes #1547622].
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.4 2006/11/24 18:04:14 jenglish Exp $
d802 1
a802 1
MODULE_SCOPE int TtkPaned_Init(Tcl_Interp *interp)
@


1.4
log
@* library/ttk/altTheme.tcl, library/ttk/clamTheme.tcl,
library/ttk/defaults.tcl, library/ttk/winTheme.tcl,
library/ttk/xpTheme.tcl: explicitly specify -anchor w on TMenubutton
* tests/ttk/entry.test: Fixed font dependency; test entry-3.2
should work on all platforms now.
* library/classicTheme.tcl: Don't define or use TkClassicDefaultFont.
* generic/ttk/ttkTreeview.c, generic/ttk/ttkPanedwindow.c:
Handle missing layouts.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.3 2006/11/07 03:45:28 jenglish Exp $
a477 2
    Ttk_ManagerSizeChanged(pw->paned.mgr);

@


1.3
log
@Miscellaneous minor changes to re-sync Ttk codebase with Tile CVS:
fix comments damaged by overzealous search-and-destroy;
removed obsolete [style default] synonym for [ttk::style configure];
removed other dead code.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.2 2006/11/03 03:06:22 das Exp $
a449 4
    int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
    const char *layoutName = horizontal ? ".Vertical.Sash" : ".Horizontal.Sash";
    Ttk_Layout sashLayout = Ttk_CreateSublayout(interp, themePtr, panedLayout,
	    layoutName, pw->core.optionTable);
d451 21
a471 2
    if (sashLayout) {
	int sashWidth, sashHeight;
d473 4
a476 3
	if (pw->paned.sashLayout)
	    Ttk_FreeLayout(pw->paned.sashLayout);
	pw->paned.sashLayout = sashLayout;
d478 1
a478 11
	Ttk_LayoutSize(sashLayout, 0, &sashWidth, &sashHeight);

	pw->paned.sashThickness = horizontal ? sashWidth : sashHeight;

	/* Sanity-check:
	 */
	if (pw->paned.sashThickness < MIN_SASH_THICKNESS)
	    pw->paned.sashThickness = MIN_SASH_THICKNESS;

	Ttk_ManagerSizeChanged(pw->paned.mgr);
    }
@


1.2
log
@	* generic/ttk/ttkBlink.c, generic/ttk/ttkButton.c:
	* generic/ttk/ttkClamTheme.c, generic/ttk/ttkClassicTheme.c:
	* generic/ttk/ttkDecls.h, generic/ttk/ttkDefaultTheme.c:
	* generic/ttk/ttkElements.c, generic/ttk/ttkEntry.c:
	* generic/ttk/ttkFrame.c, generic/ttk/ttkImage.c:
	* generic/ttk/ttkInit.c, generic/ttk/ttkLabel.c:
	* generic/ttk/ttkLayout.c, generic/ttk/ttkManager.h:
	* generic/ttk/ttkNotebook.c, generic/ttk/ttkPanedwindow.c:
	* generic/ttk/ttkProgress.c, generic/ttk/ttkScale.c:
	* generic/ttk/ttkScroll.c, generic/ttk/ttkScrollbar.c:
	* generic/ttk/ttkSeparator.c, generic/ttk/ttkSquare.c:
	* generic/ttk/ttkStubInit.c, generic/ttk/ttkStubLib.c:
	* generic/ttk/ttkTheme.c, generic/ttk/ttkTheme.h:
	* generic/ttk/ttkThemeInt.h, generic/ttk/ttkTrack.c:
	* generic/ttk/ttkTreeview.c, generic/ttk/ttkWidget.c:
	* generic/ttk/ttkWidget.h, macosx/ttkMacOSXTheme.c:
	* win/ttkWinMonitor.c, win/ttkWinTheme.c, win/ttkWinXPTheme.c: ensure
	all global Ttk symbols have Ttk or ttk prefix; declare all externally
	visible Ttk symbols not contained in stubs table as MODULE_SCOPE (or as
	static when possible); so that 'make check{exports,stubs}' once again
	complete without errors.
@
text
@d1 1
a1 1
/* $Id: ttkPanedwindow.c,v 1.1 2006/10/31 01:42:26 hobbs Exp $
d5 1
a5 1
 * Ttk widget set: ttk::panedwindow widget.
d381 1
a381 1
    { "paned", PanedGeometryRequestProc, Ttk_LostSlaveProc },
d393 1
d784 1
a784 1
    TTK_NODE("Paned.background", 0)	/* @@@@@@ BUG: empty layouts don't work */
@


1.1
log
@	* doc/ttk_Geometry.3, doc/ttk_Theme.3, doc/ttk_button.n:
	* doc/ttk_checkbutton.n, doc/ttk_combobox.n, doc/ttk_dialog.n:
	* doc/ttk_entry.n, doc/ttk_frame.n, doc/ttk_image.n:
	* doc/ttk_intro.n, doc/ttk_label.n, doc/ttk_labelframe.n:
	* doc/ttk_menubutton.n, doc/ttk_notebook.n, doc/ttk_panedwindow.n:
	* doc/ttk_progressbar.n, doc/ttk_radiobutton.n, doc/ttk_scrollbar.n:
	* doc/ttk_separator.n, doc/ttk_sizegrip.n, doc/ttk_style.n:
	* doc/ttk_treeview.n, doc/ttk_widget.n,:
	* generic/ttk/ttk.decls, generic/ttk/ttkBlink.c:
	* generic/ttk/ttkButton.c, generic/ttk/ttkCache.c:
	* generic/ttk/ttkClamTheme.c, generic/ttk/ttkClassicTheme.c:
	* generic/ttk/ttkDecls.h, generic/ttk/ttkDefaultTheme.c:
	* generic/ttk/ttkElements.c, generic/ttk/ttkEntry.c:
	* generic/ttk/ttkFrame.c, generic/ttk/ttkImage.c:
	* generic/ttk/ttkInit.c, generic/ttk/ttkLabel.c:
	* generic/ttk/ttkLayout.c, generic/ttk/ttkManager.c:
	* generic/ttk/ttkManager.h, generic/ttk/ttkNotebook.c:
	* generic/ttk/ttkPanedwindow.c, generic/ttk/ttkProgress.c:
	* generic/ttk/ttkScale.c, generic/ttk/ttkScroll.c:
	* generic/ttk/ttkScrollbar.c, generic/ttk/ttkSeparator.c:
	* generic/ttk/ttkSquare.c, generic/ttk/ttkState.c:
	* generic/ttk/ttkStubInit.c, generic/ttk/ttkStubLib.c:
	* generic/ttk/ttkTagSet.c, generic/ttk/ttkTheme.c:
	* generic/ttk/ttkTheme.h, generic/ttk/ttkThemeInt.h:
	* generic/ttk/ttkTrace.c, generic/ttk/ttkTrack.c:
	* generic/ttk/ttkTreeview.c, generic/ttk/ttkWidget.c:
	* generic/ttk/ttkWidget.h:
	* library/demos/ttk_demo.tcl, library/demos/ttk_iconlib.tcl:
	* library/demos/ttk_repeater.tcl:
	* library/ttk/altTheme.tcl, library/ttk/aquaTheme.tcl:
	* library/ttk/button.tcl, library/ttk/clamTheme.tcl:
	* library/ttk/classicTheme.tcl, library/ttk/combobox.tcl:
	* library/ttk/cursors.tcl, library/ttk/defaults.tcl:
	* library/ttk/dialog.tcl, library/ttk/entry.tcl:
	* library/ttk/fonts.tcl, library/ttk/icons.tcl:
	* library/ttk/keynav.tcl, library/ttk/menubutton.tcl:
	* library/ttk/notebook.tcl, library/ttk/panedwindow.tcl:
	* library/ttk/progress.tcl, library/ttk/scale.tcl:
	* library/ttk/scrollbar.tcl, library/ttk/sizegrip.tcl:
	* library/ttk/treeview.tcl, library/ttk/ttk.tcl:
	* library/ttk/utils.tcl, library/ttk/winTheme.tcl:
	* library/ttk/xpTheme.tcl:
	* macosx/ttkMacOSXTheme.c:
	* tests/ttk/all.tcl, tests/ttk/bwidget.test, tests/ttk/combobox.test:
	* tests/ttk/entry.test, tests/ttk/image.test:
	* tests/ttk/labelframe.test, tests/ttk/layout.test:
	* tests/ttk/misc.test, tests/ttk/notebook.test:
	* tests/ttk/panedwindow.test, tests/ttk/progressbar.test:
	* tests/ttk/scrollbar.test, tests/ttk/treetags.test:
	* tests/ttk/treeview.test, tests/ttk/ttk.test, tests/ttk/validate.test:
	* win/ttkWinMonitor.c, win/ttkWinTheme.c, win/ttkWinXPTheme.c:
	First import of Ttk themed Tk widgets as branched from tile 0.7.8

	* generic/tkInt.h, generic/tkWindow.c: add Ttk_Init call, copy
	tk classic widgets to ::tk namespace.
	* library/tk.tcl: add source of ttk/ttk.tcl, define $::ttk::library.
	* unix/Makefile.in, win/Makefile.in: add Ttk build bits
	* win/configure, win/configure.in: check for uxtheme.h (XP theme).
@
text
@d1 1
a1 1
/* $Id: panedwindow.c,v 1.13 2006/04/06 19:34:11 jenglish Exp $
d81 1
a81 1
	0,(ClientData)TTKOrientStrings,READONLY_OPTION|STYLE_CHANGED },
d83 1
a83 1
    WIDGET_INHERIT_OPTIONS(CoreOptionSpecs)
d409 1
a409 1
	SendVirtualEvent(corePtr->tkwin, "EnteredChild");
d448 1
a448 1
    Ttk_Layout panedLayout = WidgetGetLayout(interp, themePtr, recordPtr);
d486 1
a486 1
    WidgetDisplay(recordPtr, d);
d655 1
a655 1
	    return EnumerateOptions(interp, slave->slaveData, PaneOptionSpecs,
d658 1
a658 1
	    return GetOptionValue(interp, slave->slaveData,objv[3],
d718 2
a719 2
    { "configure",	WidgetConfigureCommand },
    { "cget",		WidgetCgetCommand },
d723 1
a723 1
    { "instate",	WidgetInstateCommand },
d726 1
a726 1
    { "state",  	WidgetStateCommand },
d742 2
a743 2
    CoreConfigure,		/* configureProc */
    NullPostConfigure,		/* postConfigureProc */
d746 1
a746 1
    WidgetDoLayout,		/* layoutProc */
d779 1
a779 1
    NullElementDraw
d797 1
a797 1
void Paned_Init(Tcl_Interp *interp)
d808 2
@

