Changeset 142:4fe5a65e7c37 for src/mlx


Ignore:
Timestamp:
05/01/12 15:35:26 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Eliminated the annoying background of the fuel tank figures

Location:
src/mlx/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r141 r142  
    10061006        self.pack_start(label, False, False, 4)
    10071007
    1008         self._tankFigure = gtk.DrawingArea()
     1008        self._tankFigure = gtk.EventBox()
    10091009        self._tankFigure.set_size_request(38, -1)
     1010        self._tankFigure.set_visible_window(False)
    10101011
    10111012        if pygobject:
     
    10161017        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    10171018                                  xscale = 0.0, yscale = 1.0)
    1018         alignment.add(self._tankFigure) 
     1019        alignment.add(self._tankFigure)
    10191020
    10201021        self.pack_start(alignment, True, True, 4)
     
    10511052        self._tankFigure.queue_draw()
    10521053
    1053     def _drawTankFigure(self, connStateArea, eventOrContext):
     1054    def _drawTankFigure(self, tankFigure, eventOrContext):
    10541055        """Draw the tank figure."""
    10551056        triangleSize = 5
    1056        
    1057         context = eventOrContext if pygobject else connStateArea.window.cairo_create()
    1058 
    1059         width = connStateArea.get_allocated_width() if pygobject \
    1060                 else connStateArea.allocation.width
    1061         height = connStateArea.get_allocated_height() if pygobject \
    1062                  else connStateArea.allocation.height
     1057
     1058        context = eventOrContext if pygobject else tankFigure.window.cairo_create()
     1059        (xOffset, yOffset) = (0, 0) if pygobject \
     1060                             else (tankFigure.allocation.x, tankFigure.allocation.y)
     1061       
     1062        width = tankFigure.get_allocated_width() if pygobject \
     1063                else tankFigure.allocation.width
     1064        height = tankFigure.get_allocated_height() if pygobject \
     1065                 else tankFigure.allocation.height
    10631066
    10641067        rectangleX0 = triangleSize
     
    10701073        context.set_source_rgb(0.0, 0.0, 0.0)
    10711074        context.set_line_width(rectangleLineWidth)
    1072         context.rectangle(rectangleX0 + rectangleLineWidth/2,
    1073                           rectangleY0 + rectangleLineWidth/2,
     1075        context.rectangle(xOffset + rectangleX0 + rectangleLineWidth/2,
     1076                          yOffset + rectangleY0 + rectangleLineWidth/2,
    10741077                          rectangleX1 - rectangleX0 - rectangleLineWidth,
    10751078                          rectangleY1 - rectangleY0 - rectangleLineWidth)
     
    10871090        currentHeight = self.currentWeight * rectangleInnerHeight / self.capacity
    10881091        currentX = rectangleInnerTop + rectangleInnerHeight - currentHeight
    1089         context.rectangle(rectangleInnerLeft,
    1090                           rectangleInnerTop + rectangleInnerHeight - currentHeight,
     1092        context.rectangle(xOffset + rectangleInnerLeft,
     1093                          yOffset + rectangleInnerTop +
     1094                          rectangleInnerHeight - currentHeight,
    10911095                          rectangleInnerWidth, currentHeight)
    10921096        context.fill()
     
    10971101        context.set_line_width(1.5)
    10981102        context.set_source_rgb(0.0, 0.85, 0.85)
    1099         context.move_to(rectangleX0, expectedY)
    1100         context.line_to(rectangleX1, expectedY)
     1103        context.move_to(xOffset + rectangleX0, yOffset + expectedY)
     1104        context.line_to(xOffset + rectangleX1, yOffset + expectedY)
    11011105        context.stroke()
    11021106
    11031107        context.set_line_width(0.0)
    1104         context.move_to(0, expectedY - triangleSize)
    1105         context.line_to(0, expectedY + triangleSize)
    1106         context.line_to(rectangleX0 + 1, expectedY)
    1107         context.line_to(0, expectedY - triangleSize)
     1108        context.move_to(xOffset + 0, yOffset + expectedY - triangleSize)
     1109        context.line_to(xOffset + 0, yOffset + expectedY + triangleSize)
     1110        context.line_to(xOffset + rectangleX0 + 1, yOffset + expectedY)
     1111        context.line_to(xOffset + 0, yOffset + expectedY - triangleSize)
    11081112        context.fill()
    11091113
    11101114        context.set_line_width(0.0)
    1111         context.move_to(width, expectedY - triangleSize)
    1112         context.line_to(width, expectedY + triangleSize)
    1113         context.line_to(rectangleX1 - 1, expectedY)
    1114         context.line_to(width, expectedY - triangleSize)
     1115        context.move_to(xOffset + width, yOffset + expectedY - triangleSize)
     1116        context.line_to(xOffset + width, yOffset + expectedY + triangleSize)
     1117        context.line_to(xOffset + rectangleX1 - 1, yOffset + expectedY)
     1118        context.line_to(xOffset + width, yOffset + expectedY - triangleSize)
    11151119        context.fill()
     1120
     1121        return True
    11161122
    11171123    def _expectedChanged(self, spinButton):
  • src/mlx/gui/gui.py

    r139 r142  
    8888        self._notebook = gtk.Notebook()
    8989        mainVBox.pack_start(self._notebook, True, True, 4)
    90 
     90       
    9191        self._wizard = Wizard(self)
    9292        label = gtk.Label(xstr("tab_flight"))
Note: See TracChangeset for help on using the changeset viewer.