summaryrefslogtreecommitdiffstats
path: root/release_docs/USING_HDF5_CMake.txt
blob: 9a50525612171e0efbd21b355d0e1c692269ac71 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
************************************************************************
* Build and Install HDF5 Applications with CMake                       *
************************************************************************

Notes: This short instruction is written for users who want to quickly 
       build HDF5 applications using the CMake tools. Users can adapt 
       these instructions for their own applications. For more information, 
       see the "Minimum C Project Files for CMake" section.
       
       More information about using CMake can be found at the KitWare 
       site, www.cmake.org.
         
       CMake uses the command line; however, the visual CMake tool is 
       available for the configuration step. The steps are similar for
       all of the operating systems supported by CMake.
       
       NOTES:
         1. Using CMake for building and using HDF5 is under active 
            development. While we have attempted to provide error-free 
            files, please understand that development with CMake has not 
            been extensively tested outside of HDF. The CMake specific 
            files may change before the next release.
            
         2. CMake for HDF5 development should be usable on any system 
            where CMake is supported. Please send us any comments on how 
            CMake support can be improved on any system. 
            
         3. See the appendix at the bottom of this file for an example 
            of using a ctest script for building and testing. See 
            CMake.txt for more information.



========================================================================
I. Preconditions                                                           
========================================================================

   1. We suggest you obtain the latest CMake for windows from the Kitware
      web site. The HDF5 1.8.x product requires a minimum CMake version 
      of 2.8.10.                     
                                                                         
   2. You have installed the HDF5 library built with CMake, by executing 
      the HDF Install Utility (the *.exe file in the binary package for 
      Windows). If you are using a Windows platform, you can obtain a 
      pre-built Windows binary from The HDF Group's website at 
      www.hdfgroup.org.

   3. Set the environment variable HDF5_DIR to the installed location of 
      the config files for HDF5. On Windows: 
            HDF5_DIR=C:/Program Files/HDF_Group/HDF5/1.8.x/cmake/hdf5
      
      (Note there are no quote characters used on Windows and all platforms
      use forward slashes)

   4. Created separate source and build directories.
      (CMake commands are executed in the build directory)

   5. Created a CMakeLists.txt file(s) for your source. See Section III 
      below.



========================================================================
II. Building HDF5 Applications with CMake
========================================================================

Go through these steps to build HDF5 applications with CMake.

   1. Run CMake
   2. Configure the cache settings
   3. Build HDF5 Applications
   4. Test HDF5 Applications.

