Exemplo n.º 1
0
void DataFieldFloat::Dec(void){
  // no keypad, allow user to scroll small values
  if(mFine && (mValue <= 1.0) && (mStep>=0.5) && (mMin>=0.0))
    {
      SetAsFloat(mValue - 0.1);
    }
  else
    SetAsFloat(mValue - mStep*SpeedUp(false));
}
Exemplo n.º 2
0
void DataFieldFloat::Inc(void){
  // no keypad, allow user to scroll small values
  if(mFine && (mValue < 0.95) && (mStep>=0.5) && (mMin>=0.0))
    {
      SetAsFloat(mValue + 0.1);
    }
  else
    SetAsFloat(mValue + mStep*SpeedUp(true));
}
Exemplo n.º 3
0
void
DataFieldFloat::Dec()
{
  // no keypad, allow user to scroll small values
  if (mFine && mValue <= fixed(1) && mStep >= fixed(0.5) &&
      mMin >= fixed(0))
    SetAsFloat(mValue - fixed(1) / 10);
  else
    SetAsFloat(fixed(mValue - mStep * SpeedUp(false)));
}
Exemplo n.º 4
0
void
DataFieldFloat::Inc()
{
  // no keypad, allow user to scroll small values
  if (mFine && mValue < fixed(0.95) && mStep >= fixed(0.5) &&
      mMin >= fixed(0))
    SetAsFloat(mValue + fixed(1) / 10);
  else
    SetAsFloat(fixed(mValue + mStep * SpeedUp(true)));
}
Exemplo n.º 5
0
void
DataFieldFloat::Dec(void)
{
  // no keypad, allow user to scroll small values
  if (mFine && mValue <= fixed_one && mStep >= fixed_half &&
      mMin >= fixed_zero)
    SetAsFloat(mValue - fixed_one / 10);
  else
    SetAsFloat(fixed(mValue - mStep * SpeedUp(false)));
}
Exemplo n.º 6
0
bool DataFieldFloat::SetAsBoolean(bool Value){
  bool res = GetAsBoolean();
  if (res != Value){
    if (Value)
      SetAsFloat(1.0);
    else
      SetAsFloat(0.0);
  }
  return(res);
}
Exemplo n.º 7
0
const TCHAR *
DataFieldFloat::SetAsString(const TCHAR *Value)
{
  const TCHAR *res = GetAsString();
  SetAsFloat(_tcstod(Value, NULL));
  return(res);
}
Exemplo n.º 8
0
void
DataFieldFloat::SetAsString(const TCHAR *Value)
{
  SetAsFloat(ParseString(Value));
}
Exemplo n.º 9
0
void
DataFieldFloat::SetAsInteger(int Value)
{
  SetAsFloat(fixed(Value));
}
Exemplo n.º 10
0
ComboList *
DataFieldFloat::CreateComboListStepping()
{
  // for DataFieldInteger and DataFieldFloat
  // builds ComboPopupItemList[] by calling CreateItem for each item in list
  // sets ComboPopupItemSavedIndex (global)
  // returns ComboPopupItemCount
  const fixed ComboListInitValue(-99999);
  const fixed ComboFloatPrec(0.0001); //rounds float errors to this precision

  fixed fNext = ComboListInitValue;
  fixed fCurrent = ComboListInitValue;
  fixed fLast = ComboListInitValue;
  TCHAR sTemp[ComboPopupITEMMAX];

  int iListCount = 0;
  int iSelectedIndex = -1;
  int iStepDirection = 1; // for integer & float step may be negative
  fixed fBeforeDec = fixed_zero, fAfterDec = fixed_zero, fSavedValue = fixed_zero;

  fNext = ComboListInitValue;
  fCurrent = ComboListInitValue;
  fLast = ComboListInitValue;

  SetDisableSpeedUp(true);
  SetDetachGUI(true); // disable display of inc/dec/change values

  // get step direction for int & float so we can detect if we skipped the value while iterating later
  TCHAR PropertyValueSaved[ComboPopupITEMMAX];
  TCHAR PropertyValueSavedFormatted[ComboPopupITEMMAX];
  CopyString(PropertyValueSaved, false);
  CopyString(PropertyValueSavedFormatted, true);

  fSavedValue = GetAsFixed();
  Inc();
  fBeforeDec = GetAsFixed();
  Dec();
  fAfterDec = GetAsFixed();

  if (fAfterDec < fBeforeDec)
    iStepDirection = 1;
  else
    iStepDirection = -1;

  // reset datafield to top of list (or for large floats, away from selected
  // item so it will be in the middle)
  for (iListCount = 0; iListCount < ComboList::MAX_SIZE / 2; iListCount++) {
    // for floats, go half way down only
    Dec();
    fNext = GetAsFixed();

    if (fabs(fNext - fCurrent) < ComboFloatPrec) // we're at start of the list
      break;
    if (fabs(fNext - fLast) < ComboFloatPrec) // don't repeat Yes/No/etc  (is this needed w/out Bool?)
      break;

    fLast = fCurrent;
    fCurrent = fNext;
  }

  fNext = ComboListInitValue;
  fCurrent = ComboListInitValue;
  fLast = ComboListInitValue;

  fCurrent = GetAsFixed();

  ComboList *combo_list = new ComboList();

  // if we stopped before hitting start of list create <<Less>> value at top of list
  if (iListCount == ComboList::MAX_SIZE / 2) {
    // this data index item is checked on close of dialog
    combo_list->Append(ComboList::Item::PREVIOUS_PAGE, _T("<<More Items>>"));
  }

  // now we're at the beginning of the list, so load forward until end
  for (iListCount = 0; iListCount < ComboList::MAX_SIZE - 3; iListCount++) {
    // stop at LISTMAX-3 b/c it may make an additional item if it's "off step", and
    // potentially two more items for <<More>> and << Less>>

    // test if we've stepped over the selected value which was not a multiple of the "step"
    if (iSelectedIndex == -1) {
      // not found yet
      if (iStepDirection * GetAsFixed() >
          (fSavedValue + ComboFloatPrec * iStepDirection)) {
        // step was too large, we skipped the selected value, so add it now
        iSelectedIndex =
          combo_list->Append(0, PropertyValueSaved,
                             PropertyValueSavedFormatted);
      }
    }

    if (iSelectedIndex == -1 && fabs(fCurrent - fSavedValue) < ComboFloatPrec) {
      // selected item index
      iSelectedIndex = combo_list->size();
    }

    CopyString(sTemp, true); // can't call GetAsString & GetAsStringFormatted together (same output buffer)
    combo_list->Append(0, GetAsString(), sTemp);

    Inc();
    fNext = GetAsFixed();

    if (fabs(fNext - fCurrent) < ComboFloatPrec)
      // we're at start of the list
      break;

    if ((fabs(fNext - fLast) < ComboFloatPrec) && combo_list->size() > 0)
      //we're at the end of the range
      break;

    fLast = fCurrent;
    fCurrent = fNext;
  }

  // if we stopped before hitting end of list create <<More>> value at end of list
  if (iListCount == ComboList::MAX_SIZE - 3) {
    // this data index item is checked on close of dialog
    combo_list->Append(ComboList::Item::NEXT_PAGE, _T("<<More Items>>"));
  }

  SetDisableSpeedUp(false);
  SetDetachGUI(false); // disable dispaly of inc/dec/change values

  if (iSelectedIndex >= 0)
    SetAsFloat(fSavedValue);

  combo_list->ComboPopupItemSavedIndex = iSelectedIndex;

  return combo_list;
}
Exemplo n.º 11
0
void
DataFieldFloat::SetAsString(const TCHAR *Value)
{
  SetAsFloat(fixed(_tcstod(Value, NULL)));
}
Exemplo n.º 12
0
int DataFieldFloat::SetAsInteger(int Value){
  int res = GetAsInteger();
  SetAsFloat(Value);
  return(res);
}