Пример #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"));
  }
Пример #2
0
  private void applyTextColor(ArrayList<GeoElement> geos) {

    Color color = org.geogebra.desktop.awt.GColorD.getAwtColor(btnTextColor.getSelectedColor());
    for (int i = 0; i < geos.size(); i++) {
      GeoElement geo = geos.get(i);
      if (geo instanceof GeoCasCell) {
        ((GeoCasCell) geo).setFontColor(new org.geogebra.desktop.awt.GColorD(color));
        geo.updateRepaint();
        needUndo = true;
      }
    }
  }
Пример #3
0
  /**
   * @param source event source
   * @param targetGeos cells that need updating
   */
  protected void processSource(Object source, ArrayList<GeoElement> targetGeos) {

    if (source == btnTextColor) {
      if (btnTextColor.getSelectedIndex() >= 0) {
        applyTextColor(targetGeos);
        // btnTextColor.setFgColor((Color)btnTextColor.getSelectedValue());
        // btnItalic.setForeground((Color)btnTextColor.getSelectedValue());
        // btnBold.setForeground((Color)btnTextColor.getSelectedValue());
      }
    } else if (source == btnBold) {
      applyFontStyle(targetGeos);
    } else if (source == btnItalic) {
      applyFontStyle(targetGeos);
    } else if (source == btnTextSize) {
      applyTextSize(targetGeos);
    } else if (source == btnUseAsText) {
      int i = casView.getConsoleTable().getEditingRow();
      int pos =
          ((CASTableCellEditorD)
                  casView.getConsoleTable().getCellEditor(i, CASTableD.COL_CAS_CELLS))
              .getCaretPosition();
      applyUseAsText(targetGeos);
      casView.getConsoleTable().startEditingRow(i);
      ((CASTableCellEditorD) casView.getConsoleTable().getCellEditor(i, CASTableD.COL_CAS_CELLS))
          .setCaretPosition(pos);
    } else if (source == btnShowKeyboard) {
      if (((GuiManagerInterfaceD) app.getGuiManager()) != null) {
        if (AppD.isVirtualKeyboardActive()
            && !((GuiManagerD) app.getGuiManager()).showVirtualKeyboard()) {

          // if keyboard is active but hidden, just show it
          ((GuiManagerD) app.getGuiManager()).toggleKeyboard(true);
          ((GuiManagerD) app.getGuiManager()).getVirtualKeyboard().toggleNumeric(true);

        } else {

          AppD.setVirtualKeyboardActive(!AppD.isVirtualKeyboardActive());
          ((GuiManagerD) app.getGuiManager()).toggleKeyboard(AppD.isVirtualKeyboardActive());
          ((GuiManagerD) app.getGuiManager())
              .getVirtualKeyboard()
              .toggleNumeric(AppD.isVirtualKeyboardActive());
        }
      }
    }
    updateStyleBar();
  }
Пример #4
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);
  }