Example #1
0
  public void setenabled(boolean b) {

    for (int i = 0; i < m_aButtons.length; i++) {
      UnoDialog2.setEnabled(m_aButtons[i], b);
    }
    UnoDialog2.setEnabled(lblImageText, b);
    if (showButtons) {
      UnoDialog2.setEnabled(btnBack, b);
      UnoDialog2.setEnabled(btnNext, b);
      UnoDialog2.setEnabled(lblCounter, b);
    }
    benabled = b;
  }
Example #2
0
 private void refreshImages() {
   if (showButtons) {
     refreshCounterText();
   }
   if (refreshOverNull) {
     for (int i = 0; i < m_aButtons.length; i++) {
       setVisible(m_aButtons[i], false);
     }
   }
   for (int i = 0; i < m_aButtons.length; i++) {
     Object oObj = getObjectFor(i);
     if (oObj == null) continue;
     Object[] oResources = renderer.getImageUrls(oObj);
     if (oResources == null) continue;
     if (oResources.length == 1) {
       Helper.setUnoPropertyValue(
           m_aButtons[i].getModel(), PropertyNames.PROPERTY_IMAGEURL, oResources[0]);
     } else if (oResources.length == 2) {
       oUnoDialog
           .getPeerConfiguration()
           .setImageUrl(m_aButtons[i].getModel(), oResources[0], oResources[1]);
     }
     boolean bTabStop = Boolean.TRUE; // focusable ? Boolean.TRUE : Boolean.FALSE;
     Helper.setUnoPropertyValue(m_aButtons[i].getModel(), "Tabstop", bTabStop);
     if (refreshOverNull) {
       setVisible(m_aButtons[i], true);
     }
   }
 }
Example #3
0
 /** refresh on all buttons, the selected button will get state pressed */
 private void refreshSelection() {
   // reset all buttons to not set
   for (int i = 0; i < m_aButtons.length; i++) {
     if (m_aButtons[i] != null) {
       XControlModel xModel = (XControlModel) UnoDialog2.getModel(m_aButtons[i]);
       PropertySetHelper aHelper = new PropertySetHelper(xModel);
       if (i == m_nCurrentSelection) {
         final short one = 1;
         aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(one));
       } else {
         final short zero = 0;
         aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(zero));
       }
     }
   }
 }
Example #4
0
  private XButton createButton(UnoDialog2 dialog, int _row, int _col) {
    String sButtonName = m_aControlName + "_button" + (_row * cols + _col);
    int nButtonX = getButtonPosX(_col);
    int nButtonY = getButtonPosY(_row);
    XButton aButton =
        dialog.insertImageButton(
            sButtonName,
            this,
            new String[] {
              /* PropertyNames.PROPERTY_BORDER, */
              /* "BackgroundColor", */
              PropertyNames.PROPERTY_HEIGHT,
              PropertyNames.PROPERTY_HELPURL,
              /* PropertyNames.PROPERTY_LABEL, */
              PropertyNames.PROPERTY_POSITION_X,
              PropertyNames.PROPERTY_POSITION_Y,
              /* "ScaleImage", */
              PropertyNames.PROPERTY_STEP,
              PropertyNames.PROPERTY_TABINDEX,
              "Tabstop",
              "Toggle",
              PropertyNames.PROPERTY_WIDTH
            },
            new Object[] {
              /* Short.valueOf((short) 1), */
              /* NO_BORDER, */
              /* BACKGROUND_COLOR, */
              m_aButtonHeight,
              HelpIds.getHelpIdString(helpURL++),
              /* "Test", */
              Integer.valueOf(nButtonX),
              Integer.valueOf(nButtonY),
              /* scaleImages, */
              step,
              m_tabIndex,
              Boolean.TRUE,
              Boolean.TRUE, /* Toggle */
              m_aButtonWidth
            });

    XWindow win = UnoRuntime.queryInterface(XWindow.class, aButton);
    win.setEnable(true);
    win.setVisible(true);
    return aButton;
  }
Example #5
0
  /** implementation of XActionListener will call if a button from the m_aButtonList is pressed. */
  public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) {
    XControlModel xModel = (XControlModel) UnoDialog2.getModel(actionEvent.Source);
    PropertySetHelper aHelper = new PropertySetHelper(xModel);

    int nState = aHelper.getPropertyValueAsInteger(PropertyNames.PROPERTY_STATE, -1);
    if (nState == 0) {
      // this will avoid a wrong state, if already pressed.
      aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf((short) 1));
    }

    // check which Button is pressed.
    String sControlName =
        aHelper.getPropertyValueAsString(PropertyNames.PROPERTY_NAME, PropertyNames.EMPTY_STRING);
    final String sButton = sControlName.substring(7 + m_aControlName.length());
    int nButton = Integer.parseInt(sButton);

    int index = getIndexFor(nButton);
    if (index < listModel.getSize()) {
      setSelected(index);
    }
  }
