Changeset 253
- Timestamp:
- 11/18/14 17:01:07 (10 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r247 r253 86 86 } 87 87 88 int ParamInterface::getMinMax(int prop, int& minumum, int& maximum, SString& def) 89 { 90 const char* t = type(prop) + 1; 91 while (*t) if (*t == ' ') break; else t++; 92 int ret=sscanf(t, "%d %d", &minumum, &maximum); 93 def=SString::empty(); 94 if (ret==2) 95 { 96 while (*t==' ') t++; 97 for(int skip_fields=2;skip_fields>0;skip_fields--) 98 { 99 while (*t) if (*t == ' ') break; else t++; 100 while (*t==' ') t++; 101 } 102 if (*t) 103 { 104 const char* til=strchr(t,'~'); 105 if (!til) 106 def=SString(t); 107 else 108 { 109 while ((til>t)&&(til[-1]==' ')) til--; 110 def=SString(t,til-t); 111 } 112 } 113 return 3; 114 } 115 else 116 return ret; 117 } 118 88 119 void ParamInterface::setDefault(bool numericonly) 89 120 { … … 125 156 setInt(i, c); 126 157 } 158 break; 159 case 's': if (!numericonly) 160 { 161 int a,b; SString c; 162 getMinMax(i,a,b,c); 163 setString(i,c); 164 } 127 165 break; 128 166 default: if (!numericonly) set(i, ""); … … 770 808 const char* t = pe->type + 1; 771 809 while (*t) if (*t == ' ') break; else t++; 772 paInt a = 0, b = 0;810 int a = 0, b = 0; 773 811 int result = 0; 774 if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2)812 if (sscanf(t, "%d %d", &a, &b) == 2) //using getMinMax would also get default value, which is not needed here 775 813 { 776 814 if ((x.len() > b) && (b > 0)) -
cpp/frams/param/param.h
r247 r253 136 136 @return 0 if min/max/def information is not available */ 137 137 int getMinMax(int prop, double& minumum, double& maximum, double& def); 138 int getMinMax(int prop, int& minumum, int& maximum, SString& def); 138 139 139 140 virtual void setDefault(bool numericonly = false); … … 228 229 protected: 229 230 virtual void *getTarget(int i); 230 virtual ParamEntry *entry(int i) = 0;231 231 const char* myname; 232 232 bool dontcheckchanges; … … 249 249 void* getSelected() { return object; } 250 250 251 virtual ParamEntry *entry(int i) = 0; 251 252 const char *id(int i) { return (i >= getPropCount()) ? 0 : entry(i)->id; } 252 253 const char *name(int i) { return entry(i)->name; }
Note: See TracChangeset
for help on using the changeset viewer.