Beispiel #1
0
void MAS::SpinBox::HandleEvent(Widget& obj, int msg, intptr_t arg1, intptr_t arg2) {
   if (msg == MSG_ACTIVATE) {
      if (obj == bUp) {
         double oldpos = pos;
         SetPosition(editBox.GetDouble());
         Increment();
         if (oldpos != pos) {
            PlaySample(Skin::SAMPLE_SCROLL);
            GetParent()->HandleEvent(*this, MSG_SCROLL, (intptr_t)GetIncrement());
         }
      }
      else if (obj == bDown) {
         double oldpos = pos;
         SetPosition(editBox.GetDouble());
         Decrement();
         if (oldpos != pos) {
            PlaySample(Skin::SAMPLE_SCROLL);
            GetParent()->HandleEvent(*this, MSG_SCROLL, -(intptr_t)GetIncrement());
         }
      }
      else {
         GetParent()->HandleEvent(*this, callbackID >= 0 ? callbackID : MSG_ACTIVATE);
      }
   }
   else if (msg == MSG_UCHAR && obj == editBox) {
      if (integerMode) {
         SetPosition(editBox.GetInt());
      }
      else {
         ScrollObject::SetPosition(editBox.GetDouble());
      }
   }
}
Beispiel #2
0
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	UpdateValues();
	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Current value"), GetLastValue());
		properties->AppendItem(_("Next value"), GetNextValue());
		properties->AppendItem(_("Minimum"), GetMinValue());
		properties->AppendItem(_("Maximum"), GetMaxValue());
		properties->AppendItem(_("Increment"), GetIncrement());
		properties->AppendItem(_("Cache"), GetCacheValue());
		properties->AppendYesNoItem(_("Cycled?"), GetCycled());
		properties->AppendYesNoItem(_("Called?"), GetCalled());
		properties->AppendYesNoItem(_("System sequence?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}
Beispiel #3
0
wxString pgSequence::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		UpdateValues();
		sql = wxT("-- Sequence: ") + GetQuotedFullIdentifier() + wxT("\n\n")
		      + wxT("-- DROP SEQUENCE ") + GetQuotedFullIdentifier() + wxT(";")
		      + wxT("\n\nCREATE SEQUENCE ") + GetQuotedFullIdentifier()
		      + wxT("\n  INCREMENT ") + GetIncrement().ToString()
		      + wxT("\n  MINVALUE ") + GetMinValue().ToString()
		      + wxT("\n  MAXVALUE ") + GetMaxValue().ToString()
		      + wxT("\n  START ") + GetLastValue().ToString()
		      + wxT("\n  CACHE ") + GetCacheValue().ToString();
		if (GetCycled())
			sql += wxT("\n  CYCLE");
		sql += wxT(";\n")
		       + GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier());

		if (!GetConnection()->BackendMinimumVersion(8, 2))
			sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier());
		else
			sql += GetGrant(wxT("rwU"), wxT("TABLE ") + GetQuotedFullIdentifier());

		sql += GetCommentSql();

		if (GetConnection()->BackendMinimumVersion(9, 1))
			sql += GetSeqLabelsSql();
	}

	return sql;
}
/**
 * The spin event is received after the value has changed, making it difficult to set the increment
 * correctly.  Here we detect that the value has not changed correctly and fix it.
 */
void OddsSpinCtrl::AdjustValue() {
    double value = GetValue();
    std::map<unsigned, std::pair<double, double> >::const_iterator it;
    for (it = ranges.begin(); it != ranges.end(); ++it) {
        if (DoubleEquals(previousValue, it->first)) {
            if (DoubleEquals(value, it->first - it->second.second)) {
                // eg previous value == 2, new value 1.98, adjust to 1.99
                value = it->first - it->second.first;
            } else if (DoubleEquals(value, it->first + it->second.first)) {
                // eg previous value == 2, new value 2.01, adjust to 2.02
                value = it->first + it->second.second;
            }
        }
    }
    // snap to nearest tick
    value = round(value / GetIncrement()) * GetIncrement();
    if (!DoubleEquals(value, GetValue())) {
        SetValue(value);
    }
}
// Use this function when you want to set the scroll position via the position
// of the scrollbar thumb, e.g. when dragging the slider. This function scrolls
// the content in such a way that thumbRect.x/.y becomes aNewThumbPos.
void
nsSliderFrame::SetCurrentThumbPosition(nsIContent* aScrollbar, nscoord aNewThumbPos,
                                       PRBool aIsSmooth, PRBool aImmediateRedraw, PRBool aMaySnap)
{
  nsRect crect;
  GetClientRect(crect);
  nscoord offset = IsHorizontal() ? crect.x : crect.y;
  PRInt32 newPos = NSToIntRound((aNewThumbPos - offset) / mRatio);
  
  if (aMaySnap && mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::snap,
                                        nsGkAtoms::_true, eCaseMatters)) {
    // If snap="true", then the slider may only be set to min + (increment * x).
    // Otherwise, the slider may be set to any positive integer.
    PRInt32 increment = GetIncrement(aScrollbar);
    newPos = NSToIntRound(newPos / float(increment)) * increment;
  }
  
  SetCurrentPosition(aScrollbar, newPos, aIsSmooth, aImmediateRedraw);
}
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
    UpdateValues();
    if (properties)
    {
        CreateListColumns(properties);

        properties->AppendItem(_("Name"), GetName());
        properties->AppendItem(_("OID"), GetOid());
        properties->AppendItem(_("Owner"), GetOwner());
        properties->AppendItem(_("ACL"), GetAcl());
        properties->AppendItem(_("Current value"), GetLastValue());
        properties->AppendItem(_("Minimum"), GetMinValue());
        properties->AppendItem(_("Maximum"), GetMaxValue());
        properties->AppendItem(_("Increment"), GetIncrement());
        properties->AppendItem(_("Cache"), GetCacheValue());
        properties->AppendItem(_("Cycled?"), GetCycled());
        properties->AppendItem(_("Called?"), GetCalled());
        properties->AppendItem(_("System sequence?"), GetSystemObject());
        properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
    }
}