Changeset 229


Ignore:
Timestamp:
08/16/08 00:20:36 (16 years ago)
Author:
bjn8
Message:

Refector a little bit of code for reuse. Also fixed a bug with widgets

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

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

    r220 r229  
    3131import org.expeditee.items.Text;
    3232import org.expeditee.items.XRayable;
     33import org.expeditee.items.widgets.WidgetCorner;
    3334import org.expeditee.stats.SessionStats;
    3435
     
    107108
    108109                // check for dot's being replaced with text
    109                 if (on != null && on instanceof Dot) {
     110                if (on != null && on instanceof Dot && !(on instanceof WidgetCorner)) {
    110111                        if (ch == KeyEvent.VK_BACK_SPACE || ch == KeyEvent.VK_DELETE) {
    111112                                return;
  • trunk/src/org/expeditee/items/Text.java

    r226 r229  
    13171317                return new Point(start, end);
    13181318        }
     1319       
     1320        /**
     1321         * @param mouseButton
     1322         *              Either MouseEvent.BUTTON1, MouseEvent.BUTTON2 or MouseEvent.BUTTON3.
     1323         *             
     1324         * @return
     1325         *              The color for the text selection based on the given mouse click
     1326         */
     1327        protected Color getSelectionColor(int mouseButton) {
     1328
     1329                /*
     1330                 * Color main = getPaintColor(); Color back = getPaintBackgroundColor();
     1331                 *
     1332                 * if (Math.abs(main.getRed() - back.getRed()) < 10 &&
     1333                 * Math.abs(main.getGreen() - back.getGreen()) < 10 &&
     1334                 * Math.abs(main.getBlue() - back.getBlue()) < 10) { selection = new
     1335                 * Color(Math.abs(255 - main.getRed()), Math .abs(255 -
     1336                 * main.getGreen()), Math.abs(255 - main.getBlue())); } else { selection =
     1337                 * new Color((main.getRed() + (back.getRed() * 2)) / 3, (main.getGreen() +
     1338                 * (back.getGreen() * 2)) / 3, (main .getBlue() + (back.getBlue() * 2)) /
     1339                 * 3); }
     1340                 */
     1341                int green = 160;
     1342                int red = 160;
     1343                int blue = 160;
     1344
     1345                if (FrameMouseActions.wasDeleteClicked()) {
     1346                        green = 235;
     1347                        red = 235;
     1348                        blue = 140;
     1349                } else if (mouseButton == MouseEvent.BUTTON1) {
     1350                        red = 255;
     1351                } else if (mouseButton == MouseEvent.BUTTON2) {
     1352                        green = 255;
     1353                } else if (mouseButton == MouseEvent.BUTTON3) {
     1354                        blue = 255;
     1355                }
     1356               
     1357                return new Color(red, green, blue);
     1358        }
    13191359
    13201360        @Override
     
    13771417                g.setColor(c);
    13781418
    1379                 Color selection;
    1380 
    1381                 /*
    1382                  * Color main = getPaintColor(); Color back = getPaintBackgroundColor();
    1383                  *
    1384                  * if (Math.abs(main.getRed() - back.getRed()) < 10 &&
    1385                  * Math.abs(main.getGreen() - back.getGreen()) < 10 &&
    1386                  * Math.abs(main.getBlue() - back.getBlue()) < 10) { selection = new
    1387                  * Color(Math.abs(255 - main.getRed()), Math .abs(255 -
    1388                  * main.getGreen()), Math.abs(255 - main.getBlue())); } else { selection =
    1389                  * new Color((main.getRed() + (back.getRed() * 2)) / 3, (main.getGreen() +
    1390                  * (back.getGreen() * 2)) / 3, (main .getBlue() + (back.getBlue() * 2)) /
    1391                  * 3); }
    1392                  */
    1393                 int green = 160;
    1394                 int red = 160;
    1395                 int blue = 160;
    1396 
    1397                 if (FrameMouseActions.wasDeleteClicked()) {
    1398                         green = 235;
    1399                         red = 235;
    1400                         blue = 140;
    1401                 } else if (FrameMouseActions.getLastMouseButton() == MouseEvent.BUTTON1) {
    1402                         red = 255;
    1403                 } else if (FrameMouseActions.getLastMouseButton() == MouseEvent.BUTTON2) {
    1404                         green = 255;
    1405                 } else if (FrameMouseActions.getLastMouseButton() == MouseEvent.BUTTON3) {
    1406                         blue = 255;
    1407                 }
    1408                 selection = new Color(red, green, blue);
     1419                Color selection = getSelectionColor(FrameMouseActions.getLastMouseButton());
    14091420
    14101421                // width -= getX();
Note: See TracChangeset for help on using the changeset viewer.