|
|
1.1 ! root 1: /* ! 2: * tkGeometry.c -- ! 3: * ! 4: * This file contains code generic Tk code for geometry ! 5: * management, plus code to manage the geometry of top-level ! 6: * windows (by reflecting information up to the window ! 7: * manager). ! 8: * ! 9: * Copyright 1990 Regents of the University of California. ! 10: * Permission to use, copy, modify, and distribute this ! 11: * software and its documentation for any purpose and without ! 12: * fee is hereby granted, provided that the above copyright ! 13: * notice appear in all copies. The University of California ! 14: * makes no representations about the suitability of this ! 15: * software for any purpose. It is provided "as is" without ! 16: * express or implied warranty. ! 17: */ ! 18: ! 19: #ifndef lint ! 20: static char rcsid[] = "$Header: /user6/ouster/wish/RCS/tkGeometry.c,v 1.18 92/05/13 16:51:17 ouster Exp $ SPRITE (Berkeley)"; ! 21: #endif ! 22: ! 23: #include "tkconfig.h" ! 24: #include "tkint.h" ! 25: ! 26: /* ! 27: *-------------------------------------------------------------- ! 28: * ! 29: * Tk_ManageGeometry -- ! 30: * ! 31: * Arrange for a particular procedure to handle geometry ! 32: * requests for a given window. ! 33: * ! 34: * Results: ! 35: * None. ! 36: * ! 37: * Side effects: ! 38: * Proc becomes the new geometry manager for tkwin, replacing ! 39: * any previous geometry manager. In the future, whenever ! 40: * Tk_GeometryRequest is called for tkwin, proc will be ! 41: * invoked to handle the request. Proc should have the ! 42: * following structure: ! 43: * ! 44: * void ! 45: * proc(clientData, tkwin) ! 46: * { ! 47: * } ! 48: * ! 49: * The clientData argument will be the same as the clientData ! 50: * argument to this procedure, and the tkwin arguments will ! 51: * be the same as the corresponding argument to ! 52: * Tk_GeometryRequest. Information about the desired ! 53: * geometry for tkwin is avilable to proc using macros such ! 54: * as Tk_ReqWidth. Proc should do the best it can to meet ! 55: * the request within the constraints of its geometry-management ! 56: * algorithm, but it is not obligated to meet the request. ! 57: * ! 58: *-------------------------------------------------------------- ! 59: */ ! 60: ! 61: void ! 62: Tk_ManageGeometry(tkwin, proc, clientData) ! 63: Tk_Window tkwin; /* Window whose geometry is to ! 64: * be managed by proc. */ ! 65: Tk_GeometryProc *proc; /* Procedure to manage geometry. ! 66: * NULL means make tkwin unmanaged. */ ! 67: ClientData clientData; /* Arbitrary one-word argument to ! 68: * pass to proc. */ ! 69: { ! 70: register TkWindow *winPtr = (TkWindow *) tkwin; ! 71: ! 72: winPtr->geomProc = proc; ! 73: winPtr->geomData = clientData; ! 74: } ! 75: ! 76: /* ! 77: *-------------------------------------------------------------- ! 78: * ! 79: * Tk_GeometryRequest -- ! 80: * ! 81: * This procedure is invoked by widget code to indicate ! 82: * its preferences about the size of a window it manages. ! 83: * In general, widget code should call this procedure ! 84: * rather than Tk_ResizeWindow. ! 85: * ! 86: * Results: ! 87: * None. ! 88: * ! 89: * Side effects: ! 90: * The geometry manager for tkwin (if any) is invoked to ! 91: * handle the request. If possible, it will reconfigure ! 92: * tkwin and/or other windows to satisfy the request. The ! 93: * caller gets no indication of success or failure, but it ! 94: * will get X events if the window size was actually ! 95: * changed. ! 96: * ! 97: *-------------------------------------------------------------- ! 98: */ ! 99: ! 100: void ! 101: Tk_GeometryRequest(tkwin, reqWidth, reqHeight) ! 102: Tk_Window tkwin; /* Window that geometry information ! 103: * pertains to. */ ! 104: int reqWidth, reqHeight; /* Minimum desired dimensions for ! 105: * window, in pixels. */ ! 106: { ! 107: register TkWindow *winPtr = (TkWindow *) tkwin; ! 108: ! 109: if ((reqWidth == winPtr->reqWidth) && (reqHeight == winPtr->reqHeight)) { ! 110: return; ! 111: } ! 112: winPtr->reqWidth = reqWidth; ! 113: winPtr->reqHeight = reqHeight; ! 114: if (winPtr->geomProc != NULL) { ! 115: (*winPtr->geomProc)(winPtr->geomData, tkwin); ! 116: } ! 117: } ! 118: ! 119: /* ! 120: *---------------------------------------------------------------------- ! 121: * ! 122: * Tk_SetInternalBorder -- ! 123: * ! 124: * Notify relevant geometry managers that a window has an internal ! 125: * border of a given width and that child windows should not be ! 126: * placed on that border. ! 127: * ! 128: * Results: ! 129: * None. ! 130: * ! 131: * Side effects: ! 132: * The border width is recorded for the window, and all geometry ! 133: * managers of all children are notified so that can re-layout, if ! 134: * necessary. ! 135: * ! 136: *---------------------------------------------------------------------- ! 137: */ ! 138: ! 139: void ! 140: Tk_SetInternalBorder(tkwin, width) ! 141: Tk_Window tkwin; /* Window that will have internal border. */ ! 142: int width; /* Width of internal border, in pixels. */ ! 143: { ! 144: register TkWindow *winPtr = (TkWindow *) tkwin; ! 145: ! 146: if (width == winPtr->internalBorderWidth) { ! 147: return; ! 148: } ! 149: if (width < 0) { ! 150: width = 0; ! 151: } ! 152: winPtr->internalBorderWidth = width; ! 153: for (winPtr = winPtr->childList; winPtr != NULL; ! 154: winPtr = winPtr->nextPtr) { ! 155: if (winPtr->geomProc != NULL) { ! 156: (*winPtr->geomProc)(winPtr->geomData, (Tk_Window) winPtr); ! 157: } ! 158: } ! 159: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.