Example #6
0
  public void create(UnoDialog2 dialog) {
    oUnoDialog = dialog;

    int imageTextHeight = imageTextLines * LINE_HEIGHT;

    int nXPos = pos.Width + 1;
    int nYPos = pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height;
    int nWidth = cols * (m_aButtonSize.Width + gap.Width) + gap.Width - 2;

    lblImageText =
        dialog.insertLabel(
            m_aControlName + "_imageText",
            new String[] {
              PropertyNames.PROPERTY_HEIGHT,
              PropertyNames.PROPERTY_HELPURL,
              PropertyNames.PROPERTY_LABEL,
              PropertyNames.PROPERTY_POSITION_X,
              PropertyNames.PROPERTY_POSITION_Y,
              PropertyNames.PROPERTY_STEP,
              PropertyNames.PROPERTY_TABINDEX,
              "Tabstop",
              PropertyNames.PROPERTY_WIDTH
            },
            new Object[] {
              Integer.valueOf(imageTextHeight),
              PropertyNames.EMPTY_STRING,
              "(1)",
              Integer.valueOf(nXPos),
              Integer.valueOf(nYPos),
              step,
              Short.valueOf((short) 0),
              Boolean.FALSE,
              Integer.valueOf(nWidth)
            });

    if (showButtons) {
      final String[] pNames1 =
          new String[] {
            PropertyNames.PROPERTY_HEIGHT,
            PropertyNames.PROPERTY_HELPURL,
            PropertyNames.PROPERTY_POSITION_X,
            PropertyNames.PROPERTY_POSITION_Y,
            PropertyNames.PROPERTY_STEP,
            PropertyNames.PROPERTY_TABINDEX,
            "Tabstop",
            PropertyNames.PROPERTY_WIDTH
          };

      final Integer btnSize = Integer.valueOf(14);

      // TODO: if list of strings not the same length of list object, office will die.
      btnBack =
          dialog.insertButton(
              m_aControlName + "_btnBack",
              new XActionListenerAdapter() {
                @Override
                public void actionPerformed(ActionEvent event) {
                  prevPage();
                }
              },
              pNames1,
              new Object[] {
                btnSize,
                HelpIds.getHelpIdString(helpURL++),
                Integer.valueOf(pos.Width),
                Integer.valueOf(
                    pos.Height
                        + (m_aButtonSize.Height + gap.Height) * rows
                        + gap.Height
                        + imageTextHeight
                        + 1),
                step,
                Short.valueOf((short) (tabIndex + 1)),
                Boolean.TRUE,
                btnSize
              });

      btnNext =
          dialog.insertButton(
              m_aControlName + "_btnNext",
              new XActionListenerAdapter() {
                @Override
                public void actionPerformed(ActionEvent event) {
                  nextPage();
                }
              },
              pNames1,
              new Object[] {
                btnSize,
                HelpIds.getHelpIdString(helpURL++),
                Integer.valueOf(
                    pos.Width
                        + (m_aButtonSize.Width + gap.Width) * cols
                        + gap.Width
                        - btnSize.intValue()
                        + 1),
                Integer.valueOf(
                    pos.Height
                        + (m_aButtonSize.Height + gap.Height) * rows
                        + gap.Height
                        + imageTextHeight
                        + 1),
                step,
                Short.valueOf((short) (tabIndex + 2)),
                Boolean.TRUE,
                btnSize
              });

      lblCounter =
          dialog.insertLabel(
              m_aControlName + "_lblCounter",
              pNames1,
              new Object[] {
                Integer.valueOf(LINE_HEIGHT),
                PropertyNames.EMPTY_STRING,
                Integer.valueOf(pos.Width + btnSize.intValue() + 1),
                Integer.valueOf(
                    pos.Height
                        + (m_aButtonSize.Height + gap.Height) * rows
                        + gap.Height
                        + imageTextHeight
                        + ((btnSize.intValue() - LINE_HEIGHT) / 2)),
                step,
                Short.valueOf((short) 0),
                Boolean.FALSE,
                Integer.valueOf(
                    cols * (m_aButtonSize.Width + gap.Width)
                        + gap.Width
                        - 2 * btnSize.intValue()
                        - 1)
              });

      Helper.setUnoPropertyValue(
          getModel(lblCounter), PropertyNames.PROPERTY_ALIGN, Short.valueOf((short) 1));
      Helper.setUnoPropertyValue(getModel(btnBack), PropertyNames.PROPERTY_LABEL, "<");
      Helper.setUnoPropertyValue(getModel(btnNext), PropertyNames.PROPERTY_LABEL, ">");
    }

    m_tabIndex = Short.valueOf((short) tabIndex);

    m_aButtons = new XControl[rows * cols];

    m_aButtonHeight = Integer.valueOf(m_aButtonSize.Height);
    m_aButtonWidth = Integer.valueOf(m_aButtonSize.Width);

    for (int r = 0; r < rows; r++) {
      for (int c = 0; c < cols; c++) {
        XButton aButton = createButton(dialog, r, c);
        XControl aControl = UnoRuntime.queryInterface(XControl.class, aButton);
        m_aButtons[r * cols + c] = aControl;
      }
    }
    refreshImages();
  }