File: tedDrawMotif.c

package info (click to toggle)
ted 2.11-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 11,064 kB
  • ctags: 13,935
  • sloc: ansic: 120,446; makefile: 7,469; sh: 253
file content (123 lines) | stat: -rw-r--r-- 3,679 bytes parent folder | download
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
/************************************************************************/
/*									*/
/*  Ted, Screen drawing and forcing drawing through			*/
/*  appExposeRectangle().						*/
/*									*/
/************************************************************************/

#   include	"tedConfig.h"

#   include	<stddef.h>
#   include	<stdio.h>

#   include	"tedApp.h"
#   include	"docDraw.h"

#   include	<appDebugon.h>

#   ifdef USE_MOTIF

#   include	<X11/cursorfont.h>

/************************************************************************/
/*									*/
/*  Create the windows that are used to reshape selected objects.	*/
/*									*/
/************************************************************************/

void tedSetObjectWindows(	EditDocument *			ed,
				const PositionGeometry *	pg,
				const InsertedObject *		io,
				int				ox,
				int				oy )
    {
    AppDrawingData *		add= &(ed->edDrawingData);
    Display *			display= add->addDisplay;
    Window			win= add->addDrawable;

    TedDocument *		td= (TedDocument *)ed->edPrivateData;
    int				wide= io->ioPixelsWide;
    int				high= io->ioPixelsHigh;

    XSetWindowAttributes	xswa;

    static Cursor		moveCursor;
    static Cursor		bottomCursor;
    static Cursor		rightCursor;
    static Cursor		cornerCursor;

    if  ( ed->edFileReadOnly )
	{ td->tdObjectSelected= 1; return; }

    if  ( ! moveCursor )
	{
	moveCursor= XCreateFontCursor( display, XC_fleur );
	bottomCursor= XCreateFontCursor( display, XC_bottom_side );
	rightCursor= XCreateFontCursor( display, XC_right_side );
	cornerCursor= XCreateFontCursor( display, XC_bottom_right_corner );
	}

    if  ( ! td->tdObjectWindow )
	{
	xswa.cursor= moveCursor;
	td->tdObjectWindow= XCreateWindow( display, win,
			    pg->pgXPixels- ox, pg->pgBaselinePixels- high- oy,
			    wide, high,
			    0, CopyFromParent, InputOnly, CopyFromParent,
			    0L, &xswa );

	xswa.cursor= bottomCursor;
	td->tdObjectBottomWindow= XCreateWindow( display, td->tdObjectWindow,
			    wide/ 2- RESIZE_BLOCK/ 2, high- RESIZE_BLOCK,
			    RESIZE_BLOCK, RESIZE_BLOCK,
			    0, CopyFromParent, CopyFromParent, CopyFromParent,
			    CWCursor, &xswa );

	xswa.cursor= rightCursor;
	td->tdObjectRightWindow= XCreateWindow( display, td->tdObjectWindow,
			    wide- RESIZE_BLOCK, high/ 2- RESIZE_BLOCK/ 2,
			    RESIZE_BLOCK, RESIZE_BLOCK,
			    0, CopyFromParent, CopyFromParent, CopyFromParent,
			    CWCursor, &xswa );

	xswa.cursor= cornerCursor;
	td->tdObjectCornerWindow= XCreateWindow( display, td->tdObjectWindow,
			    wide- RESIZE_BLOCK, high- RESIZE_BLOCK,
			    RESIZE_BLOCK, RESIZE_BLOCK,
			    0, CopyFromParent, CopyFromParent, CopyFromParent,
			    CWCursor, &xswa );

	XMapRaised( display, td->tdObjectBottomWindow );
	XMapRaised( display, td->tdObjectRightWindow );
	XMapRaised( display, td->tdObjectCornerWindow );
	}
    else{
	XMoveResizeWindow( display, td->tdObjectWindow,
			    pg->pgXPixels- ox, pg->pgBaselinePixels- high- oy,
			    wide, high );

	XMoveWindow( display, td->tdObjectBottomWindow,
				wide/ 2- RESIZE_BLOCK/ 2, high- RESIZE_BLOCK );
	XMoveWindow( display, td->tdObjectRightWindow,
				wide- RESIZE_BLOCK, high/ 2- RESIZE_BLOCK/ 2 );
	XMoveWindow( display, td->tdObjectCornerWindow,
				wide- RESIZE_BLOCK, high- RESIZE_BLOCK );
	}

    XMapRaised( display, td->tdObjectWindow );

    td->tdObjectSelected= 1;
    }

void tedHideObjectWindows(	EditDocument *	ed )
    {
    TedDocument *		td= (TedDocument *)ed->edPrivateData;

    if  ( ed->edFileReadOnly )
	{ td->tdObjectSelected= 0; return; }

    XUnmapWindow( XtDisplay( ed->edDocumentWidget ), td->tdObjectWindow );
    td->tdObjectSelected= 0;
    }

#   endif