Ignore:
Timestamp:
05/08/08 14:30:09 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r19 r21  
    246246
    247247                for (Item i : current.getItems())
    248                         i.showHighlight(false);
     248                        i.setSelectedMode(Item.SelectedMode.None);
    249249                return true;
    250250        }
     
    354354                _LastResponse = ResponseTimer.getElapsedSeconds();
    355355                _ResponseTimeSum += _LastResponse;
     356                DisplayIO.UpdateTitle();
    356357        }
    357358
     
    454455                return true;
    455456        }
    456        
     457
    457458        /**
    458          * Creates an interactive widget and adds it to a frame.
    459          * If txt has no parent the parent will be set to frame.
    460          *
    461          * @param frame 
    462          *              Frame to add widget to. Must not be null.
    463          *
    464          * @param txt 
    465          *              Text to create the widget from. Must not be null.
     459         * Creates an interactive widget and adds it to a frame. If txt has no
     460         * parent the parent will be set to frame.
     461         *
     462         * @param frame
     463         *            Frame to add widget to. Must not be null.
     464         *
     465         * @param txt
     466         *            Text to create the widget from. Must not be null.
    466467         *
    467468         * @return True if created/added. False if coul not create.
     
    471472        private static boolean createWidget(Frame frame, Text txt) {
    472473
    473                 if (frame == null) throw new NullPointerException("frame");
    474                 if (txt == null) throw new NullPointerException("txt");
    475                
     474                if (frame == null)
     475                        throw new NullPointerException("frame");
     476                if (txt == null)
     477                        throw new NullPointerException("txt");
     478
    476479                // Safety
    477                 if (txt.getParent() == null) txt.setParent(frame);
    478                
     480                if (txt.getParent() == null)
     481                        txt.setParent(frame);
     482
    479483                InteractiveWidget iw = null;
    480                
     484
    481485                try {
    482                        
     486
    483487                        iw = InteractiveWidget.CreateWidget(txt);
    484                        
     488
    485489                } catch (InteractiveWidgetNotAvailableException e) {
    486490                        e.printStackTrace();
    487                         FrameGraphics.ErrorMessage("Cannot create iWidget: " + e.getMessage());
    488                        
    489                 }  catch (IllegalArgumentException e) {
     491                        FrameGraphics.ErrorMessage("Cannot create iWidget: "
     492                                        + e.getMessage());
     493
     494                } catch (IllegalArgumentException e) {
    490495                        e.printStackTrace();
    491                         FrameGraphics.ErrorMessage("Cannot create iWidget: " + e.getMessage());
    492                 }
    493                
    494                 if (iw == null) return false;
     496                        FrameGraphics.ErrorMessage("Cannot create iWidget: "
     497                                        + e.getMessage());
     498                }
     499
     500                if (iw == null)
     501                        return false;
    495502
    496503                frame.removeItem(txt);
    497                
     504
    498505                frame.addAllItems(iw.getItems());
    499506
     
    682689                // if XRayMode is on, replace pictures with their underlying text
    683690                if (FrameGraphics.isXRayMode()) {
    684                        
     691
    685692                        // BROOK: Must handle these a little different
    686                         //List<InteractiveWidget> widgets = toParse.getInteractiveWidgets();
     693                        // List<InteractiveWidget> widgets =
     694                        // toParse.getInteractiveWidgets();
    687695                        ArrayList<InteractiveWidget> widgets = new ArrayList<InteractiveWidget>();
    688696                        /*
     697                         * for (Item i : items) { if (i instanceof Picture) {
     698                         * toParse.removeItem(i); toParse.addItem(((Picture) i).getText()); }
     699                         * else if (i instanceof WidgetCorner) { toParse.removeItem(i); }
     700                         * else if (i instanceof WidgetEdge) { toParse.removeItem(i); } }
     701                         */
    689702                        for (Item i : items) {
    690703                                if (i instanceof Picture) {
     
    693706                                } else if (i instanceof WidgetCorner) {
    694707                                        toParse.removeItem(i);
    695                                 } else if (i instanceof WidgetEdge) {
    696                                         toParse.removeItem(i);
    697                                 }
    698                         }*/
    699                         for (Item i : items) {
    700                                 if (i instanceof Picture) {
    701                                         toParse.removeItem(i);
    702                                         toParse.addItem(((Picture) i).getText());
    703                                 } else if (i instanceof WidgetCorner) {
    704                                         toParse.removeItem(i);
    705                                         InteractiveWidget iw = ((WidgetCorner)i).getWidgetSource();
    706                                         if (!widgets.contains(iw)) { // hmmm I should be using a set... meh
     708                                        InteractiveWidget iw = ((WidgetCorner) i).getWidgetSource();
     709                                        if (!widgets.contains(iw)) { // hmmm I should be using a
     710                                                // set... meh
    707711                                                widgets.add(iw);
    708712                                        }
    709                                 } else if (i instanceof WidgetEdge) toParse.removeItem(i);
    710                         }
    711 
     713                                } else if (i instanceof WidgetEdge)
     714                                        toParse.removeItem(i);
     715                        }
    712716
    713717                        for (InteractiveWidget iw : widgets) {
    714718                                toParse.addItem(iw.getSource());
    715719                        }
    716                        
     720
    717721                        // update the list of items
    718722                        items.clear();
     
    918922                                        if (message.contains(x, y)) {
    919923                                                message.Permission = Item.PERMISSION_COPY;
    920                                         }
    921                                         possibles.add(message);
     924                                                possibles.add(message);
     925                                        } else
     926                                                // Not sure why but if the line below is removed then
     927                                                // several items can be highlighted at once
     928                                                message.setSelectedMode(Item.SelectedMode.None);
    922929                                }
    923930                        }
     
    927934                                if (FrameGraphics.MessageLink.contains(x, y)) {
    928935                                        FrameGraphics.MessageLink.Permission = Item.PERMISSION_COPY;
    929                                 }
    930                                 possibles.add(FrameGraphics.MessageLink);
    931                         }
    932                         y -= FrameGraphics.getMaxFrameSize().getHeight();
     936                                        possibles.add(FrameGraphics.MessageLink);
     937                                }
     938                        }
     939
     940                        // this is taken into account in contains
     941                        // y -= FrameGraphics.getMaxFrameSize().height;
    933942                        // otherwise, the mouse is on the frame
    934943                } else {
     
    942951                        } else
    943952                                LastEdited = null;
    944                        
     953
    945954                        ArrayList<Item> checkList = new ArrayList<Item>();
    946955                        checkList.addAll(toCheck.getItems());
     
    10281037                        return null;
    10291038
    1030                 return getItemsEnclosedBy(DisplayIO.getCurrentFrame(), enclosure.get(0)
    1031                                 .getEnclosedShape());
     1039                List<Item> enclosed = getItemsEnclosedBy(DisplayIO.getCurrentFrame(),
     1040                                enclosure.get(0).getEnclosedShape());
     1041                for (Item i : enclosed) {
     1042                        if (!enclosure.contains(i))
     1043                                i.setSelectedMode(Item.SelectedMode.None);
     1044                }
     1045
     1046                return enclosed;
    10321047        }
    10331048
     
    11231138                        // if the item is on the frame
    11241139                        if (item.getParent() == frame || item.getParent() == null) {
    1125                                 // TODO this is a bit of a hack...
    1126                                 // the
    1127                                 // item
    1128                                 // parent
    1129                                 // should
    1130                                 // really
    1131                                 // be
    1132                                 // set
    1133                                 // when
    1134                                 // the
    1135                                 // polygon
    1136                                 // is
    1137                                 // created...
    11381140                                item.Permission = Item.PERMISSION_FULL;
    11391141                                results.add(item);
Note: See TracChangeset for help on using the changeset viewer.