summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkManager.h
blob: c03c3da58f69dab4adc862602f722630e1f4588e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* $Id: ttkManager.h,v 1.5 2007/01/11 14:49:47 jenglish Exp $
 *
 * Copyright (c) 2005, Joe English.  Freely redistributable.
 *
 * Ttk widget set: Geometry management utilities.
 *
 * TODO: opacify data structures.
 */

#ifndef _TTKMANAGER
#define _TTKMANAGER

#include "ttkTheme.h"

typedef struct TtkManager_ Ttk_Manager; /* forward */
typedef struct TtkSlave_ Ttk_Slave; /* forward */

/*
 * Geometry manager specification record:
 *
 * RequestedSize computes the requested size of the master window.
 *
 * PlaceSlaves sets the position and size of all managed slaves
 * by calling Ttk_PlaceSlave().
 *
 * SlaveAdded() is called after a new slave has been added.
 *
 * SlaveRemoved() is called immediately before a slave is removed.
 * NB: the associated slave window may have been destroyed when this
 * routine is called.
 */
typedef struct {			/* Manager hooks */
    Tk_GeomMgr tkGeomMgr;		/* "real" Tk Geometry Manager */
    Tk_OptionSpec *slaveOptionSpecs;	/* slave record options */
    size_t slaveSize;			/* size of slave record */

    int  (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr);
    void (*PlaceSlaves)(void *managerData);

    void (*SlaveAdded)(Ttk_Manager *, int slaveIndex);
    void (*SlaveRemoved)(Ttk_Manager *, int slaveIndex);
    int  (*SlaveConfigured)(
	    Tcl_Interp *, Ttk_Manager *, Ttk_Slave *, unsigned mask);
} Ttk_ManagerSpec;

/*
 * Default implementations for Tk_GeomMgr hooks:
 */
MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window slave);
MODULE_SCOPE void Ttk_LostSlaveProc(ClientData, Tk_Window slave);

struct TtkSlave_
{
    Tk_Window 		slaveWindow;
    Ttk_Manager 	*manager;
    void 		*slaveData;
    unsigned		flags;			/* private; see manager.c */
};

struct TtkManager_
{
    Ttk_ManagerSpec	*managerSpec;
    void 		*managerData;
    Tk_Window   	masterWindow;
    Tk_OptionTable 	slaveOptionTable;
    unsigned		flags;			/* private; see manager.c */
    int 	 	nSlaves;
    Ttk_Slave 		**slaves;
};

/*
 * Public API:
 */
MODULE_SCOPE Ttk_Manager *Ttk_CreateManager(
	Ttk_ManagerSpec *, void *managerData, Tk_Window masterWindow);
MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *);

MODULE_SCOPE int Ttk_AddSlave(
    Tcl_Interp *, Ttk_Manager *, Tk_Window, int position,
    int objc, Tcl_Obj *CONST objv[]);

MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, int slaveIndex);

MODULE_SCOPE int Ttk_ConfigureSlave(
    Tcl_Interp *interp, Ttk_Manager *, Ttk_Slave *,
    int objc, Tcl_Obj *CONST objv[]);

MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, int fromIndex, int toIndex);
    /* Rearrange slave positions */

MODULE_SCOPE void Ttk_PlaceSlave(
    Ttk_Manager *, int slaveIndex, int x, int y, int width, int height);
    /* Position and map the slave */

MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, int slaveIndex);
    /* Unmap the slave */

MODULE_SCOPE void Ttk_ManagerSizeChanged(Ttk_Manager *);
MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *);
    /* Notify manager that size (resp. layout) needs to be recomputed */

/* Utilities:
 */
MODULE_SCOPE int Ttk_SlaveIndex(Ttk_Manager *, Tk_Window);
    /* Returns: index in slave array of specified window, -1 if not found */

MODULE_SCOPE Ttk_Slave *Ttk_GetSlaveFromObj(
    Tcl_Interp *, Ttk_Manager *, Tcl_Obj *, int *indexPtr);

/* Accessor functions:
 */
MODULE_SCOPE int Ttk_NumberSlaves(Ttk_Manager *);
    /* Returns: number of managed slaves */

MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, int slaveIndex);
    /* Returns: private data associated with slave */

MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, int slaveIndex);
    /* Returns: slave window */

MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window slave, Tk_Window master);
    /* Returns: 1 if master can manage slave; 0 otherwise leaving error msg */

#endif /* _TTKMANAGER */