File: view.txt

package info (click to toggle)
python-wpy 0.53-0.1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 832 kB
  • ctags: 1,991
  • sloc: python: 8,624; makefile: 57; sh: 24
file content (179 lines) | stat: -rw-r--r-- 7,730 bytes parent folder | download | duplicates (3)
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
class CView, CScrollView, CEditView

Class CView represents a "view", one of the most basic objects.  A
view is a visible representation of a document which the user can
interact with.  It is how the user sees and changes the document.
It is the inside of a window, not including the frame.

Do NOT use CView directly.  Use CScrollView instead.

In an SDI application, the same view is reused each time the user
selects File New or File Open.  In an MDI app, a new view is created
each time, and there may be more than one view for each document.

You must not try to set the size and position of a view because these
are controled by the frame.  Set the size and position of the frame
instead.

To change the color of the window, set view.wpyBrush to a background brush.
This is probably a bad idea under Windows.

Instance Variables

wpyParent
	For a view, the parent is the frame, and the parent of the
	frame is the document.
wpyChildList
	For a view, the child list is a list of controls in the view.
wpyDocument
	The document which this view shows.  Equal to self.wpyParent.wpyParent.
wpyHScrollSize, wpyVScrollSize
	The total size of the view in pixels.
wpyHScrollWinSize, wpyVScrollWinSize
	The size of the view which fits in the view window.
wpyHScrollPos, wpyVScrollPos
	The scroll position, the index of the first line in the view.  This varies
	from zero to the scroll size minus the window size.

Methods

__init__(self, templ, doc, frame)
templ: The template being used to create the document.
doc: The document which the view shows.
frame: The frame around the view.
	The framework creates views as required.  The user never constructs
	a view directly.

OnUpdate(self, sender, update)
	Called as a result of the document method UpdateAllViews(self, sender, update)
	being called. Do not perform drawing here, perform drawing in OnDraw().  The
	default version invalidates the whole view so that an OnDraw messages is
	generated at a later time.  Override to set up "update" with information
	about what part of the view needs updating in order to make drawing more
	efficient.
GetAllDrawnObjs(self)
	Return a list of all drawn objects.
GetDrawnObject(self, x, y)
	Return the object drawn at the point (x, y) as an instance of CDrawnText,
	CDrawnRectangle, etc.  If there is no object at that point, then None is
	returned.  The point (x, y) is in view coordinates.  To respond to a mouse
	button press event, use GetDeviceScrollPosition() to transform the mouse
	(x, y) which is in window coordinates to view coordinates.

	An object will be returned if its rectangle contains the point (x, y).
	If objects overlap, only one of the objects will be returned, and
	the one chosen is arbitrary (so don't do that).  Objects of class
	CDrawnLine are not returned by this method.  It only returns objects
	with a rectangular nature such as text, rectangles, bitmaps, etc.
GetDrawnObjectList(self, x, y)
	Same as GetDrawnObject(), but return a list of all objects which touch
	the point including drawn lines.  If no objects, return [].
Redraw(self, obj)
	Redraw the drawn object "obj".  If obj is None, then redraw all
	objects.  The drawing tools DrawText() etc. return
	an object.  To change the object after it is drawn in OnDraw(),
	change the object's attributes and call Redraw().  For example,
		obj.wpyText = "New text"
		obj.wpyLocY = new_y
		self.Redraw(obj).
	This need not be done in OnDraw().  It would normally be done in the
	view when the user changes data.  See the drawn object
	documentation for CDrawnText etc. to see what other attributes
	can be changed.
DestroyDrawn(self, obj)
	Destroy the drawn object.
DestroyAllDrawn(self)
	Erase the view.
AddDrawn(self, obj)
	Add a drawn object to the view.

Messages

OnCreate(self, not_used)
	Sent to the view soon after it is created.  This is always the
	first message sent to a view.

OnDestroy(self)
	Sent to the view before it is destroyed.

OnInitialUpdate(self)
	Sent after "OnCreate" after the view is connected to a document but
	before the view is displayed.  Used when the document must be available.
	For example, use it to set view scroll ranges according to document size.

OnDraw(self, DC), not sent to CEditView
	Sent when the view must be redrawn.  Generally, you should plan
	to do all drawing in OnDraw().  The "DC" is the device context.  Call the methods
	of "DC" to perform drawing.

OnSize(self, new_size)
	Sent after "OnCreate" when a window is created, or when the user or system
	changes the window size.  Generally you should do layout in "OnSize".  The
	size of the client area is given by the rectangle "new_size".  Different
	systems will send several different "OnSize" events, sometimes with 1-pixel
	window sizes as part of the window creation process, so make your code robust.

OnChar(self, char ch, int flags)
	Sent when the user presses a key.  The character is ch, and flags
	gives the status of the control and shift keys.  See messages.txt.

OnVChar(self, string name, int flags)
	Sent when the user presses a virtual key.  The key name is name,
	and flags gives the status of the control and shift keys.
	See messages.txt.

OnLButtonUp    (self, int x, int y, int flags), not sent to CEditView
OnLButtonDown  (self, int x, int y, int flags), not sent to CEditView
OnLButtonDblClk(self, int x, int y, int flags), not sent to CEditView
OnRButtonUp    (self, int x, int y, int flags), not sent to CEditView
OnRButtonDown  (self, int x, int y, int flags), not sent to CEditView
OnRButtonDblClk(self, int x, int y, int flags), not sent to CEditView
	Sent when the user presses, releases or double clicks the left or
	right mouse button.  The mouse location is (x, y), and flags gives
	the state of the shift and control keys.  See messages.txt.

OnMouseMove(self, int x, int y, int flags), not sent to CEditView
	Sent when the user moves the mouse provided that a mouse button or the
	shift or control keys are pressed.  Mouse move commands are not
	generated if all keys are up.  The mouse position is (x, y) and
	flags gives the key state.  See messages.txt.

OnHScroll(self, not_used), not sent to CEditView
OnVScroll(self, not_used), not sent to CEditView
	Sent when the horizontal or vertical scroll bar of a view is operated by the
	user.  This is not used by scroll bar controls.

class CScrollView(CView)

Class CScrollView is a view with automatic scroll bars.  The scroll bars only
appear if needed, so this is a general purpose class.

A CScrollView remembers the objects you draw in OnDraw(), and so it can refresh
the screen itself.  This results in much fewer calls to OnDraw().

If you create a control (such as an edit control) in a scroll view, the location
self.wpyLocX/Y refers to the location in the view, not in the window.  So the
control will be drawn at the same location as a text object would be drawn.

Methods

GetDeviceScrollPosition(self)
	Return a tuple (x, y) representing the point of the view at the upper
	left corner of the view's window.  This is (0, 0) if the view has not been
	scrolled.  Add this point to the mouse position to get the position of the
	mouse within the view.

ScrollToPosition(self, x, y)
	Scroll the view so the point (x, y) is at the top left corner.

SetScrollSizes(self)
	Notify the system of the document size and scroll size.  This may
	cause scroll bars to appear or disappear.  Since this requires the
	document size, it is usually called in OnInitialUpdate().  You only
	need to call it again if the document size changes.  You must have
	set wpyHScrollSize and wpyVScrollSize to the correct document size
	before making this call.  If the document size changes, it may be
	convenient to call it from OnDraw().

class CEditView(CView)
	See editview.txt.