mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
bazaar: ValueCtrl: using Instancer for default Value editors definition, uses WhenEnterAction; CtrlProp: major handling restructure, CtrlMover
git-svn-id: svn://ultimatepp.org/upp/trunk@3100 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
feb51df79f
commit
ed5507be90
24 changed files with 534 additions and 370 deletions
64
bazaar/CtrlMover/CtrlMover.cpp
Normal file
64
bazaar/CtrlMover/CtrlMover.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "CtrlMover.h"
|
||||||
|
|
||||||
|
void CtrlMover::OnCtrlLeft(Ctrl& c, Point p, dword keyflags)
|
||||||
|
{
|
||||||
|
if(&c == &rc) return;
|
||||||
|
if(&c == this) return;
|
||||||
|
Visit(c);
|
||||||
|
Action();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::OnRectChange()
|
||||||
|
{
|
||||||
|
if(IsEmpty()) return;
|
||||||
|
Get().SetRect(rc.GetData());
|
||||||
|
Action();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::OnMissed(Point p, dword keyflags)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
Action();
|
||||||
|
LeftDown(p, keyflags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::Updated()
|
||||||
|
{
|
||||||
|
Reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::State(int reason)
|
||||||
|
{
|
||||||
|
if(reason != ENABLE) return;
|
||||||
|
if(!IsEnabled()) Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::Visit(Ctrl& c)
|
||||||
|
{
|
||||||
|
rc.Remove();
|
||||||
|
Add(rc.SizePos());
|
||||||
|
V::Visit(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::Clear()
|
||||||
|
{
|
||||||
|
V::Clear();
|
||||||
|
rc.Remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtrlMover::Reload()
|
||||||
|
{
|
||||||
|
V::Reload();
|
||||||
|
rc.SetData(Get().GetRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
CtrlMover::CtrlMover()
|
||||||
|
{
|
||||||
|
WhenLeftDown = THISBACK(OnCtrlLeft);
|
||||||
|
|
||||||
|
rcst = RectCtrl::StyleDefault();
|
||||||
|
rcst.rectcol = Null;
|
||||||
|
rc.SetStyle(rcst);
|
||||||
|
rc <<= THISBACK(OnRectChange);
|
||||||
|
rc.WhenMissed = THISBACK(OnMissed);
|
||||||
|
}
|
||||||
39
bazaar/CtrlMover/CtrlMover.h
Normal file
39
bazaar/CtrlMover/CtrlMover.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef _CtrlMover_CtrlMover_h
|
||||||
|
#define _CtrlMover_CtrlMover_h
|
||||||
|
|
||||||
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
#include <CtrlFinder/CtrlFinder.h>
|
||||||
|
#include <RectCtrl/RectCtrl.h>
|
||||||
|
#include <Gen/Gen.h>
|
||||||
|
|
||||||
|
//the control mover is a layer on top of other ctrl surfaces, and can grab their Ctrls to move them.
|
||||||
|
|
||||||
|
class CtrlMover : public CtrlFinder, public Visiting<Ctrl>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef CtrlMover CLASSNAME;
|
||||||
|
typedef Visiting<Ctrl> V;
|
||||||
|
CtrlMover();
|
||||||
|
|
||||||
|
virtual void Visit(Ctrl& c);
|
||||||
|
virtual void Clear();
|
||||||
|
virtual void Reload();
|
||||||
|
|
||||||
|
virtual void State(int reason);
|
||||||
|
virtual void Updated();
|
||||||
|
|
||||||
|
void OnCtrlLeft(Ctrl& c, Point p, dword keyflags);
|
||||||
|
void OnMissed(Point p, dword keyflags);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnRectChange();
|
||||||
|
|
||||||
|
RectCtrl rc;
|
||||||
|
RectCtrl::Style rcst;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
13
bazaar/CtrlMover/CtrlMover.upp
Normal file
13
bazaar/CtrlMover/CtrlMover.upp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
uses
|
||||||
|
CtrlLib,
|
||||||
|
CtrlFinder,
|
||||||
|
RectCtrl,
|
||||||
|
Gen;
|
||||||
|
|
||||||
|
file
|
||||||
|
CtrlMover.h,
|
||||||
|
CtrlMover.cpp;
|
||||||
|
|
||||||
|
mainconfig
|
||||||
|
"" = "GUI MT";
|
||||||
|
|
||||||
7
bazaar/CtrlMover/init
Normal file
7
bazaar/CtrlMover/init
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef _CtrlMover_icpp_init_stub
|
||||||
|
#define _CtrlMover_icpp_init_stub
|
||||||
|
#include "CtrlLib/init"
|
||||||
|
#include "CtrlFinder/init"
|
||||||
|
#include "RectCtrl/init"
|
||||||
|
#include "Gen/init"
|
||||||
|
#endif
|
||||||
|
|
@ -1,170 +1,7 @@
|
||||||
#ifndef _CtrlProp_CtrlProp_h
|
#ifndef _CtrlProp_CtrlProp_h_
|
||||||
#define _CtrlProp_CtrlProp_h
|
#define _CtrlProp_CtrlProp_h_
|
||||||
|
|
||||||
#include <CtrlCore/CtrlCore.h>
|
|
||||||
using namespace Upp;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROPGET = 0,
|
|
||||||
PROPSET = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class C> struct GetTyper{
|
|
||||||
typedef bool (*H)(const C&, Value&);
|
|
||||||
typedef Gate2<const C&, Value&> Handler;
|
|
||||||
static ArrayMap<String, Handler>& map() { static ArrayMap<String, Handler> _; return _; }
|
|
||||||
};
|
|
||||||
template<class C> struct SetTyper{
|
|
||||||
typedef bool (*H)(C&, const Value&);
|
|
||||||
typedef Gate2<C&, const Value&> Handler;
|
|
||||||
static ArrayMap<String, Handler>& map() { static ArrayMap<String, Handler> _; return _; }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef Gate4<Ctrl&, const String&, Value&, int> ParamHandler;
|
|
||||||
VectorMap<String, ParamHandler>& pmap();
|
|
||||||
#define REGISTERPROPS(CTRL) pmap().GetAdd(String(typeid(CTRL).name())) = callback(&GetSetProp##CTRL)
|
|
||||||
|
|
||||||
void AddToValueArray(Value& v, const Vector<String>& k);
|
|
||||||
bool GetSetPropRecurseDone(Ctrl& c, const String& p, Value& v, int f);
|
|
||||||
|
|
||||||
#define DEC_CTRL_PROPERTIES(CTRL) \
|
|
||||||
bool GetSetProp##CTRL(Ctrl& c, const String& p, Value& v, int f) \
|
|
||||||
|
|
||||||
|
|
||||||
#define CTRL_PROPERTIES(CTRL, BASE) \
|
|
||||||
DEC_CTRL_PROPERTIES(CTRL); \
|
|
||||||
DEC_CTRL_PROPERTIES(BASE); \
|
|
||||||
INITBLOCK { REGISTERPROPS(CTRL); } \
|
|
||||||
DEC_CTRL_PROPERTIES(CTRL) \
|
|
||||||
{ \
|
|
||||||
typedef CTRL _CTRL_; \
|
|
||||||
if(0) { __base: return GetSetProp##BASE(c,p,v,f); } \
|
|
||||||
ONCELOCK { \
|
|
||||||
|
|
||||||
|
|
||||||
#define END_CTRL_PROPERTIES \
|
|
||||||
} \
|
|
||||||
_CTRL_* pc = dynamic_cast<_CTRL_*>(&c); \
|
|
||||||
if(!pc) return false; \
|
|
||||||
_CTRL_& o = *pc; \
|
|
||||||
\
|
|
||||||
ArrayMap<String, SetTyper<_CTRL_>::Handler>& s = SetTyper<_CTRL_>::map(); \
|
|
||||||
ArrayMap<String, GetTyper<_CTRL_>::Handler>& g = GetTyper<_CTRL_>::map(); \
|
|
||||||
if(f&PROPSET) \
|
|
||||||
{ \
|
|
||||||
int i = s.Find(p); if(i>=0) return s[i](o, v); \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
int i = g.Find(p); if(i>=0) return g[i](o, v); \
|
|
||||||
if(p == "listset") AddToValueArray(v, s.GetKeys()); \
|
|
||||||
else if(p == "listget") AddToValueArray(v, g.GetKeys()); \
|
|
||||||
} \
|
|
||||||
goto __base; \
|
|
||||||
} \
|
|
||||||
|
|
||||||
|
|
||||||
#define EXT_PROPERTY_SET(CTRL, name, fset) \
|
|
||||||
SetTyper<CTRL>::map().GetAdd(name) = callback((SetTyper<CTRL>::H)&fset); \
|
|
||||||
|
|
||||||
|
|
||||||
#define EXT_PROPERTY_GET(CTRL, name, fget) \
|
|
||||||
GetTyper<CTRL>::map().GetAdd(name) = callback((GetTyper<CTRL>::H)&fget); \
|
|
||||||
|
|
||||||
|
|
||||||
#define EXT_PROPERTY(CTRL, name, fset, fget) \
|
|
||||||
EXT_PROPERTY_SET(CTRL, name, fset) \
|
|
||||||
EXT_PROPERTY_GET(CTRL, name, fget) \
|
|
||||||
|
|
||||||
|
|
||||||
#define PROPERTY_SET(name, fset) \
|
|
||||||
EXT_PROPERTY_SET(_CTRL_, name, fset) \
|
|
||||||
|
|
||||||
|
|
||||||
#define PROPERTY_GET(name, fset) \
|
|
||||||
EXT_PROPERTY_GET(_CTRL_, name, fset) \
|
|
||||||
|
|
||||||
|
|
||||||
#define PROPERTY(name, fset, fget) \
|
|
||||||
EXT_PROPERTY_SET(_CTRL_, name, fset) \
|
|
||||||
EXT_PROPERTY_GET(_CTRL_, name, fget) \
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define EXT_UNPROPERTY_SET(CTRL, name) \
|
|
||||||
SetTyper<CTRL>::map().RemoveKey(name); \
|
|
||||||
|
|
||||||
#define EXT_UNPROPERTY_GET(CTRL, name) \
|
|
||||||
GetTyper<CTRL>::map().RemoveKey(name); \
|
|
||||||
|
|
||||||
#define EXT_UNPROPERTY(CTRL, name) \
|
|
||||||
EXT_UNPROPERTY_SET(CTRL, name) \
|
|
||||||
EXT_UNPROPERTY_GET(CTRL, name) \
|
|
||||||
|
|
||||||
|
|
||||||
#define UNPROPERTY_SET(name, fset) \
|
|
||||||
EXT_UNPROPERTY_SET(_CTRL_, name, fset) \
|
|
||||||
|
|
||||||
|
|
||||||
#define UNPROPERTY_GET(name, fset) \
|
|
||||||
EXT_UNPROPERTY_GET(_CTRL_, name, fset) \
|
|
||||||
|
|
||||||
|
|
||||||
#define UNPROPERTY(name, fset, fget) \
|
|
||||||
EXT_UNPROPERTY_SET(_CTRL_, name, fset) \
|
|
||||||
EXT_UNPROPERTY_GET(_CTRL_, name, fget) \
|
|
||||||
|
|
||||||
|
|
||||||
bool Property(Ctrl& c, const String& p, Value& v, int f);
|
|
||||||
inline bool SetProperty(Ctrl& c, const String& p, const Value& v) { return Property(c,p,const_cast<Value&>(v),PROPSET); }
|
|
||||||
inline bool GetProperty(const Ctrl& c, const String& p, Value& v) { return Property(const_cast<Ctrl&>(c),p,v,PROPGET); }
|
|
||||||
|
|
||||||
//helpers for editing
|
|
||||||
|
|
||||||
#include <CtrlLib/CtrlLib.h>
|
|
||||||
using namespace Upp;
|
|
||||||
|
|
||||||
#include <LogPosCtrl/LogPosCtrl.h>
|
|
||||||
#include <ValueCtrl/ValueCtrl.h>
|
|
||||||
|
|
||||||
VectorMap<String, int> BidirProps(Ctrl& c);
|
|
||||||
|
|
||||||
#define LAYOUTFILE <CtrlProp/CtrlPropEdit.lay>
|
|
||||||
#include <CtrlCore/lay.h>
|
|
||||||
|
|
||||||
class PropList : public WithPropListLay<PopUpC>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef PropList CLASSNAME;
|
|
||||||
PropList();
|
|
||||||
|
|
||||||
void Evaluate(Ctrl& e);
|
|
||||||
void PopUp(Ctrl* owner, Ctrl& e) { Evaluate(e); PopUpC::PopUp(owner); }
|
|
||||||
};
|
|
||||||
|
|
||||||
class PropEdit : public WithPropEditLay<PopUpC>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef PropEdit CLASSNAME;
|
|
||||||
PropEdit();
|
|
||||||
|
|
||||||
virtual void Deactivate() {} //let other popups open
|
|
||||||
|
|
||||||
void Evaluate(Ctrl& e);
|
|
||||||
void PopUp(Ctrl* owner, Ctrl& e) { Evaluate(e); PopUpC::PopUp(owner); }
|
|
||||||
|
|
||||||
virtual void Rejector();
|
|
||||||
virtual void Acceptor();
|
|
||||||
|
|
||||||
public:
|
|
||||||
void OnUpdateRow();
|
|
||||||
|
|
||||||
Ctrl* pe;
|
|
||||||
ArrayMap<String, Tuple2<bool, Value> > vsav;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "CtrlPropCommon.h"
|
||||||
|
#include "CtrlPropEdit.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _CtrlProp_CtrlProp_hpp
|
|
||||||
#define _CtrlProp_CtrlProp_hpp
|
|
||||||
|
|
||||||
#include "CtrlProp.h"
|
|
||||||
|
|
||||||
//type specific maps for the handlers
|
|
||||||
template<class T> ArrayMap<String, Gate2<T&, const Value&> >& wpmap() { static ArrayMap<String, Gate2<T&, const Value&> > _; return _; }
|
|
||||||
template<class T> ArrayMap<String, Callback2<const T&, Value&> >& rpmap() { static ArrayMap<String, Callback2<const T&, Value&> > _; return _; }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -3,13 +3,16 @@ description "Ctrl properties editing in a common interface, see CtrlPropTest\377
|
||||||
uses
|
uses
|
||||||
CtrlLib,
|
CtrlLib,
|
||||||
LogPosCtrl,
|
LogPosCtrl,
|
||||||
ValueCtrl;
|
ValueCtrl,
|
||||||
|
Gen;
|
||||||
|
|
||||||
file
|
file
|
||||||
CtrlProp.h,
|
CtrlPropCommon.h,
|
||||||
CtrlProp.cpp,
|
CtrlPropCommon.cpp,
|
||||||
|
CtrlPropEdit.h,
|
||||||
CtrlPropEdit.cpp,
|
CtrlPropEdit.cpp,
|
||||||
CtrlPropEdit.lay,
|
CtrlPropEdit.lay,
|
||||||
|
CtrlProp.h,
|
||||||
Props readonly separator,
|
Props readonly separator,
|
||||||
Ctrl.cpp,
|
Ctrl.cpp,
|
||||||
PushCtrl.cpp,
|
PushCtrl.cpp,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "CtrlProp.h"
|
#include "CtrlPropCommon.h"
|
||||||
|
|
||||||
void AddToValueArray(Value& v, const Vector<String>& k)
|
void AddToValueArray(Value& v, const Vector<String>& k)
|
||||||
{
|
{
|
||||||
|
|
@ -23,6 +23,7 @@ VectorMap<String, ParamHandler>& pmap()
|
||||||
bool Property(Ctrl& c, const String& p, Value& v, int f)
|
bool Property(Ctrl& c, const String& p, Value& v, int f)
|
||||||
{
|
{
|
||||||
int i = pmap().Find(String(typeid(c).name()));
|
int i = pmap().Find(String(typeid(c).name()));
|
||||||
|
if(i<0) i = pmap().Find(String(typeid(Ctrl).name()));
|
||||||
if(i<0) return false;
|
if(i<0) return false;
|
||||||
return pmap()[i](c,p,v,f);
|
return pmap()[i](c,p,v,f);
|
||||||
}
|
}
|
||||||
124
bazaar/CtrlProp/CtrlPropCommon.h
Normal file
124
bazaar/CtrlProp/CtrlPropCommon.h
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
#ifndef _CtrlProp_CtrlPropCommon_h
|
||||||
|
#define _CtrlProp_CtrlPropCommon_h
|
||||||
|
|
||||||
|
#include <CtrlCore/CtrlCore.h>
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROPGET = 0,
|
||||||
|
PROPSET = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class C> struct GetTyper{
|
||||||
|
typedef bool (*H)(const C&, Value&);
|
||||||
|
typedef Gate2<const C&, Value&> Handler;
|
||||||
|
static ArrayMap<String, Handler>& map() { static ArrayMap<String, Handler> _; return _; }
|
||||||
|
};
|
||||||
|
template<class C> struct SetTyper{
|
||||||
|
typedef bool (*H)(C&, const Value&);
|
||||||
|
typedef Gate2<C&, const Value&> Handler;
|
||||||
|
static ArrayMap<String, Handler>& map() { static ArrayMap<String, Handler> _; return _; }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Gate4<Ctrl&, const String&, Value&, int> ParamHandler;
|
||||||
|
VectorMap<String, ParamHandler>& pmap();
|
||||||
|
#define REGISTERPROPS(CTRL) pmap().GetAdd(String(typeid(CTRL).name())) = callback(&GetSetProp##CTRL)
|
||||||
|
|
||||||
|
void AddToValueArray(Value& v, const Vector<String>& k);
|
||||||
|
bool GetSetPropRecurseDone(Ctrl& c, const String& p, Value& v, int f);
|
||||||
|
|
||||||
|
#define DEC_CTRL_PROPERTIES(CTRL) \
|
||||||
|
bool GetSetProp##CTRL(Ctrl& c, const String& p, Value& v, int f) \
|
||||||
|
|
||||||
|
|
||||||
|
#define CTRL_PROPERTIES(CTRL, BASE) \
|
||||||
|
DEC_CTRL_PROPERTIES(CTRL); \
|
||||||
|
DEC_CTRL_PROPERTIES(BASE); \
|
||||||
|
INITBLOCK { REGISTERPROPS(CTRL); } \
|
||||||
|
DEC_CTRL_PROPERTIES(CTRL) \
|
||||||
|
{ \
|
||||||
|
typedef CTRL _CTRL_; \
|
||||||
|
if(0) { __base: return GetSetProp##BASE(c,p,v,f); } \
|
||||||
|
ONCELOCK { \
|
||||||
|
|
||||||
|
|
||||||
|
#define END_CTRL_PROPERTIES \
|
||||||
|
} \
|
||||||
|
_CTRL_* pc = dynamic_cast<_CTRL_*>(&c); \
|
||||||
|
if(!pc) return false; \
|
||||||
|
_CTRL_& o = *pc; \
|
||||||
|
\
|
||||||
|
ArrayMap<String, SetTyper<_CTRL_>::Handler>& s = SetTyper<_CTRL_>::map(); \
|
||||||
|
ArrayMap<String, GetTyper<_CTRL_>::Handler>& g = GetTyper<_CTRL_>::map(); \
|
||||||
|
if(f&PROPSET) \
|
||||||
|
{ \
|
||||||
|
int i = s.Find(p); if(i>=0) return s[i](o, v); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
int i = g.Find(p); if(i>=0) return g[i](o, v); \
|
||||||
|
if(p == "listset") AddToValueArray(v, s.GetKeys()); \
|
||||||
|
else if(p == "listget") AddToValueArray(v, g.GetKeys()); \
|
||||||
|
} \
|
||||||
|
goto __base; \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
#define EXT_PROPERTY_SET(CTRL, name, fset) \
|
||||||
|
SetTyper<CTRL>::map().GetAdd(name) = callback((SetTyper<CTRL>::H)&fset); \
|
||||||
|
|
||||||
|
|
||||||
|
#define EXT_PROPERTY_GET(CTRL, name, fget) \
|
||||||
|
GetTyper<CTRL>::map().GetAdd(name) = callback((GetTyper<CTRL>::H)&fget); \
|
||||||
|
|
||||||
|
|
||||||
|
#define EXT_PROPERTY(CTRL, name, fset, fget) \
|
||||||
|
EXT_PROPERTY_SET(CTRL, name, fset) \
|
||||||
|
EXT_PROPERTY_GET(CTRL, name, fget) \
|
||||||
|
|
||||||
|
|
||||||
|
#define PROPERTY_SET(name, fset) \
|
||||||
|
EXT_PROPERTY_SET(_CTRL_, name, fset) \
|
||||||
|
|
||||||
|
|
||||||
|
#define PROPERTY_GET(name, fset) \
|
||||||
|
EXT_PROPERTY_GET(_CTRL_, name, fset) \
|
||||||
|
|
||||||
|
|
||||||
|
#define PROPERTY(name, fset, fget) \
|
||||||
|
EXT_PROPERTY_SET(_CTRL_, name, fset) \
|
||||||
|
EXT_PROPERTY_GET(_CTRL_, name, fget) \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define EXT_UNPROPERTY_SET(CTRL, name) \
|
||||||
|
SetTyper<CTRL>::map().RemoveKey(name); \
|
||||||
|
|
||||||
|
#define EXT_UNPROPERTY_GET(CTRL, name) \
|
||||||
|
GetTyper<CTRL>::map().RemoveKey(name); \
|
||||||
|
|
||||||
|
#define EXT_UNPROPERTY(CTRL, name) \
|
||||||
|
EXT_UNPROPERTY_SET(CTRL, name) \
|
||||||
|
EXT_UNPROPERTY_GET(CTRL, name) \
|
||||||
|
|
||||||
|
|
||||||
|
#define UNPROPERTY_SET(name, fset) \
|
||||||
|
EXT_UNPROPERTY_SET(_CTRL_, name, fset) \
|
||||||
|
|
||||||
|
|
||||||
|
#define UNPROPERTY_GET(name, fset) \
|
||||||
|
EXT_UNPROPERTY_GET(_CTRL_, name, fset) \
|
||||||
|
|
||||||
|
|
||||||
|
#define UNPROPERTY(name, fset, fget) \
|
||||||
|
EXT_UNPROPERTY_SET(_CTRL_, name, fset) \
|
||||||
|
EXT_UNPROPERTY_GET(_CTRL_, name, fget) \
|
||||||
|
|
||||||
|
|
||||||
|
bool Property(Ctrl& c, const String& p, Value& v, int f);
|
||||||
|
inline bool SetProperty(Ctrl& c, const String& p, const Value& v) { return Property(c,p,const_cast<Value&>(v),PROPSET); }
|
||||||
|
inline bool GetProperty(const Ctrl& c, const String& p, Value& v) { return Property(const_cast<Ctrl&>(c),p,v,PROPGET); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
#include "CtrlProp.h"
|
#include "CtrlPropEdit.h"
|
||||||
|
|
||||||
VectorMap<String, int> BidirProps(Ctrl& c)
|
VectorMap<String, int> BidirProps(Ctrl& c)
|
||||||
{
|
{
|
||||||
VectorMap<String, int> is;
|
VectorMap<String, int> is;
|
||||||
|
|
||||||
Value vs;
|
Value vs;
|
||||||
GetProperty(c, "listset", vs);
|
GetProperty(c, "listset", vs);
|
||||||
if(!vs.Is<ValueArray>())
|
if(!vs.Is<ValueArray>()) return is;
|
||||||
return is;
|
|
||||||
ValueArray vas = vs;
|
ValueArray vas = vs;
|
||||||
|
|
||||||
for(int i = 0; i < vas.GetCount(); i++)
|
for(int i = 0; i < vas.GetCount(); i++)
|
||||||
{
|
{
|
||||||
int& m = is.GetAdd(vas.Get(i), 0);
|
int& m = is.GetAdd(vas.Get(i), 0);
|
||||||
|
|
@ -17,10 +16,8 @@ VectorMap<String, int> BidirProps(Ctrl& c)
|
||||||
|
|
||||||
Value vg;
|
Value vg;
|
||||||
GetProperty(c, "listget", vg);
|
GetProperty(c, "listget", vg);
|
||||||
if(!vg.Is<ValueArray>())
|
if(!vg.Is<ValueArray>()) return is;
|
||||||
return is;
|
|
||||||
ValueArray vag = vg;
|
ValueArray vag = vg;
|
||||||
|
|
||||||
for(int i = 0; i < vag.GetCount(); i++)
|
for(int i = 0; i < vag.GetCount(); i++)
|
||||||
{
|
{
|
||||||
int& m = is.GetAdd(vag.Get(i), 0);
|
int& m = is.GetAdd(vag.Get(i), 0);
|
||||||
|
|
@ -30,15 +27,16 @@ VectorMap<String, int> BidirProps(Ctrl& c)
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropList::PropList()
|
PropListCtrl::PropListCtrl()
|
||||||
{
|
{
|
||||||
CtrlLayout(*this);
|
CtrlLayout(*this);
|
||||||
ok <<= THISBACK(Acceptor);
|
|
||||||
cancel <<= THISBACK(Rejector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropList::Evaluate(Ctrl& e)
|
void PropListCtrl::Reload()
|
||||||
{
|
{
|
||||||
|
V::Reload();
|
||||||
|
Ctrl& e = Get();
|
||||||
|
|
||||||
Value v;
|
Value v;
|
||||||
bool b;
|
bool b;
|
||||||
String t;
|
String t;
|
||||||
|
|
@ -68,22 +66,38 @@ void PropList::Evaluate(Ctrl& e)
|
||||||
sl.SetData(t);
|
sl.SetData(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropEdit::PropEdit()
|
PropList::PropList()
|
||||||
|
{
|
||||||
|
SetRect(plc.GetRect());
|
||||||
|
Add(plc.HSizePos().VSizePos(0,20));
|
||||||
|
Add(exit.RightPos(0, 64).BottomPos(0, 20));
|
||||||
|
exit.SetLabel("Close");
|
||||||
|
exit <<= THISBACK(Acceptor);
|
||||||
|
//cancel <<= THISBACK(Rejector);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropList::Acceptor()
|
||||||
|
{
|
||||||
|
plc.Clear();
|
||||||
|
PopUpC::Acceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
PropEditCtrl::PropEditCtrl()
|
||||||
{
|
{
|
||||||
CtrlLayout(*this);
|
CtrlLayout(*this);
|
||||||
ok <<= THISBACK(Acceptor);
|
|
||||||
cancel <<= THISBACK(Rejector);
|
|
||||||
|
|
||||||
ac.AddColumn("Property");
|
ac.AddColumn("Property");
|
||||||
ac.AddColumn("Value");
|
ac.AddColumn("Value");
|
||||||
//ac.WhenUpdateRow = THISBACK(OnUpdateRow);
|
//ac.WhenUpdateRow = THISBACK(OnUpdateRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEdit::Evaluate(Ctrl& e)
|
void PropEditCtrl::Visit(Ctrl& e)
|
||||||
{
|
{
|
||||||
pe = &e;
|
V::Visit(e);
|
||||||
|
|
||||||
ac.Clear();
|
ac.Clear();
|
||||||
vsav.Clear();
|
vsav.Clear();
|
||||||
|
|
||||||
VectorMap<String, int> is = BidirProps(e);
|
VectorMap<String, int> is = BidirProps(e);
|
||||||
|
|
||||||
|
|
@ -151,42 +165,71 @@ void PropEdit::Evaluate(Ctrl& e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ac.Layout();
|
||||||
|
//ac.UpdateRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEdit::OnUpdateRow()
|
void PropEditCtrl::Clear()
|
||||||
{
|
{
|
||||||
if(!pe) return;
|
V::Clear();
|
||||||
|
ac.Clear();
|
||||||
|
vsav.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropEditCtrl::Reload()
|
||||||
|
{
|
||||||
|
V::Reload();
|
||||||
|
Ctrl& e = Get();
|
||||||
|
for(int i = 0; i < ac.GetCount(); i++)
|
||||||
|
{
|
||||||
|
Value v;
|
||||||
|
if(!GetProperty(e, ac.Get(i, 0), v)) continue;
|
||||||
|
ac.Set(i, 1, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropEditCtrl::OnUpdateRow()
|
||||||
|
{
|
||||||
|
if(IsEmpty()) return;
|
||||||
if(!ac.IsCursor()) return; //FIXME Option Focus issue
|
if(!ac.IsCursor()) return; //FIXME Option Focus issue
|
||||||
SetProperty(*pe, ac.Get(0), ac.Get(1));
|
SetProperty(Get(), ac.Get(0), ac.Get(1));
|
||||||
vsav.GetAdd(ac.Get(0)).a = true; //dirty
|
vsav.GetAdd(ac.Get(0)).a = true; //dirty
|
||||||
pe->UpdateRefresh();
|
Action();
|
||||||
|
Get().UpdateActionRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropEditCtrl::Restore()
|
||||||
|
{
|
||||||
|
if(!IsEmpty())
|
||||||
|
{
|
||||||
|
for(int i = 0; i < vsav.GetCount(); i++)
|
||||||
|
if(vsav[i].a)
|
||||||
|
SetProperty(Get(), vsav.GetKey(i), vsav[i].b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PropEdit::PropEdit()
|
||||||
|
{
|
||||||
|
SetRect(pec.GetRect());
|
||||||
|
Add(pec.HSizePos().VSizePos(0,20));
|
||||||
|
Add(ok.RightPos(60,60).BottomPos(0,20));
|
||||||
|
Add(cancel.RightPos(0,60).BottomPos(0,20));
|
||||||
|
ok <<= THISBACK(Acceptor);
|
||||||
|
cancel <<= THISBACK(Rejector);
|
||||||
|
ok.SetLabel("OK");
|
||||||
|
cancel.SetLabel("Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEdit::Rejector()
|
void PropEdit::Rejector()
|
||||||
{
|
{
|
||||||
if(pe)
|
pec.Restore();
|
||||||
{
|
pec.Clear();
|
||||||
for(int i = 0; i < vsav.GetCount(); i++)
|
|
||||||
if(vsav[i].a)
|
|
||||||
SetProperty(*pe, vsav.GetKey(i), vsav[i].b);
|
|
||||||
}
|
|
||||||
pe = NULL;
|
|
||||||
ac.Clear();
|
|
||||||
vsav.Clear();
|
|
||||||
|
|
||||||
PopUpC::Rejector();
|
PopUpC::Rejector();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropEdit::Acceptor()
|
void PropEdit::Acceptor()
|
||||||
{
|
{
|
||||||
if(0 && pe) //FIXME when direct editing works, we can spare this out
|
pec.Clear();
|
||||||
{
|
|
||||||
for(int i = 0; i < ac.GetCount(); i++)
|
|
||||||
SetProperty(*pe, ac.Get(i, 0), ac.Get(i, 1));
|
|
||||||
}
|
|
||||||
pe = NULL;
|
|
||||||
ac.Clear();
|
|
||||||
vsav.Clear();
|
|
||||||
|
|
||||||
PopUpC::Acceptor();
|
PopUpC::Acceptor();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
78
bazaar/CtrlProp/CtrlPropEdit.h
Normal file
78
bazaar/CtrlProp/CtrlPropEdit.h
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#ifndef _CtrlProp_CtrlPropEdit_h_
|
||||||
|
#define _CtrlProp_CtrlPropEdit_h_
|
||||||
|
|
||||||
|
#include "CtrlPropCommon.h"
|
||||||
|
|
||||||
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
#include <LogPosCtrl/LogPosCtrl.h>
|
||||||
|
#include <ValueCtrl/ValueCtrl.h>
|
||||||
|
|
||||||
|
#include <Gen/Gen.h>
|
||||||
|
|
||||||
|
VectorMap<String, int> BidirProps(Ctrl& c);
|
||||||
|
|
||||||
|
#define LAYOUTFILE <CtrlProp/CtrlPropEdit.lay>
|
||||||
|
#include <CtrlCore/lay.h>
|
||||||
|
|
||||||
|
class PropListCtrl : public WithPropListLay<ParentCtrl>, public Visiting<Ctrl>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef PropListCtrl CLASSNAME;
|
||||||
|
typedef Visiting<Ctrl> V;
|
||||||
|
PropListCtrl();
|
||||||
|
|
||||||
|
virtual void Reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
class PropList : public PopUpC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef PropList CLASSNAME;
|
||||||
|
PropList();
|
||||||
|
|
||||||
|
void PopUp(Ctrl* owner, Ctrl& e) { plc.Visit(e); PopUpC::PopUp(owner); }
|
||||||
|
virtual void Acceptor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PropListCtrl plc;
|
||||||
|
Button exit;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PropEditCtrl : public WithPropEditLay<ParentCtrl>, public Visiting<Ctrl>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef PropEditCtrl CLASSNAME;
|
||||||
|
typedef Visiting<Ctrl> V;
|
||||||
|
PropEditCtrl();
|
||||||
|
|
||||||
|
virtual void Visit(Ctrl& e);
|
||||||
|
virtual void Reload();
|
||||||
|
virtual void Clear();
|
||||||
|
virtual void Restore();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void OnUpdateRow();
|
||||||
|
ArrayMap<String, Tuple2<bool, Value> > vsav;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PropEdit : public PopUpC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef PropEdit CLASSNAME;
|
||||||
|
PropEdit();
|
||||||
|
|
||||||
|
virtual void Deactivate() {} //let other popups open
|
||||||
|
|
||||||
|
void PopUp(Ctrl* owner, Ctrl& e) { pec.Visit(e); PopUpC::PopUp(owner); }
|
||||||
|
|
||||||
|
virtual void Rejector();
|
||||||
|
virtual void Acceptor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PropEditCtrl pec;
|
||||||
|
Button ok, cancel;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,18 +1,9 @@
|
||||||
LAYOUT(PropListLay, 400, 200)
|
LAYOUT(PropListLay, 400, 200)
|
||||||
ITEM(DocEdit, gl, WantFocus(false).SetEditable(false).LeftPosZ(0, 168).VSizePosZ(0, 20))
|
ITEM(DocEdit, gl, WantFocus(false).SetEditable(false).LeftPosZ(0, 168).VSizePosZ(0, 0))
|
||||||
ITEM(DocEdit, sl, WantFocus(false).SetEditable(false).HSizePosZ(168, 0).VSizePosZ(0, 20))
|
ITEM(DocEdit, sl, WantFocus(false).SetEditable(false).HSizePosZ(168, 0).VSizePosZ(0, 0))
|
||||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(0, 56).BottomPosZ(0, 20))
|
|
||||||
ITEM(Button, ok, SetLabel(t_("Ok")).RightPosZ(56, 56).BottomPosZ(0, 20))
|
|
||||||
END_LAYOUT
|
END_LAYOUT
|
||||||
|
|
||||||
LAYOUT(PropEditLay, 400, 200)
|
LAYOUT(PropEditLay, 400, 200)
|
||||||
ITEM(ArrayCtrl, ac, HSizePosZ(0, 0).VSizePosZ(0, 20))
|
ITEM(ArrayCtrl, ac, HSizePosZ(0, 0).VSizePosZ(0, 0))
|
||||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(0, 56).BottomPosZ(0, 20))
|
|
||||||
ITEM(Button, ok, SetLabel(t_("Ok")).RightPosZ(56, 56).BottomPosZ(0, 20))
|
|
||||||
END_LAYOUT
|
|
||||||
|
|
||||||
LAYOUT(ValuePopUp, 400, 200)
|
|
||||||
ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(56, 56).BottomPosZ(0, 20))
|
|
||||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(0, 56).BottomPosZ(0, 20))
|
|
||||||
END_LAYOUT
|
END_LAYOUT
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
#include "CtrlLib/init"
|
#include "CtrlLib/init"
|
||||||
#include "LogPosCtrl/init"
|
#include "LogPosCtrl/init"
|
||||||
#include "ValueCtrl/init"
|
#include "ValueCtrl/init"
|
||||||
|
#include "Gen/init"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,8 @@ using namespace Upp;
|
||||||
#define LAYOUTFILE <CtrlPropTest/CtrlPropTest.lay>
|
#define LAYOUTFILE <CtrlPropTest/CtrlPropTest.lay>
|
||||||
#include <CtrlCore/lay.h>
|
#include <CtrlCore/lay.h>
|
||||||
|
|
||||||
|
#include <CtrlMover/CtrlMover.h>
|
||||||
#include <CtrlProp/CtrlProp.h>
|
#include <CtrlProp/CtrlProp.h>
|
||||||
#include <CtrlFinder/CtrlFinder.h>
|
|
||||||
#include <RectCtrl/RectCtrl.h>
|
|
||||||
|
|
||||||
bool MyMouseHook(Ctrl *ctrl, bool inframe, int event, Point p,
|
|
||||||
int zdelta, dword keyflags);
|
|
||||||
void DoList(Ctrl& c);
|
|
||||||
void DoEdit(Ctrl& c);
|
|
||||||
bool CanEdit();
|
|
||||||
|
|
||||||
class CtrlPropTest : public WithCtrlPropTestLayout<TopWindow> {
|
class CtrlPropTest : public WithCtrlPropTestLayout<TopWindow> {
|
||||||
public:
|
public:
|
||||||
|
|
@ -26,24 +19,26 @@ public:
|
||||||
//hook
|
//hook
|
||||||
void EditCB();
|
void EditCB();
|
||||||
|
|
||||||
void OnCtrlLeft(Ctrl& c, Point p, dword keyflags);
|
|
||||||
void OnCtrlRight(Ctrl& c, Point p, dword keyflags);
|
|
||||||
void OnRectChange();
|
|
||||||
void OnMissed(Point p, dword keyflags);
|
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
void Test();
|
void Test();
|
||||||
void InitDummies();
|
void InitDummies();
|
||||||
|
|
||||||
|
//edit
|
||||||
|
void DoList(Ctrl& c);
|
||||||
|
void DoEdit(Ctrl& c);
|
||||||
|
bool CanEdit();
|
||||||
|
|
||||||
|
void OnCtrlRight(Ctrl& c, Point p, dword keyflags);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ToolBar mb;
|
ToolBar mb;
|
||||||
ToolBar::Item * mbi;
|
ToolBar::Item * mbi;
|
||||||
CtrlFinder hk;
|
|
||||||
RectCtrl rc;
|
|
||||||
RectCtrl::Style rcst;
|
|
||||||
Ptr<Ctrl> ctrl;
|
|
||||||
|
|
||||||
Array<Ctrl> arc;
|
Array<Ctrl> arc;
|
||||||
|
|
||||||
|
PropEdit pe;
|
||||||
|
PropList pl;
|
||||||
|
|
||||||
|
CtrlMover hk;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,14 @@ description "Ctrl Properties editor, grabber, resizer..\377";
|
||||||
uses
|
uses
|
||||||
CtrlLib,
|
CtrlLib,
|
||||||
CtrlProp,
|
CtrlProp,
|
||||||
CtrlFinder,
|
CtrlMover;
|
||||||
RectCtrl;
|
|
||||||
|
|
||||||
file
|
file
|
||||||
CtrlPropTest.h,
|
CtrlPropTest.h,
|
||||||
main.cpp,
|
main.cpp,
|
||||||
edit.cpp,
|
edit.cpp,
|
||||||
find.cpp,
|
CtrlPropTest.lay,
|
||||||
hook.cpp,
|
misc.cpp;
|
||||||
misc.cpp,
|
|
||||||
CtrlPropTest.lay;
|
|
||||||
|
|
||||||
mainconfig
|
mainconfig
|
||||||
"" = "GUI MT";
|
"" = "GUI MT";
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#include "CtrlPropTest.h"
|
#include "CtrlPropTest.h"
|
||||||
|
|
||||||
void DoEdit(Ctrl& c)
|
void CtrlPropTest::DoEdit(Ctrl& c)
|
||||||
{
|
{
|
||||||
PropEdit& pe = Single<PropEdit>();
|
|
||||||
if(pe.IsOpen()) return;
|
if(pe.IsOpen()) return;
|
||||||
|
|
||||||
Ctrl* owner = Ctrl::GetActiveWindow();
|
Ctrl* owner = Ctrl::GetActiveWindow();
|
||||||
|
|
@ -12,13 +11,12 @@ void DoEdit(Ctrl& c)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pe.Rejector(); pe.PopUp(owner, c);
|
pe.PopUp(owner, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoList(Ctrl& c)
|
void CtrlPropTest::DoList(Ctrl& c)
|
||||||
{
|
{
|
||||||
PropList& pe = Single<PropList>();
|
if(pl.IsOpen()) return;
|
||||||
if(pe.IsOpen()) return;
|
|
||||||
|
|
||||||
Ctrl* owner = Ctrl::GetActiveWindow();
|
Ctrl* owner = Ctrl::GetActiveWindow();
|
||||||
if(!owner)
|
if(!owner)
|
||||||
|
|
@ -27,14 +25,23 @@ void DoList(Ctrl& c)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pe.Rejector(); pe.PopUp(owner, c);
|
pl.PopUp(owner, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanEdit()
|
bool CtrlPropTest::CanEdit()
|
||||||
{
|
{
|
||||||
PropEdit& pe = Single<PropEdit>();
|
if(pe.IsOpen() || pl.IsOpen()) return false;
|
||||||
if(pe.IsOpen()) return false;
|
|
||||||
PropList& pl = Single<PropList>();
|
|
||||||
if(pl.IsOpen()) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CtrlPropTest::OnCtrlRight(Ctrl& c, Point p, dword keyflags)
|
||||||
|
{
|
||||||
|
// if(&c == &rc) return;
|
||||||
|
if(&c == &hk) return;
|
||||||
|
if(!CanEdit()) return;
|
||||||
|
if(keyflags & K_SHIFT)
|
||||||
|
DoList(c);
|
||||||
|
else
|
||||||
|
DoEdit(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
#include "CtrlPropTest.h"
|
|
||||||
|
|
||||||
void CtrlPropTest::OnCtrlLeft(Ctrl& c, Point p, dword keyflags)
|
|
||||||
{
|
|
||||||
if(&c == &rc) return;
|
|
||||||
if(&c == &hk) return;
|
|
||||||
if(!CanEdit()) return;
|
|
||||||
rc.SetData(c.GetRect());
|
|
||||||
Add(rc.SizePos());
|
|
||||||
ctrl = &c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlPropTest::OnCtrlRight(Ctrl& c, Point p, dword keyflags)
|
|
||||||
{
|
|
||||||
if(&c == &rc) return;
|
|
||||||
if(&c == &hk) return;
|
|
||||||
if(!CanEdit()) return;
|
|
||||||
if(keyflags == K_SHIFT)
|
|
||||||
DoList(c);
|
|
||||||
else
|
|
||||||
DoEdit(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlPropTest::OnRectChange()
|
|
||||||
{
|
|
||||||
if(!ctrl) return;
|
|
||||||
ctrl->SetRect(rc.GetData());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CtrlPropTest::OnMissed(Point p, dword keyflags)
|
|
||||||
{
|
|
||||||
rc.Remove(); //leave move
|
|
||||||
hk.LeftDown(p, keyflags);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#include "CtrlPropTest.h"
|
|
||||||
|
|
||||||
bool MyMouseHook(Ctrl *ctrl, bool inframe, int event, Point p,
|
|
||||||
int zdelta, dword keyflags)
|
|
||||||
{
|
|
||||||
if(event & (Ctrl::MOUSEMOVE | Ctrl::MOUSEENTER | Ctrl::MOUSELEAVE | Ctrl::CURSORIMAGE)) return false;
|
|
||||||
if((keyflags & K_MOUSERIGHT))
|
|
||||||
if((keyflags & K_SHIFT_CTRL))
|
|
||||||
{
|
|
||||||
if(!CanEdit()) return false;
|
|
||||||
|
|
||||||
CallbackArgTarget<int> m;
|
|
||||||
MenuBar menu;
|
|
||||||
menu.Add("List Properties",m[0]);
|
|
||||||
menu.Add("Edit Properties",m[1]);
|
|
||||||
menu.Execute();
|
|
||||||
if(IsNull(m)) return true;
|
|
||||||
switch(m)
|
|
||||||
{
|
|
||||||
case 0: DoList(*ctrl); break;
|
|
||||||
case 1: DoEdit(*ctrl); break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
@ -2,6 +2,5 @@
|
||||||
#define _CtrlPropTest_icpp_init_stub
|
#define _CtrlPropTest_icpp_init_stub
|
||||||
#include "CtrlLib/init"
|
#include "CtrlLib/init"
|
||||||
#include "CtrlProp/init"
|
#include "CtrlProp/init"
|
||||||
#include "CtrlFinder/init"
|
#include "CtrlMover/init"
|
||||||
#include "RectCtrl/init"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,9 @@ void CtrlPropTest::EditCB()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetFocus(); //kill foucus from all others
|
|
||||||
hk.Enable();
|
hk.Enable();
|
||||||
rc.Remove();
|
|
||||||
mbi->Check(true);
|
mbi->Check(true);
|
||||||
|
SetFocus(); //kill foucus from all others
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,19 +23,10 @@ CtrlPropTest::CtrlPropTest()
|
||||||
THISBACK(EditCB));
|
THISBACK(EditCB));
|
||||||
AddFrame(mb);
|
AddFrame(mb);
|
||||||
|
|
||||||
InstallMouseHook(&MyMouseHook);
|
|
||||||
|
|
||||||
hk.WhenLeftDown = THISBACK(OnCtrlLeft);
|
|
||||||
hk.WhenRightDown = THISBACK(OnCtrlRight);
|
hk.WhenRightDown = THISBACK(OnCtrlRight);
|
||||||
hk.Disable();
|
hk.Disable();
|
||||||
Add(hk.SizePos());
|
Add(hk.SizePos());
|
||||||
|
|
||||||
rcst = RectCtrl::StyleDefault();
|
|
||||||
rcst.rectcol = Null;
|
|
||||||
rc.SetStyle(rcst);
|
|
||||||
rc <<= THISBACK(OnRectChange);
|
|
||||||
rc.WhenMissed = THISBACK(OnMissed);
|
|
||||||
|
|
||||||
InitDummies();
|
InitDummies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,80 @@
|
||||||
#include "ValueCtrl.h"
|
#include "ValueCtrl.h"
|
||||||
|
|
||||||
|
Ctrl* OptionInstancer()
|
||||||
|
{
|
||||||
|
Option* p = new Option(); p->ClickFocus(); return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
INITBLOCK
|
||||||
|
{
|
||||||
|
VectorMap<Value, Instancer<Ctrl>::InstancerType>& map = Instancer<Ctrl>::Map();
|
||||||
|
|
||||||
|
map.Add(int(INT_V), Instancer<Ctrl>::Typed<WithEnterAction<EditInt> >::GetInstancer());
|
||||||
|
map.Add(int(DOUBLE_V), Instancer<Ctrl>::Typed<WithEnterAction<EditDouble> >::GetInstancer());
|
||||||
|
map.Add(int(STRING_V), Instancer<Ctrl>::Typed<WithEnterAction<EditString> >::GetInstancer());
|
||||||
|
map.Add(int(DATE_V), Instancer<Ctrl>::Typed<DropDate>::GetInstancer());
|
||||||
|
map.Add(int(TIME_V), Instancer<Ctrl>::Typed<DropTime>::GetInstancer());
|
||||||
|
map.Add(int(WSTRING_V),Instancer<Ctrl>::Typed<RichTextCtrl>::GetInstancer());
|
||||||
|
map.Add(int(INT64_V), Instancer<Ctrl>::Typed< WithEnterAction<EditInt64> >::GetInstancer());
|
||||||
|
|
||||||
|
//map.Add(int(BOOL_V), Instancer<Ctrl>::Typed<Option>::GetInstancer());
|
||||||
|
map.Add(int(BOOL_V), &OptionInstancer);
|
||||||
|
|
||||||
|
map.Add(int(COLOR_V), Instancer<Ctrl>::Typed<ColorPusher>::GetInstancer());
|
||||||
|
//map.Add(int(FONT_V), Instancer<Ctrl>::Typed<FontPusher>::GetInstancer());
|
||||||
|
|
||||||
|
map.Add(int(LOGPOS_V), Instancer<Ctrl>::Typed<LogPosCtrl>::GetInstancer());
|
||||||
|
map.Add(int(VALUE_V), Instancer<Ctrl>::Typed<ValuePacker>::GetInstancer());
|
||||||
|
map.Add(int(VALUEARRAY_V), Instancer<Ctrl>::Typed<ValueArrayCtrl>::GetInstancer());
|
||||||
|
map.Add(int(VOID_V), Instancer<Ctrl>::Typed<ValueCtrl>::GetInstancer());
|
||||||
|
//map.Add(int(VALUEMAP_V),Instancer<Ctrl>::Typed<>::GetInstancer());
|
||||||
|
//map.Add(int(ERROR_V), Instancer<Ctrl>::Typed<>::GetInstancer());
|
||||||
|
//map.Add(int(UNKNOWN_V), Instancer<Ctrl>::Typed<>::GetInstancer());
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CASEENUMPRINT(x) case x: return ASSTRING(x);
|
||||||
|
String VTypeToString(int vtype)
|
||||||
|
{
|
||||||
|
switch(vtype)
|
||||||
|
{
|
||||||
|
CASEENUMPRINT( INT_V )
|
||||||
|
CASEENUMPRINT( DOUBLE_V )
|
||||||
|
CASEENUMPRINT( STRING_V )
|
||||||
|
CASEENUMPRINT( DATE_V )
|
||||||
|
CASEENUMPRINT( TIME_V )
|
||||||
|
CASEENUMPRINT( WSTRING_V )
|
||||||
|
CASEENUMPRINT( INT64_V )
|
||||||
|
CASEENUMPRINT( BOOL_V )
|
||||||
|
|
||||||
|
CASEENUMPRINT( COLOR_V )
|
||||||
|
//CASEENUMPRINT( FONT_V )
|
||||||
|
|
||||||
|
CASEENUMPRINT( LOGPOS_V )
|
||||||
|
CASEENUMPRINT( VALUE_V )
|
||||||
|
CASEENUMPRINT( VALUEARRAY_V )
|
||||||
|
|
||||||
|
CASEENUMPRINT( VOID_V )
|
||||||
|
|
||||||
|
CASEENUMPRINT( VALUEMAP_V )
|
||||||
|
|
||||||
|
CASEENUMPRINT( ERROR_V )
|
||||||
|
CASEENUMPRINT( UNKNOWN_V )
|
||||||
|
default: return String().Cat() << "[#" << vtype << "_V";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ctrl* DefaultValueEditor(int vtype)
|
Ctrl* DefaultValueEditor(int vtype)
|
||||||
{
|
{
|
||||||
String t;
|
|
||||||
Ctrl* p = NULL;
|
Ctrl* p = NULL;
|
||||||
switch(vtype)
|
int i = Instancer<Ctrl>::Map().Find(vtype);
|
||||||
|
if(i>=0)
|
||||||
{
|
{
|
||||||
case INT_V: p = new EditInt(); break;
|
p = Instancer<Ctrl>::Map()[i]();
|
||||||
case DOUBLE_V: p = new EditDouble(); break;
|
|
||||||
case STRING_V: p = new EditString(); break;
|
|
||||||
case DATE_V: p = new DropDate(); break;
|
|
||||||
case TIME_V: p = new DropTime(); break;
|
|
||||||
case WSTRING_V: p = new RichTextCtrl(); break;
|
|
||||||
case INT64_V: p = new EditInt64(); break;
|
|
||||||
case BOOL_V: { Option* _p = new Option(); _p->ClickFocus(); p = _p; } break;
|
|
||||||
|
|
||||||
case COLOR_V: p = new ColorPusher(); break;
|
|
||||||
//case FONT_V: p = new FontPusher(); break; //FIXME
|
|
||||||
|
|
||||||
case LOGPOS_V: p = new LogPosCtrl(); break;
|
|
||||||
case VALUE_V: p = new ValuePacker; break;
|
|
||||||
case VALUEARRAY_V: p = new ValueArrayCtrl(); break;
|
|
||||||
|
|
||||||
case VOID_V: p = new ValueCtrl(); break;
|
|
||||||
|
|
||||||
case VALUEMAP_V: t = "VALUEMAP_V"; break;
|
|
||||||
|
|
||||||
case ERROR_V: t = "ERROR_V"; break;
|
|
||||||
case UNKNOWN_V: t = "UNKNOWN_V"; break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
if(!p)
|
if(!p)
|
||||||
{
|
{
|
||||||
StaticText* _p = new StaticText();
|
StaticText* _p = new StaticText();
|
||||||
_p->SetText(t);
|
_p->SetText(VTypeToString(vtype));
|
||||||
p = _p;
|
p = _p;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ using namespace Upp;
|
||||||
|
|
||||||
#include <PopUpC/PopUpC.h>
|
#include <PopUpC/PopUpC.h>
|
||||||
#include <LogPosCtrl/LogPosCtrl.h>
|
#include <LogPosCtrl/LogPosCtrl.h>
|
||||||
|
#include <WithEnterAction/WithEnterAction.h>
|
||||||
|
#include <Gen/Gen.h>
|
||||||
|
|
||||||
#define LAYOUTFILE <ValueCtrl/ValueCtrl.lay>
|
#define LAYOUTFILE <ValueCtrl/ValueCtrl.lay>
|
||||||
#include <CtrlCore/lay.h>
|
#include <CtrlCore/lay.h>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ description "Value editing and creating Ctrl\377";
|
||||||
uses
|
uses
|
||||||
CtrlLib,
|
CtrlLib,
|
||||||
PopUpC,
|
PopUpC,
|
||||||
LogPosCtrl;
|
LogPosCtrl,
|
||||||
|
WithEnterAction;
|
||||||
|
|
||||||
file
|
file
|
||||||
ValueCtrl.lay,
|
ValueCtrl.lay,
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
#include "CtrlLib/init"
|
#include "CtrlLib/init"
|
||||||
#include "PopUpC/init"
|
#include "PopUpC/init"
|
||||||
#include "LogPosCtrl/init"
|
#include "LogPosCtrl/init"
|
||||||
|
#include "WithEnterAction/init"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue