Esempio n. 1
0
"""MovieInWindow converted to python
Esempio n. 2
0
 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)
Esempio n. 3
0
# Test TE module, simple version
from Carbon.Win import *
from Carbon.TE import *
from Carbon import Qd
r = (40, 40, 140, 140)
w = NewWindow(r, "TETextBox test", 1, 0, -1, 1, 0x55555555)
##w.DrawGrowIcon()
r = (10, 10, 90, 90)
Qd.SetPort(w)
t = TETextBox("Nobody expects the SPANISH inquisition", r, 1)
import time
time.sleep(10)
Esempio n. 4
0
 def draw(self, visRgn=None):
     if self._visible:
         Qd.PaintRect(self._bounds)
Esempio n. 5
0
def SetCursor(what):
    """Set the cursorshape to any of these: 'arrow', 'cross', 'fist', 'hand', 'hmover', 'iBeam',
    'plus', 'vmover', 'watch', 'zoom', 'zoomin', 'zoomout'."""
    Qd.SetCursor(_cursors[what])
Esempio n. 6
0
"""PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque
Esempio n. 7
0
 def test(self, point):
     if Qd.PtInRect(point, self._bounds):
         return 1
Esempio n. 8
0
from Carbon.Menu import DrawMenuBar
from FrameWork import *
from Carbon import Win
from Carbon import Qd
from Carbon import Res
import waste
import WASTEconst
from Carbon import Scrap
import os
import EasyDialogs

UNDOLABELS = [  # Indexed by WEGetUndoInfo() value
    None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"
]

BIGREGION = Qd.NewRgn()
Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000)


class WasteWindow(ScrolledWindow):
    def open(self, path, name, data):
        self.path = path
        self.name = name
        r = windowbounds(400, 400)
        w = Win.NewWindow(r, name, 1, 0, -1, 1, 0)
        self.wid = w
        vr = 0, 0, r[2] - r[0] - 15, r[3] - r[1] - 15
        dr = (0, 0, 10240, 0)
        Qd.SetPort(w)
        Qd.TextFont(4)
        Qd.TextSize(9)
Esempio n. 9
0
 def idle(self, event):
     if self.active:
         self.active.do_idle(event)
     else:
         Qd.SetCursor(Qd.GetQDGlobalsArrow())
Esempio n. 10
0
 def PixMap(self):
     "Return a QuickDraw PixMap corresponding to this data."
     if not self.__dict__['_pm']:
         self.__dict__['_pm'] = Qd.RawBitMap(self._header)
     return self.__dict__['_pm']
Esempio n. 11
0
# Video file reader, using QuickTime
Esempio n. 12
0
 def do_update(self, wid, event):
     Qd.EraseRect(wid.GetWindowPort().GetPortBounds())
     self.ted.TEUpdate(wid.GetWindowPort().GetPortBounds())
     self.updatescrollbars()
Esempio n. 13
0
 def idle(self, *args):
     if self.active:
         self.active.do_idle()
     else:
         Qd.SetCursor(Qd.GetQDGlobalsArrow())
Esempio n. 14
0
# Test List module.
Esempio n. 15
0
 def do_listhit(self, event):
     (what, message, when, where, modifiers) = event
     Qd.SetPort(self.wid)
     where = Qd.GlobalToLocal(where)
     if self.list.LClick(where, modifiers):
         self.do_dclick(self.delgetselection())
    d.AutoSizeDialog()
    d.GetDialogWindow().ShowWindow()
    while 1:
        n = ModalDialog(None)
        if n == 1: return default
        if n == 2: return 1
        if n == 3: return 0
        if n == 4: return -1


# The deprecated Carbon QuickDraw APIs are no longer available as of
# OS X 10.8.  Raise an ImportError here in that case so that callers
# of EasyDialogs, like BuildApplet, will do the right thing.

try:
    screenbounds = Qd.GetQDGlobalsScreenBits().bounds
except AttributeError:
    raise ImportError("QuickDraw APIs not available")

screenbounds = screenbounds[0]+4, screenbounds[1]+4, \
    screenbounds[2]-4, screenbounds[3]-4

kControlProgressBarIndeterminateTag = 'inde'  # from Controls.py


class ProgressBar:
    def __init__(self, title="Working...", maxval=0, label="", id=263):
        self.w = None
        self.d = None
        _initialize()
        self.d = GetNewDialog(id, -1)
Esempio n. 17
0
 def do_rawupdate(self, window, event):
     Qd.SetPort(window)
     Qd.FrameRect(self.listrect)
     self.list.LUpdate(self.wid.GetWindowPort().visRgn)
Esempio n. 18
0
 def do_update(self, *args):
     currect = self.fitrect()
     Qd.DrawPicture(self.picture, currect)
