-
Notifications
You must be signed in to change notification settings - Fork 0
/
size.cc
125 lines (96 loc) · 2.44 KB
/
size.cc
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
/* size.cc -- Implementation of the Size mix-in Figure class
Copyright (C) 1999-2013, Brian Bray
*/
#include "bw/bwassert.h"
#include "bw/string.h"
#include "bw/figure.h"
#include "bw/context.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include "event.h"
#include "ffigure.h"
namespace bw {
/*: class Size
This is a mix-in class for Figures that indicates that the Figure wants
notification of size and location changes or wants to request size and
location changes.
*/
/*: Size::Size()
Constructor.
Prototype: Size::Size()
*/
/*: Size::~Size()
Destructor.
Prototype: Size::~Size()
*/
/*: Size::requestResize()
Request the parent figure to resize this one. The request is in logical
terms and can be relative to the parent size or a request to call
onQuerySize dynamically.
*/
void Size::requestResize( LogPos lposWidth, LogPos lposHeight )
{
Event ev;
EventRet evr;
ev.type = SizeRequest;
ev.evSizeReq.pfig = getpFigure();
ev.evSizeReq.lposWidth = lposWidth;
ev.evSizeReq.lposHeight = lposHeight;
FigureImp::doEvent( m_pParent, ev, evr );
}
/*: Size::requestMove()
Request the parent figure to move this one. The request is in logical
terms and can be relative to the parent size or a request to call
onQueryLocation dynamically.
*/
void Size::requestMove( LogPos lposX, LogPos lposY )
{
Event ev;
EventRet evr;
ev.type = MoveRequest;
ev.evSizeReq.pfig = getpFigure();
ev.evSizeReq.lposX = lposX;
ev.evSizeReq.lposY = lposY;
FigureImp::doEvent( m_pParent, ev, evr );
}
/*: Size::requestRelocate()
Request the parent figure to move and resize this one. The request
is in logical terms and can be relative to the parent size or can be
a request to call onQuerySize and onQueryLocation dynamically.
*/
void Size::requestRelocate(
LogPos lposX, LogPos lposY,
LogPos lposWidth, LogPos lposHeight )
{
Event ev;
EventRet evr;
ev.type = RelocateRequest;
ev.evSizeReq.pfig = getpFigure();
ev.evSizeReq.lposX = lposX;
ev.evSizeReq.lposY = lposY;
ev.evSizeReq.lposWidth = lposWidth;
ev.evSizeReq.lposHeight = lposHeight;
FigureImp::doEvent( m_pParent, ev, evr );
}
/* Size::doSizeEvent()
Size event handling.
*/
void Size::doSizeEvent( const Event& ev, EventRet& )
{
switch( ev.type ) {
case SizeNotify:
bwassert( m_pfi );
onResize();
break;
case MoveNotify:
onMove();
break;
case RelocateNotify:
onRelocate();
break;
default:
break;
}
}
} // namespace bw