Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/window.c
3196 views
1
/*
2
* Routine to manipulate size and position of the graphics window
3
*
4
* Compile commands
5
*
6
* DEC: cc -shared -o window window.c -I$ELMER_HOME/include
7
* LINUX: gcc -shared -o window window.c -I$ELMER_HOME/include
8
* SGI: cc -shared -o window window.c -I$ELMER_HOME/include -n32
9
* WINDOWS:
10
* cl -c -I%ELMER_HOME%\include -DWIN32 window.c
11
* link /dll /libpath:%ELMER_HOME%\lib window.obj tcl81.lib opengl32.lib
12
*
13
* in elmerpost:
14
*
15
* load window window
16
*
17
* and then you have the commands:
18
*
19
* winpos xpos ypos
20
* winsize width height
21
*/
22
23
#if defined(WIN32) || defined(win32)
24
#include <windows.h>
25
#endif
26
27
#include <stdio.h>
28
#include <math.h>
29
#include <stdlib.h>
30
31
#include <GL/gl.h>
32
#include <GL/glu.h>
33
34
#include <tcl.h>
35
36
#if !(defined(WIN32) || defined(win32))
37
#include <string.h>
38
extern int errno;
39
#include <X11/Xlib.h>
40
#endif
41
42
#ifndef WIN32
43
Display *auxXDisplay();
44
#endif
45
46
static Display *tkXDisplay()
47
{
48
Display *ptr = NULL;
49
#ifndef WIN32
50
ptr = auxXDisplay();
51
#endif
52
return ptr;
53
}
54
55
static Window tkXWindow()
56
{
57
Window ptr = 0;
58
59
#ifdef WIN32
60
ptr = auxGetHWND();
61
#else
62
ptr = auxXWindow();
63
#endif
64
65
return ptr;
66
}
67
68
static int WindowSize( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
69
{
70
int width, height;
71
72
if ( argc < 3 ) {
73
sprintf( interp->result, "Usage: winsize width height" );
74
return TCL_ERROR;
75
}
76
77
width = atoi( *++argv );
78
height = atoi( *++argv );
79
80
XResizeWindow( (Display *)tkXDisplay(), tkXWindow(), width, height );
81
82
return TCL_OK;
83
}
84
85
static int WindowPosition( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
86
{
87
int ox,oy;
88
89
if ( argc < 3 ) {
90
sprintf( interp->result, "Usage: winpos xpos ypos" );
91
return TCL_ERROR;
92
}
93
94
ox = atoi( *++argv );
95
oy = atoi( *++argv );
96
97
XMoveWindow( (Display *)tkXDisplay(), tkXWindow(), ox, oy );
98
99
return TCL_OK;
100
}
101
102
#if defined(WIN32) || defined(win32)
103
__declspec(dllexport)
104
#endif
105
int Window_Init( Tcl_Interp *interp )
106
{
107
Tcl_CreateCommand( interp, "winsize", WindowSize,
108
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
109
110
Tcl_CreateCommand( interp, "winpos", WindowPosition,
111
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
112
113
return TCL_OK;
114
}
115
116