Esempio n. 19
0
'''
Esempio n. 20
0
"""PythonSlave.py
Esempio n. 21
0
 def _drawbounds(self):
     Qd.FrameRect(self._bounds)
Esempio n. 22
0
"""imgbrowse - Display pictures using img"""
Esempio n. 23
0
    def click(self, point, modifiers):
        # what a mess...
        orgmouse = point[self._direction]
        halfgutter = self._gutter / 2
        l, t, r, b = self._bounds
        if self._direction:
            begin, end = t, b
        else:
            begin, end = l, r

        i = self.findgutter(orgmouse, begin, end)
        if i is None:
            return

        pos = orgpos = begin + (end - begin) * self._gutters[
            i]  # init pos too, for fast click on border, bug done by Petr

        minpos = self._panesizes[i][0]
        maxpos = self._panesizes[i + 1][1]
        minpos = begin + (end - begin) * minpos + 64
        maxpos = begin + (end - begin) * maxpos - 64
        if minpos > orgpos and maxpos < orgpos:
            return

        #SetCursor("fist")
        self.SetPort()
        if self._direction:
            rect = l, orgpos - 1, r, orgpos
        else:
            rect = orgpos - 1, t, orgpos, b

        # track mouse --- XXX  move to separate method?
        Qd.PenMode(QuickDraw.srcXor)
        Qd.PenPat(Qd.GetQDGlobalsGray())
        Qd.PaintRect(_intRect(rect))
        lastpos = None
        while Evt.Button():
            pos = orgpos - orgmouse + Evt.GetMouse()[self._direction]
            pos = max(pos, minpos)
            pos = min(pos, maxpos)
            if pos == lastpos:
                continue
            Qd.PenPat(Qd.GetQDGlobalsGray())
            Qd.PaintRect(_intRect(rect))
            if self._direction:
                rect = l, pos - 1, r, pos
            else:
                rect = pos - 1, t, pos, b
            Qd.PenPat(Qd.GetQDGlobalsGray())
            Qd.PaintRect(_intRect(rect))
            lastpos = pos
            self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None)
            Evt.WaitNextEvent(0, 3)
        Qd.PaintRect(_intRect(rect))
        Qd.PenNormal()
        SetCursor("watch")

        newpos = (pos - begin) / float(end - begin)
        self._gutters[i] = newpos
        self._panesizes[i] = self._panesizes[i][0], newpos
        self._panesizes[i + 1] = newpos, self._panesizes[i + 1][1]
        self.makepanebounds()
        self.installbounds()
        self._calcbounds()
Esempio n. 24
0
def main():
    print 'hello world'  # XXXX
    # skip the toolbox initializations, already done
    # XXXX Should use gestalt here to check for quicktime version
    Qt.EnterMovies()

    # Get the movie file
    fss = EasyDialogs.AskFileForOpen(
        wanted=File.FSSpec)  # Was: QuickTime.MovieFileType
    if not fss:
        sys.exit(0)

    # Open the window
    bounds = (175, 75, 175 + 160, 75 + 120)
    theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0)
    # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
    Qd.SetPort(theWindow)

    # Get the movie
    theMovie = loadMovie(fss)

    # Relocate to (0, 0)
    bounds = theMovie.GetMovieBox()
    bounds = 0, 0, bounds[2] - bounds[0], bounds[3] - bounds[1]
    theMovie.SetMovieBox(bounds)

    # Create a controller
    theController = theMovie.NewMovieController(bounds,
                                                QuickTime.mcTopLeftMovie)

    # Get movie size and update window parameters
    rv, bounds = theController.MCGetControllerBoundsRect()
    theWindow.SizeWindow(bounds[2], bounds[3], 0)  # XXXX or [3] [2]?
    Qt.AlignWindow(theWindow, 0)
    theWindow.ShowWindow()

    # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds)
    theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1')

    # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow)

    done = 0
    while not done:
        gotone, evt = Evt.WaitNextEvent(0xffff, 0)
        (what, message, when, where, modifiers) = evt
        ##              print what, message, when, where, modifiers # XXXX

        if theController.MCIsPlayerEvent(evt):
            continue

        if what == Events.mouseDown:
            part, whichWindow = Win.FindWindow(where)
            if part == Windows.inGoAway:
                done = whichWindow.TrackGoAway(where)
            elif part == Windows.inDrag:
                Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000))
        elif what == Events.updateEvt:
            whichWindow = Win.WhichWindow(message)
            if not whichWindow:
                # Probably the console window. Print something, hope it helps.
                print 'update'
            else:
                Qd.SetPort(whichWindow)
                whichWindow.BeginUpdate()
                Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds())
                whichWindow.EndUpdate()
Esempio n. 25
0
# A minimal text editor.
Esempio n. 26
0
    return finfo <> curfinfo


def _savefontinfo(port):
    """Return all font-pertaining info for a macos window"""
    if not port:
        return ()
    return port.GetPortTextFont(), port.GetPortTextFace(), port.GetPortTextMode(), \
            port.GetPortTextSize(), port.GetPortSpExtra()


def _restorefontinfo(port, (font, face, mode, size, spextra)):
    """Set all font-pertaining info for a macos window"""
    if not port:
        return
    old = Qd.GetPort()
    Qd.SetPort(port)
    Qd.TextFont(font)
    Qd.TextFace(face)
    Qd.TextMode(mode)
    Qd.TextSize(size)
    Qd.SpaceExtra(spextra)
    Qd.SetPort(old)


_pt2mm = 25.4 / 72  # 1 inch == 72 points == 25.4 mm
_POINTSIZEOFFSET = +1
_fontmap = {
    ##       'Times-Roman': ('Times', 0),
    ##       'Times-Italic': ('Times', _qd_italic),
    ##       'Times-Bold': ('Times', _qd_bold),
Esempio n. 27
0
"""VerySimplePlayer converted to python
Esempio n. 28
0
from Carbon.Menu import DrawMenuBar
from FrameWork import *
from Carbon import Win
from Carbon import Qd
from Carbon import Res
from Carbon import Fm
import waste
import WASTEconst
from Carbon import Scrap
import os
import EasyDialogs
import macfs
import string
import htmllib

WATCH = Qd.GetCursor(4).data

LEFTMARGIN = 0

UNDOLABELS = [  # Indexed by WEGetUndoInfo() value
    None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"
]

# Style and size menu. Note that style order is important (tied to bit values)
STYLES = [("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"),
          ("Shadow", ""), ("Condensed", ""), ("Extended", "")]
SIZES = [9, 10, 12, 14, 18, 24]

# Sizes for HTML tag types
HTML_SIZE = {'h1': 18, 'h2': 14}