mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CtrlLib: EditWithSpin option to disable mouse wheel action, Core: String::Find fix
git-svn-id: svn://ultimatepp.org/upp/trunk@15934 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d7a19f05e6
commit
7cd753b5ae
3 changed files with 55 additions and 20 deletions
|
|
@ -41,7 +41,7 @@ int t_find(const char *ptr, int slen, const char *p, int len, int from)
|
|||
int32 p0 = Peek32le(p);
|
||||
int32 p1 = Peek32le(p + len);
|
||||
while(s <= e) {
|
||||
if(Peek32le(s) == p0 && Peek32le(s + len) == p1)
|
||||
if((int32)Peek32le(s) == p0 && (int32)Peek32le(s + len) == p1)
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ int t_find(const char *ptr, int slen, const char *p, int len, int from)
|
|||
if(len == 4) {
|
||||
int32 p0 = Peek32le(p);
|
||||
while(s <= e) {
|
||||
if(Peek32le(s) == p0)
|
||||
if((int32)Peek32le(s) == p0)
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ int t_find(const char *ptr, int slen, const char *p, int len, int from)
|
|||
int16 p0 = Peek16le(p);
|
||||
char p1 = p[2];
|
||||
while(s <= e) {
|
||||
if(Peek16le(s) == p0 && s[2] == p1)
|
||||
if((int16)Peek16le(s) == p0 && s[2] == p1)
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ int t_find(const char *ptr, int slen, const char *p, int len, int from)
|
|||
if(len == 2) {
|
||||
int16 p0 = Peek16le(p);
|
||||
while(s <= e) {
|
||||
if(Peek16le(s) == p0)
|
||||
if((int16)Peek16le(s) == p0)
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
|
|
@ -93,21 +93,21 @@ int t_find(const char *ptr, int slen, const char *p, int len, int from)
|
|||
len -= 8;
|
||||
int64 p1 = Peek64le(p + len);
|
||||
while(s <= e) {
|
||||
if(Peek64le(s) == p0 && Peek64le(s + len) == p1)
|
||||
if((int64)Peek64le(s) == p0 && (int64)Peek64le(s + len) == p1)
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
}
|
||||
else
|
||||
while(s <= e) {
|
||||
if(Peek64le(s) == p0 && equal_back_8(s, p, len))
|
||||
if((int64)Peek64le(s) == p0 && equal_back_8(s, p, len))
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
#else
|
||||
int32 p0 = Peek32le(p);
|
||||
while(s <= e) {
|
||||
if(Peek32le(s) == p0 && equal_back_4(s, p, len))
|
||||
if((int32)Peek32le(s) == p0 && equal_back_4(s, p, len))
|
||||
return (int)(s - ptr);
|
||||
s += step;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,6 +381,8 @@ private:
|
|||
SpinButtons sb;
|
||||
IncType inc;
|
||||
bool roundfrommin;
|
||||
bool mousewheel = true;
|
||||
bool keys = true;
|
||||
|
||||
typedef WithSpin CLASSNAME;
|
||||
public:
|
||||
|
|
@ -395,6 +397,12 @@ public:
|
|||
bool IsSpinVisible() const { return sb.IsVisible(); }
|
||||
|
||||
WithSpin& RoundFromMin(bool b = true) { roundfrommin = b; return *this; }
|
||||
|
||||
WithSpin& MouseWheelSpin(bool b = true){ mousewheel = b; return *this; }
|
||||
WithSpin& NoMouseWheelSpin() { return MouseWheelSpin(false); }
|
||||
|
||||
WithSpin& KeySpin(bool b = true) { keys = b; return *this; }
|
||||
WithSpin& NoKeySpin() { return KeySpin(false); }
|
||||
|
||||
SpinButtons& SpinButtonsObject() { return sb; }
|
||||
const SpinButtons& SpinButtonsObject() const { return sb; }
|
||||
|
|
@ -489,13 +497,15 @@ void WithSpin<DataType, Base, IncType>::Dec()
|
|||
template <class DataType, class Base, class IncType>
|
||||
bool WithSpin<DataType, Base, IncType>::Key(dword key, int repcnt)
|
||||
{
|
||||
if(key == K_UP) {
|
||||
Inc();
|
||||
return true;
|
||||
}
|
||||
if(key == K_DOWN) {
|
||||
Dec();
|
||||
return true;
|
||||
if(keys) {
|
||||
if(key == K_UP) {
|
||||
Inc();
|
||||
return true;
|
||||
}
|
||||
if(key == K_DOWN) {
|
||||
Dec();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Base::Key(key, repcnt);
|
||||
}
|
||||
|
|
@ -503,10 +513,12 @@ bool WithSpin<DataType, Base, IncType>::Key(dword key, int repcnt)
|
|||
template <class DataType, class Base, class IncType>
|
||||
void WithSpin<DataType, Base, IncType>::MouseWheel(Point, int zdelta, dword)
|
||||
{
|
||||
if(zdelta < 0)
|
||||
Dec();
|
||||
else
|
||||
Inc();
|
||||
if(mousewheel) {
|
||||
if(zdelta < 0)
|
||||
Dec();
|
||||
else
|
||||
Inc();
|
||||
}
|
||||
}
|
||||
|
||||
typedef WithSpin<int, EditInt> EditIntSpin;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "WithSpin template and Value editors with spin buttons";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,2#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "WithSpin template and Value editors with spin buttons";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}%EN-US
|
||||
[ {{10000@(113.42.0) [s0; [*@7;4 WithSpin]]}}&]
|
||||
[s3;%- &]
|
||||
|
|
@ -61,7 +61,7 @@ ool]_[*@3 s]_`=_[@(0.0.255) true])&]
|
|||
[s4; &]
|
||||
[s5;:WithSpin`:`:IsSpinVisible`(`)const:%- [@(0.0.255) bool]_[* IsSpinVisible]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2; Returns true if spin buttes are shown.&]
|
||||
[s2; Returns true if spin buttons are shown.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:WithSpin`:`:RoundFromMin`(bool`):%- [_^Upp`:`:WithSpin^ WithSpin][@(0.0.255) `&
|
||||
|
|
@ -72,6 +72,29 @@ value is 3, going up from the minimum goes through values 3,
|
|||
5, 10, ..., which when RoundFromMin is active, it goes through
|
||||
3, 8, 13, ...&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:WithSpin`:`:MouseWheelSpin`(bool`):%- [_^Upp`:`:WithSpin^ WithSpin][@(0.0.255) `&
|
||||
]_[* MouseWheelSpin]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&]
|
||||
[s2; If active, the value can be altered by mouse wheel `- rolling
|
||||
the wheel is equivalent to pushing up/down arrows. Default is
|
||||
active.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:WithSpin`:`:NoMouseWheelSpin`(`):%- [_^Upp`:`:WithSpin^ WithSpin][@(0.0.255) `&
|
||||
]_[* NoMouseWheelSpin]()&]
|
||||
[s2; Same as MouseWheelSpin(false).&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:WithSpin`:`:KeySpin`(bool`):%- [_^Upp`:`:WithSpin^ WithSpin][@(0.0.255) `&]_[* K
|
||||
eySpin]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&]
|
||||
[s2; If active, the value can be altered with Up and Down keys. Default
|
||||
is active.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:WithSpin`:`:NoKeySpin`(`):%- [_^Upp`:`:WithSpin^ WithSpin][@(0.0.255) `&]_[* No
|
||||
KeySpin]()&]
|
||||
[s2; Same as KeySpin(false).&]
|
||||
[s3;%- &]
|
||||
[s4; &]
|
||||
[s5;:WithSpin`:`:SpinButtonsObject`(`):%- [_^SpinButtons^ SpinButtons][@(0.0.255) `&]_[* Sp
|
||||
inButtonsObject]()&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue