1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051 |
- #include "pch.h"
- /////////////////////////////////////////////////////////////////////////////
- //
- // ScreenPane
- //
- /////////////////////////////////////////////////////////////////////////////
- class ScreenPane : public ImagePane {
- private:
- Window* m_pwindow;
- WinPoint m_pointWindowStart;
- WinPoint m_pointMouseStart;
- public:
- ScreenPane(Window* pwindow, Image* pimage) :
- m_pwindow(pwindow),
- ImagePane(pimage)
- {
- }
- };
- /////////////////////////////////////////////////////////////////////////////
- //
- // Gauge Pane
- //
- /////////////////////////////////////////////////////////////////////////////
- GaugePane::GaugePane(Surface* psurface,
- const Color& colorFlash,
- float minValue,
- float maxValue,
- const Color& colorEmpty)
- :
- m_psurface(psurface),
- m_colorFlash(colorFlash),
- m_colorEmpty(colorEmpty),
- m_minValue(minValue),
- m_maxValue(maxValue),
- m_value(0),
- m_valueOld(0),
- m_valueFlash(0),
- m_timeLastChange(Time::Now())
- {
- assert(m_psurface);
- assert(m_minValue < m_maxValue);
- InternalSetSize(m_psurface->GetSize());
- }
- void GaugePane::Paint(Surface* psurface)
- {
- if (m_value != 0) {
- psurface->BitBlt(
- WinPoint(0, 0),
- m_psurface,
- WinRect(0, 0, m_value, YSize())
- );
- }
- if (m_value < m_valueFlash) {
- psurface->FillRect(
- WinRect(
- m_value,
- 0,
- m_valueFlash,
- YSize()
- ),
- m_colorFlash
- );
- }
- }
- void GaugePane::SetValue(float v, bool fFlash)
- {
- m_value =
- (int)bound(
- (v - m_minValue) * ((float)XSize()) / (m_maxValue - m_minValue),
- 0.0f,
- (float)XSize()
- );
- }
- void GaugePane::Update(Time time)
- {
- if (m_value != m_valueOld) {
- if (m_value < m_valueOld) {
- m_valueFlash = m_valueOld;
- } else {
- m_valueFlash = m_value;
- }
- m_timeLastChange = time;
- m_valueOld = m_value;
- NeedPaint();
- }
- if (m_value != m_valueFlash && time - m_timeLastChange > 0.25f) {
- m_valueFlash = m_value;
- NeedPaint();
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // ParseIntVector
- //
- //////////////////////////////////////////////////////////////////////////////
- void ParseIntVector(IObject* pobject, TVector<int>& vec)
- {
- IObjectList* plistVertices; CastTo(plistVertices, pobject);
- plistVertices->GetFirst();
- while (plistVertices->GetCurrent() != NULL) {
- vec.PushEnd((int)GetNumber(plistVertices->GetCurrent()));
- plistVertices->GetNext();
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // ParseFloatVector
- //
- //////////////////////////////////////////////////////////////////////////////
- void ParseFloatVector(IObject* pobject, TVector<float>& vec)
- {
- IObjectList* plistVertices; CastTo(plistVertices, pobject);
- plistVertices->GetFirst();
- while (plistVertices->GetCurrent() != NULL) {
- vec.PushEnd((float)GetNumber(plistVertices->GetCurrent()));
- plistVertices->GetNext();
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // ParseStringVector
- //
- //////////////////////////////////////////////////////////////////////////////
- void ParseStringVector(IObject* pobject, TVector<ZString>& vec)
- {
- IObjectList* plistVertices; CastTo(plistVertices, pobject);
- plistVertices->GetFirst();
- while (plistVertices->GetCurrent() != NULL) {
- vec.PushEnd(GetString(plistVertices->GetCurrent()));
- plistVertices->GetNext();
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // ThumbPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class ThumbPaneImpl : public ThumbPane{
- private:
- TRef<Surface> m_psurface;
- bool m_bHorizontal;
- public:
- ThumbPaneImpl(Modeler* pmodeler, bool bHorizontal, TRef<Image>& pImageThumb) :
- m_bHorizontal(bHorizontal)
- {
- // TODO if (pImageThumb == NULL)
- if(bHorizontal)
- m_psurface =pmodeler->LoadSurface("scrollhorizontalthumbbmp", true);
- else
- m_psurface =pmodeler->LoadSurface("scrollthumbbmp", true);
- }
- void Paint(Surface* psurface)
- {
- if (m_bHorizontal)
- {
- const WinPoint& size = m_psurface->GetSize();
- int x = 0;
- while (x + size.X() < XSize()) {
- psurface->BitBlt(
- WinPoint(x, 0),
- m_psurface,
- WinRect(0, 0, size.X(), min(size.Y(), YSize()))
- );
- x += size.X();
- }
- psurface->BitBlt(
- WinPoint(x, 0),
- m_psurface,
- WinRect(0, 0, XSize() - x, min(size.Y(), YSize()))
- );
- }
- else
- {
- const WinPoint& size = m_psurface->GetSize();
- int y = 0;
- while (y + size.Y() < YSize()) {
- psurface->BitBlt(
- WinPoint(0, y),
- m_psurface,
- WinRect(0, 0, min(size.X(), XSize()), size.Y())
- );
- y += size.Y();
- }
- psurface->BitBlt(
- WinPoint(0, y),
- m_psurface,
- WinRect(0, 0, min(size.X(), XSize()), YSize() - y)
- );
- }
- }
- void UpdateLayout()
- {
- WinPoint size = GetExpand();
- if (m_bHorizontal)
- {
- if (size.X() < 8) {
- size.SetX(8);
- }
- }
- else
- {
- if (size.Y() < 8) {
- size.SetY(8);
- }
- }
- InternalSetSize(size);
- }
- };
- TRef<ThumbPane> ThumbPane::Create(Modeler* pmodeler,
- bool bHorizontal,
- TRef<Image> pImageThumb) // Set this to NULL for default image
- {
- return new ThumbPaneImpl(pmodeler, bHorizontal, pImageThumb);
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // TrekScrollPane
- //
- //////////////////////////////////////////////////////////////////////////////
- TRef<Pane> CreateTrekScrollPane(
- WinPoint size,
- Modeler* pmodeler,
- TRef<IIntegerEventSource>& pevent,
- TRef<ScrollPane>& pscrollPane,
- bool bHoriztonal,
- TRef<ButtonPane>& pbuttonUp,
- TRef<ButtonPane>& pbuttonDown,
- TRef<Image>& pImageThumb
- ) {
- if (pbuttonUp == NULL || pbuttonDown == NULL)
- {
- TRef<Image> pimageUp;
- TRef<Image> pimageUpSel;
- TRef<Image> pimageDown;
- TRef<Image> pimageDownSel;
- //
- // Load default images if no buttons are passed as params
- //
- if (bHoriztonal)
- {
- pimageUp = pmodeler->LoadImage("scrollleftbmp" , true);
- pimageUpSel = pmodeler->LoadImage("scrollleftselbmp" , true);
- pimageDown = pmodeler->LoadImage("scrollrightbmp" , true);
- pimageDownSel = pmodeler->LoadImage("scrollrightselbmp", true);
- }
- else
- {
- pimageUp = pmodeler->LoadImage("scrollupbmp" , true);
- pimageUpSel = pmodeler->LoadImage("scrollupselbmp" , true);
- pimageDown = pmodeler->LoadImage("scrolldownbmp" , true);
- pimageDownSel = pmodeler->LoadImage("scrolldownselbmp", true);
- }
- pbuttonUp =
- CreateButton(
- new ImagePane(pimageUp),
- new ImagePane(pimageUpSel),
- false,
- 0.1f,
- 0.5f
- );
- pbuttonDown =
- CreateButton(
- new ImagePane(pimageDown),
- new ImagePane(pimageDownSel),
- false,
- 0.1f,
- 0.5f
- );
- }
- pscrollPane =
- CreateScrollPane(
- new JustifyPane(),
- ThumbPane::Create(pmodeler, bHoriztonal, pImageThumb),
- pbuttonUp,
- pbuttonUp->GetEventSource(),
- pbuttonDown,
- pbuttonDown->GetEventSource(),
- bHoriztonal, // false == vertical
- 0.25f,
- 1,
- 1,
- 1,
- 1,
- size
- );
- pevent = pscrollPane->GetEventSource();
- return pscrollPane;
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ScrollPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class ScrollPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- bool m_bHorizontal;
- bool m_bDefaultImages;
- public:
- ScrollPaneFactory(Modeler* pmodeler, bool bHorizontal, bool bDefaultImages) :
- m_pmodeler(pmodeler),
- m_bHorizontal(bHorizontal),
- m_bDefaultImages(bDefaultImages)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
- TRef<ButtonPane> pbuttonUp;
- TRef<ButtonPane> pbuttonDown;
- TRef<Image> pImageThumb;
- if(m_bDefaultImages)
- {
- pbuttonUp = NULL;
- pbuttonDown = NULL;
- pImageThumb = NULL;
- }
- else
- {
- //
- // Pop buttons off stack
- //
- CastTo(pbuttonUp, (IObject*)stack.Pop());
- CastTo(pbuttonDown, (IObject*)stack.Pop());
- CastTo(pImageThumb, (Value*)(IObject*)stack.Pop());
- }
- WinPoint temp;
- temp.SetX((int)ppoint->GetValue().X());
- temp.SetY((int)ppoint->GetValue().Y());
- return
- CreateTrekScrollPane(
- temp,
- m_pmodeler,
- TRef<IIntegerEventSource>(),
- TRef<ScrollPane>(),
- m_bHorizontal,
- pbuttonUp,
- pbuttonDown,
- pImageThumb
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ListPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class ListPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ListPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
- return
- (Pane*)CreateListPane(
- WinPoint::Cast(ppoint->GetValue()),
- NULL,
- NULL,
- NULL,
- false
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // EditPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class EditPaneFactory : public IFunction {
- private:
- TRef<Number> m_ptime;
- public:
- EditPaneFactory(Number* ptime) :
- m_ptime(ptime)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
- TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
- TRef<Pane> ppane = CreateEditPane(ZString(), pfont->GetValue(), m_ptime);
- ppane->SetSize(WinPoint::Cast(ppoint->GetValue()));
- return ppane;
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // StringListPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class StringListWithScrollBarPaneFactory: public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- StringListWithScrollBarPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
- TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
- TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
- TRef<ColorValue> pcolor; CastTo(pcolor, (IObject*)stack.Pop());
- return (Pane*)
- CreateStringListPane(
- WinPoint::Cast(ppoint->GetValue()),
- NULL,
- NULL,
- pscrollPane,
- false,
- pfont->GetValue(),
- Color::White(),
- pcolor->GetValue()
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ListPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class ListWithScrollBarPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ListWithScrollBarPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
- TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
- return
- (Pane*)CreateListPane(
- WinPoint::Cast(ppoint->GetValue()),
- NULL,
- NULL,
- pscrollPane,
- false
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ListHoriztonalPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class ListHorizontalWithScrollBarPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ListHorizontalWithScrollBarPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
- TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
- return
- (Pane*)CreateListPane(
- WinPoint::Cast(ppoint->GetValue()),
- NULL,
- NULL,
- pscrollPane,
- true
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ImagePaneFactory
- //
- //////////////////////////////////////////////////////////////////////////////
- class ImagePaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ImagePaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- void AddChildren(Pane* ppaneParent, ObjectStack& stack)
- {
- TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
- plist->GetFirst();
- while (plist->GetCurrent() != NULL) {
- IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
- TRef<Pane> ppaneChild; CastTo(ppaneChild, ppair->GetFirst() );
- TRef<PointValue> ppointChild; CastTo(ppointChild, ppair->GetSecond() );
- ppaneParent->InsertAtBottom(ppaneChild);
- ppaneChild->SetOffset(
- WinPoint(
- (int)ppointChild->GetValue().X(),
- (int)ppointChild->GetValue().Y()
- )
- );
- plist->GetNext();
- }
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
- TRef<Pane> ppane = new ImagePane(pimage);
- AddChildren(ppane, stack);
- return ppane;
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ScreenPane
- //
- //////////////////////////////////////////////////////////////////////////////
- Window* g_pwindow;
- void SetEffectWindow(Window* pwindow)
- {
- g_pwindow = pwindow;
- }
- class ScreenPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ScreenPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- void AddChildren(Pane* ppaneParent, ObjectStack& stack)
- {
- TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
- plist->GetFirst();
- while (plist->GetCurrent() != NULL) {
- IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
- TRef<Pane> ppaneChild; CastTo(ppaneChild, ppair->GetFirst() );
- TRef<PointValue> ppointChild; CastTo(ppointChild, ppair->GetSecond() );
- ppaneParent->InsertAtBottom(ppaneChild);
- ppaneChild->SetOffset(
- WinPoint(
- (int)ppointChild->GetValue().X(),
- (int)ppointChild->GetValue().Y()
- )
- );
- plist->GetNext();
- }
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
- TRef<Pane> ppane = new ScreenPane(g_pwindow, pimage);
- AddChildren(ppane, stack);
- return ppane;
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // Hover Site
- //
- //////////////////////////////////////////////////////////////////////////////
- class HoverSiteImpl : public HoverSite {
- private:
- TRef<ModifiableNumber> m_pnumber;
-
- public:
- HoverSiteImpl(float initialID) :
- m_pnumber(new ModifiableNumber(initialID))
- {
- }
- void Enter(float id)
- {
- m_pnumber->SetValue(id);
- }
- void Leave(float id)
- {
- m_pnumber->SetValue(0);
- }
- Number* GetID()
- {
- return m_pnumber;
- }
- };
- TRef<HoverSite> CreateHoverSite(float initialID)
- {
- return new HoverSiteImpl(initialID);
- }
- class HoverSiteFactory : public IFunction {
- public:
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<Number> pnumber; CastTo(pnumber, (IObject*)stack.Pop());
- return CreateHoverSite(pnumber->GetValue());
- }
- };
- class GetHoverSiteIDFactory : public IFunction {
- public:
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<HoverSite> psite; CastTo(psite, (IObject*)stack.Pop());
- return psite->GetID();
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // Hover Pane
- //
- //////////////////////////////////////////////////////////////////////////////
- class HoverPane : public Pane {
- private:
- TRef<HoverSite> m_psite;
- float m_id;
- bool m_bEntered;
- public:
- HoverPane(HoverSite* psite, float id, Pane* ppane) :
- Pane(ppane),
- m_psite(psite),
- m_id(id),
- m_bEntered(false)
- {
- }
- void UpdateLayout()
- {
- DefaultUpdateLayout();
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // IMouseInput Methods
- //
- //////////////////////////////////////////////////////////////////////////////
- void MouseEnter(IInputProvider* pprovider, const Point& point)
- {
- if (!Child()->IsHidden()) {
- m_bEntered = true;
- m_psite->Enter(m_id);
- }
- }
- void MouseLeave(IInputProvider* pprovider)
- {
- if (m_bEntered) {
- m_bEntered = false;
- m_psite->Leave(m_id);
- }
- }
- };
- TRef<Pane> CreateHoverPane(HoverSite* psite, float id, Pane* ppane)
- {
- return new HoverPane(psite, id, ppane);
- }
- class HoverPaneFactory : public IFunction {
- public:
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<HoverSite> psite; CastTo(psite, (IObject*)stack.Pop());
- TRef<Number> pid; CastTo(pid, (IObject*)stack.Pop());
- TRef<Pane> ppane; CastTo(ppane, (IObject*)stack.Pop());
- return
- (Pane*)CreateHoverPane(
- psite,
- pid->GetValue(),
- ppane
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // Hover Pane for Button Bar Panes and Lists
- //
- //////////////////////////////////////////////////////////////////////////////
- class HoverPaneColumns : public Pane {
- private:
- TRef<HoverSite> m_psite;
- float m_id;
- TVector<int> m_vecColumns;
- float m_startid;
- public:
- HoverPaneColumns(HoverSite* psite, float id, Pane* ppane, TVector<int>& pvecColumns) :
- Pane(ppane),
- m_psite(psite),
- m_id(id),
- m_startid(id),
- m_vecColumns(pvecColumns)
-
-
- {
- }
- void UpdateLayout()
- {
- DefaultUpdateLayout();
- }
- //////////////////////////////////////////////////////////////////////////////
- //
- // IMouseInput Methods
- //
- //////////////////////////////////////////////////////////////////////////////
- void MouseEnter(IInputProvider* pprovider, const Point& point)
- {
- m_psite->Enter(m_id);
- }
- void MouseLeave(IInputProvider* pprovider)
- {
- m_psite->Leave(m_id);
- }
- void MouseMove(IInputProvider* pprovider, const Point& point, bool bCaptured, bool bInside)
- {
- int count = m_vecColumns.GetCount();
- int xprev = 0;
-
- for (int index = 0; index < count; index++) {
- int x = m_vecColumns[index];
- if ((int)point.X() < x) {
- if ((int)point.X() > xprev) {
- m_id = (float)(m_startid + index);
- m_psite->Enter(m_id);
- }
- } else {
- m_id = 0;
- }
- xprev = x;
- }
- }
- };
- TRef<Pane> CreateHoverPaneColumns(HoverSite* psite, float id, Pane* ppane, TVector<int>& pvecColumns)
- {
- return new HoverPaneColumns(psite, id, ppane, pvecColumns);
- }
- class HoverPaneColumnsFactory : public IFunction {
- public:
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<HoverSite> psite; CastTo(psite, (IObject*)stack.Pop());
- TRef<Number> pid; CastTo(pid, (IObject*)stack.Pop());
- TRef<Pane> ppane; CastTo(ppane, (IObject*)stack.Pop());
- TVector<int> pvecColumns;
- ParseIntVector((IObject*)stack.Pop(), pvecColumns);
-
- return
- (Pane*)CreateHoverPaneColumns(
- psite,
- pid->GetValue(),
- ppane,
- pvecColumns
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- // ParentPane
- //
- //////////////////////////////////////////////////////////////////////////////
- class ParentPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ParentPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- void AddChildren(Pane* ppaneParent, ObjectStack& stack)
- {
- TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
- plist->GetFirst();
- while (plist->GetCurrent() != NULL) {
- IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
- TRef<Pane> ppaneChild; CastTo(ppaneChild, ppair->GetFirst() );
- TRef<PointValue> ppointChild; CastTo(ppointChild, ppair->GetSecond() );
- ppaneParent->InsertAtBottom(ppaneChild);
- ppaneChild->SetOffset(
- WinPoint(
- (int)ppointChild->GetValue().X(),
- (int)ppointChild->GetValue().Y()
- )
- );
- plist->GetNext();
- }
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<Pane> ppane; CastTo(ppane, (Value*)(IObject*)stack.Pop());
- AddChildren(ppane, stack);
- return ppane;
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- //
- //
- //////////////////////////////////////////////////////////////////////////////
- class ButtonEffectPaneFactory : public IFunction {
- private:
- TRef<Modeler> m_pmodeler;
- public:
- ButtonEffectPaneFactory(Modeler* pmodeler) :
- m_pmodeler(pmodeler)
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
- TRef<Number> pnumberFaces; CastTo(pnumberFaces, (IObject*)stack.Pop());
- TRef<Boolean> pboolToggle; CastTo(pboolToggle, (IObject*)stack.Pop());
- DWORD dwFaces = (DWORD)pnumberFaces->GetValue();
- return
- CreateButton(
- CreateButtonFacePane(
- pimage->GetSurface(),
- dwFaces
- ),
- pboolToggle->GetValue(),
- 0,
- 0
- );
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- //
- //
- //////////////////////////////////////////////////////////////////////////////
- TRef<Pane> CreateBlackPane(Pane* ppane)
- {
- return new BorderPane(0, Color::Black(), ppane);
- }
- class BlackPaneFactory : public IFunction {
- public:
- BlackPaneFactory()
- {
- }
- TRef<IObject> Apply(ObjectStack& stack)
- {
- TRef<Pane> ppane; CastTo(ppane, (Value*)(IObject*)stack.Pop());
- return CreateBlackPane(ppane);
- }
- };
- //////////////////////////////////////////////////////////////////////////////
- //
- //
- //
- //////////////////////////////////////////////////////////////////////////////
- void AddPaneFactories(
- INameSpace* pns,
- Modeler* pmodeler,
- IPopupContainer* ppopupContainer,
- Number* ptime
- ) {
- pns->AddMember("ButtonFaceUp", new Number((float)ButtonFaceUp));
- pns->AddMember("ButtonFaceDown", new Number((float)ButtonFaceDown));
- pns->AddMember("ButtonNormal", new Number((float)ButtonNormal));
- pns->AddMember("ButtonNormalCheckBox", new Number((float)ButtonNormalCheckBox));
- pns->AddMember("Button3State", new Number((float)Button3State));
- pns->AddMember("ButtonUpDown", new Number((float)(ButtonFaceUp | ButtonFaceDown)));
- pns->AddMember("ButtonEffectPane", new ButtonEffectPaneFactory(pmodeler));
- pns->AddMember("BlackPane", new BlackPaneFactory());
- pns->AddMember("StringListWithScrollBarPane", new StringListWithScrollBarPaneFactory(pmodeler));
- pns->AddMember("EditPane", new EditPaneFactory(ptime));
- pns->AddMember("ScrollBarPane", new ScrollPaneFactory(pmodeler, false, true));
- pns->AddMember("ScrollBarHorizontalPane", new ScrollPaneFactory(pmodeler, true, true));
- pns->AddMember("CustomScrollBarPane", new ScrollPaneFactory(pmodeler, false, false));
- pns->AddMember("CustomScrollBarHorizontalPane", new ScrollPaneFactory(pmodeler, true, false));
- pns->AddMember("ListPane", new ListPaneFactory(pmodeler));
- pns->AddMember("ListWithScrollBarPane", new ListWithScrollBarPaneFactory(pmodeler));
- pns->AddMember("ListHorizontalWithScrollBarPane", new ListHorizontalWithScrollBarPaneFactory(pmodeler));
- pns->AddMember("ImagePane", new ImagePaneFactory(pmodeler));
- pns->AddMember("ScreenPane", new ScreenPaneFactory(pmodeler));
- pns->AddMember("HoverSite", new HoverSiteFactory());
- pns->AddMember("HoverPane", new HoverPaneFactory());
- pns->AddMember("HoverPaneColumns", new HoverPaneColumnsFactory());
- pns->AddMember("HoverSiteGetID", new GetHoverSiteIDFactory());
- pns->AddMember("ParentPane", new ParentPaneFactory(pmodeler));
- }
|