def open(self): self.menu = menu = FrameWork.Menu(self._parentwindow.parent.menubar, 'Foo', -1) for i in range(len(self._items)): item = self._items[i] if type(item) == StringType: menuitemtext = object = item elif type(item) == TupleType and len(item) == 2: menuitemtext, object = item self._items[i] = object else: raise Wbase.WidgetsError, "illegal itemlist for popup menu" menuitem = FrameWork.MenuItem(menu, menuitemtext, None, None) self._calcbounds() self._control = Ctl.NewControl(self._parentwindow.wid, self._bounds, self._title, 1, self._value, self.menu.id, self._max, self._procID, 0) self.SetPort() self.enable(self._enabled)
def _createscrollbars(self, reset=0): # # See if we need them. # if self.bary: self.bary.DisposeControl() if self.controlhandler: self.controlhandler._del_control(self.bary) self.bary = None l, t, r, b = self.rect if reset: self.ted.WECalText() self.ted.WESelView() vr = self.ted.WEGetViewRect() dr = self.ted.WEGetDestRect() need_bary = ((dr[3] - dr[1]) >= (vr[3] - vr[1])) if need_bary: vr = l + LEFTMARGIN, t + TOPMARGIN, r - ( RIGHTMARGIN + SCROLLBARWIDTH - 1), b - BOTTOMMARGIN dr = dr[0], dr[1], dr[0] + vr[2] - vr[0], dr[3] self.ted.WESetViewRect(vr) self.ted.WESetDestRect(dr) self.ted.WECalText() vr = self.ted.WEGetViewRect() dr = self.ted.WEGetDestRect() rect = r - (SCROLLBARWIDTH - 1), t - 1, r + 1, b + 1 vy = self._getybarvalue() self.bary = Ctl.NewControl(self.wid, rect, "", 1, vy, 0, dr[3] - dr[1] - (vr[3] - vr[1]), 16, 0) if not self.activated: self.bary.DeactivateControl() self._updatedocview() if self.controlhandler: self.controlhandler._add_control(self.bary, self._scrollbarcallback, self._scrollbarcallback) else: vr = l + LEFTMARGIN, t + TOPMARGIN, r - RIGHTMARGIN, b - BOTTOMMARGIN dr = dr[0], dr[1], dr[0] + vr[2] - vr[0], dr[3] self.ted.WESetViewRect(vr) self.ted.WESetDestRect(dr) self.ted.WECalText() self.ted.WEScroll(vr[0] - dr[0], vr[1] - dr[1]) # Test....
def open(self): self._calcbounds() # NewControl doesn't accept 32-bit value, min, or max, so for consistency # with the new 32-bit set/get methods, out-of-range values are initially # set as zero, followed by a 32-bit set of the actual value. # Values not representable in 16 bits will fail on MacOS 8.1, however # the vast majority of control usage should still be compatible. _value, _min, _max = self._value, self._min, self._max if -32768 <= _value <= 32767: bigvalue = None else: bigvalue = _value _value = 0 if -32768 <= _min <= 32767: bigmin = None else: bigmin = _min _min = 0 if -32768 <= _max <= 32767: bigmax = None else: bigmax = _max _max = 0 self._control = Ctl.NewControl(self._parentwindow.wid, self._bounds, self._title, 1, _value, _min, _max, self._procID, 0) if bigvalue: self._control.SetControl32BitValue(bigvalue) if bigmin: self._control.SetControl32BitMinimum(bigmin) if bigmax: self._control.SetControl32BitMaximum(bigmax) if self._viewsize: try: self._control.SetControlViewSize(self._viewsize) # Not available in MacOS 8.1, but that's OK since it only affects # proportional scrollbars which weren't available in 8.1 either. except NotImplementedError: pass self.enable(self._enabled)