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

Further enhanced the fuel widget.

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r132 r144  
    3535    JUSTIFY_CENTER = gtk.JUSTIFY_CENTER
    3636
     37    CONTROL_MASK = gdk.CONTROL_MASK
     38    SHIFT_MASK = gdk.SHIFT_MASK
     39    BUTTON1_MASK = gdk.BUTTON1_MASK
     40
     41    SCROLL_UP = gdk.SCROLL_UP
     42    SCROLL_DOWN = gdk.SCROLL_DOWN
     43
     44    SPIN_USER_DEFINED = gtk.SPIN_USER_DEFINED
     45
    3746    def text2unicode(text):
    3847        """Convert the given text, returned by a Gtk widget, to Unicode."""
     
    6170    WRAP_WORD = gtk.WrapMode.WORD
    6271    JUSTIFY_CENTER = gtk.Justification.CENTER
     72
     73    CONTROL_MASK = gdk.ModifierType.CONTROL_MASK
     74    SHIFT_MASK = gdk.ModifierType.SHIFT_MASK
     75    BUTTON1_MASK = gdk.ModifierType.BUTTON1_MASK
     76
     77    SCROLL_UP = gdk.ScrollDirection.UP
     78    SCROLL_DOWN = gdk.ScrollDirection.DOWN
     79
     80    SPIN_USER_DEFINED = gtk.SpinType.USER_DEFINED
    6381
    6482    import codecs
  • src/mlx/gui/flight.py

    r142 r144  
    10091009        self._tankFigure.set_size_request(38, -1)
    10101010        self._tankFigure.set_visible_window(False)
     1011        self._tankFigure.set_tooltip_markup(xstr("fuel_tank_tooltip"))
    10111012
    10121013        if pygobject:
     
    10141015        else:
    10151016            self._tankFigure.connect("expose_event", self._drawTankFigure)
    1016 
     1017        self._tankFigure.connect("button_press_event", self._buttonPressed)
     1018        self._tankFigure.connect("motion_notify_event", self._motionNotify)
     1019        self._tankFigure.connect("scroll-event", self._scrolled)
     1020       
    10171021        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    10181022                                  xscale = 0.0, yscale = 1.0)
     
    10811085        rectangleInnerLeft   = rectangleX0 + rectangleLineWidth
    10821086        rectangleInnerRight  = rectangleX1 - rectangleLineWidth
    1083         rectangleInnerTop    = rectangleY0 + rectangleLineWidth
    1084         rectangleInnerBottom = rectangleY1 - rectangleLineWidth
     1087        self._rectangleInnerTop = rectangleInnerTop = rectangleY0 + rectangleLineWidth
     1088        self._rectangleInnerBottom = rectangleInnerBottom = rectangleY1 - rectangleLineWidth
    10851089
    10861090        rectangleInnerWidth = rectangleInnerRight - rectangleInnerLeft
     
    11211125        return True
    11221126
     1127    def _setExpectedFromY(self, y):
     1128        """Set the expected weight from the given Y-coordinate."""
     1129        level = (self._rectangleInnerBottom - y) / \
     1130                (self._rectangleInnerBottom - self._rectangleInnerTop)
     1131        level = min(1.0, max(0.0, level))
     1132        self._expectedButton.set_value(level * self.capacity)
     1133       
     1134    def _buttonPressed(self, tankFigure, event):
     1135        """Called when a button is pressed in the figure.
     1136
     1137        The expected level will be set there."""
     1138        if event.button==1:
     1139            self._setExpectedFromY(event.y)
     1140       
     1141    def _motionNotify(self, tankFigure, event):
     1142        """Called when the mouse pointer moves within the area of a tank figure."""
     1143        if event.state==BUTTON1_MASK:           
     1144            self._setExpectedFromY(event.y)
     1145
     1146    def _scrolled(self, tankFigure, event):
     1147        """Called when a scroll event is received."""
     1148        increment = 1 if event.state==CONTROL_MASK \
     1149                    else 100 if event.state==SHIFT_MASK \
     1150                    else 10 if event.state==0 else 0
     1151        if increment!=0:
     1152            if event.direction==SCROLL_DOWN:
     1153                increment *= -1
     1154            self._expectedButton.spin(SPIN_USER_DEFINED, increment)
     1155       
    11231156    def _expectedChanged(self, spinButton):
    11241157        """Called when the expected value has changed."""
     
    11531186        self._pumpIndex = 0
    11541187
    1155     def activate(self):
    1156         """Activate the page."""
    1157         gui = self._wizard.gui
    1158 
    1159         self._setupTanks(gui.flight.aircraft.fuelTanks,
    1160                          self._wizard._fuelData)
     1188    # def activate(self):
     1189    #     """Activate the page."""
     1190    #     gui = self._wizard.gui
     1191
     1192    #     self._setupTanks(gui.flight.aircraft.fuelTanks,
     1193    #                      self._wizard._fuelData)
    11611194
    11621195    def finalize(self):
     
    25202553            page.reset()
    25212554       
    2522         self.setCurrentPage(0)
     2555        self.setCurrentPage(6)
    25232556
    25242557    def getFleet(self, callback, force = False):
Note: See TracChangeset for help on using the changeset viewer.