Changeset 3830:515e89090fcf in orange


Ignore:
Timestamp:
05/06/08 14:45:42 (6 years ago)
Author:
gregor <gregor@…>
Branch:
default
Convert:
37211afdd5a343c167c757e6ec552823c34d10a9
Message:
  • changed the looks, ...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeCanvas/orngCanvasItems.py

    r3816 r3830  
    88ERROR = 0 
    99WARNING = 1 
    10  
    11 widgetWidth = 68 
    12 widgetHeight = 68 
    13  
    1410 
    1511class TempCanvasLine(QGraphicsLineItem): 
     
    123119 
    124120 
     121IOBoxWidth = 11 
     122IOBoxHeight = 22 
     123WidgetIconHeight = 48 
     124WidgetIconWidth = 48 
     125WidgetWidth = WidgetIconWidth + 2*IOBoxWidth + 2 
     126WidgetHeight = WidgetIconHeight + 2 + 14 
     127RectWidth = 3 
     128 
    125129 
    126130# ####################################### 
     
    150154        self.image = QPixmap(widget.getFullIconName()) 
    151155 
    152         self.imageEdge = None 
    153         if os.path.exists(os.path.join(canvasDlg.picsDir,"WidgetEdge.png")): 
    154             self.imageEdge = QPixmap(os.path.join(canvasDlg.picsDir,"WidgetEdge.png")) 
    155  
    156         self.setRect(0,0, widgetWidth, widgetHeight) 
     156        self.imageLeftEdge = QPixmap(os.path.join(canvasDlg.picsDir,"leftEdge.png")) 
     157        self.imageRightEdge = QPixmap(os.path.join(canvasDlg.picsDir,"rightEdge.png")) 
     158 
     159        self.setRect(0,0, WidgetWidth, WidgetHeight) 
    157160        self.selected = False 
    158161        self.invalidPosition = False    # is the widget positioned over other widgets 
     
    213216        if (self.instance != None): 
    214217            if self.canvasDlg.menuSaveSettings == 1:        # save settings only if checked in the main menu 
    215                 try:     
     218                try: 
    216219                    self.instance.saveSettings() 
    217                 except:  
     220                except: 
    218221                    print "Unable to successfully save settings for %s widget" % (self.instance.captionTitle) 
    219222                    type, val, traceback = sys.exc_info() 
     
    243246        self.errorIcon.hide() 
    244247 
    245         yPos = self.y() - 27 - self.progressBarShown * 20 
     248        yPos = self.y() - 18 - self.progressBarShown * 23 
    246249        iconNum = sum([widgetState.get("Info", {}).values() != [],  widgetState.get("Warning", {}).values() != [], widgetState.get("Error", {}).values() != []]) 
    247250 
    248251        if self.canvasDlg.settings["ocShow"]:        # if show icons is enabled in canvas options dialog 
    249             startX = self.x() + (self.rect().width()/2) - (iconNum*self.canvasDlg.widgetIcons["Info"].width()/2) 
     252            startX = self.x() + (self.rect().width()/2) - ((iconNum*(self.canvasDlg.widgetIcons["Info"].width()+2))/2) 
    250253            off  = 0 
    251254            if len(widgetState.get("Info", {}).values()) > 0 and self.canvasDlg.settings["ocInfo"]: 
     
    261264        icon.show() 
    262265        icon.setToolTip(reduce(lambda x,y: x+'<br>'+y, stateDict.values())) 
    263         return icon.pixmap().width() 
     266        return icon.pixmap().width() + 3 
    264267 
    265268    def isSelected(self): 
     
    293296        if self.widget.getInputs() == []: return False 
    294297 
    295         LBox = QRectF(self.x(), self.y()+18,8,16) 
     298        LBox = QRectF(self.x(), self.y()+ (WidgetIconHeight-IOBoxHeight)/2 + RectWidth, IOBoxWidth, IOBoxHeight) 
    296299        if isinstance(pos, QPointF) and LBox.contains(pos): return True 
    297300        elif isinstance(pos, QRectF) and LBox.intersects(pos): return True 
     
    302305        if self.widget.getOutputs() == []: return False 
    303306 
    304         RBox = QRectF(self.x() + 60, self.y()+18,8,16) 
     307        RBox = QRectF(self.x() + IOBoxWidth + WidgetIconWidth + 2, self.y()+ (WidgetIconHeight-IOBoxHeight)/2 + RectWidth, IOBoxWidth, IOBoxHeight) 
    305308        if isinstance(pos, QPointF) and RBox.contains(pos): return True 
    306309        elif isinstance(pos, QRectF) and RBox.intersects(pos): return True 
     
    312315    def getEdgePoint(self, pos): 
    313316        if self.mouseInsideLeftChannel(pos): 
    314             return QPoint(self.x(), self.y() + 26) 
     317            return QPoint(self.x() + IOBoxWidth/2, self.y() + WidgetIconHeight/2 + RectWidth) 
    315318        elif self.mouseInsideRightChannel(pos): 
    316             return QPoint(self.x()+ 68, self.y() + 26) 
     319            return QPoint(self.x()+ IOBoxWidth + WidgetIconWidth + 2 + IOBoxWidth/2, self.y() + WidgetIconHeight/2 + RectWidth) 
    317320 
    318321 
    319322    def getLeftEdgePoint(self): 
    320         return QPoint(self.x(), self.y() + 26) 
     323        return QPoint(self.x(), self.y() + WidgetIconHeight/2 + RectWidth) 
    321324 
    322325    def getRightEdgePoint(self): 
    323         return QPoint(self.x()+ 68, self.y() + 26) 
     326        return QPoint(self.x()+ IOBoxWidth + WidgetIconWidth + 2 + IOBoxWidth/2, self.y() + WidgetIconHeight/2 + RectWidth) 
    324327 
    325328    # draw the widget 
    326329    def paint(self, painter, option, widget = None): 
    327330        if self.isProcessing: 
    328             painter.setPen(QPen(self.canvasDlg.widgetActiveColor)) 
    329             painter.setBrush(QBrush(self.canvasDlg.widgetActiveColor)) 
    330             #painter.drawRect(8, 0, 52, 52) 
    331             painter.drawRect(7, 0, 54, 54) 
     331            color = self.canvasDlg.widgetActiveColor 
    332332        elif self.selected: 
    333333            if self.invalidPosition: color = Qt.red 
    334334            else:                    color = self.canvasDlg.widgetSelectedColor 
     335 
     336        if self.isProcessing or self.selected: 
    335337            painter.setPen(QPen(color)) 
    336338            painter.setBrush(QBrush(color)) 
    337             painter.drawRect(7, 0, 54, 54) 
    338  
    339         painter.drawPixmap(2+8, 3, self.image) 
    340  
    341         if self.imageEdge != None: 
    342             if self.widget.getInputs() != []:    painter.drawPixmap(0, 18, self.imageEdge) 
    343             if self.widget.getOutputs() != []:   painter.drawPixmap(widgetWidth-8, 18, self.imageEdge) 
    344         else: 
    345             painter.setBrush(QBrush(QColor(0,0,255))) 
    346             if self.widget.getInputs() != []:    painter.drawRect(0, 18, 8, 16) 
    347             if self.widget.getOutputs() != []:   painter.drawRect(widgetWidth-8, 18, 8, 16) 
     339            painter.drawRect(IOBoxWidth+1-RectWidth, 0, WidgetIconWidth+2*RectWidth, WidgetIconHeight+2*RectWidth) 
     340 
     341        painter.drawPixmap(IOBoxWidth + 1, RectWidth, self.image) 
     342 
     343        if self.widget.getInputs() != []:    painter.drawPixmap(0, (WidgetIconHeight-IOBoxHeight)/2 + RectWidth, self.imageLeftEdge) 
     344        if self.widget.getOutputs() != []:   painter.drawPixmap(IOBoxWidth + WidgetIconWidth + 2, (WidgetIconHeight-IOBoxHeight)/2 + RectWidth, self.imageRightEdge) 
    348345 
    349346        # draw the label 
    350347        painter.setPen(QPen(QColor(0,0,0))) 
    351         midX, midY = widgetWidth/2., self.image.height()+7 
     348        midX, midY = WidgetWidth/2., 2 + WidgetIconHeight + 5 
    352349        painter.drawText(midX-200/2, midY, 200, 20, Qt.AlignTop | Qt.AlignHCenter, self.caption) 
    353350 
    354351        yPos = -20 
    355352        if self.progressBarShown: 
    356             rect = QRectF(8, yPos, widgetWidth-16, 16) 
     353            rect = QRectF(IOBoxWidth, yPos, WidgetIconWidth+2, 16) 
    357354            painter.setPen(QPen(QColor(0,0,0))) 
    358355            painter.setBrush(QBrush(QColor(255,255,255))) 
     
    360357 
    361358            painter.setBrush(QBrush(QColor(0,128,255))) 
    362             painter.drawRect(QRectF(8, -20, (widgetWidth-16)*self.progressBarValue/100., 16)) 
     359            painter.drawRect(QRectF(IOBoxWidth, -20, (WidgetIconWidth+2)*self.progressBarValue/100., 16)) 
    363360            painter.drawText(rect, Qt.AlignCenter, "%d %%" % (self.progressBarValue)) 
    364361 
Note: See TracChangeset for help on using the changeset viewer.