These steps are described in more detail below.



   1. Run CMake

      The visual CMake executable is named "cmake-gui.exe" on Windows and should be
      available in your Start menu. For Linux, UNIX, and Mac users the
      executable is named "cmake-gui" and can be found where CMake was 
      installed. 
      
      Specify the source and build directories. Make the build and source 
      directories different. For example on Windows, if the source is at 
      c:\MyHDFstuff\hdf5, then use c:\MyHDFstuff\hdf5\build or 
      c:\MyHDFstuff\build\hdf5 for the build directory. 
      
      PREFERRED:
        Users can perform the configuration step without using the visual 
        cmake-gui program. The following is an example command line 
        configuration step executed within the build directory:
        
        cmake -G "<generator>"  [-D<options>]  <sourcepath>
        
        Where <generator> is    
            * Borland Makefiles
            * MSYS Makefiles
            * MinGW Makefiles
            * NMake Makefiles
            * Unix Makefiles
            * Visual Studio 11
            * Visual Studio 11 Win64
            * Visual Studio 10
            * Visual Studio 10 Win64
            * Visual Studio 6
            * Visual Studio 7
            * Visual Studio 7 .NET 2003
            * Visual Studio 8 2005
            * Visual Studio 8 2005 Win64
            * Visual Studio 9 2008
            * Visual Studio 9 2008 Win64

        <options> is:
            * BUILD_TESTING:BOOL=ON
            * USE_SHARED_LIBS:BOOL=[ON | OFF]

   2. Configure the cache settings

      2.1  Visual CMake users, click the Configure button. If this is the first time you are 
           running cmake-gui in this directory, you will be prompted for the 
           generator you wish to use (for example on Windows, Visual Studio 10). 
           CMake will read in the CMakeLists.txt files from the source directory and 
           display options for the HDF5 project. After the first configure you 
           can adjust the cache settings and/or specify locations of other programs.
      
           Any conflicts or new values will be highlighted by the configure
           process in red. Once you are happy with all the settings and there are no 
           more values in red, click the Generate button to produce the appropriate 
           build files. 
      
           On Windows, if you are using a Visual Studio generator, the solution and 
           project files will be created in the build folder.
      
           On linux, if you are using the Unix Makefiles generator, the Makefiles will
           be created in the build folder.

      2.2  Alternative command line example on Windows in c:\MyHDFstuff\hdf5\build directory:
      
           cmake -G "Visual Studio 10" -DBUILD_TESTING:BOOL=ON -DUSE_SHARED_LIBS:BOOL=ON ..

   3. Build HDF5 Applications
   
      On Windows, you can build HDF5 applications using either the Visual Studio Environment 
      or the command line. The command line is normally used on linux, Unix, and Mac.

      To build from the command line, navigate to your build directory and
      execute the following:
          
              cmake --build . --config {Debug | Release}     
              
      NOTE: "--config {Debug | Release}" may be optional on your platform. We
            recommend choosing either Debug or Release on Windows. If you are
            using the pre-built binaries from HDF, use Release.                                                                                     
             
      3.1  If you wish to use the Visual Studio environment, open the solution 
           file in your build directory. Be sure to select either Debug or 
           Release and build the solution.
             
   4. Test HDF5 Applications

      To test the build, navigate to your build directory and execute:
      
              ctest . -C {Debug | Release}
              
      NOTE: "-C {Debug | Release}" may be optional on your platform. We
            recommend choosing either Debug or Release to match the build
            step on Windows.                                                                                      

   5. The files that support building with CMake are all of the files in the 
      config/cmake folder, the CMakeLists.txt files in each source folder, and 
      CTestConfig.cmake. CTestConfig.cmake is specific to the internal testing 
      performed by The HDF Group. It should be altered for the user's 
      installation and needs. The cacheinit.cmake file settings are used by
      The HDF Group for daily testing. It should be altered/ignored for the user's 
      installation and needs. 



========================================================================
III. Minimum C Project Files for CMake
========================================================================

   6. Create a CMakeLists.txt file at the source root. Include the 
      following text in the file:

##########################################################
cmake_minimum_required (VERSION 2.8.10)
PROJECT (HDF5MyApp C CXX)

FIND_PACKAGE (HDF5 NAMES hdf5)
# FIND_PACKAGE (HDF5) # Find non-cmake built HDF5
INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIR})
set (LINK_LIBS ${LINK_LIBS} ${HDF5_LIBRARIES})

set (example hdf_example)

add_executable (${example} ${PROJECT_SOURCE_DIR}/${example}.c)
TARGET_C_PROPERTIES (${example} " " " ")
target_link_libraries (${example} ${LINK_LIBS})

ENABLE_TESTING ()
include (CTest)

add_test (NAME test_example COMMAND ${example})
##########################################################



========================================================================
IV. APPENDIX
========================================================================

Below is an example of the ctest script used by The HDF Group. See the
Appendix in the INSTALL_CMake.txt file for the CTestScript.cmake file used
by this script. Adjust the values as necessary. Note that the source folder
is entered on the command line and the build folder is created as a sub-folder.
Windows should adjust the forward slash to double backslashes, except for
the HDF_DIR environment variable.

NOTE: these files are available at the HDF web site:
    http://www.hdfgroup.org/HDF5/release/cmakebuild.html

    CTestScript.cmake
    
    HDF518ExamplesWindowsbinaryCMake.cmake



========================================================================
ctest
========================================================================

############################################################################
# Product specific script, HDF518Example.cmake, that uses the 
# CTestScript.cmake file (see Appendix in the CMake.txt). Usage:
# "ctest -S HDF518Example.cmake,hdf518Examples -C Release -O hdf518EX.log"
# where hdf518Examples is the source folder relative to the location of these scripts
############################################################################

cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)

set(CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY})
set(CTEST_SOURCE_NAME ${CTEST_SCRIPT_ARG})
set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}/build)
set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}")
set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}")
set(CTEST_BUILD_CONFIGURATION "Release")
set(MODEL "Experimental")

# build generator name, see cmake generator list
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")

# machine description, can be removed on linux
set(CTEST_SITE "machine.domain")
set(SITE_OS_NAME "os name")
set(SITE_OS_VERSION "os version")
set(SITE_OS_BITS "os size")
set(SITE_COMPILER_NAME "compiler name")
set(SITE_COMPILER_VERSION "compiler version")

# needed for source updates, change as required
set(REPOSITORY_URL "http://svn.hdfgroup.uiuc.edu/hdf5-examples/trunk/1_8")

set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/hdf5Examples-1.8")

# location of the installed hdf5 (cmake configuration folder)
set(ENV{HDF5_DIR} "/usr/share/cmake/hdf5")

include(${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake)

message("DONE")
#################################################################################



========================================================================
For further assistance, send email to help@hdfgroup.org
========================================================================


1' href='#n261'>261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
/* 
 * xgc.c --
 *
 *	This file contains generic routines for manipulating X graphics
 *	contexts. 
 *
 * Copyright (c) 1995-1996 Sun Microsystems, Inc.
 * Copyright (c) 2002-2007 Daniel A. Steffen <das@users.sourceforge.net>
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include <tkInt.h>

#if !defined(MAC_TCL) && !defined(MAC_OSX_TK)
#	include <X11/Xlib.h>
#endif
#ifdef MAC_TCL
#	include <Xlib.h>
#	include <X.h>
#	define Cursor XCursor
#	define Region XRegion
#endif
#ifdef MAC_OSX_TK
#	include <tkMacOSXInt.h>
#	include <X11/Xlib.h>
#	include <X11/X.h>
#	define Cursor XCursor
#	define Region XRegion
#endif


/*
 *----------------------------------------------------------------------
 *
 * AllocClipMask --
 *
 *	Static helper proc to allocate new or clear existing TkpClipMask.
 *
 * Results:
 *	Returns ptr to the new/cleared TkpClipMask.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static TkpClipMask *AllocClipMask(GC gc) {
    TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask;
    
    if (clip_mask == None) {
	clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask));
	gc->clip_mask = (Pixmap) clip_mask;
#ifdef MAC_OSX_TK
    } else if (clip_mask->type == TKP_CLIP_REGION) {
	TkpReleaseRegion(clip_mask->value.region);
#endif
    }
    return clip_mask;
}

/*
 *----------------------------------------------------------------------
 *
 * FreeClipMask --
 *
 *	Static helper proc to free TkpClipMask.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static void FreeClipMask(GC gc) {
    if (gc->clip_mask != None) {
#ifdef MAC_OSX_TK
	if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) {
	    TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region);
	}
#endif
	ckfree((char*) gc->clip_mask);
	gc->clip_mask = None;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * XCreateGC --
 *
 *	Allocate a new GC, and initialize the specified fields.
 *
 * Results:
 *	Returns a newly allocated GC. 
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

GC
XCreateGC(display, d, mask, values)
    Display* display;
    Drawable d;
    unsigned long mask;
    XGCValues* values;
{
    GC gp;

/*
 * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars are
 * defined, which is invisible from the outside. The list is assumed to end
 * with a 0-char, so this must be set explicitely during initialization.
 */

#define MAX_DASH_LIST_SIZE 10

    gp = (XGCValues *)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE);
    if (!gp) {
	return None;
    }

    gp->function = 	(mask & GCFunction) 	?values->function	:GXcopy;
    gp->plane_mask = 	(mask & GCPlaneMask) 	?values->plane_mask 	:~0;
    gp->foreground = 	(mask & GCForeground) 	?values->foreground 	:
	    BlackPixelOfScreen(DefaultScreenOfDisplay(display));
    gp->background = 	(mask & GCBackground) 	?values->background 	:
	    WhitePixelOfScreen(DefaultScreenOfDisplay(display));
    gp->line_width = 	(mask & GCLineWidth)	?values->line_width	:1;	
    gp->line_style = 	(mask & GCLineStyle)	?values->line_style	:LineSolid;
    gp->cap_style =  	(mask & GCCapStyle)	?values->cap_style	:0;
    gp->join_style = 	(mask & GCJoinStyle)	?values->join_style	:0;
    gp->fill_style =  	(mask & GCFillStyle)	?values->fill_style	:FillSolid;
    gp->fill_rule =  	(mask & GCFillRule)	?values->fill_rule	:WindingRule;
    gp->arc_mode = 	(mask & GCArcMode)	?values->arc_mode	:ArcPieSlice;
    gp->tile = 		(mask & GCTile)		?values->tile		:None;
    gp->stipple = 	(mask & GCStipple)	?values->stipple	:None;
    gp->ts_x_origin = 	(mask & GCTileStipXOrigin)	?values->ts_x_origin:0;
    gp->ts_y_origin = 	(mask & GCTileStipYOrigin)	?values->ts_y_origin:0;
    gp->font = 		(mask & GCFont)		?values->font		:None;
    gp->subwindow_mode = (mask & GCSubwindowMode)?values->subwindow_mode:ClipByChildren;
    gp->graphics_exposures = (mask & GCGraphicsExposures)?values->graphics_exposures:True;
    gp->clip_x_origin = (mask & GCClipXOrigin)	?values->clip_x_origin	:0;
    gp->clip_y_origin = (mask & GCClipYOrigin)	?values->clip_y_origin	:0;
    gp->dash_offset = 	(mask & GCDashOffset)	?values->dash_offset	:0;
    gp->dashes = 	(mask & GCDashList)	?values->dashes		:4;
    (&(gp->dashes))[1] = 	0;

    gp->clip_mask = None;
    if (mask & GCClipMask) {
	TkpClipMask *clip_mask = AllocClipMask(gp);
	
	clip_mask->type = TKP_CLIP_PIXMAP;
	clip_mask->value.pixmap = values->clip_mask;
    }

    return gp;
}

