Ignore:
Timestamp:
07/23/06 08:33:15 (18 years ago)
Author:
Nicholas Riley
Message:

Display message on empty list (no longer need to add/remove border). Don't let alarms go off while you're deciding whether to discard them. First, untested attempt at handling hard resets (waiting on advice from Danger). Very ugly rewrite of alarm alert; needs much fixing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hiptop/pester/net/sabi/pester/AlarmListView.java

    r277 r278  
    55import danger.ui.AlertWindow;
    66import danger.ui.ActiveListView;
     7import danger.ui.Font;
     8import danger.ui.Pen;
    79import danger.ui.Rect;
     10import danger.ui.Style;
    811import danger.ui.ToolTipWindow;
    912import danger.util.ActiveList;
     
    2528        setAutoResize(true);
    2629        setList(Alarms.getList());
    27         if (alarmsSet() == 0)
    28             setHasBorder(false); // this doesn't work in the rsrc file
    2930        Application.registerForEvent(this, Event.EVENT_TIME_CHANGED);
    3031        super.onDecoded();
     
    5354            alarmSetDialog().editAlarm(new Alarm(), true);
    5455            return true;
    55         case EVENT_CONFIRM_DISCARD_ALARM:
     56        case EVENT_DISCARD_ALARM:
     57            mToolTipAlarm.deactivate();
     58            Alarm alarm = (Alarm)getFocusedItem();
     59            alarm.beginEditing();
    5660            AlertWindow alert =
    5761                Application.getCurrentApp().getAlert(ID_DISCARD_ALERT, this);
    58             // XXX localize
    5962            alert.setMessage("Permanently discard \u201c" +
    60                              ((Alarm)getFocusedItem()).getMessage() +
    61                              "\u201d?");
     63                             alarm.getMessage() + "\u201d?"); // XXX localize
    6264            alert.show();
    6365            return true;
    64         case EVENT_DISCARD_ALARM:
     66        case EVENT_CONFIRM_DISCARD:
    6567            Alarms.removeAlarm((Alarm)getFocusedItem());
    6668            return true;
    67         case Event.EVENT_TIME_CHANGED: // XXX EVENT_TIME_FORMAT_CHANGED too
     69        case EVENT_CANCEL_DISCARD:
     70            ((Alarm)getFocusedItem()).resume();
     71            return true;
     72        // XXX for EVENT_TIME_FORMAT_CHANGED, we also need to force a
     73        // full redraw (in addition to invalidating the tooltip)
     74        case Event.EVENT_TIME_CHANGED:
    6875            if (mToolTipWindow == null || !mToolTipWindow.isVisible())
    6976                return true;
     
    110117    }
    111118
     119    protected void paintEmptyList(Pen p, int width, int height) {
     120        Style style = getStyle();
     121        Font font = style.getFont(Style.DISABLED_LABEL_FONT);
     122        int y = (height / 4) - (font.getAscent() / 2);
     123        if (y < 0) {
     124            setHeight(sAlarmListWindow.getHeight());
     125            return;
     126        }
     127        // XXX localize
     128        String emptyMessage =
     129            "Press " + Font.GLYPH_MENU + " to set an alarm.";
     130        int x = (width / 2) - (font.getWidth(emptyMessage) / 2);
     131        p.setFont(font);
     132        p.setColor(style.getColor(Style.DISABLED_LABEL_COLOR));
     133        p.drawText(x, y, emptyMessage);
     134    }
     135
    112136    public int alarmsSet() {
    113137        return getListSize();
     
    119143        // which is admirable in general, but not what we want
    120144        setFocus(index);
    121         setHasBorder(true);
    122145    }
    123146    public void onItemRemoved(ActiveList list, Object item, int index) {
     
    125148        sAlarmListWindow.updateAlarmCount();
    126149        super.onItemRemoved(list, item, index);
    127         if (alarmsSet() == 0)
    128             setHasBorder(false);
    129150    }
    130151}
Note: See TracChangeset for help on using the changeset viewer.