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 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): 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): 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 getMinSize(self): w, h = opengl.glGetStringSize("VALUES") return w + 10, h + 4
def getMinSize(self): w, h = opengl.glGetStringSize(self._label) return w + 10, h + 4