/*
 *----------------------------------------------------------------------
 *
 * XChangeGC --
 *
 *	Changes the GC components specified by valuemask for the
 *	specified GC.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Updates the specified GC.
 *
 *----------------------------------------------------------------------
 */

int
XChangeGC(d, gc, mask, values)
    Display * d;
    GC gc;
    unsigned long mask;
    XGCValues *values;
{
    if (mask & GCFunction) { gc->function = values->function; }
    if (mask & GCPlaneMask) { gc->plane_mask = values->plane_mask; }
    if (mask & GCForeground) { gc->foreground = values->foreground; }
    if (mask & GCBackground) { gc->background = values->background; }
    if (mask & GCLineWidth) { gc->line_width = values->line_width; }	
    if (mask & GCLineStyle) { gc->line_style = values->line_style; }
    if (mask & GCCapStyle) { gc->cap_style = values->cap_style; }
    if (mask & GCJoinStyle) { gc->join_style = values->join_style; }
    if (mask & GCFillStyle) { gc->fill_style = values->fill_style; }
    if (mask & GCFillRule) { gc->fill_rule = values->fill_rule; }
    if (mask & GCArcMode) { gc->arc_mode = values->arc_mode; }
    if (mask & GCTile) { gc->tile = values->tile; }
    if (mask & GCStipple) { gc->stipple = values->stipple; }
    if (mask & GCTileStipXOrigin) { gc->ts_x_origin = values->ts_x_origin; }
    if (mask & GCTileStipYOrigin) { gc->ts_y_origin = values->ts_y_origin; }
    if (mask & GCFont) { gc->font = values->font; }
    if (mask & GCSubwindowMode) { gc->subwindow_mode = values->subwindow_mode; }
    if (mask & GCGraphicsExposures) { gc->graphics_exposures = values->graphics_exposures; }
    if (mask & GCClipXOrigin) { gc->clip_x_origin = values->clip_x_origin; }
    if (mask & GCClipYOrigin) { gc->clip_y_origin = values->clip_y_origin; }
    if (mask & GCClipMask) { XSetClipMask(d, gc, values->clip_mask); }
    if (mask & GCDashOffset) { gc->dash_offset = values->dash_offset; }
    if (mask & GCDashList) { gc->dashes = values->dashes; (&(gc->dashes))[1] = 0;}
    return 0;
}

