Exemplo n.º 1
0
/*! 
 * Makes a labeled spin box, with the label given by [text] to the left of the
 * box and right aligned to it, provided that [layout] is a horizontal layout 
 * box in which to place them.  (In a toolbar, [layout] can be NULL.)  
 * [minValue], [maxValue], and [step] are the  minimum, maximum, and step 
 * sizes for the spin box.  If [nDecimal] is non-zero, it creates and returns 
 * a QDoubleSpinBox with that number of decimal places.  It skips the label
 * if [text] is NULL.  The focus policy is set to ClickFocus.  Keyboard 
 * tracking is turned off.  If a pointer is supplied in the optional argument [labelPtr]
 * (which is NULL by default), it is returned with the label pointer.
 */
QAbstractSpinBox *diaLabeledSpin(int nDecimal, float minValue, float maxValue,
                                 float step, const char *text, QWidget *parent,
                                 QBoxLayout *layout, QLabel **labelPtr)
{
  QSpinBox *spin;
  QDoubleSpinBox *fspin;
  if (text) {
    QLabel *label = diaLabel(text, parent, layout);
    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    if (labelPtr)
      *labelPtr = label;
  }
  if (nDecimal) {
    fspin = new QDoubleSpinBox(parent);
    fspin->setDecimals(nDecimal);
    fspin->setRange((double)minValue, (double)maxValue);
    fspin->setSingleStep((double)step);
    spin = (QSpinBox *)fspin;
  } else {
    spin = new QSpinBox(parent);
    spin->setRange(B3DNINT(minValue), B3DNINT(maxValue));
    spin->setSingleStep(B3DNINT(step));
  }
  if (layout)
    layout->addWidget(spin);
  spin->setFocusPolicy(Qt::ClickFocus);
  spin->setKeyboardTracking(false);
  return (QAbstractSpinBox *)spin;
}
Exemplo n.º 2
0
/*
 * The class constructor
 */
