def draw(self): x, y, w, h = self.getSize() glPushMatrix() glTranslatef(x, y, 0) if self.hasFocus(): glColor4ub(255,255,255,255) else: glColor4ub(255,255,255,192) glBegin(GL_QUADS) glTexCoord2f(1, 0) glVertex2f( w, 0) glTexCoord2f(0, 0) glVertex2f( 0, 0) glTexCoord2f(0, 1) glVertex2f( 0, h-1) glTexCoord2f(1, 1) glVertex2f( w, h-1) glEnd() glTranslate(5, h - 5, 0) glColor4ub(0,0,0,255) opengl.glDrawStringLeft(self._value) if self.hasFocus(): glTranslate(opengl.glGetStringSize(self._value[0:self._selectPos])[0] - 2, -1, 0) opengl.glDrawStringLeft('|') glPopMatrix()
def draw(self): x, y, w, h = self.getSize() glPushMatrix() glTranslatef(x, y, 0) if self.hasFocus(): glColor4ub(255,255,255,255) else: glColor4ub(255,255,255,192) glBegin(GL_QUADS) glTexCoord2f(1, 0) glVertex2f( w, 0) glTexCoord2f(0, 0) glVertex2f( 0, 0) glTexCoord2f(0, 1) glVertex2f( 0, h) glTexCoord2f(1, 1) glVertex2f( w, h) glEnd() glTranslate(5, h - 5, 0) glColor4ub(0,0,0,255) opengl.glDrawStringLeft(self._value) if self.hasFocus(): glTranslate(opengl.glGetStringSize(self._value[0:self._selectPos])[0] - 2, -1, 0) opengl.glDrawStringLeft('|') glPopMatrix()
def _OnGuiPaint(self, e): self._idleCalled = False h = self.GetSize().GetHeight() w = self.GetSize().GetWidth() oldButtonSize = self._buttonSize if h / 3 < w / 4: w = h * 4 / 3 if w < 64 * 8: self._buttonSize = 32 elif w < 64 * 10: self._buttonSize = 48 elif w < 64 * 15: self._buttonSize = 64 elif w < 64 * 20: self._buttonSize = 80 else: self._buttonSize = 96 if self._buttonSize != oldButtonSize: self._container.updateLayout() dc = wx.PaintDC(self) try: self.SetCurrent(self._context) for obj in self.glReleaseList: obj.release() del self.glReleaseList[:] renderStartTime = time.time() self.OnPaint(e) self._drawGui() glFlush() if version.isDevVersion(): renderTime = time.time() - renderStartTime if renderTime == 0: renderTime = 0.001 glLoadIdentity() glTranslate(10, self.GetSize().GetHeight() - 30, -1) glColor4f(0.2, 0.2, 0.2, 0.5) opengl.glDrawStringLeft("fps:%d" % (1 / renderTime)) self.SwapBuffers() except: errStr = _("An error has occurred during the 3D view drawing.") tb = traceback.extract_tb(sys.exc_info()[2]) errStr += "\n%s: '%s'" % (str( sys.exc_info()[0].__name__), str(sys.exc_info()[1])) for n in xrange(len(tb) - 1, -1, -1): locationInfo = tb[n] errStr += "\n @ %s:%s:%d" % (os.path.basename( locationInfo[0]), locationInfo[2], locationInfo[1]) if not self._shownError: wx.CallAfter(wx.MessageBox, errStr, _("3D window error"), wx.OK | wx.ICON_EXCLAMATION) self._shownError = True
def draw(self): if self._hidden: return w, h = self.getMinSize() pos = self._getPixelPos() glPushMatrix() glTranslatef(pos[0], pos[1], 0) glDisable(GL_TEXTURE_2D) if self.hasFocus(): glColor4ub(60, 60, 60, 255) else: glColor4ub(60, 60, 60, 192) glBegin(GL_QUADS) glVertex2f(w / 2, -h / 2) glVertex2f(-w / 2, -h / 2) glVertex2f(-w / 2, h / 2) glVertex2f(w / 2, h / 2) glEnd() scrollLength = h - w glTranslate(0.0, scrollLength / 2, 0) if self._focus: glColor4ub(0, 0, 0, 255) glPushMatrix() glTranslate(-w / 2, opengl.glGetStringSize(str(self._minValue))[1] / 2, 0) opengl.glDrawStringRight(str(self._minValue)) glTranslate(0, -scrollLength, 0) opengl.glDrawStringRight(str(self._maxValue)) if self._maxValue - self._minValue > 0: glTranslate( w, scrollLength - scrollLength * ((self._value - self._minValue) / (self._maxValue - self._minValue)), 0) opengl.glDrawStringLeft(str(self._value)) glPopMatrix() glColor4ub(255, 255, 255, 240) if self._maxValue - self._minValue != 0: glTranslate( 0.0, -scrollLength * ((self._value - self._minValue) / (self._maxValue - self._minValue)), 0) glBegin(GL_QUADS) glVertex2f(w / 2, -w / 2) glVertex2f(-w / 2, -w / 2) glVertex2f(-w / 2, w / 2) glVertex2f(w / 2, w / 2) glEnd() glPopMatrix()
def _OnGuiPaint(self, e): self._idleCalled = False h = self.GetSize().GetHeight() w = self.GetSize().GetWidth() oldButtonSize = self._buttonSize if h / 3 < w / 4: w = h * 4 / 3 if w < 64 * 8: self._buttonSize = 32 elif w < 64 * 10: self._buttonSize = 48 elif w < 64 * 15: self._buttonSize = 64 elif w < 64 * 20: self._buttonSize = 80 else: self._buttonSize = 96 if self._buttonSize != oldButtonSize: self._container.updateLayout() dc = wx.PaintDC(self) try: self.SetCurrent(self._context) for obj in self.glReleaseList: obj.release() del self.glReleaseList[:] renderStartTime = time.time() self.OnPaint(e) self._drawGui() glFlush() if version.isDevVersion(): renderTime = time.time() - renderStartTime if renderTime == 0: renderTime = 0.001 glLoadIdentity() glTranslate(10, self.GetSize().GetHeight() - 30, -1) glColor4f(0.2,0.2,0.2,0.5) opengl.glDrawStringLeft("fps:%d" % (1 / renderTime)) self.SwapBuffers() except: errStr = _("An error has occurred during the 3D view drawing.") tb = traceback.extract_tb(sys.exc_info()[2]) errStr += "\n%s: '%s'" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1])) for n in xrange(len(tb)-1, -1, -1): locationInfo = tb[n] errStr += "\n @ %s:%s:%d" % (os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1]) if not self._shownError: wx.CallAfter(wx.MessageBox, errStr, _("3D window error"), wx.OK | wx.ICON_EXCLAMATION) self._shownError = True
def draw(self): if self._hidden: return w, h = self.getMinSize() pos = self._getPixelPos() glPushMatrix() glTranslatef(pos[0], pos[1], 0) glDisable(GL_TEXTURE_2D) if self.hasFocus(): glColor4ub(60, 60, 60, 255) else: glColor4ub(60, 60, 60, 192) glBegin(GL_QUADS) glVertex2f(w / 2, -h / 2) glVertex2f(-w / 2, -h / 2) glVertex2f(-w / 2, h / 2) glVertex2f(w / 2, h / 2) glEnd() scrollLength = h - w glTranslate(0.0, scrollLength / 2, 0) if self._focus: glColor4ub(0, 0, 0, 255) glPushMatrix() glTranslate(-w / 2, opengl.glGetStringSize(str(self._minValue))[1] / 2, 0) opengl.glDrawStringRight(str(self._minValue)) glTranslate(0, -scrollLength, 0) opengl.glDrawStringRight(str(self._maxValue)) if self._maxValue - self._minValue > 0: glTranslate( w, scrollLength - scrollLength * ((self._value - self._minValue) / (self._maxValue - self._minValue)), 0, ) opengl.glDrawStringLeft(str(self._value)) glPopMatrix() glColor4ub(255, 255, 255, 240) if self._maxValue - self._minValue != 0: glTranslate(0.0, -scrollLength * ((self._value - self._minValue) / (self._maxValue - self._minValue)), 0) glBegin(GL_QUADS) glVertex2f(w / 2, -w / 2) glVertex2f(-w / 2, -w / 2) glVertex2f(-w / 2, w / 2) glVertex2f(w / 2, w / 2) glEnd() glPopMatrix()
def draw(self): x, y, w, h = self.getSize() glPushMatrix() glTranslatef(x, y, 0) glColor4ub(255,255,255,128) glBegin(GL_QUADS) glTexCoord2f(1, 0) glVertex2f( w, 0) glTexCoord2f(0, 0) glVertex2f( 0, 0) glTexCoord2f(0, 1) glVertex2f( 0, h) glTexCoord2f(1, 1) glVertex2f( w, h) glEnd() glTranslate(5, h - 5, 0) glColor4ub(0,0,0,255) opengl.glDrawStringLeft(self._label) glPopMatrix()
def draw(self): x, y, w, h = self.getSize() glPushMatrix() glTranslatef(x, y, 0) # glColor4ub(255,255,255,128) # glBegin(GL_QUADS) # glTexCoord2f(1, 0) # glVertex2f( w, 0) # glTexCoord2f(0, 0) # glVertex2f( 0, 0) # glTexCoord2f(0, 1) # glVertex2f( 0, h) # glTexCoord2f(1, 1) # glVertex2f( w, h) # glEnd() glTranslate(5, h - 5, 0) glColor4ub(255,255,255,255) opengl.glDrawStringLeft(self._label) glPopMatrix()
def draw(self): if self._hidden: return cx = (self._imageID % 4) / 4 cy = int(self._imageID / 4) / 4 bs = self.getMinSize()[0] pos = self._getPixelPos() glBindTexture(GL_TEXTURE_2D, self._base._glButtonsTexture) scale = 0.8 if self._selected: scale = 1.0 elif self._focus: scale = 0.9 if self._disabled: glColor4ub(128,128,128,128) else: glColor4ub(255,255,255,255) opengl.glDrawTexturedQuad(pos[0]-bs*scale/2, pos[1]-bs*scale/2, bs*scale, bs*scale, 0) opengl.glDrawTexturedQuad(pos[0]-bs*scale/2, pos[1]-bs*scale/2, bs*scale, bs*scale, self._imageID) if self._showExpandArrow: if self._selected: opengl.glDrawTexturedQuad(pos[0]+bs*scale/2-bs*scale/4*1.2, pos[1]-bs*scale/2*1.2, bs*scale/4, bs*scale/4, 1) else: opengl.glDrawTexturedQuad(pos[0]+bs*scale/2-bs*scale/4*1.2, pos[1]-bs*scale/2*1.2, bs*scale/4, bs*scale/4, 1, 2) glPushMatrix() glTranslatef(pos[0], pos[1], 0) glDisable(GL_TEXTURE_2D) if self._focus: glTranslatef(0, -0.55*bs*scale, 0) glPushMatrix() glColor4ub(60,60,60,255) glTranslatef(-1, -1, 0) opengl.glDrawStringCenter(self._tooltip) glTranslatef(0, 2, 0) opengl.glDrawStringCenter(self._tooltip) glTranslatef(2, 0, 0) opengl.glDrawStringCenter(self._tooltip) glTranslatef(0, -2, 0) opengl.glDrawStringCenter(self._tooltip) glPopMatrix() glColor4ub(255,255,255,255) opengl.glDrawStringCenter(self._tooltip) glPopMatrix() progress = self._progressBar if progress is not None: glColor4ub(60,60,60,255) opengl.glDrawQuad(pos[0]-bs/2, pos[1]+bs/2, bs, bs / 4) glColor4ub(255,255,255,255) opengl.glDrawQuad(pos[0]-bs/2+2, pos[1]+bs/2+2, (bs - 5) * progress + 1, bs / 4 - 4) elif len(self._altTooltip) > 0: glPushMatrix() glTranslatef(pos[0], pos[1], 0) glTranslatef(0.6*bs*scale, 0, 0) glPushMatrix() glColor4ub(60,60,60,255) glTranslatef(-1, -1, 0) opengl.glDrawStringLeft(self._altTooltip) glTranslatef(0, 2, 0) opengl.glDrawStringLeft(self._altTooltip) glTranslatef(2, 0, 0) opengl.glDrawStringLeft(self._altTooltip) glTranslatef(0, -2, 0) opengl.glDrawStringLeft(self._altTooltip) glPopMatrix() glColor4ub(255,255,255,255) opengl.glDrawStringLeft(self._altTooltip) glPopMatrix()