Import Tk 8.6.11
This commit is contained in:
@@ -2,10 +2,7 @@
|
||||
* Copyright (c) 2004, Joe English
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <tk.h>
|
||||
#include "tkInt.h"
|
||||
|
||||
#include "ttkTheme.h"
|
||||
#include "ttkWidget.h"
|
||||
@@ -57,20 +54,20 @@ typedef struct
|
||||
* relevant to the tab.
|
||||
*
|
||||
* PaneOptionSpecs includes additional options for child window placement
|
||||
* and is used to configure the slave.
|
||||
* and is used to configure the content window.
|
||||
*/
|
||||
static Tk_OptionSpec TabOptionSpecs[] =
|
||||
{
|
||||
{TK_OPTION_STRING_TABLE, "-state", "", "",
|
||||
"normal", -1,Tk_Offset(Tab,state),
|
||||
0,(ClientData)TabStateStrings,0 },
|
||||
0, (void *)TabStateStrings, 0 },
|
||||
{TK_OPTION_STRING, "-text", "text", "Text", "",
|
||||
Tk_Offset(Tab,textObj), -1, 0,0,GEOMETRY_CHANGED },
|
||||
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
|
||||
Tk_Offset(Tab,imageObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
|
||||
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
|
||||
NULL, Tk_Offset(Tab,compoundObj), -1,
|
||||
TK_OPTION_NULL_OK,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED },
|
||||
TK_OPTION_NULL_OK, (void *)ttkCompoundStrings, GEOMETRY_CHANGED },
|
||||
{TK_OPTION_INT, "-underline", "underline", "Underline", "-1",
|
||||
Tk_Offset(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED },
|
||||
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }
|
||||
@@ -102,7 +99,7 @@ typedef struct
|
||||
int activeIndex; /* index of currently active tab */
|
||||
Ttk_Layout tabLayout; /* Sublayout for tabs */
|
||||
|
||||
Ttk_Box clientArea; /* Where to pack slave widgets */
|
||||
Ttk_Box clientArea; /* Where to pack content widgets */
|
||||
} NotebookPart;
|
||||
|
||||
typedef struct
|
||||
@@ -191,13 +188,13 @@ static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle)
|
||||
* +++ Tab management.
|
||||
*/
|
||||
|
||||
static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window slaveWindow)
|
||||
static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window window)
|
||||
{
|
||||
Tk_OptionTable optionTable = nb->notebook.paneOptionTable;
|
||||
void *record = ckalloc(sizeof(Tab));
|
||||
Tab *record = (Tab *)ckalloc(sizeof(Tab));
|
||||
memset(record, 0, sizeof(Tab));
|
||||
|
||||
if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
|
||||
if (Tk_InitOptions(interp, (char *)record, optionTable, window) != TCL_OK) {
|
||||
ckfree(record);
|
||||
return NULL;
|
||||
}
|
||||
@@ -213,7 +210,7 @@ static void DestroyTab(Notebook *nb, Tab *tab)
|
||||
}
|
||||
|
||||
static int ConfigureTab(
|
||||
Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window slaveWindow,
|
||||
Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window window,
|
||||
int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Ttk_Sticky sticky = tab->sticky;
|
||||
@@ -221,8 +218,8 @@ static int ConfigureTab(
|
||||
Tk_SavedOptions savedOptions;
|
||||
int mask = 0;
|
||||
|
||||
if (Tk_SetOptions(interp, (ClientData)tab, nb->notebook.paneOptionTable,
|
||||
objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK)
|
||||
if (Tk_SetOptions(interp, (void *)tab, nb->notebook.paneOptionTable,
|
||||
objc, objv, window, &savedOptions, &mask) != TCL_OK)
|
||||
{
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -234,7 +231,7 @@ static int ConfigureTab(
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
if (Ttk_GetPaddingFromObj(interp, slaveWindow, tab->paddingObj, &padding)
|
||||
if (Ttk_GetPaddingFromObj(interp, window, tab->paddingObj, &padding)
|
||||
!= TCL_OK)
|
||||
{
|
||||
goto error;
|
||||
@@ -261,8 +258,8 @@ error:
|
||||
static int IdentifyTab(Notebook *nb, int x, int y)
|
||||
{
|
||||
int index;
|
||||
for (index = 0; index < Ttk_NumberSlaves(nb->notebook.mgr); ++index) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index);
|
||||
for (index = 0; index < Ttk_NumberContent(nb->notebook.mgr); ++index) {
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,index);
|
||||
if ( tab->state != TAB_STATE_HIDDEN
|
||||
&& Ttk_BoxContains(tab->parcel, x,y))
|
||||
{
|
||||
@@ -294,7 +291,7 @@ static void ActivateTab(Notebook *nb, int index)
|
||||
static Ttk_State TabState(Notebook *nb, int index)
|
||||
{
|
||||
Ttk_State state = nb->core.state;
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
|
||||
Tab *itab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
int i = 0;
|
||||
|
||||
if (index == nb->notebook.currentIndex) {
|
||||
@@ -306,8 +303,8 @@ static Ttk_State TabState(Notebook *nb, int index)
|
||||
if (index == nb->notebook.activeIndex) {
|
||||
state |= TTK_STATE_ACTIVE;
|
||||
}
|
||||
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
|
||||
for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
|
||||
if (tab->state == TAB_STATE_HIDDEN) {
|
||||
continue;
|
||||
}
|
||||
@@ -316,8 +313,8 @@ static Ttk_State TabState(Notebook *nb, int index)
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i >= 0; --i) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
|
||||
for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i != -1; --i) {
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
|
||||
if (tab->state == TAB_STATE_HIDDEN) {
|
||||
continue;
|
||||
}
|
||||
@@ -326,7 +323,7 @@ static Ttk_State TabState(Notebook *nb, int index)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (tab->state == TAB_STATE_DISABLED) {
|
||||
if (itab->state == TAB_STATE_DISABLED) {
|
||||
state |= TTK_STATE_DISABLED;
|
||||
}
|
||||
|
||||
@@ -357,8 +354,8 @@ static void TabrowSize(
|
||||
int tabrowWidth = 0, tabrowHeight = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
|
||||
for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
|
||||
Ttk_State tabState = TabState(nb,i);
|
||||
|
||||
Ttk_RebindSublayout(tabLayout, tab);
|
||||
@@ -382,13 +379,13 @@ static void TabrowSize(
|
||||
*
|
||||
* Total height is tab height + client area height + pane internal padding
|
||||
* Total width is max(client width, tab width) + pane internal padding
|
||||
* Client area size determined by max size of slaves,
|
||||
* Client area size determined by max size of content windows,
|
||||
* overridden by -width and/or -height if nonzero.
|
||||
*/
|
||||
|
||||
static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
|
||||
{
|
||||
Notebook *nb = clientData;
|
||||
Notebook *nb = (Notebook *)clientData;
|
||||
NotebookStyle nbstyle;
|
||||
Ttk_Padding padding;
|
||||
Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client");
|
||||
@@ -399,18 +396,18 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
|
||||
|
||||
NotebookStyleOptions(nb, &nbstyle);
|
||||
|
||||
/* Compute max requested size of all slaves:
|
||||
/* Compute max requested size of all content windows:
|
||||
*/
|
||||
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
|
||||
Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, i);
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
|
||||
int slaveWidth
|
||||
= Tk_ReqWidth(slaveWindow) + Ttk_PaddingWidth(tab->padding);
|
||||
int slaveHeight
|
||||
= Tk_ReqHeight(slaveWindow) + Ttk_PaddingHeight(tab->padding);
|
||||
for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
|
||||
Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, i);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
|
||||
int width
|
||||
= Tk_ReqWidth(window) + Ttk_PaddingWidth(tab->padding);
|
||||
int height
|
||||
= Tk_ReqHeight(window) + Ttk_PaddingHeight(tab->padding);
|
||||
|
||||
clientWidth = MAX(clientWidth, slaveWidth);
|
||||
clientHeight = MAX(clientHeight, slaveHeight);
|
||||
clientWidth = MAX(clientWidth, width);
|
||||
clientHeight = MAX(clientHeight, height);
|
||||
}
|
||||
|
||||
/* Client width/height overridable by widget options:
|
||||
@@ -465,7 +462,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
|
||||
static void SqueezeTabs(
|
||||
Notebook *nb, int needed, int available)
|
||||
{
|
||||
int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
int nTabs = Ttk_NumberContent(nb->notebook.mgr);
|
||||
|
||||
if (nTabs > 0) {
|
||||
int difference = available - needed;
|
||||
@@ -474,7 +471,7 @@ static void SqueezeTabs(
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nTabs; ++i) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,i);
|
||||
double ad = slack + tab->width * delta;
|
||||
tab->width += (int)ad;
|
||||
slack = ad - (int)ad;
|
||||
@@ -489,11 +486,11 @@ static void PlaceTabs(
|
||||
Notebook *nb, Ttk_Box tabrowBox, Ttk_PositionSpec tabPlacement)
|
||||
{
|
||||
Ttk_Layout tabLayout = nb->notebook.tabLayout;
|
||||
int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
int nTabs = Ttk_NumberContent(nb->notebook.mgr);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nTabs; ++i) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
|
||||
Ttk_State tabState = TabState(nb, i);
|
||||
|
||||
if (tab->state != TAB_STATE_HIDDEN) {
|
||||
@@ -517,11 +514,11 @@ static void PlaceTabs(
|
||||
* Computes notebook layout and places tabs.
|
||||
*
|
||||
* Side effects:
|
||||
* Sets clientArea, used to place slave panes.
|
||||
* Sets clientArea, used to place panes.
|
||||
*/
|
||||
static void NotebookDoLayout(void *recordPtr)
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
Tk_Window nbwin = nb->core.tkwin;
|
||||
Ttk_Box cavity = Ttk_WinBox(nbwin);
|
||||
int tabrowWidth = 0, tabrowHeight = 0;
|
||||
@@ -571,32 +568,32 @@ static void NotebookDoLayout(void *recordPtr)
|
||||
}
|
||||
|
||||
/*
|
||||
* NotebookPlaceSlave --
|
||||
* NotebookPlaceContent --
|
||||
* Set the position and size of a child widget
|
||||
* based on the current client area and slave options:
|
||||
* based on the current client area and content window options:
|
||||
*/
|
||||
static void NotebookPlaceSlave(Notebook *nb, int slaveIndex)
|
||||
static void NotebookPlaceContent(Notebook *nb, int index)
|
||||
{
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
|
||||
Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, slaveIndex);
|
||||
Ttk_Box slaveBox =
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index);
|
||||
Ttk_Box box =
|
||||
Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding),
|
||||
Tk_ReqWidth(slaveWindow), Tk_ReqHeight(slaveWindow),tab->sticky);
|
||||
Tk_ReqWidth(window), Tk_ReqHeight(window),tab->sticky);
|
||||
|
||||
Ttk_PlaceSlave(nb->notebook.mgr, slaveIndex,
|
||||
slaveBox.x, slaveBox.y, slaveBox.width, slaveBox.height);
|
||||
Ttk_PlaceContent(nb->notebook.mgr, index,
|
||||
box.x, box.y, box.width, box.height);
|
||||
}
|
||||
|
||||
/* NotebookPlaceSlaves --
|
||||
/* NotebookPlaceContents --
|
||||
* Geometry manager hook.
|
||||
*/
|
||||
static void NotebookPlaceSlaves(void *recordPtr)
|
||||
static void NotebookPlaceContents(void *recordPtr)
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
int currentIndex = nb->notebook.currentIndex;
|
||||
if (currentIndex >= 0) {
|
||||
NotebookDoLayout(nb);
|
||||
NotebookPlaceSlave(nb, currentIndex);
|
||||
NotebookPlaceContent(nb, currentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,7 +603,7 @@ static void NotebookPlaceSlaves(void *recordPtr)
|
||||
*/
|
||||
static void SelectTab(Notebook *nb, int index)
|
||||
{
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
int currentIndex = nb->notebook.currentIndex;
|
||||
|
||||
if (index == currentIndex) {
|
||||
@@ -624,15 +621,15 @@ static void SelectTab(Notebook *nb, int index)
|
||||
}
|
||||
|
||||
if (currentIndex >= 0) {
|
||||
Ttk_UnmapSlave(nb->notebook.mgr, currentIndex);
|
||||
Ttk_UnmapContent(nb->notebook.mgr, currentIndex);
|
||||
}
|
||||
|
||||
/* Must be set before calling NotebookPlaceSlave(), otherwise it may
|
||||
* happen that NotebookPlaceSlaves(), triggered by an interveaning
|
||||
/* Must be set before calling NotebookPlaceContent(), otherwise it may
|
||||
* happen that NotebookPlaceContents(), triggered by an interveaning
|
||||
* geometry request, will swap to old index. */
|
||||
nb->notebook.currentIndex = index;
|
||||
|
||||
NotebookPlaceSlave(nb, index);
|
||||
NotebookPlaceContent(nb, index);
|
||||
TtkRedisplayWidget(&nb->core);
|
||||
|
||||
TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
|
||||
@@ -645,13 +642,13 @@ static void SelectTab(Notebook *nb, int index)
|
||||
*/
|
||||
static int NextTab(Notebook *nb, int index)
|
||||
{
|
||||
int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
int nTabs = Ttk_NumberContent(nb->notebook.mgr);
|
||||
int nextIndex;
|
||||
|
||||
/* Scan forward for following usable tab:
|
||||
*/
|
||||
for (nextIndex = index + 1; nextIndex < nTabs; ++nextIndex) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex);
|
||||
if (tab->state == TAB_STATE_NORMAL) {
|
||||
return nextIndex;
|
||||
}
|
||||
@@ -660,7 +657,7 @@ static int NextTab(Notebook *nb, int index)
|
||||
/* Not found -- scan backwards.
|
||||
*/
|
||||
for (nextIndex = index - 1; nextIndex >= 0; --nextIndex) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex);
|
||||
if (tab->state == TAB_STATE_NORMAL) {
|
||||
return nextIndex;
|
||||
}
|
||||
@@ -684,7 +681,7 @@ static void SelectNearestTab(Notebook *nb)
|
||||
int nextIndex = NextTab(nb, currentIndex);
|
||||
|
||||
if (currentIndex >= 0) {
|
||||
Ttk_UnmapSlave(nb->notebook.mgr, currentIndex);
|
||||
Ttk_UnmapContent(nb->notebook.mgr, currentIndex);
|
||||
}
|
||||
if (currentIndex != nextIndex) {
|
||||
TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
|
||||
@@ -695,14 +692,14 @@ static void SelectNearestTab(Notebook *nb)
|
||||
TtkRedisplayWidget(&nb->core);
|
||||
}
|
||||
|
||||
/* TabRemoved -- GM SlaveRemoved hook.
|
||||
/* TabRemoved -- GM TabRemoved hook.
|
||||
* Select the next tab if the current one is being removed.
|
||||
* Adjust currentIndex to account for removed slave.
|
||||
* Adjust currentIndex to account for removed content window.
|
||||
*/
|
||||
static void TabRemoved(void *managerData, int index)
|
||||
{
|
||||
Notebook *nb = managerData;
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
|
||||
Notebook *nb = (Notebook *)managerData;
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
|
||||
if (index == nb->notebook.currentIndex) {
|
||||
SelectNearestTab(nb);
|
||||
@@ -717,7 +714,11 @@ static void TabRemoved(void *managerData, int index)
|
||||
TtkRedisplayWidget(&nb->core);
|
||||
}
|
||||
|
||||
static int TabRequest(void *managerData, int index, int width, int height)
|
||||
static int TabRequest(
|
||||
TCL_UNUSED(void *),
|
||||
TCL_UNUSED(int),
|
||||
TCL_UNUSED(int),
|
||||
TCL_UNUSED(int))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -727,17 +728,17 @@ static int TabRequest(void *managerData, int index, int width, int height)
|
||||
*/
|
||||
static int AddTab(
|
||||
Tcl_Interp *interp, Notebook *nb,
|
||||
int destIndex, Tk_Window slaveWindow,
|
||||
int destIndex, Tk_Window window,
|
||||
int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Tab *tab;
|
||||
if (!Ttk_Maintainable(interp, slaveWindow, nb->core.tkwin)) {
|
||||
if (!Ttk_Maintainable(interp, window, nb->core.tkwin)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#if 0 /* can't happen */
|
||||
if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) {
|
||||
if (Ttk_ContentIndex(nb->notebook.mgr, window) >= 0) {
|
||||
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added",
|
||||
Tk_PathName(slaveWindow)));
|
||||
Tk_PathName(window)));
|
||||
Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -745,16 +746,16 @@ static int AddTab(
|
||||
|
||||
/* Create and insert tab.
|
||||
*/
|
||||
tab = CreateTab(interp, nb, slaveWindow);
|
||||
tab = CreateTab(interp, nb, window);
|
||||
if (!tab) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (ConfigureTab(interp, nb, tab, slaveWindow, objc, objv) != TCL_OK) {
|
||||
if (ConfigureTab(interp, nb, tab, window, objc, objv) != TCL_OK) {
|
||||
DestroyTab(nb, tab);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
Ttk_InsertSlave(nb->notebook.mgr, destIndex, slaveWindow, tab);
|
||||
Ttk_InsertContent(nb->notebook.mgr, destIndex, window, tab);
|
||||
|
||||
/* Adjust indices and/or autoselect first tab:
|
||||
*/
|
||||
@@ -768,9 +769,9 @@ static int AddTab(
|
||||
}
|
||||
|
||||
static Ttk_ManagerSpec NotebookManagerSpec = {
|
||||
{ "notebook", Ttk_GeometryRequestProc, Ttk_LostSlaveProc },
|
||||
{ "notebook", Ttk_GeometryRequestProc, Ttk_LostContentProc },
|
||||
NotebookSize,
|
||||
NotebookPlaceSlaves,
|
||||
NotebookPlaceContents,
|
||||
TabRequest,
|
||||
TabRemoved
|
||||
};
|
||||
@@ -789,7 +790,7 @@ static const int NotebookEventMask
|
||||
;
|
||||
static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr)
|
||||
{
|
||||
Notebook *nb = clientData;
|
||||
Notebook *nb = (Notebook *)clientData;
|
||||
|
||||
if (eventPtr->type == DestroyNotify) { /* Remove self */
|
||||
Tk_DeleteEventHandler(nb->core.tkwin,
|
||||
@@ -813,7 +814,7 @@ static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr)
|
||||
* + positional specifications @x,y,
|
||||
* + "current",
|
||||
* + numeric indices [0..nTabs],
|
||||
* + slave window names
|
||||
* + content window names
|
||||
*
|
||||
* Stores index of specified tab in *index_rtn, -1 if not found.
|
||||
*
|
||||
@@ -844,15 +845,15 @@ static int FindTabIndex(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* ... or integer index or slave window name:
|
||||
/* ... or integer index or content window name:
|
||||
*/
|
||||
if (Ttk_GetSlaveIndexFromObj(
|
||||
if (Ttk_GetContentIndexFromObj(
|
||||
interp, nb->notebook.mgr, objPtr, index_rtn) == TCL_OK)
|
||||
{
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* Nothing matched; Ttk_GetSlaveIndexFromObj will have left error message.
|
||||
/* Nothing matched; Ttk_GetContentIndexFromObj will have left error message.
|
||||
*/
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -885,10 +886,9 @@ static int GetTabIndex(
|
||||
static int NotebookAddCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
int index = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
Tk_Window slaveWindow;
|
||||
int slaveIndex;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
Tk_Window window;
|
||||
int index;
|
||||
Tab *tab;
|
||||
|
||||
if (objc <= 2 || objc % 2 != 1) {
|
||||
@@ -896,21 +896,21 @@ static int NotebookAddCommand(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
slaveWindow = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin);
|
||||
if (!slaveWindow) {
|
||||
window = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin);
|
||||
if (!window) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
slaveIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow);
|
||||
index = Ttk_ContentIndex(nb->notebook.mgr, window);
|
||||
|
||||
if (slaveIndex < 0) { /* New tab */
|
||||
return AddTab(interp, nb, index, slaveWindow, objc-3,objv+3);
|
||||
if (index < 0) { /* New tab */
|
||||
return AddTab(interp, nb, Ttk_NumberContent(nb->notebook.mgr), window, objc-3,objv+3);
|
||||
}
|
||||
|
||||
tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
|
||||
tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
if (tab->state == TAB_STATE_HIDDEN) {
|
||||
tab->state = TAB_STATE_NORMAL;
|
||||
}
|
||||
if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) {
|
||||
if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
@@ -925,9 +925,9 @@ static int NotebookAddCommand(
|
||||
static int NotebookInsertCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
int current = nb->notebook.currentIndex;
|
||||
int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
int nContent = Ttk_NumberContent(nb->notebook.mgr);
|
||||
int srcIndex, destIndex;
|
||||
|
||||
if (objc < 4) {
|
||||
@@ -936,46 +936,46 @@ static int NotebookInsertCommand(
|
||||
}
|
||||
|
||||
if (!strcmp(Tcl_GetString(objv[2]), "end")) {
|
||||
destIndex = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
} else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
|
||||
destIndex = Ttk_NumberContent(nb->notebook.mgr);
|
||||
} else if (TCL_OK != Ttk_GetContentIndexFromObj(
|
||||
interp, nb->notebook.mgr, objv[2], &destIndex)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (Tcl_GetString(objv[3])[0] == '.') {
|
||||
/* Window name -- could be new or existing slave.
|
||||
/* Window name -- could be new or existing content window.
|
||||
*/
|
||||
Tk_Window slaveWindow =
|
||||
Tk_Window window =
|
||||
Tk_NameToWindow(interp,Tcl_GetString(objv[3]),nb->core.tkwin);
|
||||
|
||||
if (!slaveWindow) {
|
||||
if (!window) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
srcIndex = Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow);
|
||||
if (srcIndex < 0) { /* New slave */
|
||||
return AddTab(interp, nb, destIndex, slaveWindow, objc-4,objv+4);
|
||||
srcIndex = Ttk_ContentIndex(nb->notebook.mgr, window);
|
||||
if (srcIndex < 0) { /* New content window */
|
||||
return AddTab(interp, nb, destIndex, window, objc-4,objv+4);
|
||||
}
|
||||
} else if (Ttk_GetSlaveIndexFromObj(
|
||||
} else if (Ttk_GetContentIndexFromObj(
|
||||
interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK)
|
||||
{
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* Move existing slave:
|
||||
/* Move existing content window:
|
||||
*/
|
||||
if (ConfigureTab(interp, nb,
|
||||
Ttk_SlaveData(nb->notebook.mgr,srcIndex),
|
||||
Ttk_SlaveWindow(nb->notebook.mgr,srcIndex),
|
||||
(Tab *)Ttk_ContentData(nb->notebook.mgr, srcIndex),
|
||||
Ttk_ContentWindow(nb->notebook.mgr, srcIndex),
|
||||
objc-4,objv+4) != TCL_OK)
|
||||
{
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (destIndex >= nSlaves) {
|
||||
destIndex = nSlaves - 1;
|
||||
if (destIndex >= nContent) {
|
||||
destIndex = nContent - 1;
|
||||
}
|
||||
Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex);
|
||||
Ttk_ReorderContent(nb->notebook.mgr, srcIndex, destIndex);
|
||||
|
||||
/* Adjust internal indexes:
|
||||
*/
|
||||
@@ -999,7 +999,7 @@ static int NotebookInsertCommand(
|
||||
static int NotebookForgetCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
int index;
|
||||
|
||||
if (objc != 3) {
|
||||
@@ -1011,7 +1011,7 @@ static int NotebookForgetCommand(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
Ttk_ForgetSlave(nb->notebook.mgr, index);
|
||||
Ttk_ForgetContent(nb->notebook.mgr, index);
|
||||
TtkRedisplayWidget(&nb->core);
|
||||
|
||||
return TCL_OK;
|
||||
@@ -1023,7 +1023,7 @@ static int NotebookForgetCommand(
|
||||
static int NotebookHideCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
int index;
|
||||
Tab *tab;
|
||||
|
||||
@@ -1036,7 +1036,7 @@ static int NotebookHideCommand(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
tab = Ttk_SlaveData(nb->notebook.mgr, index);
|
||||
tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
tab->state = TAB_STATE_HIDDEN;
|
||||
if (index == nb->notebook.currentIndex) {
|
||||
SelectNearestTab(nb);
|
||||
@@ -1056,16 +1056,17 @@ static int NotebookIdentifyCommand(
|
||||
static const char *whatTable[] = { "element", "tab", NULL };
|
||||
enum { IDENTIFY_ELEMENT, IDENTIFY_TAB };
|
||||
int what = IDENTIFY_ELEMENT;
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
Ttk_Element element = NULL;
|
||||
int x, y, tabIndex;
|
||||
int x, y;
|
||||
int tabIndex;
|
||||
|
||||
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
|
||||
if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
|
||||
|| Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK
|
||||
|| (objc == 5 && Tcl_GetIndexFromObjStruct(interp, objv[2], whatTable,
|
||||
sizeof(char *), "option", 0, &what) != TCL_OK)
|
||||
@@ -1075,7 +1076,7 @@ static int NotebookIdentifyCommand(
|
||||
|
||||
tabIndex = IdentifyTab(nb, x, y);
|
||||
if (tabIndex >= 0) {
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, tabIndex);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, tabIndex);
|
||||
Ttk_State state = TabState(nb, tabIndex);
|
||||
Ttk_Layout tabLayout = nb->notebook.tabLayout;
|
||||
|
||||
@@ -1110,8 +1111,9 @@ static int NotebookIdentifyCommand(
|
||||
static int NotebookIndexCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
int index, status;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
int index;
|
||||
int status;
|
||||
|
||||
if (objc != 3) {
|
||||
Tcl_WrongNumArgs(interp, 2, objv, "tab");
|
||||
@@ -1122,8 +1124,8 @@ static int NotebookIndexCommand(
|
||||
* Special-case for "end":
|
||||
*/
|
||||
if (!strcmp("end", Tcl_GetString(objv[2]))) {
|
||||
int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(nSlaves));
|
||||
int nContent = Ttk_NumberContent(nb->notebook.mgr);
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(nContent));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -1142,11 +1144,11 @@ static int NotebookIndexCommand(
|
||||
static int NotebookSelectCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
|
||||
if (objc == 2) {
|
||||
if (nb->notebook.currentIndex >= 0) {
|
||||
Tk_Window pane = Ttk_SlaveWindow(
|
||||
Tk_Window pane = Ttk_ContentWindow(
|
||||
nb->notebook.mgr, nb->notebook.currentIndex);
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(pane), -1));
|
||||
}
|
||||
@@ -1168,7 +1170,7 @@ static int NotebookSelectCommand(
|
||||
static int NotebookTabsCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
Ttk_Manager *mgr = nb->notebook.mgr;
|
||||
Tcl_Obj *result;
|
||||
int i;
|
||||
@@ -1179,8 +1181,8 @@ static int NotebookTabsCommand(
|
||||
}
|
||||
|
||||
result = Tcl_NewListObj(0, NULL);
|
||||
for (i = 0; i < Ttk_NumberSlaves(mgr); ++i) {
|
||||
const char *pathName = Tk_PathName(Ttk_SlaveWindow(mgr,i));
|
||||
for (i = 0; i < Ttk_NumberContent(mgr); ++i) {
|
||||
const char *pathName = Tk_PathName(Ttk_ContentWindow(mgr,i));
|
||||
|
||||
Tcl_ListObjAppendElement(NULL, result, Tcl_NewStringObj(pathName,-1));
|
||||
}
|
||||
@@ -1193,10 +1195,10 @@ static int NotebookTabsCommand(
|
||||
static int NotebookTabCommand(
|
||||
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
Ttk_Manager *mgr = nb->notebook.mgr;
|
||||
int index;
|
||||
Tk_Window slaveWindow;
|
||||
Tk_Window window;
|
||||
Tab *tab;
|
||||
|
||||
if (objc < 3) {
|
||||
@@ -1208,18 +1210,18 @@ static int NotebookTabCommand(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
tab = Ttk_SlaveData(mgr, index);
|
||||
slaveWindow = Ttk_SlaveWindow(mgr, index);
|
||||
tab = (Tab *)Ttk_ContentData(mgr, index);
|
||||
window = Ttk_ContentWindow(mgr, index);
|
||||
|
||||
if (objc == 3) {
|
||||
return TtkEnumerateOptions(interp, tab,
|
||||
PaneOptionSpecs, nb->notebook.paneOptionTable, slaveWindow);
|
||||
PaneOptionSpecs, nb->notebook.paneOptionTable, window);
|
||||
} else if (objc == 4) {
|
||||
return TtkGetOptionValue(interp, tab, objv[3],
|
||||
nb->notebook.paneOptionTable, slaveWindow);
|
||||
nb->notebook.paneOptionTable, window);
|
||||
} /* else */
|
||||
|
||||
if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) {
|
||||
if (ConfigureTab(interp, nb, tab, window, objc-3,objv+3) != TCL_OK) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
@@ -1258,7 +1260,7 @@ static const Ttk_Ensemble NotebookCommands[] = {
|
||||
|
||||
static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
|
||||
nb->notebook.mgr = Ttk_CreateManager(
|
||||
&NotebookManagerSpec, recordPtr, nb->core.tkwin);
|
||||
@@ -1278,7 +1280,7 @@ static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
|
||||
|
||||
static void NotebookCleanup(void *recordPtr)
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
|
||||
Ttk_DeleteManager(nb->notebook.mgr);
|
||||
if (nb->notebook.tabLayout)
|
||||
@@ -1287,7 +1289,7 @@ static void NotebookCleanup(void *recordPtr)
|
||||
|
||||
static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask)
|
||||
{
|
||||
Notebook *nb = clientData;
|
||||
Notebook *nb = (Notebook *)clientData;
|
||||
|
||||
/*
|
||||
* Error-checks:
|
||||
@@ -1311,7 +1313,7 @@ static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask)
|
||||
static Ttk_Layout NotebookGetLayout(
|
||||
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
|
||||
{
|
||||
Notebook *nb = recordPtr;
|
||||
Notebook *nb = (Notebook *)recordPtr;
|
||||
Ttk_Layout notebookLayout = TtkWidgetGetLayout(interp, theme, recordPtr);
|
||||
Ttk_Layout tabLayout;
|
||||
|
||||
@@ -1339,7 +1341,7 @@ static Ttk_Layout NotebookGetLayout(
|
||||
static void DisplayTab(Notebook *nb, int index, Drawable d)
|
||||
{
|
||||
Ttk_Layout tabLayout = nb->notebook.tabLayout;
|
||||
Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
|
||||
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
|
||||
Ttk_State state = TabState(nb, index);
|
||||
|
||||
if (tab->state != TAB_STATE_HIDDEN) {
|
||||
@@ -1351,8 +1353,8 @@ static void DisplayTab(Notebook *nb, int index, Drawable d)
|
||||
|
||||
static void NotebookDisplay(void *clientData, Drawable d)
|
||||
{
|
||||
Notebook *nb = clientData;
|
||||
int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
|
||||
Notebook *nb = (Notebook *)clientData;
|
||||
int nContent = Ttk_NumberContent(nb->notebook.mgr);
|
||||
int index;
|
||||
|
||||
/* Draw notebook background (base layout):
|
||||
@@ -1362,7 +1364,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
|
||||
/* Draw tabs from left to right, but draw the current tab last
|
||||
* so it will overwrite its neighbors.
|
||||
*/
|
||||
for (index = 0; index < nSlaves; ++index) {
|
||||
for (index = 0; index < nContent; ++index) {
|
||||
if (index != nb->notebook.currentIndex) {
|
||||
DisplayTab(nb, index, d);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user