PixelView::PixelView(QWidget *parent, const char *name, Qt::WindowFlags fl)
  : QWidget(parent, fl)
{
  int i, j, iz = B3DNINT(App->cvi->zmouse);
  setAttribute(Qt::WA_DeleteOnClose);
  setAttribute(Qt::WA_AlwaysShowToolTips);
  QVBoxLayout *vBox = new QVBoxLayout(this);
  vBox->setSpacing(3);

  // Make the mouse report box
  QHBoxLayout *hBox = diaHBoxLayout(vBox);
  mMouseLabel = diaLabel(" ", this, hBox);
  hBox->addStretch();
  hBox->setSpacing(5);

  mFileValBox = diaCheckBox("File value", this, hBox);
  diaSetChecked(mFileValBox, fromFile);
  connect(mFileValBox, SIGNAL(toggled(bool)), this, 
          SLOT(fromFileToggled(bool)));
  mFileValBox->setToolTip("Show value from file, not byte value from memory"
                ", at mouse position");
  mFileValBox->setEnabled(fileReadable(App->cvi, iz));

  QCheckBox *gbox = diaCheckBox("Grid", this, hBox);
  diaSetChecked(gbox, showButs);
  connect(gbox, SIGNAL(toggled(bool)), this, SLOT(showButsToggled(bool)));
  gbox->setToolTip("Show buttons with values from file or memory)");

  hBox = diaHBoxLayout(vBox);
  mGridValBox = diaCheckBox("Grid value from file", this, hBox);
  diaSetChecked(mGridValBox, gridFromFile);
  connect(mGridValBox, SIGNAL(toggled(bool)), this, 
          SLOT(gridFileToggled(bool)));
  mGridValBox->setToolTip("Show value from file, not byte value from memory"
                ", in each button");
  mGridValBox->setEnabled(fileReadable(App->cvi, iz));

  mConvertBox = NULL;
  if (App->cvi->rgbStore) {
    mConvertBox = diaCheckBox("Convert RGB to gray scale", this, hBox);
    diaSetChecked(mConvertBox, convertRGB);
    connect(mConvertBox, SIGNAL(toggled(bool)), this, 
            SLOT(convertToggled(bool)));
    mConvertBox->setToolTip("Show luminance values instead of RGB triplets"
                  );
  }
Exemplo n.º 3
0
/*
 * Object list class constructor
 */
ImodvOlist::ImodvOlist(QWidget *parent, Qt::WFlags fl)
  : QWidget(parent, fl)
{
  int nPerCol, olistNcol, ob, i;
  QString qstr;
  QLabel *label;
  const char *labels[] = {"New", "Delete", "Clear", "Add All", "Swap", "ON", "OFF",
                    "On", "Off"};
  const char *tips[] = {"Start a new object group, copied from current group",
                  "Remove the current object group from list of groups",
                  "Remove all objects from the current group",
                  "Add all objects to the current group",
                  "Remove current members and add all non-members",
                  "Turn ON all objects in the current group",
                  "Turn OFF all objects in the current group",
                  "Turn ON objects NOT in the current group",
                  "Turn OFF objects NOT in the current group"};
  
  setAttribute(Qt::WA_DeleteOnClose);
  setAttribute(Qt::WA_AlwaysShowToolTips);
  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->setContentsMargins(5, 5, 5, 5);
  layout->setSpacing(6);

  QGroupBox *grpbox = new QGroupBox("Object Group Selection");
  layout->addWidget(grpbox);
  QVBoxLayout *gblay = new QVBoxLayout(grpbox);
  gblay->setContentsMargins(6, 3, 6, 6);
  gblay->setSpacing(6);
  QHBoxLayout *hbox = diaHBoxLayout(gblay); 
  
  mGroupSpin = (QSpinBox *)diaLabeledSpin(0, 0., 0., 1., "Group", grpbox,hbox);
  mGroupSpin->setSpecialValueText("None");
  connect(mGroupSpin, SIGNAL(valueChanged(int)), this, 
          SLOT(curGroupChanged(int)));
  mGroupSpin->setToolTip("Select the current object group or turn off "
                "selection");

  mNumberLabel = diaLabel("/99", grpbox, hbox);
  mNameEdit = new QLineEdit(grpbox);
  hbox->addWidget(mNameEdit);
  mNameEdit->setMaxLength(OBJGRP_STRSIZE - 1);
  mNameEdit->setFocusPolicy(Qt::ClickFocus);
  connect(mNameEdit, SIGNAL(returnPressed()), this,
          SLOT(returnPressed()));
  connect(mNameEdit, SIGNAL(textChanged(const QString&)), this,
          SLOT(nameChanged(const QString&)));
  mNameEdit->setToolTip("Enter a name for the current group");

  QSignalMapper *clickMapper = new QSignalMapper(this);
  connect(clickMapper, SIGNAL(mapped(int)), this,
          SLOT(actionButtonClicked(int)));

  // Make the buttons and put in hbox
  for (i = 0; i < OBJLIST_NUMBUTTONS; i++) {

    if (i == 0 || i == 5)
      hbox = diaHBoxLayout(gblay);
    if (i == 7) {
      label = diaLabel("Others:", grpbox, hbox);
      label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    }

    qstr = labels[i];
    mButtons[i] = diaPushButton(LATIN1(qstr), grpbox, hbox);
    clickMapper->setMapping(mButtons[i], i);
    connect(mButtons[i], SIGNAL(clicked()), clickMapper, SLOT(map()));
    mButtons[i]->setToolTip(tips[i]);
  }

  mScroll = new QScrollArea(this);
  layout->addWidget(mScroll);
  mFrame = new QFrame();
  mScroll->setAutoFillBackground(true);
  QPalette palette = mFrame->palette();
  QColor bkg = palette.color(mFrame->backgroundRole());
  diaSetWidgetColor(mScroll->viewport(), bkg);
  mGrid = new QGridLayout(mFrame);
  mGrid->setSpacing(2);
  olistNcol = (numOolistButtons + MAX_LIST_IN_COL - 1) / MAX_LIST_IN_COL;
  nPerCol = (numOolistButtons + olistNcol - 1) / olistNcol;

  // Get a signal mapper, connect to the slot for these buttons
  QSignalMapper *mapper = new QSignalMapper(this);
  connect(mapper, SIGNAL(mapped(int)), this, SLOT(toggleListSlot(int)));
  QSignalMapper *gmapper = new QSignalMapper(this);
  connect(gmapper, SIGNAL(mapped(int)), this, SLOT(toggleGroupSlot(int)));
  
  // Make the buttons, set properties and map them
  for (ob = 0; ob < numOolistButtons; ob++) {
    QHBoxLayout *hLayout = new QHBoxLayout();
    mGrid->addLayout(hLayout, ob % nPerCol, ob / nPerCol);
    groupButtons[ob] = diaCheckBox("", mFrame, hLayout);
    qstr.sprintf("%d: ",ob + 1);
    OolistButtons[ob] = diaCheckBox(LATIN1(qstr), mFrame, hLayout);
    OolistButtons[ob]->setAutoFillBackground(true);
    mapper->setMapping(OolistButtons[ob], ob);
    connect(OolistButtons[ob], SIGNAL(toggled(bool)), mapper, SLOT(map()));
    gmapper->setMapping(groupButtons[ob], ob);
    connect(groupButtons[ob], SIGNAL(toggled(bool)), gmapper, SLOT(map()));
    hLayout->setStretchFactor(OolistButtons[ob], 100);

    // Hide the buttons later after window size is set
    grouping = true;
  }
  mScroll->setWidget(mFrame);

  // Make a line
  QFrame *line = new QFrame(this);
  line->setFrameShape( QFrame::HLine );
  line->setFrameShadow( QFrame::Sunken );
  layout->addWidget(line);

  QHBoxLayout *box = diaHBoxLayout(layout);
  mDoneButton = diaPushButton("Done", this, box);
  connect(mDoneButton, SIGNAL(clicked()), this, SLOT(donePressed()));
  mHelpButton = diaPushButton("Help", this, box);
  connect(mHelpButton, SIGNAL(clicked()), this, SLOT(helpPressed()));
  setFontDependentWidths();
}