.Various changes

git-svn-id: svn://ultimatepp.org/upp/trunk@3332 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-04-10 09:46:32 +00:00
parent 294f9a2dbe
commit 209423b323
10 changed files with 87 additions and 36 deletions

View file

@ -177,6 +177,7 @@ public:
Time GetMin() const { return minval; }
Time GetMax() const { return maxval; }
bool IsNotNull() const { return notnull; }
bool IsSeconds() const { return seconds; }
ConvertTime(Time minval = ToTime(Date::Low()), Time maxval = ToTime(Date::High()), bool notnull = false);
virtual ~ConvertTime();
@ -202,6 +203,8 @@ public:
ConvertString& TrimLeft(bool b = true) { trimleft = b; return *this; }
ConvertString& TrimRight(bool b = true) { trimright = b; return *this; }
ConvertString& TrimBoth(bool b = true) { return TrimLeft(b).TrimRight(b); }
bool IsTrimLeft() const { return trimleft; }
bool IsTrimRight() const { return trimright; }
#ifdef flagSO
ConvertString(int maxlen = INT_MAX, bool notnull = false);

View file

@ -9,7 +9,7 @@ struct Size_ : Moveable< Size_<T> > {
void Clear() { cx = cy = 0; }
bool IsEmpty() const { return cx == 0 || cy == 0; }
void SetNull() { cx = Null; }
void SetNull() { cx = cy = Null; }
bool IsNullInstance() const { return UPP::IsNull(cx); }
Size_& operator+=(Size_ p) { cx += p.cx; cy += p.cy; return *this; }
@ -213,6 +213,7 @@ struct Rect_ : Moveable< Rect_<T> > {
void Clear() { left = top = right = bottom = 0; }
bool IsEmpty() const { return right <= left || bottom <= top; }
void SetNull() { left = top = right = bottom = Null; }
bool IsNullInstance() const;
Pt TopLeft() const { return Pt(left, top); }
@ -369,7 +370,7 @@ struct Rect_ : Moveable< Rect_<T> > {
template <class T>
inline Rect_<T>::Rect_(const Nuller&) {
left = top = right = bottom = Null;
SetNull();
}
template <>

View file

@ -80,7 +80,7 @@ bool ClipboardOpen()
// Win32 has serious race condition problem with clipboard; system or other apps open it
// right after we close it thus blocking us to send more formats
// So the solution is to wait and retry... (mirek, 2011-01-09)
int delay = 1;
int delay = 5;
for(int i = 0; i < 5; i++) {
if(OpenClipboard(utilityHWND))
return true;

View file

@ -458,16 +458,25 @@ void SpinButtons::FrameLayout(Rect& r)
dec.Show();
Size sz = r.Size();
int h = r.Height();
int h2 = h / 2;
int h7 = min(sz.cx / 2, style->width);
inc.SetFrameRect(r.right - h7, r.top, h7, h2);
dec.SetFrameRect(r.right - h7, r.top + h2, h7, r.Height() - h2);
r.right -= h7;
if(onsides) {
dec.SetFrameRect(r.left, r.top, h7, h);
inc.SetFrameRect(r.right - h7, r.top, h7, h);
r.left += h7;
r.right -= h7;
}
else {
int h2 = h / 2;
inc.SetFrameRect(r.right - h7, r.top, h7, h2);
dec.SetFrameRect(r.right - h7, r.top + h2, h7, h - h2);
r.right -= h7;
}
}
void SpinButtons::FrameAddSize(Size& sz)
{
sz.cx += min(sz.cx / 2, 12);
sz.cx += (1 + onsides) * min(sz.cx / 2, style->width);
}
void SpinButtons::FrameAdd(Ctrl& ctrl)
@ -500,6 +509,7 @@ SpinButtons& SpinButtons::SetStyle(const Style& s)
SpinButtons::SpinButtons() {
visible = true;
onsides = false;
inc.NoWantFocus();
dec.NoWantFocus();
style = NULL;

View file

@ -145,8 +145,8 @@ public:
void Set(int ii, const Value& val, bool canselect = true);
void Set(int ii, const Value& val, const Display& display, bool canselect = true);
void Set(const Value& key, const Value& val, const Display& display, bool canselect);
void Set(const Value& key, const Value& val, bool canselect);
void Set(const Value& key, const Value& val, const Display& display, bool canselect = true);
void Set(const Value& key, const Value& val, bool canselect = true);
void Insert(int ii, const Value& val, bool canselect = true);
void Insert(int ii, const Value& val, const Display& display, bool canselect = true);

View file

@ -203,20 +203,25 @@ public:
void Error(bool error = true) { errorbg = error; }
EditField& Password(bool pwd = true) { password = pwd; Finish(); return *this; }
bool IsPassword() const { return password; }
EditField& SetFilter(int (*f)(int)) { filter = f; return *this; }
EditField& SetConvert(const Convert& c) { convert = &c; Refresh(); return *this; }
EditField& SetInactiveConvert(const Convert& c) { inactive_convert = &c; Refresh(); return *this; }
EditField& AutoFormat(bool b = true) { autoformat = b; return *this; }
EditField& NoAutoFormat() { return AutoFormat(false); }
bool IsAutoFormat() const { return autoformat; }
EditField& SetCharset(byte cs) { charset = cs; return *this; }
EditField& SetFont(Font _font);
EditField& ClickSelect(bool b = true) { clickselect = b; return *this; }
bool IsClickSelect() const { return clickselect; }
EditField& InitCaps(bool b = true) { initcaps = b; return *this; }
bool IsInitCaps() const { return initcaps; }
EditField& NullText(const Image& icon, const char *text = t_("(default)"), Color ink = SColorDisabled);
EditField& NullText(const Image& icon, const char *text, Font fnt, Color ink);
EditField& NullText(const char *text = t_("(default)"), Color ink = SColorDisabled);
EditField& NullText(const char *text, Font fnt, Color ink);
EditField& MaxChars(int mc) { maxlen = mc; return *this; }
int GetMaxChars() const { return maxlen; }
EditField& AutoSize(int maxcx = INT_MAX) { autosize = maxcx; Finish(); return *this; }
EditField& NoBackground(bool b = true) { nobg = b; Transparent(); Refresh(); return *this; }
EditField& AlignRight(bool b = true) { alignright = b; Refresh(); return *this; }
@ -250,20 +255,22 @@ public:
EditMinMax& Min(DataType min) { Cv::Min(min); Ctrl::Refresh(); return *this; }
EditMinMax& Max(DataType max) { Cv::Max(max); Ctrl::Refresh(); return *this; }
EditMinMax& MinMax(DataType min, DataType max) { Min(min); return Max(max); }
EditMinMax& NotNull(bool nn = true) { Cv::NotNull(nn); Ctrl::Refresh(); return *this; }
};
template <class DataType, class Cv>
class EditMinMaxNotNull : public EditValue<DataType, Cv> {
template <class DataType, class Base>
class EditMinMaxNotNull : public Base {
public:
EditMinMaxNotNull& operator=(const DataType& t) { EditField::SetData(t); return *this; }
EditMinMaxNotNull() { Cv::NotNull(); }
EditMinMaxNotNull(DataType min, DataType max) { Cv::NotNull(); Cv::MinMax(min, max); }
EditMinMaxNotNull() { Base::NotNull(); }
EditMinMaxNotNull(DataType min, DataType max) { Base::NotNull(); Base::MinMax(min, max); }
EditMinMaxNotNull& Min(DataType min) { Cv::Min(min); Ctrl::Refresh(); return *this; }
EditMinMaxNotNull& Max(DataType max) { Cv::Max(max); Ctrl::Refresh(); return *this; }
EditMinMaxNotNull& NotNull(bool nn = true) { Cv::NotNull(nn); Ctrl::Refresh(); return *this; }
EditMinMaxNotNull& Min(DataType min) { Base::Min(min); return *this; }
EditMinMaxNotNull& Max(DataType max) { Base::Max(max); return *this; }
EditMinMaxNotNull& MinMax(DataType max) { Base::MinMax(min, max); return *this; }
EditMinMaxNotNull& NotNull(bool nn = true) { Base::NotNull(nn); return *this; }
};
typedef EditMinMax<int, ConvertInt> EditInt;
@ -271,10 +278,10 @@ typedef EditMinMax<int64, ConvertInt64> EditInt64;
typedef EditMinMax<double, ConvertDouble> EditDouble;
typedef EditMinMax<Date, ConvertDate> EditDate;
typedef EditMinMax<Time, ConvertTime> EditTime;
typedef EditMinMaxNotNull<int, ConvertInt> EditIntNotNull;
typedef EditMinMaxNotNull<double, ConvertDouble> EditDoubleNotNull;
typedef EditMinMaxNotNull<Date, ConvertDate> EditDateNotNull;
typedef EditMinMaxNotNull<Time, ConvertTime> EditTimeNotNull;
typedef EditMinMaxNotNull<int, EditInt> EditIntNotNull;
typedef EditMinMaxNotNull<double, EditDouble> EditDoubleNotNull;
typedef EditMinMaxNotNull<Date, EditDate> EditDateNotNull;
typedef EditMinMaxNotNull<Time, EditTime> EditTimeNotNull;
class EditString : public EditValue<WString, ConvertString> {
public:
@ -317,9 +324,15 @@ protected:
void Init();
public:
EditIntSpin& ShowSpin(bool s = true) { sb.Show(s); return *this; }
EditIntSpin& SetInc(int _inc) { inc = _inc; return *this; }
int GetInc() const { return inc; }
EditIntSpin& SetInc(int _inc) { inc = _inc; return *this; }
int GetInc() const { return inc; }
EditIntSpin& OnSides(bool b = true) { sb.OnSides(b); return *this; }
bool IsOnSides() const { return sb.IsOnSides(); }
EditIntSpin& ShowSpin(bool s = true) { sb.Show(s); return *this; }
SpinButtons& SpinButtonsObject() { return sb; }
const SpinButtons& SpinButtonsObject() const { return sb; }
EditIntSpin();
EditIntSpin(int min, int max);
@ -338,19 +351,26 @@ protected:
void Init();
private:
SpinButtons spin;
SpinButtons sb;
double inc;
public:
typedef EditDoubleSpin CLASSNAME;
public:
EditDoubleSpin& SetInc(double _inc = 0.1) { inc = _inc; return *this; }
double GetInc() const { return inc; }
EditDoubleSpin& OnSides(bool b = true) { sb.OnSides(b); return *this; }
bool IsOnSides() const { return sb.IsOnSides(); }
EditDoubleSpin& ShowSpin(bool s = true) { sb.Show(s); return *this; }
SpinButtons& SpinButtonsObject() { return sb; }
const SpinButtons& SpinButtonsObject() const { return sb; }
EditDoubleSpin(double inc = 0.1);
EditDoubleSpin(double min, double max, double inc = 0.1);
virtual ~EditDoubleSpin();
EditDoubleSpin& SetInc(double _inc = 0.1) { inc = _inc; return *this; }
double GetInc() const { return inc; }
EditDoubleSpin& ShowSpin(bool s = true) { spin.Show(s); return *this; }
};
class EditDoubleNotNullSpin : public EditDoubleSpin

View file

@ -1103,9 +1103,9 @@ EditDoubleSpin::~EditDoubleSpin() {}
void EditDoubleSpin::Init()
{
AddFrame(spin);
spin.inc.WhenRepeat = spin.inc.WhenAction = THISBACK(Inc);
spin.dec.WhenRepeat = spin.dec.WhenAction = THISBACK(Dec);
AddFrame(sb);
sb.inc.WhenRepeat = sb.inc.WhenAction = THISBACK(Inc);
sb.dec.WhenRepeat = sb.dec.WhenAction = THISBACK(Dec);
}
void EditDoubleSpin::Inc()

View file

@ -138,7 +138,7 @@ public:
};
private:
bool visible;
bool visible, onsides;
const Style *style;
public:
@ -150,6 +150,9 @@ public:
static const Style& StyleDefault();
SpinButtons& SetStyle(const Style& s);
SpinButtons& OnSides(bool b = true) { onsides = b; inc.RefreshParentLayout(); return *this; }
bool IsOnSides() const { return onsides; }
SpinButtons();
virtual ~SpinButtons();
@ -186,11 +189,16 @@ public:
void operator=(int b) { Set(b); }
Option& BlackEdge(bool b = true) { blackedge = b; Refresh(); return *this; }
bool IsBlackEdge() const { return blackedge; }
Option& SwitchImage(bool b = true) { switchimage = b; Refresh(); return *this; }
bool IsSwitchImage() const { return switchimage; }
Option& ThreeState(bool b = true) { threestate = b; notnull = false; return *this; }
bool IsThreeState() const { return threestate; }
Option& ShowLabel(bool b = true) { showlabel = b; Refresh(); return *this; }
bool IsShowLabel() const { return showlabel; }
Option& NotNull(bool nn = true) { notnull = nn; Refresh(); return *this; }
Option& NoNotNull() { return NotNull(false); }
bool IsNotNull() const { return notnull; }
Option();
virtual ~Option();

View file

@ -77,6 +77,8 @@ public:
StaticRect& Background(const Value& chvalue);
StaticRect& Color(class Color c) { Background(c); return *this; }
Value GetBackground() const { return bg; }
StaticRect();
virtual ~StaticRect();
};

View file

@ -176,12 +176,15 @@ public:
Color GetColor(int i) const { return color[i]; }
TextCtrl& UndoSteps(int n) { undosteps = n; Undodo(); return *this; }
int GetUndoSteps() const { return undosteps; }
TextCtrl& ProcessTab(bool b = true) { processtab = b; return *this; }
TextCtrl& NoProcessTab() { return ProcessTab(false); }
TextCtrl& ProcessEnter(bool b = true) { processenter = b; return *this; }
TextCtrl& NoProcessEnter() { return ProcessEnter(false); }
TextCtrl& NoBackground(bool b = true) { nobg = b; Transparent(); Refresh(); return *this; }
bool IsProcessTab() { return processtab; }
bool IsNoBackground() const { return nobg; }
bool IsProcessTab() const { return processtab; }
bool IsProcessEnter() const { return processenter; }
typedef TextCtrl CLASSNAME;
@ -331,10 +334,12 @@ public:
LineEdit& SetFont(Font f);
Font GetFont() const { return font; }
LineEdit& NoHorzScrollbar(bool b = true) { nohbar = b; ScrollIntoCursor(); return *this; }
bool IsNoHorzScrollbar() const { return nohbar; }
LineEdit& ShowTabs(bool st = true) { showtabs = st; Refresh(); return *this; }
bool IsShowTabs() const { return showtabs; }
LineEdit& WithCutLine(bool b) { cutline = b; return *this; }
LineEdit& NoCutLine() { return WithCutLine(false); }
bool IsWithCutLine() const { return cutline; }
LineEdit& SetFilter(int (*f)(int c)) { filter = f; return *this; }
LineEdit& SetScrollBarStyle(const ScrollBar::Style& s) { sb.SetStyle(s); return *this; }
@ -420,12 +425,14 @@ public:
DocEdit& SetFont(Font f) { font = f; RefreshStyle(); return *this; }
DocEdit& SetFilter(int (*f)(int c)) { filter = f; return *this; }
DocEdit& AutoHideSb(bool b = true) { sb.AutoHide(b); return *this; }
bool IsAutoHideSb() const { return sb.IsAutoHide(); }
DocEdit& UpDownLeave(bool u = true) { updownleave = u; return *this; }
DocEdit& NoUpDownLeave() { return UpDownLeave(false); }
bool IsUpDownLeave() const { return updownleave; }
DocEdit& SetScrollBarStyle(const ScrollBar::Style& s) { sb.SetStyle(s); return *this; }
DocEdit& EofLine(bool b = true) { eofline = b; return *this; }
DocEdit& NoEofLine() { return EofLine(false); }
bool IsEofLine() const { return eofline; }
typedef DocEdit CLASSNAME;