SASC-NG
DVBSoftCAM

cMenuEditIntItem Class Reference

#include <menuitems.h>

Inheritance diagram for cMenuEditIntItem:

List of all members.

Public Member Functions

 cMenuEditIntItem (const char *Name, int *Value, int Min=0, int Max=INT_MAX, const char *MinString=NULL, const char *MaxString=NULL)
virtual eOSState ProcessKey (eKeys Key)

Protected Member Functions

virtual void Set (void)

Protected Attributes

int * value
int min
int max
const char * minString
const char * maxString

Detailed Description

Definition at line 26 of file menuitems.h.


Constructor & Destructor Documentation

cMenuEditIntItem::cMenuEditIntItem ( const char *  Name,
int *  Value,
int  Min = 0,
int  Max = INT_MAX,
const char *  MinString = NULL,
const char *  MaxString = NULL 
)

Definition at line 40 of file menuitems.cpp.

References max, maxString, min, minString, Set(), and value.

:cMenuEditItem(Name)
{
  value = Value;
  min = Min;
  max = Max;
  minString = MinString;
  maxString = MaxString;
  if (*value < min)
     *value = min;
  else if (*value > max)
     *value = max;
  Set();
}

Member Function Documentation

eOSState cMenuEditIntItem::ProcessKey ( eKeys  Key) [virtual]

Reimplemented from cOsdItem.

Reimplemented in cMenuEditChanItem, cMenuEditTranItem, and cMenuEditCapItem.

Definition at line 68 of file menuitems.cpp.

References cOsdItem::fresh, k0, k9, kLeft, kNone, kRight, max, min, NORMALKEY, osContinue, osUnknown, Set(), and value.

{
  eOSState state = cMenuEditItem::ProcessKey(Key);

  if (state == osUnknown) {
     int newValue = *value;
     Key = NORMALKEY(Key);
     switch (Key) {
       case kNone: break;
       case k0 ... k9:
            if (fresh) {
               *value = 0;
               fresh = false;
               }
            newValue = *value * 10 + (Key - k0);
            break;
       case kLeft: // TODO might want to increase the delta if repeated quickly?
            newValue = *value - 1;
            fresh = true;
            break;
       case kRight:
            newValue = *value + 1;
            fresh = true;
            break;
       default:
            if (*value < min) { *value = min; Set(); }
            if (*value > max) { *value = max; Set(); }
            return state;
       }
     if ((!fresh || min <= newValue) && newValue <= max) {
        *value = newValue;
        Set();
        }
     state = osContinue;
     }
  return state;
}
void cMenuEditIntItem::Set ( void  ) [protected, virtual]

Reimplemented from cOsdItem.

Reimplemented in cMenuEditBoolItem, cMenuEditBitItem, cMenuEditStraItem, cMenuEditChanItem, and cMenuEditCapItem.

Definition at line 55 of file menuitems.cpp.

References max, maxString, min, minString, cMenuEditItem::SetValue(), and value.

Referenced by cMenuEditIntItem(), and ProcessKey().

{
  if (minString && *value == min)
     SetValue(minString);
  else if (maxString && *value == max)
     SetValue(maxString);
  else {
     char buf[16];
     snprintf(buf, sizeof(buf), "%d", *value);
     SetValue(buf);
     }
}

Member Data Documentation

int cMenuEditIntItem::max [protected]

Definition at line 29 of file menuitems.h.

Referenced by cMenuEditIntItem(), ProcessKey(), and Set().

const char * cMenuEditIntItem::maxString [protected]

Definition at line 30 of file menuitems.h.

Referenced by cMenuEditIntItem(), and Set().

int cMenuEditIntItem::min [protected]

Definition at line 29 of file menuitems.h.

Referenced by cMenuEditIntItem(), ProcessKey(), and Set().

const char* cMenuEditIntItem::minString [protected]

Definition at line 30 of file menuitems.h.

Referenced by cMenuEditIntItem(), and Set().

int* cMenuEditIntItem::value [protected]

Reimplemented in cMenuEditBitItem.

Definition at line 28 of file menuitems.h.

Referenced by cMenuEditIntItem(), ProcessKey(), cMenuEditCapItem::Set(), cMenuEditBoolItem::Set(), and Set().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines