summaryrefslogtreecommitdiffstats
path: root/Mac/Demo/PICTbrowse
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
commit182b5aca27d376b08a2904bed42b751496f932f3 (patch)
treedf13115820dbc879c0fe2eae488c9f8c0215a7da /Mac/Demo/PICTbrowse
parente6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff)
downloadcpython-182b5aca27d376b08a2904bed42b751496f932f3.zip
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Demo/PICTbrowse')
-rw-r--r--Mac/Demo/PICTbrowse/ICONbrowse.py256
-rw-r--r--Mac/Demo/PICTbrowse/PICTbrowse.py222
-rw-r--r--Mac/Demo/PICTbrowse/PICTbrowse2.py258
-rw-r--r--Mac/Demo/PICTbrowse/cicnbrowse.py256
-rw-r--r--Mac/Demo/PICTbrowse/oldPICTbrowse.py260
5 files changed, 626 insertions, 626 deletions
diff --git a/Mac/Demo/PICTbrowse/ICONbrowse.py b/Mac/Demo/PICTbrowse/ICONbrowse.py
index 1194b7e..701ef7f 100644
--- a/Mac/Demo/PICTbrowse/ICONbrowse.py
+++ b/Mac/Demo/PICTbrowse/ICONbrowse.py
@@ -27,137 +27,137 @@ MAXWIDTH=320
MAXHEIGHT=320
def main():
- macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
- ICONbrowse()
+ macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
+ ICONbrowse()
class ICONbrowse(FrameWork.Application):
- def __init__(self):
- # First init menus, etc.
- FrameWork.Application.__init__(self)
- # Next create our dialog
- self.main_dialog = MyDialog(self)
- # Now open the dialog
- contents = self.findICONresources()
- self.main_dialog.open(ID_MAIN, contents)
- # Finally, go into the event loop
- self.mainloop()
-
- def makeusermenus(self):
- self.filemenu = m = FrameWork.Menu(self.menubar, "File")
- self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
-
- def quit(self, *args):
- self._quit()
-
- def showICON(self, resid):
- w = ICONwindow(self)
- w.open(resid)
- #EasyDialogs.Message('Show ICON %r' % (resid,))
-
- def findICONresources(self):
- num = Res.CountResources('ICON')
- rv = []
- for i in range(1, num+1):
- Res.SetResLoad(0)
- try:
- r = Res.GetIndResource('ICON', i)
- finally:
- Res.SetResLoad(1)
- id, type, name = r.GetResInfo()
- rv.append((id, name))
- return rv
-
+ def __init__(self):
+ # First init menus, etc.
+ FrameWork.Application.__init__(self)
+ # Next create our dialog
+ self.main_dialog = MyDialog(self)
+ # Now open the dialog
+ contents = self.findICONresources()
+ self.main_dialog.open(ID_MAIN, contents)
+ # Finally, go into the event loop
+ self.mainloop()
+
+ def makeusermenus(self):
+ self.filemenu = m = FrameWork.Menu(self.menubar, "File")
+ self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
+
+ def quit(self, *args):
+ self._quit()
+
+ def showICON(self, resid):
+ w = ICONwindow(self)
+ w.open(resid)
+ #EasyDialogs.Message('Show ICON %r' % (resid,))
+
+ def findICONresources(self):
+ num = Res.CountResources('ICON')
+ rv = []
+ for i in range(1, num+1):
+ Res.SetResLoad(0)
+ try:
+ r = Res.GetIndResource('ICON', i)
+ finally:
+ Res.SetResLoad(1)
+ id, type, name = r.GetResInfo()
+ rv.append((id, name))
+ return rv
+
class ICONwindow(FrameWork.Window):
- def open(self, (resid, resname)):
- if not resname:
- resname = '#%r' % (resid,)
- self.resid = resid
- self.picture = Icn.GetIcon(self.resid)
- l, t, r, b = 0, 0, 32, 32
- self.pictrect = (l, t, r, b)
- width = r-l
- height = b-t
- if width < MINWIDTH: width = MINWIDTH
- elif width > MAXWIDTH: width = MAXWIDTH
- if height < MINHEIGHT: height = MINHEIGHT
- elif height > MAXHEIGHT: height = MAXHEIGHT
- bounds = (LEFT, TOP, LEFT+width, TOP+height)
-
- self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
- self.do_postopen()
-
- def do_update(self, *args):
- currect = self.fitrect()
- Icn.PlotIcon(currect, self.picture)
-
- def fitrect(self):
- """Return self.pictrect scaled to fit in window"""
- graf = self.wid.GetWindowPort()
- screenrect = graf.GetPortBounds()
- picwidth = self.pictrect[2] - self.pictrect[0]
- picheight = self.pictrect[3] - self.pictrect[1]
- if picwidth > screenrect[2] - screenrect[0]:
- factor = float(picwidth) / float(screenrect[2]-screenrect[0])
- picwidth = picwidth / factor
- picheight = picheight / factor
- if picheight > screenrect[3] - screenrect[1]:
- factor = float(picheight) / float(screenrect[3]-screenrect[1])
- picwidth = picwidth / factor
- picheight = picheight / factor
- return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
- screenrect[1]+int(picheight))
-
+ def open(self, (resid, resname)):
+ if not resname:
+ resname = '#%r' % (resid,)
+ self.resid = resid
+ self.picture = Icn.GetIcon(self.resid)
+ l, t, r, b = 0, 0, 32, 32
+ self.pictrect = (l, t, r, b)
+ width = r-l
+ height = b-t
+ if width < MINWIDTH: width = MINWIDTH
+ elif width > MAXWIDTH: width = MAXWIDTH
+ if height < MINHEIGHT: height = MINHEIGHT
+ elif height > MAXHEIGHT: height = MAXHEIGHT
+ bounds = (LEFT, TOP, LEFT+width, TOP+height)
+
+ self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
+ self.do_postopen()
+
+ def do_update(self, *args):
+ currect = self.fitrect()
+ Icn.PlotIcon(currect, self.picture)
+
+ def fitrect(self):
+ """Return self.pictrect scaled to fit in window"""
+ graf = self.wid.GetWindowPort()
+ screenrect = graf.GetPortBounds()
+ picwidth = self.pictrect[2] - self.pictrect[0]
+ picheight = self.pictrect[3] - self.pictrect[1]
+ if picwidth > screenrect[2] - screenrect[0]:
+ factor = float(picwidth) / float(screenrect[2]-screenrect[0])
+ picwidth = picwidth / factor
+ picheight = picheight / factor
+ if picheight > screenrect[3] - screenrect[1]:
+ factor = float(picheight) / float(screenrect[3]-screenrect[1])
+ picwidth = picwidth / factor
+ picheight = picheight / factor
+ return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
+ screenrect[1]+int(picheight))
+
class MyDialog(FrameWork.DialogWindow):
- "Main dialog window for ICONbrowse"
-
- def open(self, id, contents):
- self.id = id
- FrameWork.DialogWindow.open(self, ID_MAIN)
- self.dlg.SetDialogDefaultItem(MAIN_SHOW)
- self.contents = contents
- self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
- h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
- Controls.kControlListBoxListHandleTag)
- self.list = List.as_List(h)
- self.setlist()
-
- def setlist(self):
- self.list.LDelRow(0, 0)
- self.list.LSetDrawingMode(0)
- if self.contents:
- self.list.LAddRow(len(self.contents), 0)
- for i in range(len(self.contents)):
- v = repr(self.contents[i][0])
- if self.contents[i][1]:
- v = v + '"' + self.contents[i][1] + '"'
- self.list.LSetCell(v, (0, i))
- self.list.LSetDrawingMode(1)
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def getselection(self):
- items = []
- point = (0,0)
- while 1:
- ok, point = self.list.LGetSelect(1, point)
- if not ok:
- break
- items.append(point[1])
- point = point[0], point[1]+1
- values = []
- for i in items:
- values.append(self.contents[i])
- return values
-
- def do_show(self, *args):
- selection = self.getselection()
- for resid in selection:
- self.parent.showICON(resid)
-
- def do_close(self):
- self.close()
-
- def do_itemhit(self, item, event):
- if item == MAIN_SHOW:
- self.do_show()
+ "Main dialog window for ICONbrowse"
+
+ def open(self, id, contents):
+ self.id = id
+ FrameWork.DialogWindow.open(self, ID_MAIN)
+ self.dlg.SetDialogDefaultItem(MAIN_SHOW)
+ self.contents = contents
+ self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
+ h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
+ Controls.kControlListBoxListHandleTag)
+ self.list = List.as_List(h)
+ self.setlist()
+
+ def setlist(self):
+ self.list.LDelRow(0, 0)
+ self.list.LSetDrawingMode(0)
+ if self.contents:
+ self.list.LAddRow(len(self.contents), 0)
+ for i in range(len(self.contents)):
+ v = repr(self.contents[i][0])
+ if self.contents[i][1]:
+ v = v + '"' + self.contents[i][1] + '"'
+ self.list.LSetCell(v, (0, i))
+ self.list.LSetDrawingMode(1)
+ self.list.LUpdate(self.wid.GetWindowPort().visRgn)
+
+ def getselection(self):
+ items = []
+ point = (0,0)
+ while 1:
+ ok, point = self.list.LGetSelect(1, point)
+ if not ok:
+ break
+ items.append(point[1])
+ point = point[0], point[1]+1
+ values = []
+ for i in items:
+ values.append(self.contents[i])
+ return values
+
+ def do_show(self, *args):
+ selection = self.getselection()
+ for resid in selection:
+ self.parent.showICON(resid)
+
+ def do_close(self):
+ self.close()
+
+ def do_itemhit(self, item, event):
+ if item == MAIN_SHOW:
+ self.do_show()
main()
diff --git a/Mac/Demo/PICTbrowse/PICTbrowse.py b/Mac/Demo/PICTbrowse/PICTbrowse.py
index eace869..0adfc83 100644
--- a/Mac/Demo/PICTbrowse/PICTbrowse.py
+++ b/Mac/Demo/PICTbrowse/PICTbrowse.py
@@ -22,120 +22,120 @@ LEFT=200
TOP=64
def main():
- macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
- PICTbrowse()
+ macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
+ PICTbrowse()
class PICTbrowse(FrameWork.Application):
- def __init__(self):
- # First init menus, etc.
- FrameWork.Application.__init__(self)
- # Next create our dialog
- self.main_dialog = MyDialog(self)
- # Now open the dialog
- contents = self.findPICTresources()
- self.main_dialog.open(ID_MAIN, contents)
- # Finally, go into the event loop
- self.mainloop()
-
- def makeusermenus(self):
- self.filemenu = m = FrameWork.Menu(self.menubar, "File")
- self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
-
- def quit(self, *args):
- self._quit()
-
- def showPICT(self, resid):
- w = PICTwindow(self)
- w.open(resid)
- #EasyDialogs.Message('Show PICT %r' % (resid,))
-
- def findPICTresources(self):
- num = Res.CountResources('PICT')
- rv = []
- for i in range(1, num+1):
- Res.SetResLoad(0)
- try:
- r = Res.GetIndResource('PICT', i)
- finally:
- Res.SetResLoad(1)
- id, type, name = r.GetResInfo()
- rv.append((id, name))
- return rv
-
+ def __init__(self):
+ # First init menus, etc.
+ FrameWork.Application.__init__(self)
+ # Next create our dialog
+ self.main_dialog = MyDialog(self)
+ # Now open the dialog
+ contents = self.findPICTresources()
+ self.main_dialog.open(ID_MAIN, contents)
+ # Finally, go into the event loop
+ self.mainloop()
+
+ def makeusermenus(self):
+ self.filemenu = m = FrameWork.Menu(self.menubar, "File")
+ self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
+
+ def quit(self, *args):
+ self._quit()
+
+ def showPICT(self, resid):
+ w = PICTwindow(self)
+ w.open(resid)
+ #EasyDialogs.Message('Show PICT %r' % (resid,))
+
+ def findPICTresources(self):
+ num = Res.CountResources('PICT')
+ rv = []
+ for i in range(1, num+1):
+ Res.SetResLoad(0)
+ try:
+ r = Res.GetIndResource('PICT', i)
+ finally:
+ Res.SetResLoad(1)
+ id, type, name = r.GetResInfo()
+ rv.append((id, name))
+ return rv
+
class PICTwindow(FrameWork.Window):
- def open(self, (resid, resname)):
- if not resname:
- resname = '#%r' % (resid,)
- self.resid = resid
- picture = Qd.GetPicture(self.resid)
- # Get rect for picture
- print repr(picture.data[:16])
- sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
- print 'pict:', t, l, b, r
- width = r-l
- height = b-t
- if width < 64: width = 64
- elif width > 480: width = 480
- if height < 64: height = 64
- elif height > 320: height = 320
- bounds = (LEFT, TOP, LEFT+width, TOP+height)
- print 'bounds:', bounds
-
- self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
- self.wid.SetWindowPic(picture)
- self.do_postopen()
-
+ def open(self, (resid, resname)):
+ if not resname:
+ resname = '#%r' % (resid,)
+ self.resid = resid
+ picture = Qd.GetPicture(self.resid)
+ # Get rect for picture
+ print repr(picture.data[:16])
+ sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
+ print 'pict:', t, l, b, r
+ width = r-l
+ height = b-t
+ if width < 64: width = 64
+ elif width > 480: width = 480
+ if height < 64: height = 64
+ elif height > 320: height = 320
+ bounds = (LEFT, TOP, LEFT+width, TOP+height)
+ print 'bounds:', bounds
+
+ self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
+ self.wid.SetWindowPic(picture)
+ self.do_postopen()
+
class MyDialog(FrameWork.DialogWindow):
- "Main dialog window for PICTbrowse"
-
- def open(self, id, contents):
- self.id = id
- FrameWork.DialogWindow.open(self, ID_MAIN)
- self.dlg.SetDialogDefaultItem(MAIN_SHOW)
- self.contents = contents
- self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
- h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
- Controls.kControlListBoxListHandleTag)
- self.list = List.as_List(h)
- self.setlist()
-
- def setlist(self):
- self.list.LDelRow(0, 0)
- self.list.LSetDrawingMode(0)
- if self.contents:
- self.list.LAddRow(len(self.contents), 0)
- for i in range(len(self.contents)):
- v = repr(self.contents[i][0])
- if self.contents[i][1]:
- v = v + '"' + self.contents[i][1] + '"'
- self.list.LSetCell(v, (0, i))
- self.list.LSetDrawingMode(1)
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def getselection(self):
- items = []
- point = (0,0)
- while 1:
- ok, point = self.list.LGetSelect(1, point)
- if not ok:
- break
- items.append(point[1])
- point = point[0], point[1]+1
- values = []
- for i in items:
- values.append(self.contents[i])
- return values
-
- def do_show(self, *args):
- selection = self.getselection()
- for resid in selection:
- self.parent.showPICT(resid)
-
- def do_close(self):
- self.close()
-
- def do_itemhit(self, item, event):
- if item == MAIN_SHOW:
- self.do_show()
+ "Main dialog window for PICTbrowse"
+
+ def open(self, id, contents):
+ self.id = id
+ FrameWork.DialogWindow.open(self, ID_MAIN)
+ self.dlg.SetDialogDefaultItem(MAIN_SHOW)
+ self.contents = contents
+ self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
+ h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
+ Controls.kControlListBoxListHandleTag)
+ self.list = List.as_List(h)
+ self.setlist()
+
+ def setlist(self):
+ self.list.LDelRow(0, 0)
+ self.list.LSetDrawingMode(0)
+ if self.contents:
+ self.list.LAddRow(len(self.contents), 0)
+ for i in range(len(self.contents)):
+ v = repr(self.contents[i][0])
+ if self.contents[i][1]:
+ v = v + '"' + self.contents[i][1] + '"'
+ self.list.LSetCell(v, (0, i))
+ self.list.LSetDrawingMode(1)
+ self.list.LUpdate(self.wid.GetWindowPort().visRgn)
+
+ def getselection(self):
+ items = []
+ point = (0,0)
+ while 1:
+ ok, point = self.list.LGetSelect(1, point)
+ if not ok:
+ break
+ items.append(point[1])
+ point = point[0], point[1]+1
+ values = []
+ for i in items:
+ values.append(self.contents[i])
+ return values
+
+ def do_show(self, *args):
+ selection = self.getselection()
+ for resid in selection:
+ self.parent.showPICT(resid)
+
+ def do_close(self):
+ self.close()
+
+ def do_itemhit(self, item, event):
+ if item == MAIN_SHOW:
+ self.do_show()
main()
diff --git a/Mac/Demo/PICTbrowse/PICTbrowse2.py b/Mac/Demo/PICTbrowse/PICTbrowse2.py
index 875c99b..84cf8b8 100644
--- a/Mac/Demo/PICTbrowse/PICTbrowse2.py
+++ b/Mac/Demo/PICTbrowse/PICTbrowse2.py
@@ -26,138 +26,138 @@ MAXWIDTH=320
MAXHEIGHT=320
def main():
- macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
- PICTbrowse()
+ macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
+ PICTbrowse()
class PICTbrowse(FrameWork.Application):
- def __init__(self):
- # First init menus, etc.
- FrameWork.Application.__init__(self)
- # Next create our dialog
- self.main_dialog = MyDialog(self)
- # Now open the dialog
- contents = self.findPICTresources()
- self.main_dialog.open(ID_MAIN, contents)
- # Finally, go into the event loop
- self.mainloop()
-
- def makeusermenus(self):
- self.filemenu = m = FrameWork.Menu(self.menubar, "File")
- self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
-
- def quit(self, *args):
- self._quit()
-
- def showPICT(self, resid):
- w = PICTwindow(self)
- w.open(resid)
- #EasyDialogs.Message('Show PICT %r' % (resid,))
-
- def findPICTresources(self):
- num = Res.CountResources('PICT')
- rv = []
- for i in range(1, num+1):
- Res.SetResLoad(0)
- try:
- r = Res.GetIndResource('PICT', i)
- finally:
- Res.SetResLoad(1)
- id, type, name = r.GetResInfo()
- rv.append((id, name))
- return rv
-
+ def __init__(self):
+ # First init menus, etc.
+ FrameWork.Application.__init__(self)
+ # Next create our dialog
+ self.main_dialog = MyDialog(self)
+ # Now open the dialog
+ contents = self.findPICTresources()
+ self.main_dialog.open(ID_MAIN, contents)
+ # Finally, go into the event loop
+ self.mainloop()
+
+ def makeusermenus(self):
+ self.filemenu = m = FrameWork.Menu(self.menubar, "File")
+ self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
+
+ def quit(self, *args):
+ self._quit()
+
+ def showPICT(self, resid):
+ w = PICTwindow(self)
+ w.open(resid)
+ #EasyDialogs.Message('Show PICT %r' % (resid,))
+
+ def findPICTresources(self):
+ num = Res.CountResources('PICT')
+ rv = []
+ for i in range(1, num+1):
+ Res.SetResLoad(0)
+ try:
+ r = Res.GetIndResource('PICT', i)
+ finally:
+ Res.SetResLoad(1)
+ id, type, name = r.GetResInfo()
+ rv.append((id, name))
+ return rv
+
class PICTwindow(FrameWork.Window):
- def open(self, (resid, resname)):
- if not resname:
- resname = '#%r' % (resid,)
- self.resid = resid
- self.picture = Qd.GetPicture(self.resid)
- # Get rect for picture
- sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10])
- self.pictrect = (l, t, r, b)
- width = r-l
- height = b-t
- if width < MINWIDTH: width = MINWIDTH
- elif width > MAXWIDTH: width = MAXWIDTH
- if height < MINHEIGHT: height = MINHEIGHT
- elif height > MAXHEIGHT: height = MAXHEIGHT
- bounds = (LEFT, TOP, LEFT+width, TOP+height)
-
- self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
- self.do_postopen()
-
- def do_update(self, *args):
- currect = self.fitrect()
- Qd.DrawPicture(self.picture, currect)
-
- def fitrect(self):
- """Return self.pictrect scaled to fit in window"""
- graf = self.dlg.GetWindowPort()
- screenrect = graf.GetPortBounds()
- picwidth = self.pictrect[2] - self.pictrect[0]
- picheight = self.pictrect[3] - self.pictrect[1]
- if picwidth > screenrect[2] - screenrect[0]:
- factor = float(picwidth) / float(screenrect[2]-screenrect[0])
- picwidth = picwidth / factor
- picheight = picheight / factor
- if picheight > screenrect[3] - screenrect[1]:
- factor = float(picheight) / float(screenrect[3]-screenrect[1])
- picwidth = picwidth / factor
- picheight = picheight / factor
- return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
- screenrect[1]+int(picheight))
-
+ def open(self, (resid, resname)):
+ if not resname:
+ resname = '#%r' % (resid,)
+ self.resid = resid
+ self.picture = Qd.GetPicture(self.resid)
+ # Get rect for picture
+ sz, t, l, b, r = struct.unpack('hhhhh', self.picture.data[:10])
+ self.pictrect = (l, t, r, b)
+ width = r-l
+ height = b-t
+ if width < MINWIDTH: width = MINWIDTH
+ elif width > MAXWIDTH: width = MAXWIDTH
+ if height < MINHEIGHT: height = MINHEIGHT
+ elif height > MAXHEIGHT: height = MAXHEIGHT
+ bounds = (LEFT, TOP, LEFT+width, TOP+height)
+
+ self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
+ self.do_postopen()
+
+ def do_update(self, *args):
+ currect = self.fitrect()
+ Qd.DrawPicture(self.picture, currect)
+
+ def fitrect(self):
+ """Return self.pictrect scaled to fit in window"""
+ graf = self.dlg.GetWindowPort()
+ screenrect = graf.GetPortBounds()
+ picwidth = self.pictrect[2] - self.pictrect[0]
+ picheight = self.pictrect[3] - self.pictrect[1]
+ if picwidth > screenrect[2] - screenrect[0]:
+ factor = float(picwidth) / float(screenrect[2]-screenrect[0])
+ picwidth = picwidth / factor
+ picheight = picheight / factor
+ if picheight > screenrect[3] - screenrect[1]:
+ factor = float(picheight) / float(screenrect[3]-screenrect[1])
+ picwidth = picwidth / factor
+ picheight = picheight / factor
+ return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
+ screenrect[1]+int(picheight))
+
class MyDialog(FrameWork.DialogWindow):
- "Main dialog window for PICTbrowse"
-
- def open(self, id, contents):
- self.id = id
- FrameWork.DialogWindow.open(self, ID_MAIN)
- self.dlg.SetDialogDefaultItem(MAIN_SHOW)
- self.contents = contents
- self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
- h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
- Controls.kControlListBoxListHandleTag)
- self.list = List.as_List(h)
- self.setlist()
-
- def setlist(self):
- self.list.LDelRow(0, 0)
- self.list.LSetDrawingMode(0)
- if self.contents:
- self.list.LAddRow(len(self.contents), 0)
- for i in range(len(self.contents)):
- v = repr(self.contents[i][0])
- if self.contents[i][1]:
- v = v + '"' + self.contents[i][1] + '"'
- self.list.LSetCell(v, (0, i))
- self.list.LSetDrawingMode(1)
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def getselection(self):
- items = []
- point = (0,0)
- while 1:
- ok, point = self.list.LGetSelect(1, point)
- if not ok:
- break
- items.append(point[1])
- point = point[0], point[1]+1
- values = []
- for i in items:
- values.append(self.contents[i])
- return values
-
- def do_show(self, *args):
- selection = self.getselection()
- for resid in selection:
- self.parent.showPICT(resid)
-
- def do_close(self):
- self.close()
-
- def do_itemhit(self, item, event):
- if item == MAIN_SHOW:
- self.do_show()
+ "Main dialog window for PICTbrowse"
+
+ def open(self, id, contents):
+ self.id = id
+ FrameWork.DialogWindow.open(self, ID_MAIN)
+ self.dlg.SetDialogDefaultItem(MAIN_SHOW)
+ self.contents = contents
+ self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
+ h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
+ Controls.kControlListBoxListHandleTag)
+ self.list = List.as_List(h)
+ self.setlist()
+
+ def setlist(self):
+ self.list.LDelRow(0, 0)
+ self.list.LSetDrawingMode(0)
+ if self.contents:
+ self.list.LAddRow(len(self.contents), 0)
+ for i in range(len(self.contents)):
+ v = repr(self.contents[i][0])
+ if self.contents[i][1]:
+ v = v + '"' + self.contents[i][1] + '"'
+ self.list.LSetCell(v, (0, i))
+ self.list.LSetDrawingMode(1)
+ self.list.LUpdate(self.wid.GetWindowPort().visRgn)
+
+ def getselection(self):
+ items = []
+ point = (0,0)
+ while 1:
+ ok, point = self.list.LGetSelect(1, point)
+ if not ok:
+ break
+ items.append(point[1])
+ point = point[0], point[1]+1
+ values = []
+ for i in items:
+ values.append(self.contents[i])
+ return values
+
+ def do_show(self, *args):
+ selection = self.getselection()
+ for resid in selection:
+ self.parent.showPICT(resid)
+
+ def do_close(self):
+ self.close()
+
+ def do_itemhit(self, item, event):
+ if item == MAIN_SHOW:
+ self.do_show()
main()
diff --git a/Mac/Demo/PICTbrowse/cicnbrowse.py b/Mac/Demo/PICTbrowse/cicnbrowse.py
index e3d7972..d95e7c8 100644
--- a/Mac/Demo/PICTbrowse/cicnbrowse.py
+++ b/Mac/Demo/PICTbrowse/cicnbrowse.py
@@ -27,137 +27,137 @@ MAXWIDTH=320
MAXHEIGHT=320
def main():
- macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
- CIconbrowse()
+ macresource.need('DLOG', ID_MAIN, "PICTbrowse.rsrc")
+ CIconbrowse()
class CIconbrowse(FrameWork.Application):
- def __init__(self):
- # First init menus, etc.
- FrameWork.Application.__init__(self)
- # Next create our dialog
- self.main_dialog = MyDialog(self)
- # Now open the dialog
- contents = self.findcicnresources()
- self.main_dialog.open(ID_MAIN, contents)
- # Finally, go into the event loop
- self.mainloop()
-
- def makeusermenus(self):
- self.filemenu = m = FrameWork.Menu(self.menubar, "File")
- self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
-
- def quit(self, *args):
- self._quit()
-
- def showCIcon(self, resid):
- w = CIconwindow(self)
- w.open(resid)
- #EasyDialogs.Message('Show cicn %r' % (resid,))
-
- def findcicnresources(self):
- num = Res.CountResources('cicn')
- rv = []
- for i in range(1, num+1):
- Res.SetResLoad(0)
- try:
- r = Res.GetIndResource('cicn', i)
- finally:
- Res.SetResLoad(1)
- id, type, name = r.GetResInfo()
- rv.append((id, name))
- return rv
-
+ def __init__(self):
+ # First init menus, etc.
+ FrameWork.Application.__init__(self)
+ # Next create our dialog
+ self.main_dialog = MyDialog(self)
+ # Now open the dialog
+ contents = self.findcicnresources()
+ self.main_dialog.open(ID_MAIN, contents)
+ # Finally, go into the event loop
+ self.mainloop()
+
+ def makeusermenus(self):
+ self.filemenu = m = FrameWork.Menu(self.menubar, "File")
+ self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
+
+ def quit(self, *args):
+ self._quit()
+
+ def showCIcon(self, resid):
+ w = CIconwindow(self)
+ w.open(resid)
+ #EasyDialogs.Message('Show cicn %r' % (resid,))
+
+ def findcicnresources(self):
+ num = Res.CountResources('cicn')
+ rv = []
+ for i in range(1, num+1):
+ Res.SetResLoad(0)
+ try:
+ r = Res.GetIndResource('cicn', i)
+ finally:
+ Res.SetResLoad(1)
+ id, type, name = r.GetResInfo()
+ rv.append((id, name))
+ return rv
+
class CIconwindow(FrameWork.Window):
- def open(self, (resid, resname)):
- if not resname:
- resname = '#%r' % (resid,)
- self.resid = resid
- self.picture = Icn.GetCIcon(self.resid)
- l, t, r, b = 0, 0, 32, 32
- self.pictrect = (l, t, r, b)
- width = r-l
- height = b-t
- if width < MINWIDTH: width = MINWIDTH
- elif width > MAXWIDTH: width = MAXWIDTH
- if height < MINHEIGHT: height = MINHEIGHT
- elif height > MAXHEIGHT: height = MAXHEIGHT
- bounds = (LEFT, TOP, LEFT+width, TOP+height)
-
- self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
- self.do_postopen()
-
- def do_update(self, *args):
- currect = self.fitrect()
- Icn.PlotCIcon(currect, self.picture)
-
- def fitrect(self):
- """Return self.pictrect scaled to fit in window"""
- graf = self.wid.GetWindowPort()
- screenrect = graf.GetPortBounds()
- picwidth = self.pictrect[2] - self.pictrect[0]
- picheight = self.pictrect[3] - self.pictrect[1]
- if picwidth > screenrect[2] - screenrect[0]:
- factor = float(picwidth) / float(screenrect[2]-screenrect[0])
- picwidth = picwidth / factor
- picheight = picheight / factor
- if picheight > screenrect[3] - screenrect[1]:
- factor = float(picheight) / float(screenrect[3]-screenrect[1])
- picwidth = picwidth / factor
- picheight = picheight / factor
- return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
- screenrect[1]+int(picheight))
-
+ def open(self, (resid, resname)):
+ if not resname:
+ resname = '#%r' % (resid,)
+ self.resid = resid
+ self.picture = Icn.GetCIcon(self.resid)
+ l, t, r, b = 0, 0, 32, 32
+ self.pictrect = (l, t, r, b)
+ width = r-l
+ height = b-t
+ if width < MINWIDTH: width = MINWIDTH
+ elif width > MAXWIDTH: width = MAXWIDTH
+ if height < MINHEIGHT: height = MINHEIGHT
+ elif height > MAXHEIGHT: height = MAXHEIGHT
+ bounds = (LEFT, TOP, LEFT+width, TOP+height)
+
+ self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
+ self.do_postopen()
+
+ def do_update(self, *args):
+ currect = self.fitrect()
+ Icn.PlotCIcon(currect, self.picture)
+
+ def fitrect(self):
+ """Return self.pictrect scaled to fit in window"""
+ graf = self.wid.GetWindowPort()
+ screenrect = graf.GetPortBounds()
+ picwidth = self.pictrect[2] - self.pictrect[0]
+ picheight = self.pictrect[3] - self.pictrect[1]
+ if picwidth > screenrect[2] - screenrect[0]:
+ factor = float(picwidth) / float(screenrect[2]-screenrect[0])
+ picwidth = picwidth / factor
+ picheight = picheight / factor
+ if picheight > screenrect[3] - screenrect[1]:
+ factor = float(picheight) / float(screenrect[3]-screenrect[1])
+ picwidth = picwidth / factor
+ picheight = picheight / factor
+ return (screenrect[0], screenrect[1], screenrect[0]+int(picwidth),
+ screenrect[1]+int(picheight))
+
class MyDialog(FrameWork.DialogWindow):
- "Main dialog window for cicnbrowse"
-
- def open(self, id, contents):
- self.id = id
- FrameWork.DialogWindow.open(self, ID_MAIN)
- self.dlg.SetDialogDefaultItem(MAIN_SHOW)
- self.contents = contents
- self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
- h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
- Controls.kControlListBoxListHandleTag)
- self.list = List.as_List(h)
- self.setlist()
-
- def setlist(self):
- self.list.LDelRow(0, 0)
- self.list.LSetDrawingMode(0)
- if self.contents:
- self.list.LAddRow(len(self.contents), 0)
- for i in range(len(self.contents)):
- v = repr(self.contents[i][0])
- if self.contents[i][1]:
- v = v + '"' + self.contents[i][1] + '"'
- self.list.LSetCell(v, (0, i))
- self.list.LSetDrawingMode(1)
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def getselection(self):
- items = []
- point = (0,0)
- while 1:
- ok, point = self.list.LGetSelect(1, point)
- if not ok:
- break
- items.append(point[1])
- point = point[0], point[1]+1
- values = []
- for i in items:
- values.append(self.contents[i])
- return values
-
- def do_show(self, *args):
- selection = self.getselection()
- for resid in selection:
- self.parent.showCIcon(resid)
-
- def do_close(self):
- self.close()
-
- def do_itemhit(self, item, event):
- if item == MAIN_SHOW:
- self.do_show()
+ "Main dialog window for cicnbrowse"
+
+ def open(self, id, contents):
+ self.id = id
+ FrameWork.DialogWindow.open(self, ID_MAIN)
+ self.dlg.SetDialogDefaultItem(MAIN_SHOW)
+ self.contents = contents
+ self.ctl = self.dlg.GetDialogItemAsControl(MAIN_LIST)
+ h = self.ctl.GetControlData_Handle(Controls.kControlListBoxPart,
+ Controls.kControlListBoxListHandleTag)
+ self.list = List.as_List(h)
+ self.setlist()
+
+ def setlist(self):
+ self.list.LDelRow(0, 0)
+ self.list.LSetDrawingMode(0)
+ if self.contents:
+ self.list.LAddRow(len(self.contents), 0)
+ for i in range(len(self.contents)):
+ v = repr(self.contents[i][0])
+ if self.contents[i][1]:
+ v = v + '"' + self.contents[i][1] + '"'
+ self.list.LSetCell(v, (0, i))
+ self.list.LSetDrawingMode(1)
+ self.list.LUpdate(self.wid.GetWindowPort().visRgn)
+
+ def getselection(self):
+ items = []
+ point = (0,0)
+ while 1:
+ ok, point = self.list.LGetSelect(1, point)
+ if not ok:
+ break
+ items.append(point[1])
+ point = point[0], point[1]+1
+ values = []
+ for i in items:
+ values.append(self.contents[i])
+ return values
+
+ def do_show(self, *args):
+ selection = self.getselection()
+ for resid in selection:
+ self.parent.showCIcon(resid)
+
+ def do_close(self):
+ self.close()
+
+ def do_itemhit(self, item, event):
+ if item == MAIN_SHOW:
+ self.do_show()
main()
diff --git a/Mac/Demo/PICTbrowse/oldPICTbrowse.py b/Mac/Demo/PICTbrowse/oldPICTbrowse.py
index 5f5893c..8600bb2 100644
--- a/Mac/Demo/PICTbrowse/oldPICTbrowse.py
+++ b/Mac/Demo/PICTbrowse/oldPICTbrowse.py
@@ -21,139 +21,139 @@ LEFT=200
TOP=64
def main():
- macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc")
- PICTbrowse()
+ macresource.need('DLOG', ID_MAIN, "oldPICTbrowse.rsrc")
+ PICTbrowse()
class PICTbrowse(FrameWork.Application):
- def __init__(self):
- # First init menus, etc.
- FrameWork.Application.__init__(self)
- # Next create our dialog
- self.main_dialog = MyDialog(self)
- # Now open the dialog
- contents = self.findPICTresources()
- self.main_dialog.open(ID_MAIN, contents)
- # Finally, go into the event loop
- self.mainloop()
-
- def makeusermenus(self):
- self.filemenu = m = FrameWork.Menu(self.menubar, "File")
- self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
-
- def quit(self, *args):
- self._quit()
-
- def showPICT(self, resid):
- w = PICTwindow(self)
- w.open(resid)
- #EasyDialogs.Message('Show PICT %r' % (resid,))
-
- def findPICTresources(self):
- num = Res.CountResources('PICT')
- rv = []
- for i in range(1, num+1):
- Res.SetResLoad(0)
- try:
- r = Res.GetIndResource('PICT', i)
- finally:
- Res.SetResLoad(1)
- id, type, name = r.GetResInfo()
- rv.append((id, name))
- return rv
-
+ def __init__(self):
+ # First init menus, etc.
+ FrameWork.Application.__init__(self)
+ # Next create our dialog
+ self.main_dialog = MyDialog(self)
+ # Now open the dialog
+ contents = self.findPICTresources()
+ self.main_dialog.open(ID_MAIN, contents)
+ # Finally, go into the event loop
+ self.mainloop()
+
+ def makeusermenus(self):
+ self.filemenu = m = FrameWork.Menu(self.menubar, "File")
+ self.quititem = FrameWork.MenuItem(m, "Quit", "Q", self.quit)
+
+ def quit(self, *args):
+ self._quit()
+
+ def showPICT(self, resid):
+ w = PICTwindow(self)
+ w.open(resid)
+ #EasyDialogs.Message('Show PICT %r' % (resid,))
+
+ def findPICTresources(self):
+ num = Res.CountResources('PICT')
+ rv = []
+ for i in range(1, num+1):
+ Res.SetResLoad(0)
+ try:
+ r = Res.GetIndResource('PICT', i)
+ finally:
+ Res.SetResLoad(1)
+ id, type, name = r.GetResInfo()
+ rv.append((id, name))
+ return rv
+
class PICTwindow(FrameWork.Window):
- def open(self, (resid, resname)):
- if not resname:
- resname = '#%r' % (resid,)
- self.resid = resid
- picture = Qd.GetPicture(self.resid)
- # Get rect for picture
- print repr(picture.data[:16])
- sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
- print 'pict:', t, l, b, r
- width = r-l
- height = b-t
- if width < 64: width = 64
- elif width > 480: width = 480
- if height < 64: height = 64
- elif height > 320: height = 320
- bounds = (LEFT, TOP, LEFT+width, TOP+height)
- print 'bounds:', bounds
-
- self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
- self.wid.SetWindowPic(picture)
- self.do_postopen()
-
+ def open(self, (resid, resname)):
+ if not resname:
+ resname = '#%r' % (resid,)
+ self.resid = resid
+ picture = Qd.GetPicture(self.resid)
+ # Get rect for picture
+ print repr(picture.data[:16])
+ sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
+ print 'pict:', t, l, b, r
+ width = r-l
+ height = b-t
+ if width < 64: width = 64
+ elif width > 480: width = 480
+ if height < 64: height = 64
+ elif height > 320: height = 320
+ bounds = (LEFT, TOP, LEFT+width, TOP+height)
+ print 'bounds:', bounds
+
+ self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
+ self.wid.SetWindowPic(picture)
+ self.do_postopen()
+
class MyDialog(FrameWork.DialogWindow):
- "Main dialog window for PICTbrowse"
-
- def open(self, id, contents):
- self.id = id
- FrameWork.DialogWindow.open(self, ID_MAIN)
- self.dlg.SetDialogDefaultItem(MAIN_SHOW)
- tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
- rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space
- self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid,
- 0, 1, 1, 1)
- self.contents = contents
- self.setlist()
-
- def setlist(self):
- self.list.LDelRow(0, 0)
- self.list.LSetDrawingMode(0)
- if self.contents:
- self.list.LAddRow(len(self.contents), 0)
- for i in range(len(self.contents)):
- v = repr(self.contents[i][0])
- if self.contents[i][1]:
- v = v + '"' + self.contents[i][1] + '"'
- self.list.LSetCell(v, (0, i))
- self.list.LSetDrawingMode(1)
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def do_listhit(self, event):
- (what, message, when, where, modifiers) = event
- Qd.SetPort(self.wid)
- where = Qd.GlobalToLocal(where)
- print 'LISTHIT', where
- if self.list.LClick(where, modifiers):
- self.do_show()
-
- def getselection(self):
- items = []
- point = (0,0)
- while 1:
- ok, point = self.list.LGetSelect(1, point)
- if not ok:
- break
- items.append(point[1])
- point = point[0], point[1]+1
- values = []
- for i in items:
- values.append(self.contents[i])
- return values
-
- def do_show(self, *args):
- selection = self.getselection()
- for resid in selection:
- self.parent.showPICT(resid)
-
- def do_rawupdate(self, window, event):
- tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
- Qd.SetPort(self.wid)
- Qd.FrameRect(rect)
- self.list.LUpdate(self.wid.GetWindowPort().visRgn)
-
- def do_activate(self, activate, event):
- self.list.LActivate(activate)
-
- def do_close(self):
- self.close()
-
- def do_itemhit(self, item, event):
- if item == MAIN_LIST:
- self.do_listhit(event)
- if item == MAIN_SHOW:
- self.do_show()
+ "Main dialog window for PICTbrowse"
+
+ def open(self, id, contents):
+ self.id = id
+ FrameWork.DialogWindow.open(self, ID_MAIN)
+ self.dlg.SetDialogDefaultItem(MAIN_SHOW)
+ tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
+ rect2 = rect[0]+1, rect[1]+1, rect[2]-17, rect[3]-17 # Scroll bar space
+ self.list = List.LNew(rect2, (0, 0, 1, len(contents)), (0,0), 0, self.wid,
+ 0, 1, 1, 1)
+ self.contents = contents
+ self.setlist()
+
+ def setlist(self):
+ self.list.LDelRow(0, 0)
+ self.list.LSetDrawingMode(0)
+ if self.contents:
+ self.list.LAddRow(len(self.contents), 0)
+ for i in range(len(self.contents)):
+ v = repr(self.contents[i][0])
+ if self.contents[i][1]:
+ v = v + '"' + self.contents[i][1] + '"'
+ self.list.LSetCell(v, (0, i))
+ self.list.LSetDrawingMode(1)
+ self.list.LUpdate(self.wid.GetWindowPort().visRgn)
+
+ def do_listhit(self, event):
+ (what, message, when, where, modifiers) = event
+ Qd.SetPort(self.wid)
+ where = Qd.GlobalToLocal(where)
+ print 'LISTHIT', where
+ if self.list.LClick(where, modifiers):
+ self.do_show()
+
+ def getselection(self):
+ items = []
+ point = (0,0)
+ while 1:
+ ok, point = self.list.LGetSelect(1, point)
+ if not ok:
+ break
+ items.append(point[1])
+ point = point[0], point[1]+1
+ values = []
+ for i in items:
+ values.append(self.contents[i])
+ return values
+
+ def do_show(self, *args):
+ selection = self.getselection()
+ for resid in selection:
+ self.parent.showPICT(resid)
+
+ def do_rawupdate(self, window, event):
+ tp, h, rect = self.dlg.GetDialogItem(MAIN_LIST)
+ Qd.SetPort(self.wid)
+ Qd.FrameRect(rect)
+ self.list.LUpdate(self.wid.GetWindowPort().visRgn)
+
+ def do_activate(self, activate, event):
+ self.list.LActivate(activate)
+
+ def do_close(self):
+ self.close()
+
+ def do_itemhit(self, item, event):
+ if item == MAIN_LIST:
+ self.do_listhit(event)
+ if item == MAIN_SHOW:
+ self.do_show()
main()