pagepane.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. #include "pch.h"
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Link Pane
  5. //
  6. //////////////////////////////////////////////////////////////////////////////
  7. class TabWordPane : public Pane {
  8. private:
  9. public:
  10. TabWordPane(int x) :
  11. Pane(NULL, WinPoint(0, 0))
  12. {
  13. }
  14. int GetAlignedXSize(int xPos)
  15. {
  16. int tabs = (xPos / 16) + 1;
  17. int size = tabs * 16 - xPos;
  18. return size;
  19. }
  20. };
  21. //////////////////////////////////////////////////////////////////////////////
  22. //
  23. // Link Pane
  24. //
  25. //////////////////////////////////////////////////////////////////////////////
  26. class LinkPane : public StringPane {
  27. private:
  28. TRef<StringEventSourceImpl> m_peventSource;
  29. ZString m_strTopic;
  30. Color m_color;
  31. Color m_colorSelected;
  32. bool m_bInside;
  33. public:
  34. LinkPane(
  35. StringEventSourceImpl* peventSource,
  36. const ZString& str,
  37. const ZString& strTopic,
  38. IEngineFont* pfont,
  39. const Color& color,
  40. const Color& colorSelected
  41. ) :
  42. StringPane(str, pfont),
  43. m_peventSource(peventSource),
  44. m_strTopic(strTopic),
  45. m_color(color),
  46. m_colorSelected(colorSelected),
  47. m_bInside(false)
  48. {
  49. SetTextColor(m_color);
  50. }
  51. void MouseEnter(IInputProvider* pprovider, const Point& point)
  52. {
  53. m_bInside = true;
  54. SetTextColor(m_colorSelected);
  55. }
  56. void MouseLeave(IInputProvider* pprovider)
  57. {
  58. m_bInside = false;
  59. SetTextColor(m_color);
  60. }
  61. MouseResult Button(IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown)
  62. {
  63. if (button == 0 && bDown) {
  64. m_peventSource->Trigger(m_strTopic);
  65. }
  66. return MouseResult();
  67. }
  68. };
  69. //////////////////////////////////////////////////////////////////////////////
  70. //
  71. // Page Pane
  72. //
  73. //////////////////////////////////////////////////////////////////////////////
  74. class PagePaneImpl : public PagePane {
  75. private:
  76. TRef<Modeler> m_pmodeler;
  77. TRef<PagePaneIncluder> m_ppagePaneIncluder;
  78. TRef<IEngineFont> m_pfontDefault;
  79. Color m_colorDefault;
  80. TRef<IEngineFont> m_pfont;
  81. Color m_color;
  82. Color m_colorMain;
  83. Color m_colorSecondary;
  84. Color m_colorHighlight;
  85. int m_width;
  86. TRef<StringEventSourceImpl> m_peventSourceMain;
  87. TRef<StringEventSourceImpl> m_peventSourceSecondary;
  88. public:
  89. PagePaneImpl(
  90. Modeler* pmodeler,
  91. int width,
  92. StringEventSourceImpl* peventSourceMain,
  93. StringEventSourceImpl* peventSourceSecondary
  94. ) :
  95. m_pmodeler(pmodeler),
  96. m_width(width)
  97. {
  98. if (peventSourceMain) {
  99. m_peventSourceMain = peventSourceMain;
  100. } else {
  101. m_peventSourceMain = new StringEventSourceImpl();
  102. }
  103. if (peventSourceSecondary) {
  104. m_peventSourceSecondary = peventSourceSecondary;
  105. } else {
  106. m_peventSourceSecondary = new StringEventSourceImpl();
  107. }
  108. }
  109. //////////////////////////////////////////////////////////////////////////////
  110. //
  111. // Implementation
  112. //
  113. //////////////////////////////////////////////////////////////////////////////
  114. void InsertWord(PCC pcc, PCC pccEnd)
  115. {
  116. TRef<StringPane> pstringPane =
  117. new StringPane(
  118. ZString(pcc, pccEnd - pcc) + " ",
  119. m_pfont
  120. );
  121. pstringPane->SetTextColor(m_color);
  122. InsertAtBottom(pstringPane);
  123. }
  124. void InsertString(const ZString& str)
  125. {
  126. TRef<StringPane> pstringPane =
  127. new StringPane(
  128. str + " ",
  129. m_pfont
  130. );
  131. pstringPane->SetTextColor(m_color);
  132. InsertAtBottom(pstringPane);
  133. }
  134. void InsertTab()
  135. {
  136. InsertAtBottom(new TabWordPane(1));
  137. }
  138. bool InsertLink(PCC& pcc, PCC pccEnd, const Color& color, StringEventSourceImpl* peventSource)
  139. {
  140. //
  141. // topic|text>
  142. //
  143. //
  144. // topic
  145. //
  146. ZString strTopic;
  147. if (!ParseSymbol(pcc, pccEnd, '|', strTopic)) {
  148. return false;
  149. }
  150. //
  151. // text
  152. //
  153. ZString strText;
  154. if (!ParseSymbol(pcc, pccEnd, '>', strText)) {
  155. return false;
  156. }
  157. //
  158. // The LinkPane
  159. //
  160. TRef<LinkPane> plinkPane =
  161. new LinkPane(
  162. peventSource,
  163. strText + " ",
  164. strTopic,
  165. m_pfont,
  166. color,
  167. m_colorHighlight
  168. );
  169. InsertAtBottom(plinkPane);
  170. return true;
  171. }
  172. bool Error(const ZString& str)
  173. {
  174. m_color = Color::Red();
  175. Parse(NULL, "Error: " + str);
  176. return false;
  177. }
  178. bool MatchBrace(PCC& pcc, PCC pccEnd)
  179. {
  180. int depth = 1;
  181. while (pcc < pccEnd && depth != 0) {
  182. if (*pcc == '<') {
  183. depth++;
  184. } else if (*pcc == '>') {
  185. depth--;
  186. }
  187. pcc++;
  188. }
  189. if (depth != 0) {
  190. return Error("Expected '>'");
  191. }
  192. return true;
  193. }
  194. bool ParseComment(PCC& pcc, PCC pccEnd)
  195. {
  196. return MatchBrace(pcc, pccEnd);
  197. }
  198. bool ParseBullet(INameSpace* pns, PCC& pcc, PCC pccEnd)
  199. {
  200. ZString strImage;
  201. if (!ParseSymbol(pcc, pccEnd, '|', strImage)) {
  202. return false;
  203. }
  204. TRef<Image> pimage = m_pmodeler->LoadImage(strImage + "bmp", true, false);
  205. if (pimage == NULL) {
  206. return Error("Invalid image");
  207. }
  208. PCC pccStart = pcc;
  209. if (!MatchBrace(pcc, pccEnd)) {
  210. return false;
  211. }
  212. TRef<PagePaneImpl> ppagePane =
  213. new PagePaneImpl(
  214. m_pmodeler,
  215. m_width - int(pimage->GetBounds().GetRect().XSize()),
  216. m_peventSourceMain,
  217. m_peventSourceSecondary
  218. );
  219. ppagePane->SetAttributes(
  220. m_pfontDefault,
  221. m_colorDefault,
  222. m_colorMain,
  223. m_colorSecondary,
  224. m_colorHighlight
  225. );
  226. ppagePane->m_pfont = m_pfontDefault;
  227. ppagePane->m_color = m_colorDefault;
  228. ppagePane->RemoveAllChildren();
  229. ppagePane->Parse(pns, pccStart, pcc - 1);
  230. InsertAtBottom(
  231. new JustifyPane(
  232. JustifyPane::Left | JustifyPane::Top,
  233. WinPoint(m_width, 0),
  234. new RowPane(
  235. new ImagePane(pimage),
  236. ppagePane
  237. )
  238. )
  239. );
  240. return true;
  241. }
  242. bool ParseSymbol(PCC& pcc, PCC pccEnd, char chEnd, ZString& str)
  243. {
  244. PCC pccSymbol = pcc;
  245. while (
  246. pcc < pccEnd
  247. && *pcc != chEnd
  248. ) {
  249. pcc++;
  250. }
  251. if (pcc == pccEnd || *pcc != chEnd) {
  252. return Error("Expected '>'");
  253. }
  254. str = ZString(pccSymbol, pcc - pccSymbol);
  255. pcc++;
  256. return true;
  257. }
  258. bool Include(INameSpace* pns, const ZString& str, const ZString& strFile)
  259. {
  260. if (m_ppagePaneIncluder) {
  261. TRef<ZFile> pfile = m_ppagePaneIncluder->Include(str);
  262. if (pfile == NULL) {
  263. pfile = m_pmodeler->LoadFile(strFile, "mml", false);
  264. }
  265. if (pfile) {
  266. if (pfile->GetLength() > 0) {
  267. PCC pcc = (PCC)(pfile->GetPointer());
  268. Parse(pns, pcc, pcc + pfile->GetLength());
  269. }
  270. }
  271. }
  272. return true;
  273. }
  274. bool ParseTag(INameSpace* pns, PCC& pcc, PCC pccEnd)
  275. {
  276. pcc++;
  277. if (pcc == pccEnd) {
  278. return Error("End of string");
  279. }
  280. //
  281. // << or <>
  282. //
  283. if (*pcc == '<' || *pcc == '>') {
  284. InsertWord(pcc, pcc+1);
  285. pcc++;
  286. return true;
  287. }
  288. //
  289. // <xff>
  290. //
  291. if (*pcc == 'x') {
  292. pcc++;
  293. char ch = ReadHexNumber(pcc, 2);
  294. InsertWord(&ch, (&ch) + 1);
  295. if (pcc == pccEnd || pcc[0] != '>') {
  296. return Error("Expected '>'");
  297. }
  298. pcc++;
  299. return true;
  300. }
  301. //
  302. // <!comment>
  303. //
  304. if (*pcc == '!') {
  305. return ParseComment(pcc, pccEnd);
  306. }
  307. //
  308. // <p>
  309. //
  310. if (*pcc == 'p') {
  311. if (pcc == pccEnd || pcc[1] != '>') {
  312. return Error("Expected '>'");
  313. }
  314. InsertAtBottom(new Pane(NULL, WinPoint(0, m_pfontDefault->GetHeight())));
  315. pcc += 2;
  316. return true;
  317. }
  318. //
  319. // Get the tag
  320. //
  321. ZString strTag;
  322. if (!ParseSymbol(pcc, pccEnd, '|', strTag)) {
  323. return false;
  324. }
  325. //
  326. // <Color|color>
  327. // <Font|smallFont>
  328. // <Image|image>
  329. // <Main|topic|text>
  330. // <Secondary|topic|text>
  331. // <Bullet|image|text>
  332. // <String|identifier>
  333. //
  334. ZString str;
  335. if (strTag == "Color") {
  336. if (!ParseSymbol(pcc, pccEnd, '>', str)) {
  337. return false;
  338. }
  339. TRef<ColorValue> pcolor; CastTo(pcolor, pns->FindMember(str));
  340. if (pcolor) {
  341. m_color = pcolor->GetValue();
  342. return true;
  343. } else {
  344. return Error("Invalid color");
  345. }
  346. } else if (strTag == "String") {
  347. if (!ParseSymbol(pcc, pccEnd, '>', str)) {
  348. return false;
  349. }
  350. TRef<StringValue> pstring; CastTo(pstring, pns->FindMember(str));
  351. if (pstring) {
  352. InsertString(pstring->GetValue());
  353. return true;
  354. } else {
  355. return Error("undefined identifier '" + str + "'");
  356. }
  357. } else if (strTag == "Include") {
  358. if (!ParseSymbol(pcc, pccEnd, '|', str)) {
  359. return false;
  360. }
  361. ZString strFile;
  362. if (!ParseSymbol(pcc, pccEnd, '>', strFile)) {
  363. return false;
  364. }
  365. return Include(pns, str, strFile);
  366. } else if (strTag == "Font") {
  367. if (!ParseSymbol(pcc, pccEnd, '>', str)) {
  368. return false;
  369. }
  370. TRef<FontValue> pfont; CastTo(pfont, pns->FindMember(str));
  371. if (pfont) {
  372. m_pfont = pfont->GetValue();
  373. return true;
  374. } else {
  375. return Error("Invalid font");
  376. }
  377. } else if (strTag == "Image") {
  378. if (!ParseSymbol(pcc, pccEnd, '>', str)) {
  379. return false;
  380. }
  381. TRef<Image> pimage = m_pmodeler->LoadImage(str + "bmp", true, false);
  382. if (pimage) {
  383. InsertAtBottom(new ImagePane(pimage));
  384. return true;
  385. } else {
  386. return Error("Invalid image");
  387. }
  388. } else if (strTag == "Main") {
  389. return InsertLink(pcc, pccEnd, m_colorMain, m_peventSourceMain);
  390. } else if (strTag == "Secondary") {
  391. return InsertLink(pcc, pccEnd, m_colorSecondary, m_peventSourceSecondary);
  392. } else if (strTag == "Bullet") {
  393. return ParseBullet(pns, pcc, pccEnd);
  394. }
  395. return Error("Unknown tag: " + strTag);
  396. }
  397. void ParseWord(PCC& pcc, PCC pccEnd)
  398. {
  399. PCC pccStart = pcc;
  400. while (
  401. pcc < pccEnd
  402. && *pcc != ' '
  403. && *pcc != '\t'
  404. && *pcc != '<'
  405. && *pcc != 10
  406. && *pcc != 13
  407. ) {
  408. pcc++;
  409. }
  410. InsertWord(pccStart, pcc);
  411. }
  412. void SkipWhite(PCC& pcc, PCC pccEnd)
  413. {
  414. while (
  415. pcc < pccEnd
  416. && (
  417. *pcc == ' '
  418. || *pcc == 10
  419. || *pcc == 13
  420. )
  421. ) {
  422. pcc++;
  423. }
  424. }
  425. void Parse(INameSpace* pns, PCC pccStart, PCC pccEnd)
  426. {
  427. PCC pcc = pccStart;
  428. //
  429. // Find all the words
  430. //
  431. SkipWhite(pcc, pccEnd);
  432. while (pcc < pccEnd) {
  433. if (*pcc == '<') {
  434. //
  435. // It's a tag
  436. //
  437. if (!ParseTag(pns, pcc, pccEnd)) {
  438. return;
  439. }
  440. } else if (*pcc == '\t') {
  441. //
  442. // It's a tab
  443. //
  444. pcc++;
  445. InsertTab();
  446. } else {
  447. //
  448. // It's a word
  449. //
  450. ParseWord(pcc, pccEnd);
  451. }
  452. SkipWhite(pcc, pccEnd);
  453. }
  454. }
  455. void Parse(INameSpace* pns, const ZString& str)
  456. {
  457. Parse(pns, &str[0], (&str[0]) + str.GetLength());
  458. }
  459. void FixupLineY(Pane* ppaneFirst, Pane* ppaneLast, int ysize)
  460. {
  461. for (Pane* ppane = ppaneFirst; ppane != ppaneLast; ppane = ppane->Next()) {
  462. InternalSetOffset(
  463. ppane,
  464. WinPoint(
  465. ppane->XOffset(),
  466. ppane->YOffset() + (ysize - ppane->YSize())
  467. )
  468. );
  469. }
  470. }
  471. //////////////////////////////////////////////////////////////////////////////
  472. //
  473. // PagePane methods
  474. //
  475. //////////////////////////////////////////////////////////////////////////////
  476. void SetAttributes(
  477. IEngineFont* pfont,
  478. const Color& color,
  479. const Color& colorMain,
  480. const Color& colorSecondary,
  481. const Color& colorHighlight
  482. ) {
  483. m_pfontDefault = pfont;
  484. m_colorDefault = color;
  485. m_colorMain = colorMain;
  486. m_colorSecondary = colorSecondary;
  487. m_colorHighlight = colorHighlight;
  488. }
  489. TRef<IStringEventSource> GetMainLinkEventSource()
  490. {
  491. return m_peventSourceMain;
  492. }
  493. TRef<IStringEventSource> GetSecondaryLinkEventSource()
  494. {
  495. return m_peventSourceSecondary;
  496. }
  497. void SetTopic(INameSpace* pns, const ZString& str)
  498. {
  499. RemoveAllChildren();
  500. m_color = m_colorDefault;
  501. m_pfont = m_pfontDefault;
  502. TRef<ZFile> pfile = m_pmodeler->LoadFile(str, "mml", false);
  503. if (pfile) {
  504. if (pfile->GetLength() > 0) {
  505. PCC pcc = (PCC)(pfile->GetPointer());
  506. Parse(pns, pcc, pcc + pfile->GetLength());
  507. }
  508. } else {
  509. ZString str("<Color|red>Error: Can't open file '" + str + "'");
  510. Parse(pns, PCC(str), PCC(str) + str.GetLength());
  511. }
  512. }
  513. void SetTopicText(INameSpace* pns, const ZString& str)
  514. {
  515. RemoveAllChildren();
  516. m_color = m_colorDefault;
  517. m_pfont = m_pfontDefault;
  518. PCC pcc = str;
  519. Parse(pns, pcc, pcc + str.GetLength());
  520. }
  521. void SetPagePaneIncluder(PagePaneIncluder* ppagePaneIncluder)
  522. {
  523. m_ppagePaneIncluder = ppagePaneIncluder;
  524. }
  525. //////////////////////////////////////////////////////////////////////////////
  526. //
  527. // Pane methods
  528. //
  529. //////////////////////////////////////////////////////////////////////////////
  530. void UpdateLayout()
  531. {
  532. //
  533. // Update the size of all the children
  534. //
  535. Pane* ppane;
  536. for(ppane = Child(); ppane != NULL; ppane = ppane->Next()) {
  537. InternalSetExpand(ppane, WinPoint(0, 0));
  538. ppane->UpdateLayout();
  539. }
  540. //
  541. // Flow the words
  542. //
  543. int xsize = XExpand();
  544. int ysizeLine = 0;
  545. int x = 0;
  546. int y = 0;
  547. Pane* ppaneLine = Child();
  548. for(ppane = Child(); ppane != NULL; ppane = ppane->Next()) {
  549. //
  550. // Go to the next line?
  551. //
  552. int xsizePane = ppane->GetAlignedXSize(x);
  553. if (
  554. xsizePane == 0
  555. || (
  556. x + xsizePane > xsize
  557. && x != 0
  558. )
  559. ) {
  560. //
  561. // Doesn't fit on this line.
  562. //
  563. FixupLineY(ppaneLine, ppane, ysizeLine);
  564. y += ysizeLine;
  565. x = 0;
  566. ysizeLine = 0;
  567. ppaneLine = ppane;
  568. }
  569. //
  570. // Place the word
  571. //
  572. InternalSetOffset(ppane, WinPoint(x, y));
  573. x += xsizePane;
  574. ysizeLine = max(ysizeLine, ppane->YSize());
  575. }
  576. //
  577. // fixup the last line
  578. //
  579. FixupLineY(ppaneLine, NULL, ysizeLine);
  580. //
  581. // This panes's size
  582. //
  583. InternalSetSize(WinPoint(xsize, y + ysizeLine));
  584. }
  585. };
  586. //////////////////////////////////////////////////////////////////////////////
  587. //
  588. //
  589. //
  590. //////////////////////////////////////////////////////////////////////////////
  591. class ScrollingPanePane :
  592. public Pane,
  593. public IIntegerEventSink
  594. {
  595. private:
  596. TRef<ScrollPane> m_pscroll;
  597. TRef<Pane> m_ppane;
  598. TRef<IIntegerEventSink> m_pintegerEventSink;
  599. //TRef<ModifiablePointValue> m_ppoint;
  600. public:
  601. ScrollingPanePane(Pane* ppane, const WinPoint& size, ScrollPane* pscroll) :
  602. m_ppane(ppane),
  603. m_pscroll(pscroll)
  604. {
  605. InternalSetSize(size);
  606. InsertAtBottom(ppane);
  607. /*
  608. m_ppoint = new ModiablePointValue(Point(0, 0));
  609. InsertAtBotttom(
  610. new AnimatedImagePane(
  611. new PaneImage(
  612. new AnimatedImagePaneRect(
  613. new TranslateImage(
  614. pimage,
  615. m_ppoint
  616. ),
  617. rect
  618. ),
  619. false,
  620. true
  621. )
  622. )
  623. );
  624. */
  625. if (m_pscroll) {
  626. m_pscroll->GetEventSource()->AddSink(
  627. m_pintegerEventSink = IIntegerEventSink::CreateDelegate(this)
  628. );
  629. }
  630. }
  631. ~ScrollingPanePane()
  632. {
  633. if (m_pscroll) {
  634. m_pscroll->GetEventSource()->RemoveSink(m_pintegerEventSink);
  635. }
  636. }
  637. //////////////////////////////////////////////////////////////////////////////
  638. //
  639. // Implementation methods
  640. //
  641. //////////////////////////////////////////////////////////////////////////////
  642. bool OnEvent(IIntegerEventSource* pevent, int value)
  643. {
  644. NeedPaint();
  645. NeedLayout();
  646. return true;
  647. }
  648. //////////////////////////////////////////////////////////////////////////////
  649. //
  650. // Pane methods
  651. //
  652. //////////////////////////////////////////////////////////////////////////////
  653. void UpdateLayout()
  654. {
  655. InternalSetOffset(m_ppane, WinPoint(0, -m_pscroll->GetPos()));
  656. m_ppane->UpdateLayout();
  657. m_pscroll->SetLineSize(8);
  658. m_pscroll->SetSizes(
  659. m_ppane->YSize(),
  660. YSize()
  661. );
  662. }
  663. void Paint(Surface* psurface)
  664. {
  665. }
  666. };
  667. //////////////////////////////////////////////////////////////////////////////
  668. //
  669. // PagePane Wrapper
  670. //
  671. //////////////////////////////////////////////////////////////////////////////
  672. class PagePaneWrapper : public PagePane {
  673. private:
  674. TRef<PagePane> m_ppagePane;
  675. public:
  676. PagePaneWrapper(Modeler* pmodeler, const WinPoint& size, ScrollPane* pscrollPane)
  677. {
  678. m_ppagePane = new PagePaneImpl(pmodeler, size.X(), NULL, NULL);
  679. TRef<Pane> ppane =
  680. new JustifyPane(
  681. JustifyPane::Left | JustifyPane::Top,
  682. size,
  683. m_ppagePane
  684. );
  685. if (pscrollPane) {
  686. InsertAtBottom(
  687. new ScrollingPanePane(
  688. ppane,
  689. size,
  690. pscrollPane
  691. )
  692. );
  693. } else {
  694. InsertAtBottom(ppane);
  695. }
  696. }
  697. //////////////////////////////////////////////////////////////////////////////
  698. //
  699. // PagePane methods
  700. //
  701. //////////////////////////////////////////////////////////////////////////////
  702. void SetAttributes(
  703. IEngineFont* pfont,
  704. const Color& color,
  705. const Color& colorMain,
  706. const Color& colorSecondary,
  707. const Color& colorHighlight
  708. ) {
  709. m_ppagePane->SetAttributes(
  710. pfont,
  711. color,
  712. colorMain,
  713. colorSecondary,
  714. colorHighlight
  715. );
  716. }
  717. TRef<IStringEventSource> GetMainLinkEventSource()
  718. {
  719. return m_ppagePane->GetMainLinkEventSource();
  720. }
  721. TRef<IStringEventSource> GetSecondaryLinkEventSource()
  722. {
  723. return m_ppagePane->GetSecondaryLinkEventSource();
  724. }
  725. void SetTopic(INameSpace* pns, const ZString& str)
  726. {
  727. m_ppagePane->SetTopic(pns, str);
  728. }
  729. void SetTopicText(INameSpace* pns, const ZString& str)
  730. {
  731. m_ppagePane->SetTopicText(pns, str);
  732. }
  733. void SetPagePaneIncluder(PagePaneIncluder* ppagePaneIncluder)
  734. {
  735. m_ppagePane->SetPagePaneIncluder(ppagePaneIncluder);
  736. }
  737. //////////////////////////////////////////////////////////////////////////////
  738. //
  739. // Pane methods
  740. //
  741. //////////////////////////////////////////////////////////////////////////////
  742. void UpdateLayout()
  743. {
  744. DefaultUpdateLayout();
  745. }
  746. };
  747. //////////////////////////////////////////////////////////////////////////////
  748. //
  749. // Factories
  750. //
  751. //////////////////////////////////////////////////////////////////////////////
  752. class PagePaneFactory : public IFunction {
  753. private:
  754. TRef<Modeler> m_pmodeler;
  755. public:
  756. PagePaneFactory(Modeler* pmodeler) :
  757. m_pmodeler(pmodeler)
  758. {
  759. }
  760. TRef<IObject> Apply(ObjectStack& stack)
  761. {
  762. TRef<PointValue> psize; CastTo(psize, (IObject*)stack.Pop());
  763. TRef<ScrollPane> pscrollPane; CastTo(pscrollPane, (Pane*)(IObject*)stack.Pop());
  764. return new PagePaneWrapper(m_pmodeler, WinPoint::Cast(psize->GetValue()), pscrollPane);
  765. }
  766. };
  767. void AddPagePaneFactory(
  768. INameSpace* pns,
  769. Modeler* pmodeler
  770. ) {
  771. pns->AddMember("PagePane", new PagePaneFactory(pmodeler));
  772. }