Commit 14d53bf1 authored by Guido van Rossum's avatar Guido van Rossum

Added vspacepixels.

Integrated with stdwinq.
parent 48154be1
...@@ -20,7 +20,7 @@ class formatter(): ...@@ -20,7 +20,7 @@ class formatter():
self.v = top # Top of current line self.v = top # Top of current line
self.center = 0 self.center = 0
self.justify = 1 self.justify = 1
self.setfont('') # Current font self.setfont('') # Default font
self._reset() # Prepare for new line self._reset() # Prepare for new line
return self return self
# #
...@@ -122,10 +122,14 @@ class formatter(): ...@@ -122,10 +122,14 @@ class formatter():
# Vertical space is expressed in fractions of the current # Vertical space is expressed in fractions of the current
# font's line height. # font's line height.
# #
def vspace(self, dy): def vspace(self, lines):
self.vspacepixels(int(lines * self.d.lineheight()))
#
# Add vertical space given in pixels.
#
def vspacepixels(self, dv):
self.flush() self.flush()
dy = int(float(dy) * float(self.d.lineheight())) self.v = self.v + dv
self.v = self.v + dy
# #
# Set temporary (hanging) indent, for paragraph start. # Set temporary (hanging) indent, for paragraph start.
# First flush. # First flush.
...@@ -149,7 +153,7 @@ class formatter(): ...@@ -149,7 +153,7 @@ class formatter():
# Test procedure # Test procedure
# #
def test(): def test():
import stdwin import stdwin, stdwinq
from stdwinevents import * from stdwinevents import *
try: try:
import mac import mac
...@@ -170,7 +174,7 @@ def test(): ...@@ -170,7 +174,7 @@ def test():
w = stdwin.open(title) w = stdwin.open(title)
winsize = w.getwinsize() winsize = w.getwinsize()
while 1: while 1:
type, window, detail = stdwin.getevent() type, window, detail = stdwinq.getevent()
if type = WE_CLOSE: if type = WE_CLOSE:
break break
elif type = WE_SIZE: elif type = WE_SIZE:
......
...@@ -20,7 +20,7 @@ class formatter(): ...@@ -20,7 +20,7 @@ class formatter():
self.v = top # Top of current line self.v = top # Top of current line
self.center = 0 self.center = 0
self.justify = 1 self.justify = 1
self.setfont('') # Current font self.setfont('') # Default font
self._reset() # Prepare for new line self._reset() # Prepare for new line
return self return self
# #
...@@ -122,10 +122,14 @@ class formatter(): ...@@ -122,10 +122,14 @@ class formatter():
# Vertical space is expressed in fractions of the current # Vertical space is expressed in fractions of the current
# font's line height. # font's line height.
# #
def vspace(self, dy): def vspace(self, lines):
self.vspacepixels(int(lines * self.d.lineheight()))
#
# Add vertical space given in pixels.
#
def vspacepixels(self, dv):
self.flush() self.flush()
dy = int(float(dy) * float(self.d.lineheight())) self.v = self.v + dv
self.v = self.v + dy
# #
# Set temporary (hanging) indent, for paragraph start. # Set temporary (hanging) indent, for paragraph start.
# First flush. # First flush.
...@@ -149,7 +153,7 @@ class formatter(): ...@@ -149,7 +153,7 @@ class formatter():
# Test procedure # Test procedure
# #
def test(): def test():
import stdwin import stdwin, stdwinq
from stdwinevents import * from stdwinevents import *
try: try:
import mac import mac
...@@ -170,7 +174,7 @@ def test(): ...@@ -170,7 +174,7 @@ def test():
w = stdwin.open(title) w = stdwin.open(title)
winsize = w.getwinsize() winsize = w.getwinsize()
while 1: while 1:
type, window, detail = stdwin.getevent() type, window, detail = stdwinq.getevent()
if type = WE_CLOSE: if type = WE_CLOSE:
break break
elif type = WE_SIZE: elif type = WE_SIZE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment