efpane.cpp 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. #include "pch.h"
  2. /////////////////////////////////////////////////////////////////////////////
  3. //
  4. // ScreenPane
  5. //
  6. /////////////////////////////////////////////////////////////////////////////
  7. class ScreenPane : public ImagePane {
  8. private:
  9. Window* m_pwindow;
  10. WinPoint m_pointWindowStart;
  11. WinPoint m_pointMouseStart;
  12. public:
  13. ScreenPane(Window* pwindow, Image* pimage) :
  14. m_pwindow(pwindow),
  15. ImagePane(pimage)
  16. {
  17. }
  18. };
  19. /////////////////////////////////////////////////////////////////////////////
  20. //
  21. // Gauge Pane
  22. //
  23. /////////////////////////////////////////////////////////////////////////////
  24. GaugePane::GaugePane(Surface* psurface,
  25. const Color& colorFlash,
  26. float minValue,
  27. float maxValue,
  28. const Color& colorEmpty)
  29. :
  30. m_psurface(psurface),
  31. m_colorFlash(colorFlash),
  32. m_colorEmpty(colorEmpty),
  33. m_minValue(minValue),
  34. m_maxValue(maxValue),
  35. m_value(0),
  36. m_valueOld(0),
  37. m_valueFlash(0),
  38. m_timeLastChange(Time::Now())
  39. {
  40. assert(m_psurface);
  41. assert(m_minValue < m_maxValue);
  42. InternalSetSize(m_psurface->GetSize());
  43. }
  44. void GaugePane::Paint(Surface* psurface)
  45. {
  46. if (m_value != 0) {
  47. psurface->BitBlt(
  48. WinPoint(0, 0),
  49. m_psurface,
  50. WinRect(0, 0, m_value, YSize())
  51. );
  52. }
  53. if (m_value < m_valueFlash) {
  54. psurface->FillRect(
  55. WinRect(
  56. m_value,
  57. 0,
  58. m_valueFlash,
  59. YSize()
  60. ),
  61. m_colorFlash
  62. );
  63. }
  64. }
  65. void GaugePane::SetValue(float v, bool fFlash)
  66. {
  67. m_value =
  68. (int)bound(
  69. (v - m_minValue) * ((float)XSize()) / (m_maxValue - m_minValue),
  70. 0.0f,
  71. (float)XSize()
  72. );
  73. }
  74. void GaugePane::Update(Time time)
  75. {
  76. if (m_value != m_valueOld) {
  77. if (m_value < m_valueOld) {
  78. m_valueFlash = m_valueOld;
  79. } else {
  80. m_valueFlash = m_value;
  81. }
  82. m_timeLastChange = time;
  83. m_valueOld = m_value;
  84. NeedPaint();
  85. }
  86. if (m_value != m_valueFlash && time - m_timeLastChange > 0.25f) {
  87. m_valueFlash = m_value;
  88. NeedPaint();
  89. }
  90. }
  91. //////////////////////////////////////////////////////////////////////////////
  92. //
  93. // ParseIntVector
  94. //
  95. //////////////////////////////////////////////////////////////////////////////
  96. void ParseIntVector(IObject* pobject, TVector<int>& vec)
  97. {
  98. IObjectList* plistVertices; CastTo(plistVertices, pobject);
  99. plistVertices->GetFirst();
  100. while (plistVertices->GetCurrent() != NULL) {
  101. vec.PushEnd((int)GetNumber(plistVertices->GetCurrent()));
  102. plistVertices->GetNext();
  103. }
  104. }
  105. //////////////////////////////////////////////////////////////////////////////
  106. //
  107. // ParseFloatVector
  108. //
  109. //////////////////////////////////////////////////////////////////////////////
  110. void ParseFloatVector(IObject* pobject, TVector<float>& vec)
  111. {
  112. IObjectList* plistVertices; CastTo(plistVertices, pobject);
  113. plistVertices->GetFirst();
  114. while (plistVertices->GetCurrent() != NULL) {
  115. vec.PushEnd((float)GetNumber(plistVertices->GetCurrent()));
  116. plistVertices->GetNext();
  117. }
  118. }
  119. //////////////////////////////////////////////////////////////////////////////
  120. //
  121. // ParseStringVector
  122. //
  123. //////////////////////////////////////////////////////////////////////////////
  124. void ParseStringVector(IObject* pobject, TVector<ZString>& vec)
  125. {
  126. IObjectList* plistVertices; CastTo(plistVertices, pobject);
  127. plistVertices->GetFirst();
  128. while (plistVertices->GetCurrent() != NULL) {
  129. vec.PushEnd(GetString(plistVertices->GetCurrent()));
  130. plistVertices->GetNext();
  131. }
  132. }
  133. //////////////////////////////////////////////////////////////////////////////
  134. //
  135. // ThumbPane
  136. //
  137. //////////////////////////////////////////////////////////////////////////////
  138. class ThumbPaneImpl : public ThumbPane{
  139. private:
  140. TRef<Surface> m_psurface;
  141. bool m_bHorizontal;
  142. public:
  143. ThumbPaneImpl(Modeler* pmodeler, bool bHorizontal, TRef<Image>& pImageThumb) :
  144. m_bHorizontal(bHorizontal)
  145. {
  146. // TODO if (pImageThumb == NULL)
  147. if(bHorizontal)
  148. m_psurface =pmodeler->LoadSurface("scrollhorizontalthumbbmp", true);
  149. else
  150. m_psurface =pmodeler->LoadSurface("scrollthumbbmp", true);
  151. }
  152. void Paint(Surface* psurface)
  153. {
  154. if (m_bHorizontal)
  155. {
  156. const WinPoint& size = m_psurface->GetSize();
  157. int x = 0;
  158. while (x + size.X() < XSize()) {
  159. psurface->BitBlt(
  160. WinPoint(x, 0),
  161. m_psurface,
  162. WinRect(0, 0, size.X(), min(size.Y(), YSize()))
  163. );
  164. x += size.X();
  165. }
  166. psurface->BitBlt(
  167. WinPoint(x, 0),
  168. m_psurface,
  169. WinRect(0, 0, XSize() - x, min(size.Y(), YSize()))
  170. );
  171. }
  172. else
  173. {
  174. const WinPoint& size = m_psurface->GetSize();
  175. int y = 0;
  176. while (y + size.Y() < YSize()) {
  177. psurface->BitBlt(
  178. WinPoint(0, y),
  179. m_psurface,
  180. WinRect(0, 0, min(size.X(), XSize()), size.Y())
  181. );
  182. y += size.Y();
  183. }
  184. psurface->BitBlt(
  185. WinPoint(0, y),
  186. m_psurface,
  187. WinRect(0, 0, min(size.X(), XSize()), YSize() - y)
  188. );
  189. }
  190. }
  191. void UpdateLayout()
  192. {
  193. WinPoint size = GetExpand();
  194. if (m_bHorizontal)
  195. {
  196. if (size.X() < 8) {
  197. size.SetX(8);
  198. }
  199. }
  200. else
  201. {
  202. if (size.Y() < 8) {
  203. size.SetY(8);
  204. }
  205. }
  206. InternalSetSize(size);
  207. }
  208. };
  209. TRef<ThumbPane> ThumbPane::Create(Modeler* pmodeler,
  210. bool bHorizontal,
  211. TRef<Image> pImageThumb) // Set this to NULL for default image
  212. {
  213. return new ThumbPaneImpl(pmodeler, bHorizontal, pImageThumb);
  214. }
  215. //////////////////////////////////////////////////////////////////////////////
  216. //
  217. // TrekScrollPane
  218. //
  219. //////////////////////////////////////////////////////////////////////////////
  220. TRef<Pane> CreateTrekScrollPane(
  221. WinPoint size,
  222. Modeler* pmodeler,
  223. TRef<IIntegerEventSource>& pevent,
  224. TRef<ScrollPane>& pscrollPane,
  225. bool bHoriztonal,
  226. TRef<ButtonPane>& pbuttonUp,
  227. TRef<ButtonPane>& pbuttonDown,
  228. TRef<Image>& pImageThumb
  229. ) {
  230. if (pbuttonUp == NULL || pbuttonDown == NULL)
  231. {
  232. TRef<Image> pimageUp;
  233. TRef<Image> pimageUpSel;
  234. TRef<Image> pimageDown;
  235. TRef<Image> pimageDownSel;
  236. //
  237. // Load default images if no buttons are passed as params
  238. //
  239. if (bHoriztonal)
  240. {
  241. pimageUp = pmodeler->LoadImage("scrollleftbmp" , true);
  242. pimageUpSel = pmodeler->LoadImage("scrollleftselbmp" , true);
  243. pimageDown = pmodeler->LoadImage("scrollrightbmp" , true);
  244. pimageDownSel = pmodeler->LoadImage("scrollrightselbmp", true);
  245. }
  246. else
  247. {
  248. pimageUp = pmodeler->LoadImage("scrollupbmp" , true);
  249. pimageUpSel = pmodeler->LoadImage("scrollupselbmp" , true);
  250. pimageDown = pmodeler->LoadImage("scrolldownbmp" , true);
  251. pimageDownSel = pmodeler->LoadImage("scrolldownselbmp", true);
  252. }
  253. pbuttonUp =
  254. CreateButton(
  255. new ImagePane(pimageUp),
  256. new ImagePane(pimageUpSel),
  257. false,
  258. 0.1f,
  259. 0.5f
  260. );
  261. pbuttonDown =
  262. CreateButton(
  263. new ImagePane(pimageDown),
  264. new ImagePane(pimageDownSel),
  265. false,
  266. 0.1f,
  267. 0.5f
  268. );
  269. }
  270. pscrollPane =
  271. CreateScrollPane(
  272. new JustifyPane(),
  273. ThumbPane::Create(pmodeler, bHoriztonal, pImageThumb),
  274. pbuttonUp,
  275. pbuttonUp->GetEventSource(),
  276. pbuttonDown,
  277. pbuttonDown->GetEventSource(),
  278. bHoriztonal, // false == vertical
  279. 0.25f,
  280. 1,
  281. 1,
  282. 1,
  283. 1,
  284. size
  285. );
  286. pevent = pscrollPane->GetEventSource();
  287. return pscrollPane;
  288. };
  289. //////////////////////////////////////////////////////////////////////////////
  290. //
  291. // ScrollPane
  292. //
  293. //////////////////////////////////////////////////////////////////////////////
  294. class ScrollPaneFactory : public IFunction {
  295. private:
  296. TRef<Modeler> m_pmodeler;
  297. bool m_bHorizontal;
  298. bool m_bDefaultImages;
  299. public:
  300. ScrollPaneFactory(Modeler* pmodeler, bool bHorizontal, bool bDefaultImages) :
  301. m_pmodeler(pmodeler),
  302. m_bHorizontal(bHorizontal),
  303. m_bDefaultImages(bDefaultImages)
  304. {
  305. }
  306. TRef<IObject> Apply(ObjectStack& stack)
  307. {
  308. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  309. TRef<ButtonPane> pbuttonUp;
  310. TRef<ButtonPane> pbuttonDown;
  311. TRef<Image> pImageThumb;
  312. if(m_bDefaultImages)
  313. {
  314. pbuttonUp = NULL;
  315. pbuttonDown = NULL;
  316. pImageThumb = NULL;
  317. }
  318. else
  319. {
  320. //
  321. // Pop buttons off stack
  322. //
  323. CastTo(pbuttonUp, (IObject*)stack.Pop());
  324. CastTo(pbuttonDown, (IObject*)stack.Pop());
  325. CastTo(pImageThumb, (Value*)(IObject*)stack.Pop());
  326. }
  327. WinPoint temp;
  328. temp.SetX((int)ppoint->GetValue().X());
  329. temp.SetY((int)ppoint->GetValue().Y());
  330. return
  331. CreateTrekScrollPane(
  332. temp,
  333. m_pmodeler,
  334. TRef<IIntegerEventSource>(),
  335. TRef<ScrollPane>(),
  336. m_bHorizontal,
  337. pbuttonUp,
  338. pbuttonDown,
  339. pImageThumb
  340. );
  341. }
  342. };
  343. //////////////////////////////////////////////////////////////////////////////
  344. //
  345. // ListPane
  346. //
  347. //////////////////////////////////////////////////////////////////////////////
  348. class ListPaneFactory : public IFunction {
  349. private:
  350. TRef<Modeler> m_pmodeler;
  351. public:
  352. ListPaneFactory(Modeler* pmodeler) :
  353. m_pmodeler(pmodeler)
  354. {
  355. }
  356. TRef<IObject> Apply(ObjectStack& stack)
  357. {
  358. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  359. return
  360. (Pane*)CreateListPane(
  361. WinPoint::Cast(ppoint->GetValue()),
  362. NULL,
  363. NULL,
  364. NULL,
  365. false
  366. );
  367. }
  368. };
  369. //////////////////////////////////////////////////////////////////////////////
  370. //
  371. // EditPane
  372. //
  373. //////////////////////////////////////////////////////////////////////////////
  374. class EditPaneFactory : public IFunction {
  375. private:
  376. TRef<Number> m_ptime;
  377. public:
  378. EditPaneFactory(Number* ptime) :
  379. m_ptime(ptime)
  380. {
  381. }
  382. TRef<IObject> Apply(ObjectStack& stack)
  383. {
  384. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  385. TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
  386. TRef<Pane> ppane = CreateEditPane(ZString(), pfont->GetValue(), m_ptime);
  387. ppane->SetSize(WinPoint::Cast(ppoint->GetValue()));
  388. return ppane;
  389. }
  390. };
  391. //////////////////////////////////////////////////////////////////////////////
  392. //
  393. // StringListPane
  394. //
  395. //////////////////////////////////////////////////////////////////////////////
  396. class StringListWithScrollBarPaneFactory: public IFunction {
  397. private:
  398. TRef<Modeler> m_pmodeler;
  399. public:
  400. StringListWithScrollBarPaneFactory(Modeler* pmodeler) :
  401. m_pmodeler(pmodeler)
  402. {
  403. }
  404. TRef<IObject> Apply(ObjectStack& stack)
  405. {
  406. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  407. TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
  408. TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
  409. TRef<ColorValue> pcolor; CastTo(pcolor, (IObject*)stack.Pop());
  410. return (Pane*)
  411. CreateStringListPane(
  412. WinPoint::Cast(ppoint->GetValue()),
  413. NULL,
  414. NULL,
  415. pscrollPane,
  416. false,
  417. pfont->GetValue(),
  418. Color::White(),
  419. pcolor->GetValue()
  420. );
  421. }
  422. };
  423. //////////////////////////////////////////////////////////////////////////////
  424. //
  425. // ListPane
  426. //
  427. //////////////////////////////////////////////////////////////////////////////
  428. class ListWithScrollBarPaneFactory : public IFunction {
  429. private:
  430. TRef<Modeler> m_pmodeler;
  431. public:
  432. ListWithScrollBarPaneFactory(Modeler* pmodeler) :
  433. m_pmodeler(pmodeler)
  434. {
  435. }
  436. TRef<IObject> Apply(ObjectStack& stack)
  437. {
  438. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  439. TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
  440. return
  441. (Pane*)CreateListPane(
  442. WinPoint::Cast(ppoint->GetValue()),
  443. NULL,
  444. NULL,
  445. pscrollPane,
  446. false
  447. );
  448. }
  449. };
  450. //////////////////////////////////////////////////////////////////////////////
  451. //
  452. // ListHoriztonalPane
  453. //
  454. //////////////////////////////////////////////////////////////////////////////
  455. class ListHorizontalWithScrollBarPaneFactory : public IFunction {
  456. private:
  457. TRef<Modeler> m_pmodeler;
  458. public:
  459. ListHorizontalWithScrollBarPaneFactory(Modeler* pmodeler) :
  460. m_pmodeler(pmodeler)
  461. {
  462. }
  463. TRef<IObject> Apply(ObjectStack& stack)
  464. {
  465. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  466. TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
  467. return
  468. (Pane*)CreateListPane(
  469. WinPoint::Cast(ppoint->GetValue()),
  470. NULL,
  471. NULL,
  472. pscrollPane,
  473. true
  474. );
  475. }
  476. };
  477. //////////////////////////////////////////////////////////////////////////////
  478. //
  479. // ImagePaneFactory
  480. //
  481. //////////////////////////////////////////////////////////////////////////////
  482. class ImagePaneFactory : public IFunction {
  483. private:
  484. TRef<Modeler> m_pmodeler;
  485. public:
  486. ImagePaneFactory(Modeler* pmodeler) :
  487. m_pmodeler(pmodeler)
  488. {
  489. }
  490. void AddChildren(Pane* ppaneParent, ObjectStack& stack)
  491. {
  492. TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
  493. plist->GetFirst();
  494. while (plist->GetCurrent() != NULL) {
  495. IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
  496. TRef<Pane> ppaneChild; CastTo(ppaneChild, ppair->GetFirst() );
  497. TRef<PointValue> ppointChild; CastTo(ppointChild, ppair->GetSecond() );
  498. ppaneParent->InsertAtBottom(ppaneChild);
  499. ppaneChild->SetOffset(
  500. WinPoint(
  501. (int)ppointChild->GetValue().X(),
  502. (int)ppointChild->GetValue().Y()
  503. )
  504. );
  505. plist->GetNext();
  506. }
  507. }
  508. TRef<IObject> Apply(ObjectStack& stack)
  509. {
  510. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  511. TRef<Pane> ppane = new ImagePane(pimage);
  512. AddChildren(ppane, stack);
  513. return ppane;
  514. }
  515. };
  516. //////////////////////////////////////////////////////////////////////////////
  517. //
  518. // ScreenPane
  519. //
  520. //////////////////////////////////////////////////////////////////////////////
  521. Window* g_pwindow;
  522. void SetEffectWindow(Window* pwindow)
  523. {
  524. g_pwindow = pwindow;
  525. }
  526. class ScreenPaneFactory : public IFunction {
  527. private:
  528. TRef<Modeler> m_pmodeler;
  529. public:
  530. ScreenPaneFactory(Modeler* pmodeler) :
  531. m_pmodeler(pmodeler)
  532. {
  533. }
  534. void AddChildren(Pane* ppaneParent, ObjectStack& stack)
  535. {
  536. TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
  537. plist->GetFirst();
  538. while (plist->GetCurrent() != NULL) {
  539. IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
  540. TRef<Pane> ppaneChild; CastTo(ppaneChild, ppair->GetFirst() );
  541. TRef<PointValue> ppointChild; CastTo(ppointChild, ppair->GetSecond() );
  542. ppaneParent->InsertAtBottom(ppaneChild);
  543. ppaneChild->SetOffset(
  544. WinPoint(
  545. (int)ppointChild->GetValue().X(),
  546. (int)ppointChild->GetValue().Y()
  547. )
  548. );
  549. plist->GetNext();
  550. }
  551. }
  552. TRef<IObject> Apply(ObjectStack& stack)
  553. {
  554. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  555. TRef<Pane> ppane = new ScreenPane(g_pwindow, pimage);
  556. AddChildren(ppane, stack);
  557. return ppane;
  558. }
  559. };
  560. //////////////////////////////////////////////////////////////////////////////
  561. //
  562. // Hover Site
  563. //
  564. //////////////////////////////////////////////////////////////////////////////
  565. class HoverSiteImpl : public HoverSite {
  566. private:
  567. TRef<ModifiableNumber> m_pnumber;
  568. public:
  569. HoverSiteImpl(float initialID) :
  570. m_pnumber(new ModifiableNumber(initialID))
  571. {
  572. }
  573. void Enter(float id)
  574. {
  575. m_pnumber->SetValue(id);
  576. }
  577. void Leave(float id)
  578. {
  579. m_pnumber->SetValue(0);
  580. }
  581. Number* GetID()
  582. {
  583. return m_pnumber;
  584. }
  585. };
  586. TRef<HoverSite> CreateHoverSite(float initialID)
  587. {
  588. return new HoverSiteImpl(initialID);
  589. }
  590. class HoverSiteFactory : public IFunction {
  591. public:
  592. TRef<IObject> Apply(ObjectStack& stack)
  593. {
  594. TRef<Number> pnumber; CastTo(pnumber, (IObject*)stack.Pop());
  595. return CreateHoverSite(pnumber->GetValue());
  596. }
  597. };
  598. class GetHoverSiteIDFactory : public IFunction {
  599. public:
  600. TRef<IObject> Apply(ObjectStack& stack)
  601. {
  602. TRef<HoverSite> psite; CastTo(psite, (IObject*)stack.Pop());
  603. return psite->GetID();
  604. }
  605. };
  606. //////////////////////////////////////////////////////////////////////////////
  607. //
  608. // Hover Pane
  609. //
  610. //////////////////////////////////////////////////////////////////////////////
  611. class HoverPane : public Pane {
  612. private:
  613. TRef<HoverSite> m_psite;
  614. float m_id;
  615. bool m_bEntered;
  616. public:
  617. HoverPane(HoverSite* psite, float id, Pane* ppane) :
  618. Pane(ppane),
  619. m_psite(psite),
  620. m_id(id),
  621. m_bEntered(false)
  622. {
  623. }
  624. void UpdateLayout()
  625. {
  626. DefaultUpdateLayout();
  627. }
  628. //////////////////////////////////////////////////////////////////////////////
  629. //
  630. // IMouseInput Methods
  631. //
  632. //////////////////////////////////////////////////////////////////////////////
  633. void MouseEnter(IInputProvider* pprovider, const Point& point)
  634. {
  635. if (!Child()->IsHidden()) {
  636. m_bEntered = true;
  637. m_psite->Enter(m_id);
  638. }
  639. }
  640. void MouseLeave(IInputProvider* pprovider)
  641. {
  642. if (m_bEntered) {
  643. m_bEntered = false;
  644. m_psite->Leave(m_id);
  645. }
  646. }
  647. };
  648. TRef<Pane> CreateHoverPane(HoverSite* psite, float id, Pane* ppane)
  649. {
  650. return new HoverPane(psite, id, ppane);
  651. }
  652. class HoverPaneFactory : public IFunction {
  653. public:
  654. TRef<IObject> Apply(ObjectStack& stack)
  655. {
  656. TRef<HoverSite> psite; CastTo(psite, (IObject*)stack.Pop());
  657. TRef<Number> pid; CastTo(pid, (IObject*)stack.Pop());
  658. TRef<Pane> ppane; CastTo(ppane, (IObject*)stack.Pop());
  659. return
  660. (Pane*)CreateHoverPane(
  661. psite,
  662. pid->GetValue(),
  663. ppane
  664. );
  665. }
  666. };
  667. //////////////////////////////////////////////////////////////////////////////
  668. //
  669. // Hover Pane for Button Bar Panes and Lists
  670. //
  671. //////////////////////////////////////////////////////////////////////////////
  672. class HoverPaneColumns : public Pane {
  673. private:
  674. TRef<HoverSite> m_psite;
  675. float m_id;
  676. TVector<int> m_vecColumns;
  677. float m_startid;
  678. public:
  679. HoverPaneColumns(HoverSite* psite, float id, Pane* ppane, TVector<int>& pvecColumns) :
  680. Pane(ppane),
  681. m_psite(psite),
  682. m_id(id),
  683. m_startid(id),
  684. m_vecColumns(pvecColumns)
  685. {
  686. }
  687. void UpdateLayout()
  688. {
  689. DefaultUpdateLayout();
  690. }
  691. //////////////////////////////////////////////////////////////////////////////
  692. //
  693. // IMouseInput Methods
  694. //
  695. //////////////////////////////////////////////////////////////////////////////
  696. void MouseEnter(IInputProvider* pprovider, const Point& point)
  697. {
  698. m_psite->Enter(m_id);
  699. }
  700. void MouseLeave(IInputProvider* pprovider)
  701. {
  702. m_psite->Leave(m_id);
  703. }
  704. void MouseMove(IInputProvider* pprovider, const Point& point, bool bCaptured, bool bInside)
  705. {
  706. int count = m_vecColumns.GetCount();
  707. int xprev = 0;
  708. for (int index = 0; index < count; index++) {
  709. int x = m_vecColumns[index];
  710. if ((int)point.X() < x) {
  711. if ((int)point.X() > xprev) {
  712. m_id = (float)(m_startid + index);
  713. m_psite->Enter(m_id);
  714. }
  715. } else {
  716. m_id = 0;
  717. }
  718. xprev = x;
  719. }
  720. }
  721. };
  722. TRef<Pane> CreateHoverPaneColumns(HoverSite* psite, float id, Pane* ppane, TVector<int>& pvecColumns)
  723. {
  724. return new HoverPaneColumns(psite, id, ppane, pvecColumns);
  725. }
  726. class HoverPaneColumnsFactory : public IFunction {
  727. public:
  728. TRef<IObject> Apply(ObjectStack& stack)
  729. {
  730. TRef<HoverSite> psite; CastTo(psite, (IObject*)stack.Pop());
  731. TRef<Number> pid; CastTo(pid, (IObject*)stack.Pop());
  732. TRef<Pane> ppane; CastTo(ppane, (IObject*)stack.Pop());
  733. TVector<int> pvecColumns;
  734. ParseIntVector((IObject*)stack.Pop(), pvecColumns);
  735. return
  736. (Pane*)CreateHoverPaneColumns(
  737. psite,
  738. pid->GetValue(),
  739. ppane,
  740. pvecColumns
  741. );
  742. }
  743. };
  744. //////////////////////////////////////////////////////////////////////////////
  745. //
  746. // ParentPane
  747. //
  748. //////////////////////////////////////////////////////////////////////////////
  749. class ParentPaneFactory : public IFunction {
  750. private:
  751. TRef<Modeler> m_pmodeler;
  752. public:
  753. ParentPaneFactory(Modeler* pmodeler) :
  754. m_pmodeler(pmodeler)
  755. {
  756. }
  757. void AddChildren(Pane* ppaneParent, ObjectStack& stack)
  758. {
  759. TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
  760. plist->GetFirst();
  761. while (plist->GetCurrent() != NULL) {
  762. IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
  763. TRef<Pane> ppaneChild; CastTo(ppaneChild, ppair->GetFirst() );
  764. TRef<PointValue> ppointChild; CastTo(ppointChild, ppair->GetSecond() );
  765. ppaneParent->InsertAtBottom(ppaneChild);
  766. ppaneChild->SetOffset(
  767. WinPoint(
  768. (int)ppointChild->GetValue().X(),
  769. (int)ppointChild->GetValue().Y()
  770. )
  771. );
  772. plist->GetNext();
  773. }
  774. }
  775. TRef<IObject> Apply(ObjectStack& stack)
  776. {
  777. TRef<Pane> ppane; CastTo(ppane, (Value*)(IObject*)stack.Pop());
  778. AddChildren(ppane, stack);
  779. return ppane;
  780. }
  781. };
  782. //////////////////////////////////////////////////////////////////////////////
  783. //
  784. //
  785. //
  786. //////////////////////////////////////////////////////////////////////////////
  787. class ButtonEffectPaneFactory : public IFunction {
  788. private:
  789. TRef<Modeler> m_pmodeler;
  790. public:
  791. ButtonEffectPaneFactory(Modeler* pmodeler) :
  792. m_pmodeler(pmodeler)
  793. {
  794. }
  795. TRef<IObject> Apply(ObjectStack& stack)
  796. {
  797. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  798. TRef<Number> pnumberFaces; CastTo(pnumberFaces, (IObject*)stack.Pop());
  799. TRef<Boolean> pboolToggle; CastTo(pboolToggle, (IObject*)stack.Pop());
  800. DWORD dwFaces = (DWORD)pnumberFaces->GetValue();
  801. return
  802. CreateButton(
  803. CreateButtonFacePane(
  804. pimage->GetSurface(),
  805. dwFaces
  806. ),
  807. pboolToggle->GetValue(),
  808. 0,
  809. 0
  810. );
  811. }
  812. };
  813. //////////////////////////////////////////////////////////////////////////////
  814. //
  815. //
  816. //
  817. //////////////////////////////////////////////////////////////////////////////
  818. TRef<Pane> CreateBlackPane(Pane* ppane)
  819. {
  820. return new BorderPane(0, Color::Black(), ppane);
  821. }
  822. class BlackPaneFactory : public IFunction {
  823. public:
  824. BlackPaneFactory()
  825. {
  826. }
  827. TRef<IObject> Apply(ObjectStack& stack)
  828. {
  829. TRef<Pane> ppane; CastTo(ppane, (Value*)(IObject*)stack.Pop());
  830. return CreateBlackPane(ppane);
  831. }
  832. };
  833. //////////////////////////////////////////////////////////////////////////////
  834. //
  835. //
  836. //
  837. //////////////////////////////////////////////////////////////////////////////
  838. void AddPaneFactories(
  839. INameSpace* pns,
  840. Modeler* pmodeler,
  841. IPopupContainer* ppopupContainer,
  842. Number* ptime
  843. ) {
  844. pns->AddMember("ButtonFaceUp", new Number((float)ButtonFaceUp));
  845. pns->AddMember("ButtonFaceDown", new Number((float)ButtonFaceDown));
  846. pns->AddMember("ButtonNormal", new Number((float)ButtonNormal));
  847. pns->AddMember("ButtonNormalCheckBox", new Number((float)ButtonNormalCheckBox));
  848. pns->AddMember("Button3State", new Number((float)Button3State));
  849. pns->AddMember("ButtonUpDown", new Number((float)(ButtonFaceUp | ButtonFaceDown)));
  850. pns->AddMember("ButtonEffectPane", new ButtonEffectPaneFactory(pmodeler));
  851. pns->AddMember("BlackPane", new BlackPaneFactory());
  852. pns->AddMember("StringListWithScrollBarPane", new StringListWithScrollBarPaneFactory(pmodeler));
  853. pns->AddMember("EditPane", new EditPaneFactory(ptime));
  854. pns->AddMember("ScrollBarPane", new ScrollPaneFactory(pmodeler, false, true));
  855. pns->AddMember("ScrollBarHorizontalPane", new ScrollPaneFactory(pmodeler, true, true));
  856. pns->AddMember("CustomScrollBarPane", new ScrollPaneFactory(pmodeler, false, false));
  857. pns->AddMember("CustomScrollBarHorizontalPane", new ScrollPaneFactory(pmodeler, true, false));
  858. pns->AddMember("ListPane", new ListPaneFactory(pmodeler));
  859. pns->AddMember("ListWithScrollBarPane", new ListWithScrollBarPaneFactory(pmodeler));
  860. pns->AddMember("ListHorizontalWithScrollBarPane", new ListHorizontalWithScrollBarPaneFactory(pmodeler));
  861. pns->AddMember("ImagePane", new ImagePaneFactory(pmodeler));
  862. pns->AddMember("ScreenPane", new ScreenPaneFactory(pmodeler));
  863. pns->AddMember("HoverSite", new HoverSiteFactory());
  864. pns->AddMember("HoverPane", new HoverPaneFactory());
  865. pns->AddMember("HoverPaneColumns", new HoverPaneColumnsFactory());
  866. pns->AddMember("HoverSiteGetID", new GetHoverSiteIDFactory());
  867. pns->AddMember("ParentPane", new ParentPaneFactory(pmodeler));
  868. }