/*
 *----------------------------------------------------------------------
 *
 * XFreeGC --
 *
 *	Deallocates the specified graphics context.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

int XFreeGC(d, gc)
    Display * d;
    GC gc;
{
    if (gc != None) {
	FreeClipMask(gc);
	ckfree((char *) gc);
    }
    return 0;
}

/*
 *----------------------------------------------------------------------
 *
 * XSetForeground, etc. --
 *
 *	The following functions are simply accessor functions for
 *	the GC slots.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Each function sets some slot in the GC.
 *
 *----------------------------------------------------------------------
 */

int
XSetForeground(display, gc, foreground)
    Display *display;
    GC gc;
    unsigned long foreground;
{
    gc->foreground = foreground;
    return 0;
}

int
XSetBackground(display, gc, background)
    Display *display;
    GC gc;
    unsigned long background;
{
    gc->background = background;
    return 0;
}

int
XSetDashes(display, gc, dash_offset, dash_list, n)
    Display* display;
    GC gc;
    int dash_offset;
    _Xconst char* dash_list;
    int n;
{
    char *p = &(gc->dashes);

#ifdef TkWinDeleteBrush
    TkWinDeleteBrush(gc->fgBrush);
    TkWinDeletePen(gc->fgPen);
    TkWinDeleteBrush(gc->bgBrush);
    TkWinDeletePen(gc->fgExtPen);
#endif
    gc->dash_offset = dash_offset;
    if (n > MAX_DASH_LIST_SIZE) n = MAX_DASH_LIST_SIZE;
    while (n-- > 0) {
	*p++ = *dash_list++;
    }
    *p = 0;
    return 0;
}

int
XSetFunction(display, gc, function)
    Display *display;
    GC gc;
    int function;
{
    gc->function = function;
    return 0;
}

int
XSetFillRule(display, gc, fill_rule)
    Display *display;
    GC gc;
    int fill_rule;
{
    gc->fill_rule = fill_rule;
    return 0;
}

int
XSetFillStyle(display, gc, fill_style)
    Display *display;
    GC gc;
    int fill_style;
{
    gc->fill_style = fill_style;
    return 0;
}

int
XSetTSOrigin(display, gc, x, y)
    Display *display;
    GC gc;
    int x, y;
{
    gc->ts_x_origin = x;
    gc->ts_y_origin = y;
    return 0;
}

int
XSetFont(display, gc, font)
    Display *display;
    GC gc;
    Font font;
{
    gc->font = font;
    return 0;
}

int
XSetArcMode(display, gc, arc_mode)
    Display *display;
    GC gc;
    int arc_mode;
{
    gc->arc_mode = arc_mode;
    return 0;
}

int
XSetStipple(display, gc, stipple)
    Display *display;
    GC gc;
    Pixmap stipple;
{
    gc->stipple = stipple;
    return 0;
}

int
XSetLineAttributes(display, gc, line_width, line_style, cap_style,
	join_style)
    Display *display;
    GC gc;
    unsigned int line_width;
    int line_style;
    int cap_style;
    int join_style;
{
    gc->line_width = line_width;
    gc->line_style = line_style;
    gc->cap_style = cap_style;
    gc->join_style = join_style;
    return 0;
}

int
XSetClipOrigin(display, gc, clip_x_origin, clip_y_origin)
    Display* display;
    GC gc;
    int clip_x_origin;
    int clip_y_origin;
{
    gc->clip_x_origin = clip_x_origin;
    gc->clip_y_origin = clip_y_origin;
    return 0;
}

