Example #1
0
  /** Update localization */
  public void setLabels() {
    initGUI();

    btnUseAsText.setToolTipText(loc.getPlainTooltip("stylebar.UseAsText"));
    btnTextColor.setToolTipText(loc.getPlainTooltip("stylebar.TextColor"));
    btnTextSize.setToolTipText(loc.getPlainTooltip("stylebar.TextSize"));
    btnBold.setToolTipText(loc.getPlainTooltip("stylebar.Bold"));
    btnItalic.setToolTipText(loc.getPlainTooltip("stylebar.Italic"));
  }
Example #2
0
  private void applyFontStyle(ArrayList<GeoElement> geos) {

    int fontStyle = 0;
    if (btnBold.isSelected()) fontStyle += 1;
    if (btnItalic.isSelected()) fontStyle += 2;
    for (int i = 0; i < geos.size(); i++) {
      GeoElement geo = geos.get(i);
      Log.debug(((GeoCasCell) geo).getGeoText());
      if (geo instanceof GeoCasCell
          && ((GeoCasCell) geo).getGeoText().getFontStyle() != fontStyle) {
        ((GeoCasCell) geo).getGeoText().setFontStyle(fontStyle);
        geo.updateRepaint();
        needUndo = true;
      }
    }
  }
Example #3
0
  private void initGUI() {

    removeAll();

    ImageIcon kbdIcon = app.getScaledIcon("cas-keyboard.png");

    iconHeight = kbdIcon.getIconHeight();
    iconDimension = new Dimension(iconHeight, iconHeight);
    btnShowKeyboard = new MyToggleButton(kbdIcon, iconHeight);

    createTextButtons();

    add(btnUseAsText);
    add(btnTextColor);
    add(btnBold);
    add(btnItalic);

    btnShowKeyboard.addActionListener(this);
    add(btnShowKeyboard);
    // add(btnTextSize); //TODO: Fix text size

    popupBtnList = newPopupBtnList();
    toggleBtnList = newToggleBtnList();

    updateStyleBar();
  }
Example #4
0
 private void applyUseAsText(ArrayList<GeoElement> geos) {
   // btnUseAsText
   for (int i = 0; i < geos.size(); i++) {
     GeoElement geo = geos.get(i);
     if (geo instanceof GeoCasCell) {
       ((GeoCasCell) geo).setUseAsText(btnUseAsText.isSelected());
       geo.updateRepaint();
       needUndo = true;
     }
   }
 }
Example #5
0
  private void createTextButtons() {

    // ========================
    // text color button
    final Dimension textColoriconHeight = new Dimension(iconHeight, iconHeight);

    btnTextColor =
        new ColorPopupMenuButton(
            app, textColoriconHeight, ColorPopupMenuButton.COLORSET_DEFAULT, false) {

          private static final long serialVersionUID = 1L;

          private Color geoColor;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);

            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              geoColor =
                  org.geogebra.desktop.awt.GColorD.getAwtColor(((GeoCasCell) geo).getFontColor());
              updateColorTable();

              // find the geoColor in the table and select it
              int index = this.getColorIndex(geoColor);
              setSelectedIndex(index);

              // if nothing was selected, set the icon to show the
              // non-standard color
              if (index == -1) {
                this.setIcon(getButtonIcon());
              }

              setFgColor(geoColor);
              setFontStyle(((TextProperties) geo).getFontStyle());
            }
          }

          @Override
          public ImageIcon getButtonIcon() {
            return GeoGebraIcon.createTextSymbolIcon(
                "A",
                app.getPlainFont(),
                textColoriconHeight,
                org.geogebra.desktop.awt.GColorD.getAwtColor(getSelectedColor()),
                null);
          }
        };

    btnTextColor.addActionListener(this);

    // ========================================
    // use as text button
    ImageIcon useAsTextIcon =
        GeoGebraIcon.createStringIcon(
            app.getPlain("Text").substring(0, 1),
            app.getPlainFont(),
            true,
            false,
            true,
            iconDimension,
            Color.black,
            null);
    btnUseAsText =
        new MyToggleButton(useAsTextIcon, iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            setVisible(true);
            btnUseAsText.setSelected(checkGeoText(geos));
          }
        };
    btnUseAsText.addActionListener(this);

    // ========================================
    // bold text button
    ImageIcon boldIcon =
        GeoGebraIcon.createStringIcon(
            app.getPlain("Bold").substring(0, 1),
            app.getPlainFont(),
            true,
            false,
            true,
            iconDimension,
            Color.black,
            null);
    btnBold =
        new MyToggleButton(boldIcon, iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);
            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              int style = ((GeoCasCell) geo).getGeoText().getFontStyle();
              btnBold.setSelected(style == Font.BOLD || style == (Font.BOLD + Font.ITALIC));
            }
          }
        };
    btnBold.addActionListener(this);

    // ========================================
    // italic text button
    ImageIcon italicIcon =
        GeoGebraIcon.createStringIcon(
            app.getPlain("Italic").substring(0, 1),
            app.getPlainFont(),
            false,
            true,
            true,
            iconDimension,
            Color.black,
            null);
    btnItalic =
        new MyToggleButton(italicIcon, iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);
            this.setVisible(geosOK);
            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              int style = ((GeoCasCell) geo).getGeoText().getFontStyle();
              btnItalic.setSelected(style == Font.ITALIC || style == (Font.BOLD + Font.ITALIC));
            }
          }
        };
    btnItalic.addActionListener(this);

    // ========================================
    // text size button

    String[] textSizeArray = app.getLocalization().getFontSizeStrings();

    btnTextSize =
        new PopupMenuButton(
            app,
            textSizeArray,
            -1,
            1,
            new Dimension(-1, iconHeight),
            org.geogebra.common.gui.util.SelectionTable.MODE_TEXT) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);

            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]);
              setSelectedIndex(
                  GeoText.getFontSizeIndex(
                      ((GeoCasCell) geo).getFontSizeMultiplier())); // font size
              // ranges from
              // -4 to 4, transform
              // this to 0,1,..,4
            }
          }
        };
    btnTextSize.addActionListener(this);
    btnTextSize.setKeepVisible(false);
  }