/*
 *----------------------------------------------------------------------
 *
 * TkSetRegion, XSetClipMask --
 *
 *	Sets the clipping region/pixmap for a GC.
 *
 *	Note that unlike the Xlib equivalent, it is not safe to delete the
 *	region after setting it into the GC (except on Mac OS X). The only
 *	uses of TkSetRegion are currently in DisplayFrame and in
 *	ImgPhotoDisplay, which use the GC immediately.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Allocates or dealloates a TkpClipMask.
 *
 *----------------------------------------------------------------------
 */

void
TkSetRegion(display, gc, r)
    Display* display;
    GC gc;
    TkRegion r;
{
    if (r == None) {
	FreeClipMask(gc);
    } else {
	TkpClipMask *clip_mask = AllocClipMask(gc);

	clip_mask->type = TKP_CLIP_REGION;
	clip_mask->value.region = r;
#ifdef MAC_OSX_TK
	TkpRetainRegion(r);
#endif
    }
}

int
XSetClipMask(display, gc, pixmap)
    Display* display;
    GC gc;
    Pixmap pixmap;
{
    if (pixmap == None) {
	FreeClipMask(gc);
    } else {
	TkpClipMask *clip_mask = AllocClipMask(gc);

	clip_mask->type = TKP_CLIP_PIXMAP;
	clip_mask->value.pixmap = pixmap;
    }
    return 0;
}

/*
 * Some additional dummy functions (hopefully implemented soon).
 */

#if 0
Cursor
XCreateFontCursor(display, shape)
    Display* display;
    unsigned int shape;
{
    return (Cursor) 0;
}

void
XDrawImageString(display, d, gc, x, y, string, length)
    Display* display;
    Drawable d;
    GC gc;
    int x;
    int y;
    _Xconst char* string;
    int length;
{
}
#endif

void
XDrawPoint(display, d, gc, x, y)
    Display* display;
    Drawable d;
    GC gc;
    int x;
    int y;
{
    XDrawLine(display, d, gc, x, y, x, y);
}

void
XDrawPoints(display, d, gc, points, npoints, mode)
    Display* display;
    Drawable d;
    GC gc;
    XPoint* points;
    int npoints;
    int mode;
{
    int i;

    for (i=0; i<npoints; i++) {
	XDrawPoint(display, d, gc, points[i].x, points[i].y);
    }
}

#if !defined(MAC_TCL) && !defined(MAC_OSX_TK)
void
XDrawSegments(display, d, gc, segments, nsegments)
    Display* display;
    Drawable d;
    GC gc;
    XSegment* segments;
    int nsegments;
{
}
#endif

#if 0
char *
XFetchBuffer(display, nbytes_return, buffer)
    Display* display;
    int* nbytes_return;
    int buffer;
{
    return (char *) 0;
}

Status XFetchName(display, w, window_name_return)
    Display* display;
    Window w;
    char** window_name_return;
{
    return (Status) 0;
}

Atom *XListProperties(display, w, num_prop_return)
    Display* display;
    Window w;
    int* num_prop_return;
{
    return (Atom *) 0;
}

void
XMapRaised(display, w)
    Display* display;
    Window w;
{
}

void
XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height)
    Display* display;
    Drawable d;
    GC gc;
    XImage* image;
    int src_x;
    int src_y;
    int dest_x;
    int dest_y;
    unsigned int width;
    unsigned int height;
{
}

void
XQueryTextExtents(display, font_ID, string, nchars, direction_return,
	font_ascent_return, font_descent_return, overall_return)
    Display* display;
    XID font_ID;
    _Xconst char* string;
    int nchars;
    int* direction_return;
    int* font_ascent_return;
    int* font_descent_return;
    XCharStruct* overall_return;
{
}

void
XReparentWindow(display, w, parent, x, y)
    Display* display;
    Window w;
    Window parent;
    int x;
    int y;
{
}

void
XRotateBuffers(display, rotate)
    Display* display;
    int rotate;
{
}

void
XStoreBuffer(display, bytes, nbytes, buffer)
    Display* display;
    _Xconst char* bytes;
    int nbytes;
    int buffer;
{
}

void
XUndefineCursor(display, w)
    Display* display;
    Window w;
{
}
#endif