MyGUI  3.2.1
MyGUI_BackwardCompatibility.cpp
Go to the documentation of this file.
1 /*
2  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3  * Distributed under the MIT License
4  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5  */
6 
7 #include "MyGUI_Precompiled.h"
9 #include "MyGUI_Button.h"
10 #include "MyGUI_ComboBox.h"
11 #include "MyGUI_EditBox.h"
12 #include "MyGUI_ItemBox.h"
13 #include "MyGUI_ListBox.h"
14 #include "MyGUI_MenuControl.h"
15 #include "MyGUI_MenuItem.h"
16 #include "MyGUI_MultiListBox.h"
17 #include "MyGUI_ProgressBar.h"
18 #include "MyGUI_ScrollView.h"
19 #include "MyGUI_TabControl.h"
20 #include "MyGUI_Widget.h"
21 #include "MyGUI_Window.h"
22 #include "MyGUI_TabItem.h"
23 #include "MyGUI_Canvas.h"
24 #include "MyGUI_LayoutManager.h"
25 #include "MyGUI_FontManager.h"
26 #include "MyGUI_ResourceManager.h"
27 #include "MyGUI_Gui.h"
28 #include "MyGUI_PointerManager.h"
29 #include "MyGUI_InputManager.h"
30 #include "MyGUI_RenderManager.h"
31 #include "MyGUI_LanguageManager.h"
32 #include "MyGUI_LayoutManager.h"
33 #include "MyGUI_PluginManager.h"
34 #include "MyGUI_SkinManager.h"
35 #include "MyGUI_WidgetManager.h"
36 #include "MyGUI_FactoryManager.h"
38 
39 namespace MyGUI
40 {
41 
42 #ifndef MYGUI_DONT_USE_OBSOLETE
43 
45  {
46  static_cast<Button*>(this)->setStateSelected(_value);
47  }
49  {
50  return static_cast<Button*>(this)->getStateSelected();
51  }
53  {
54  static_cast<Button*>(this)->setStateSelected(_value);
55  }
57  {
58  return static_cast<Button*>(this)->getStateSelected();
59  }
61  {
62  return static_cast<Button*>(this)->_getImageBox();
63  }
65  {
66  if (static_cast<Button*>(this)->_getImageBox())
67  static_cast<Button*>(this)->_getImageBox()->setImageIndex(_index);
68  }
70  {
71  if (static_cast<Button*>(this)->_getImageBox())
72  return static_cast<Button*>(this)->_getImageBox()->getImageIndex();
73  return ITEM_NONE;
74  }
75 
76 
78  {
79  return static_cast<ComboBox*>(this)->getIndexSelected();
80  }
82  {
83  static_cast<ComboBox*>(this)->setIndexSelected(_index);
84  }
86  {
87  static_cast<ComboBox*>(this)->clearIndexSelected();
88  }
89 
90  void MemberObsolete<ComboBox>::insertItem(size_t _index, const UString& _name)
91  {
92  static_cast<ComboBox*>(this)->insertItemAt(_index, _name);
93  }
94  void MemberObsolete<ComboBox>::setItem(size_t _index, const UString& _item)
95  {
96  static_cast<ComboBox*>(this)->setItemNameAt(_index, _item);
97  }
99  {
100  return static_cast<ComboBox*>(this)->getItemNameAt(_index);
101  }
103  {
104  static_cast<ComboBox*>(this)->removeItemAt(_index);
105  }
107  {
108  static_cast<ComboBox*>(this)->removeAllItems();
109  }
111  {
112  return static_cast<ComboBox*>(this)->getIndexSelected();
113  }
115  {
116  static_cast<ComboBox*>(this)->clearIndexSelected();
117  }
119  {
120  static_cast<ComboBox*>(this)->setIndexSelected(_index);
121  }
122 
124  {
125  static_cast<ComboBox*>(this)->setMaxListLength(_value);
126  }
128  {
129  return static_cast<ComboBox*>(this)->getMaxListLength();
130  }
131 
132 
134  {
135  static_cast<EditBox*>(this)->setVisibleVScroll(_visible);
136  }
138  {
139  return static_cast<EditBox*>(this)->isVisibleVScroll();
140  }
142  {
143  static_cast<EditBox*>(this)->setVisibleHScroll(_visible);
144  }
146  {
147  return static_cast<EditBox*>(this)->isVisibleHScroll();
148  }
149 
150  void MemberObsolete<EditBox>::setTextColour(size_t _start, size_t _count, const Colour& _colour)
151  {
152  static_cast<EditBox*>(this)->setTextIntervalColour(_start, _count, _colour);
153  }
154  void MemberObsolete<EditBox>::getTextSelect(size_t& _start, size_t& _end)
155  {
156  _start = static_cast<EditBox*>(this)->getTextSelectionStart();
157  _end = static_cast<EditBox*>(this)->getTextSelectionEnd();
158  }
159  UString MemberObsolete<EditBox>::getText(size_t _start, size_t _count)
160  {
161  return static_cast<EditBox*>(this)->getTextInterval(_start, _count);
162  }
163  void MemberObsolete<EditBox>::setTextSelect(size_t _start, size_t _end)
164  {
165  static_cast<EditBox*>(this)->setTextSelection(_start, _end);
166  }
168  {
169  static_cast<EditBox*>(this)->deleteTextSelection();
170  }
172  {
173  return static_cast<EditBox*>(this)->getTextSelection();
174  }
176  {
177  return static_cast<EditBox*>(this)->isTextSelection();
178  }
180  {
181  static_cast<EditBox*>(this)->setTextSelectionColour(_colour);
182  }
183 
184 
186  {
187  return static_cast<ItemBox*>(this)->getIndexSelected();
188  }
190  {
191  static_cast<ItemBox*>(this)->setIndexSelected(_index);
192  }
194  {
195  static_cast<ItemBox*>(this)->clearIndexSelected();
196  }
197 
198  void MemberObsolete<ItemBox>::insertItem(size_t _index, Any _data)
199  {
200  static_cast<ItemBox*>(this)->insertItemAt(_index, _data);
201  }
202  void MemberObsolete<ItemBox>::setItemData(size_t _index, Any _data)
203  {
204  static_cast<ItemBox*>(this)->setItemDataAt(_index, _data);
205  }
207  {
208  static_cast<ItemBox*>(this)->removeItemAt(_index);
209  }
211  {
212  static_cast<ItemBox*>(this)->removeAllItems();
213  }
215  {
216  return static_cast<ItemBox*>(this)->getIndexSelected();
217  }
219  {
220  static_cast<ItemBox*>(this)->clearIndexSelected();
221  }
223  {
224  static_cast<ItemBox*>(this)->setIndexSelected(_index);
225  }
226 
228  {
229  return static_cast<ItemBox*>(this)->getWidgetDrag();
230  }
232  {
233  static_cast<ItemBox*>(this)->resetDrag();
234  }
235 
237  {
238  static_cast<ItemBox*>(this)->setVerticalAlignment(_value);
239  }
241  {
242  return static_cast<ItemBox*>(this)->getVerticalAlignment();
243  }
244 
245 
247  {
248  return static_cast<ListBox*>(this)->getIndexSelected();
249  }
251  {
252  static_cast<ListBox*>(this)->setIndexSelected(_index);
253  }
255  {
256  static_cast<ListBox*>(this)->clearIndexSelected();
257  }
258 
259  void MemberObsolete<ListBox>::insertItem(size_t _index, const UString& _item)
260  {
261  static_cast<ListBox*>(this)->insertItemAt(_index, _item);
262  }
263  void MemberObsolete<ListBox>::setItem(size_t _index, const UString& _item)
264  {
265  static_cast<ListBox*>(this)->setItemNameAt(_index, _item);
266  }
268  {
269  return static_cast<ListBox*>(this)->getItemNameAt(_index);
270  }
272  {
273  static_cast<ListBox*>(this)->removeItemAt(_index);
274  }
276  {
277  static_cast<ListBox*>(this)->removeAllItems();
278  }
280  {
281  return static_cast<ListBox*>(this)->findItemIndexWith(_item);
282  }
284  {
285  return static_cast<ListBox*>(this)->getIndexSelected();
286  }
288  {
289  static_cast<ListBox*>(this)->clearIndexSelected();
290  }
292  {
293  static_cast<ListBox*>(this)->setIndexSelected(_index);
294  }
296  {
297  static_cast<ListBox*>(this)->beginToItemAt(_index);
298  }
300  {
301  static_cast<ListBox*>(this)->beginToItemFirst();
302  }
304  {
305  static_cast<ListBox*>(this)->beginToItemLast();
306  }
308  {
309  static_cast<ListBox*>(this)->beginToItemSelected();
310  }
311  bool MemberObsolete<ListBox>::isItemVisible(size_t _index, bool _fill)
312  {
313  return static_cast<ListBox*>(this)->isItemVisibleAt(_index, _fill);
314  }
316  {
317  return static_cast<ListBox*>(this)->isItemSelectedVisible(_fill);
318  }
319 
320 
322  {
323  static_cast<MenuControl*>(this)->setVisible(true);
324  }
326  {
327  static_cast<MenuControl*>(this)->setVisible(false);
328  }
330  {
331  return static_cast<MenuControl*>(this)->getVisible();
332  }
333 
335  {
336  static_cast<MenuControl*>(this)->setItemChildVisibleAt(_index, true);
337  }
339  {
340  static_cast<MenuControl*>(this)->setItemChildVisible(_item, true);
341  }
343  {
344  static_cast<MenuControl*>(this)->setItemChildVisibleAt(_index, false);
345  }
347  {
348  static_cast<MenuControl*>(this)->setItemChildVisible(_item, false);
349  }
350 
352  {
353  static_cast<MenuControl*>(this)->setVerticalAlignment(_value);
354  }
356  {
357  return static_cast<MenuControl*>(this)->getVerticalAlignment();
358  }
359 
361  {
362  static_cast<MenuItem*>(this)->setItemChildVisible(true);
363  }
365  {
366  static_cast<MenuItem*>(this)->setItemChildVisible(false);
367  }
368 
369 
371  {
372  return static_cast<MultiListBox*>(this)->getIndexSelected();
373  }
375  {
376  static_cast<MultiListBox*>(this)->setIndexSelected(_index);
377  }
379  {
380  static_cast<MultiListBox*>(this)->clearIndexSelected();
381  }
382 
383  size_t MemberObsolete<MultiListBox>::findItem(size_t _column, const UString& _name)
384  {
385  return static_cast<MultiListBox*>(this)->findSubItemWith(_column, _name);
386  }
387  const UString& MemberObsolete<MultiListBox>::getSubItem(size_t _column, size_t _index)
388  {
389  return static_cast<MultiListBox*>(this)->getSubItemNameAt(_column, _index);
390  }
391  void MemberObsolete<MultiListBox>::setSubItem(size_t _column, size_t _index, const UString& _name)
392  {
393  static_cast<MultiListBox*>(this)->setSubItemNameAt(_column, _index, _name);
394  }
396  {
397  static_cast<MultiListBox*>(this)->removeColumnAt(_column);
398  }
400  {
401  static_cast<MultiListBox*>(this)->removeAllColumns();
402  }
404  {
405  return static_cast<MultiListBox*>(this)->getColumnWidthAt(_column);
406  }
408  {
409  return static_cast<MultiListBox*>(this)->getColumnNameAt(_column);
410  }
411  void MemberObsolete<MultiListBox>::setColumnWidth(size_t _column, int _width)
412  {
413  static_cast<MultiListBox*>(this)->setColumnWidthAt(_column, _width);
414  }
415  void MemberObsolete<MultiListBox>::addColumn(int _width, const UString& _name)
416  {
417  static_cast<MultiListBox*>(this)->addColumn(_name, _width);
418  }
419  void MemberObsolete<MultiListBox>::setColumnName(size_t _column, const UString& _name)
420  {
421  static_cast<MultiListBox*>(this)->setColumnNameAt(_column, _name);
422  }
423  void MemberObsolete<MultiListBox>::insertColumn(size_t _column, int _width, const UString& _name)
424  {
425  static_cast<MultiListBox*>(this)->insertColumnAt(_column, _name, _width);
426  }
428  {
429  return static_cast<MultiListBox*>(this)->getIndexSelected();
430  }
432  {
433  static_cast<MultiListBox*>(this)->clearIndexSelected();
434  }
436  {
437  static_cast<MultiListBox*>(this)->setIndexSelected(_index);
438  }
439  void MemberObsolete<MultiListBox>::insertItem(size_t _index, const UString& _name)
440  {
441  static_cast<MultiListBox*>(this)->insertItemAt(_index, _name);
442  }
443  void MemberObsolete<MultiListBox>::setItem(size_t _index, const UString& _name)
444  {
445  static_cast<MultiListBox*>(this)->setItemNameAt(_index, _name);
446  }
448  {
449  return static_cast<MultiListBox*>(this)->getItemNameAt(_index);
450  }
452  {
453  static_cast<MultiListBox*>(this)->removeItemAt(_index);
454  }
456  {
457  static_cast<MultiListBox*>(this)->removeAllItems();
458  }
459 
460 
462  {
463  if (_value == Align::Right)
464  static_cast<ProgressBar*>(this)->setFlowDirection(FlowDirection::RightToLeft);
465  else if (_value == Align::Top)
466  static_cast<ProgressBar*>(this)->setFlowDirection(FlowDirection::TopToBottom);
467  else if (_value == Align::Bottom)
468  static_cast<ProgressBar*>(this)->setFlowDirection(FlowDirection::BottomToTop);
469  else
470  static_cast<ProgressBar*>(this)->setFlowDirection(FlowDirection::LeftToRight);
471  }
472 
474  {
475  if (static_cast<ProgressBar*>(this)->getFlowDirection() == FlowDirection::RightToLeft)
476  return Align::Right;
477  else if (static_cast<ProgressBar*>(this)->getFlowDirection() == FlowDirection::TopToBottom)
478  return Align::Top;
479  else if (static_cast<ProgressBar*>(this)->getFlowDirection() == FlowDirection::BottomToTop)
480  return Align::Bottom;
481 
482  return Align::Left;
483  }
484 
485 
487  {
488  static_cast<ScrollView*>(this)->setVisibleVScroll(_visible);
489  }
491  {
492  return static_cast<ScrollView*>(this)->isVisibleVScroll();
493  }
495  {
496  static_cast<ScrollView*>(this)->setVisibleHScroll(_visible);
497  }
499  {
500  return static_cast<ScrollView*>(this)->isVisibleHScroll();
501  }
502 
503 
505  {
506  return static_cast<TabControl*>(this)->getButtonWidthAt(_index);
507  }
509  {
510  return static_cast<TabControl*>(this)->getButtonWidth(_sheet);
511  }
513  {
514  static_cast<TabControl*>(this)->setButtonWidthAt(_index, _width);
515  }
517  {
518  static_cast<TabControl*>(this)->setButtonWidth(_sheet, _width);
519  }
521  {
522  static_cast<TabControl*>(this)->beginToItemAt(_index);
523  }
525  {
526  static_cast<TabControl*>(this)->beginToItemSelected();
527  }
529  {
530  return static_cast<TabControl*>(this)->getItemCount();
531  }
533  {
534  return static_cast<TabControl*>(this)->getItemName(_sheet);
535  }
537  {
538  return static_cast<TabControl*>(this)->getItemNameAt(_index);
539  }
541  {
542  return static_cast<TabControl*>(this)->getItemAt(_index);
543  }
544  void MemberObsolete<TabControl>::setSheetNameIndex(size_t _index, const UString& _name, int _width)
545  {
546  static_cast<TabControl*>(this)->setItemNameAt(_index, _name);
547  }
548  void MemberObsolete<TabControl>::setSheetName(TabItem* _sheet, const UString& _name, int _width)
549  {
550  static_cast<TabControl*>(this)->setItemName(_sheet, _name);
551  }
553  {
554  return static_cast<TabControl*>(this)->addItem(_name, _width);
555  }
556  TabItem* MemberObsolete<TabControl>::insertSheet(size_t _index, const UString& _name, int _width)
557  {
558  return static_cast<TabControl*>(this)->insertItemAt(_index, _name);
559  }
561  {
562  static_cast<TabControl*>(this)->removeItemAt(_index);
563  }
565  {
566  static_cast<TabControl*>(this)->removeItem(_sheet);
567  }
568  void MemberObsolete<TabControl>::selectSheetIndex(size_t _index, bool _smooth)
569  {
570  static_cast<TabControl*>(this)->setIndexSelected(_index);
571  }
573  {
574  static_cast<TabControl*>(this)->setItemSelected(_sheet);
575  }
577  {
578  return static_cast<TabControl*>(this)->getIndexSelected();
579  }
580 
582  {
583  return static_cast<TabControl*>(this)->getIndexSelected();
584  }
586  {
587  static_cast<TabControl*>(this)->setIndexSelected(_index);
588  }
589 
590 
592  {
593  return static_cast<Widget*>(this)->getEnabled();
594  }
596  {
597  return static_cast<Widget*>(this)->getInheritsAlpha();
598  }
600  {
601  return static_cast<Widget*>(this)->getNeedKeyFocus();
602  }
604  {
605  return static_cast<Widget*>(this)->getNeedMouseFocus();
606  }
608  {
609  return static_cast<Widget*>(this)->getInheritsPick();
610  }
612  {
613  return static_cast<Widget*>(this)->getVisible();
614  }
615 
616 
618  {
619  static_cast<Window*>(this)->setVisibleSmooth(true);
620  }
622  {
623  static_cast<Window*>(this)->setVisibleSmooth(false);
624  }
626  {
627  static_cast<Window*>(this)->setMinSize(_minmax.left, _minmax.top);
628  static_cast<Window*>(this)->setMaxSize(_minmax.right, _minmax.bottom);
629  }
630  void MemberObsolete<Window>::setMinMax(int _min_w, int _min_h, int _max_w, int _max_h)
631  {
632  static_cast<Window*>(this)->setMinSize(_min_w, _min_h);
633  static_cast<Window*>(this)->setMaxSize(_max_w, _max_h);
634  }
636  {
637  return IntRect(static_cast<Window*>(this)->getMinSize().width, static_cast<Window*>(this)->getMinSize().height, static_cast<Window*>(this)->getMaxSize().width, static_cast<Window*>(this)->getMaxSize().height);
638  }
639 
640  bool MemberObsolete<FontManager>::load(const std::string& _file)
641  {
642  return ResourceManager::getInstance().load(_file);
643  }
644 
645  void MemberObsolete<FontManager>::loadOldFontFormat(xml::ElementPtr _node2, const std::string& _file, Version _version, const std::string& _tag)
646  {
648  while (_node.next())
649  {
650  if (_node->getName() == _tag)
651  {
652  std::string name;
653  if (!_node->findAttribute("name", name))
654  return;
655 
656  std::string type;
657  if (type.empty())
658  {
659  if (_node->findAttribute("resolution").empty())
660  type = "ResourceManualFont";
661  else
662  type = "ResourceTrueTypeFont";
663  }
664 
665  xml::Document doc;
666  xml::ElementPtr root = doc.createRoot("MyGUI");
667  xml::ElementPtr node = root->createChild("Resource");
668  node->addAttribute("type", type);
669  node->addAttribute("name", name);
670 
671  std::string tmp;
672  if (_node->findAttribute("source", tmp))
673  {
674  xml::ElementPtr prop = node->createChild("Property");
675  prop->addAttribute("key", "Source");
676  prop->addAttribute("value", tmp);
677  }
678 
679  if (_node->findAttribute("size", tmp))
680  {
681  xml::ElementPtr prop = node->createChild("Property");
682  prop->addAttribute("key", "Size");
683  prop->addAttribute("value", tmp);
684  }
685 
686  if (_node->findAttribute("resolution", tmp))
687  {
688  xml::ElementPtr prop = node->createChild("Property");
689  prop->addAttribute("key", "Resolution");
690  prop->addAttribute("value", tmp);
691  }
692 
693  if (_node->findAttribute("antialias_colour", tmp))
694  {
695  xml::ElementPtr prop = node->createChild("Property");
696  prop->addAttribute("key", "Antialias");
697  prop->addAttribute("value", tmp);
698  }
699 
700  if (_node->findAttribute("space_width", tmp))
701  {
702  xml::ElementPtr prop = node->createChild("Property");
703  prop->addAttribute("key", "SpaceWidth");
704  prop->addAttribute("value", tmp);
705  }
706 
707  if (_node->findAttribute("tab_width", tmp))
708  {
709  xml::ElementPtr prop = node->createChild("Property");
710  prop->addAttribute("key", "TabWidth");
711  prop->addAttribute("value", tmp);
712  }
713 
714  if (_node->findAttribute("cursor_width", tmp))
715  {
716  xml::ElementPtr prop = node->createChild("Property");
717  prop->addAttribute("key", "CursorWidth");
718  prop->addAttribute("value", tmp);
719  }
720 
721  if (_node->findAttribute("distance", tmp))
722  {
723  xml::ElementPtr prop = node->createChild("Property");
724  prop->addAttribute("key", "Distance");
725  prop->addAttribute("value", tmp);
726  }
727 
728  if (_node->findAttribute("offset_height", tmp))
729  {
730  xml::ElementPtr prop = node->createChild("Property");
731  prop->addAttribute("key", "OffsetHeight");
732  prop->addAttribute("value", tmp);
733  }
734 
735  if (_node->findAttribute("default_height", tmp))
736  {
737  xml::ElementPtr prop = node->createChild("Property");
738  prop->addAttribute("key", "DefaultHeight");
739  prop->addAttribute("value", tmp);
740  }
741 
742  xml::ElementPtr codes = node->createChild("Codes");
743 
744  xml::ElementEnumerator codeold = _node->getElementEnumerator();
745  while (codeold.next("Code"))
746  {
747  xml::ElementPtr codenew = codes->createChild("Code");
748 
749  if (codeold->findAttribute("range", tmp))
750  codenew->addAttribute("range", tmp);
751 
752  if (codeold->findAttribute("hide", tmp))
753  codenew->addAttribute("hide", tmp);
754 
755  if (codeold->findAttribute("index", tmp))
756  codenew->addAttribute("index", tmp);
757 
758  if (codeold->findAttribute("coord", tmp))
759  codenew->addAttribute("coord", tmp);
760  }
761 
762  ResourceManager::getInstance().loadFromXmlNode(root, _file, _version);
763  }
764  }
765  }
766 
768  {
769  static_cast<Gui*>(this)->destroyWidgets(_widgets);
770  }
771 
772  bool MemberObsolete<Gui>::injectMouseMove( int _absx, int _absy, int _absz)
773  {
774  return InputManager::getInstance().injectMouseMove(_absx, _absy, _absz);
775  }
776  bool MemberObsolete<Gui>::injectMousePress( int _absx, int _absy, MouseButton _id )
777  {
778  return InputManager::getInstance().injectMousePress(_absx, _absy, _id);
779  }
780  bool MemberObsolete<Gui>::injectMouseRelease( int _absx, int _absy, MouseButton _id )
781  {
782  return InputManager::getInstance().injectMouseRelease(_absx, _absy, _id);
783  }
785  {
786  return InputManager::getInstance().injectKeyPress(_key, _text);
787  }
789  {
791  }
792 
794  {
796  }
798  {
800  }
802  {
804  }
805 
806  bool MemberObsolete<Gui>::load(const std::string& _file)
807  {
808  return ResourceManager::getInstance().load(_file);
809  }
810 
812  {
814  }
816  {
818  }
820  {
822  }
823 
825  {
827  }
829  {
831  }
832 
834  {
835  Gui::getInstance().frameEvent(_time);
836  }
837 
839  {
841  }
842 
844  {
846  }
847 
849  {
851  }
852 
853  bool MemberObsolete<LanguageManager>::load(const std::string& _file)
854  {
855  return ResourceManager::getInstance().load(_file);
856  }
857 
858  bool MemberObsolete<LayerManager>::load(const std::string& _file)
859  {
860  return ResourceManager::getInstance().load(_file);
861  }
862 
864  {
865  return static_cast<LayoutManager*>(this)->loadLayout(_file);
866  }
867 
868  bool MemberObsolete<PluginManager>::load(const std::string& _file)
869  {
870  return ResourceManager::getInstance().load(_file);
871  }
872 
874  {
875  static_cast<PointerManager*>(this)->setDefaultPointer(_value);
876  }
878  {
879  static_cast<PointerManager*>(this)->setVisible(true);
880  }
882  {
883  static_cast<PointerManager*>(this)->setVisible(false);
884  }
886  {
887  return static_cast<PointerManager*>(this)->isVisible();
888  }
889  bool MemberObsolete<PointerManager>::load(const std::string& _file)
890  {
891  return ResourceManager::getInstance().load(_file);
892  }
893  void MemberObsolete<PointerManager>::loadOldPointerFormat(xml::ElementPtr _node, const std::string& _file, Version _version, const std::string& _tag)
894  {
895  std::string pointer;
896  std::string layer;
897 
899  while (node.next())
900  {
901  if (node->getName() == _tag)
902  {
903  layer = node->findAttribute("layer");
904  pointer = node->findAttribute("default");
905 
906  // сохраняем
907  std::string shared_text = node->findAttribute("texture");
908 
909  // берем детей и крутимся, основной цикл
911  while (info.next("Info"))
912  {
913  std::string name = info->findAttribute("name");
914  if (name.empty())
915  continue;
916 
917  std::string texture = info->findAttribute("texture");
918 
919  std::string type = (shared_text.empty() && texture.empty()) ? "ResourceImageSetPointer" : "ResourceManualPointer";
920 
921  xml::Document doc;
922  xml::ElementPtr root = doc.createRoot("MyGUI");
923  xml::ElementPtr newnode = root->createChild("Resource");
924  newnode->addAttribute("type", type);
925  newnode->addAttribute("name", name);
926 
927  std::string tmp;
928  if (info->findAttribute("point", tmp))
929  {
930  xml::ElementPtr prop = newnode->createChild("Property");
931  prop->addAttribute("key", "Point");
932  prop->addAttribute("value", tmp);
933  }
934 
935  if (info->findAttribute("size", tmp))
936  {
937  xml::ElementPtr prop = newnode->createChild("Property");
938  prop->addAttribute("key", "Size");
939  prop->addAttribute("value", tmp);
940  }
941 
942  if (info->findAttribute("resource", tmp))
943  {
944  xml::ElementPtr prop = newnode->createChild("Property");
945  prop->addAttribute("key", "Resource");
946  prop->addAttribute("value", tmp);
947  }
948 
949  if (info->findAttribute("offset", tmp))
950  {
951  xml::ElementPtr prop = newnode->createChild("Property");
952  prop->addAttribute("key", "Coord");
953  prop->addAttribute("value", tmp);
954  }
955 
956  if (!shared_text.empty() || !texture.empty())
957  {
958  xml::ElementPtr prop = newnode->createChild("Property");
959  prop->addAttribute("key", "Texture");
960  prop->addAttribute("value", shared_text.empty() ? texture : shared_text);
961  }
962 
963  ResourceManager::getInstance().loadFromXmlNode(root, _file, _version);
964  }
965  }
966  }
967 
968  if (!layer.empty())
969  static_cast<PointerManager*>(this)->setLayerName(layer);
970 
971  if (!pointer.empty())
972  static_cast<PointerManager*>(this)->setDefaultPointer(pointer);
973  }
974 
976  {
977  return static_cast<ResourceManager*>(this)->getCount();
978  }
979  IResourcePtr MemberObsolete<ResourceManager>::getResource(const std::string& _name, bool _throw)
980  {
981  return static_cast<ResourceManager*>(this)->getByName(_name, _throw);
982  }
983 
985  {
986  return static_cast<SkinManager*>(this)->getByName(_name);
987  }
988  bool MemberObsolete<SkinManager>::load(const std::string& _file)
989  {
990  return ResourceManager::getInstance().load(_file);
991  }
992  void MemberObsolete<SkinManager>::loadOldSkinFormat(xml::ElementPtr _node, const std::string& _file, Version _version, const std::string& _tag)
993  {
994  std::string resourceCategory = ResourceManager::getInstance().getCategoryName();
995 
996  // берем детей и крутимся, основной цикл со скинами
998  while (skin.next(_tag))
999  {
1000  std::string type = skin->findAttribute("type");
1001  if (type.empty())
1002  type = "ResourceSkin";
1003 
1004  IObject* object = FactoryManager::getInstance().createObject(resourceCategory, type);
1005  if (object != nullptr)
1006  {
1007  ResourceSkin* data = object->castType<ResourceSkin>();
1008  data->deserialization(skin.current(), _version);
1009 
1011  }
1012  }
1013  }
1014 
1015 
1017  {
1018  static_cast<WidgetManager*>(this)->destroyWidgets(_widgets);
1019  }
1020  Widget* MemberObsolete<WidgetManager>::findWidgetT(const std::string& _name, bool _throw)
1021  {
1022  return Gui::getInstance().findWidgetT(_name, _throw);
1023  }
1024  Widget* MemberObsolete<WidgetManager>::findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw)
1025  {
1026  return Gui::getInstance().findWidgetT(_name, _prefix, _throw);
1027  }
1028  void MemberObsolete<WidgetManager>::parse(Widget* _widget, const std::string& _key, const std::string& _value)
1029  {
1030  _widget->setProperty(_key, _value);
1031  }
1032 
1033 
1034 #endif // MYGUI_DONT_USE_OBSOLETE
1035 
1036 #ifndef MYGUI_DONT_USE_OBSOLETE
1037 
1038  static std::string convertAlignToDirection(const std::string& _value)
1039  {
1040  Align align = utility::parseValue<Align>(_value);
1041  if (align == Align::Right)
1043  else if (align == Align::Top)
1045  else if (align == Align::Bottom)
1048  }
1049 
1050  static std::string convertRectToCoord(const std::string& _value)
1051  {
1052  IntRect rect = IntRect::parse(_value);
1053  IntCoord coord(rect.left, rect.top, rect.width(), rect.height());
1054  return coord.print();
1055  }
1056 
1057  typedef std::set<std::string> SetString;
1061 
1062 #endif // MYGUI_DONT_USE_OBSOLETE
1063 
1064  bool BackwardCompatibility::isIgnoreProperty(const std::string& _key)
1065  {
1066 #ifndef MYGUI_DONT_USE_OBSOLETE
1067  if (mPropertyIgnore.find(_key) != mPropertyIgnore.end())
1068  return true;
1069 #endif // MYGUI_DONT_USE_OBSOLETE
1070  return false;
1071  }
1072 
1073  bool BackwardCompatibility::checkProperty(Widget* _owner, std::string& _key, std::string& _value)
1074  {
1075 #ifndef MYGUI_DONT_USE_OBSOLETE
1076  if (mPropertyIgnore.find(_key) != mPropertyIgnore.end())
1077  return false;
1078 
1079  MapString::iterator item = mPropertyRename.find(_key);
1080  if (item != mPropertyRename.end())
1081  {
1082  MYGUI_LOG(Warning, (*item).first << " is deprecated, use " << (*item).second << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1083  _key = (*item).second;
1084  }
1085  else if (_key == "Progress_StartPoint")
1086  {
1087  MYGUI_LOG(Warning, "Progress_StartPoint is deprecated, use Progress_FlowDirection" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1088  _key = "Progress_FlowDirection";
1089  _value = convertAlignToDirection(_value);
1090  }
1091  else if (_key == "ComboBox_AddItem")
1092  {
1093  MYGUI_LOG(Warning, "ComboBox_AddItem is deprecated" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1094  ComboBox* widget = _owner->castType<ComboBox>(false);
1095  if (widget != nullptr)
1096  widget->addItem(_value);
1097  return false;
1098  }
1099  else if (_key == "List_AddItem")
1100  {
1101  MYGUI_LOG(Warning, "List_AddItem is deprecated" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1102  ListBox* widget = _owner->castType<ListBox>(false);
1103  if (widget != nullptr)
1104  widget->addItem(_value);
1105  return false;
1106  }
1107  else if (_key == "Tab_AddSheet")
1108  {
1109  MYGUI_LOG(Warning, "Tab_AddSheet is deprecated" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1110  TabControl* widget = _owner->castType<TabControl>(false);
1111  if (widget != nullptr)
1112  widget->addItem(_value);
1113  return false;
1114  }
1115  else if (_key == "Tab_AddItem")
1116  {
1117  MYGUI_LOG(Warning, "Tab_AddItem is deprecated" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1118  TabControl* widget = _owner->castType<TabControl>(false);
1119  if (widget != nullptr)
1120  widget->addItem(_value);
1121  return false;
1122  }
1123  else if (_key == "Window_MinMax")
1124  {
1125  MYGUI_LOG(Warning, "Window_MinMax is deprecated, use Window_MinSize or Window_MaxSize" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1126  Window* widget = _owner->castType<Window>(false);
1127  if (widget != nullptr)
1128  {
1129  IntRect rect = IntRect::parse(_value);
1130  widget->setMinSize(rect.left, rect.top);
1131  widget->setMaxSize(rect.right, rect.bottom);
1132  }
1133  return false;
1134  }
1135  else if (_key == "ImageRect")
1136  {
1137  MYGUI_LOG(Warning, "ImageRect is deprecated, use ImageCoord" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1138  _key = "ImageCoord";
1139  _value = convertRectToCoord(_value);
1140  }
1141  else if (_key == "StartPoint")
1142  {
1143  MYGUI_LOG(Warning, "StartPoint is deprecated, use FlowDirection" << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1144  _key = "FlowDirection";
1145  _value = convertAlignToDirection(_value);
1146  }
1147 
1148 #endif // MYGUI_DONT_USE_OBSOLETE
1149  return true;
1150  }
1151 
1153  {
1154 #ifndef MYGUI_DONT_USE_OBSOLETE
1155  mPropertyRename["Widget_Caption"] = "Caption";
1156  mPropertyRename["Button_Pressed"] = "StateSelected";
1157  mPropertyRename["ButtonPressed"] = "StateSelected";
1158  mPropertyRename["StateCheck"] = "StateSelected";
1159  mPropertyRename["Edit_ShowVScroll"] = "VisibleVScroll";
1160  mPropertyRename["Edit_ShowHScroll"] = "VisibleHScroll";
1161  mPropertyRename["ScrollView_VScroll"] = "VisibleVScroll";
1162  mPropertyRename["ScrollView_HScroll"] = "VisibleHScroll";
1163  mPropertyRename["Progress_Position"] = "RangePosition";
1164  mPropertyRename["Scroll_Position"] = "RangePosition";
1165  mPropertyRename["Tab_SelectSheet"] = "SelectItem";
1166  mPropertyRename["Image_Texture"] = "ImageTexture";
1167  mPropertyRename["Image_Coord"] = "ImageRegion";
1168  mPropertyRename["Image_Tile"] = "ImageTile";
1169  mPropertyRename["Image_Index"] = "ImageIndex";
1170  mPropertyRename["Image_Resource"] = "ImageResource";
1171  mPropertyRename["Image_Group"] = "ImageGroup";
1172  mPropertyRename["Image_Name"] = "ImageName";
1173  mPropertyRename["MenuItem_Id"] = "MenuItemId";
1174  mPropertyRename["MenuItem_Type"] = "MenuItemType";
1175  mPropertyRename["Combo_MaxLength"] = "MaxListLength";
1176  mPropertyRename["AlignText"] = "TextAlign";
1177  mPropertyRename["ToStick"] = "Snap";
1178  mPropertyRename["ListSmoothShow"] = "SmoothShow";
1179  mPropertyRename["HeightList"] = "MaxListLength";
1180  mPropertyRename["AlignVert"] = "VerticalAlignment";
1181 
1182  mPropertyIgnore.insert("DragLayer");
1183  mPropertyIgnore.insert("SkinLine");
1184  mPropertyIgnore.insert("HeightLine");
1185  mPropertyIgnore.insert("SkinLine");
1186  mPropertyIgnore.insert("HeightLine");
1187  mPropertyIgnore.insert("SeparatorHeight");
1188  mPropertyIgnore.insert("SeparatorSkin");
1189  mPropertyIgnore.insert("SubmenuImageSize");
1190  mPropertyIgnore.insert("SubMenuSkin");
1191  mPropertyIgnore.insert("SubMenuLayer");
1192  mPropertyIgnore.insert("DistanceButton");
1193  mPropertyIgnore.insert("ButtonSkin");
1194  mPropertyIgnore.insert("ButtonType");
1195  mPropertyIgnore.insert("ButtonSize");
1196  mPropertyIgnore.insert("ButtonOffset");
1197  mPropertyIgnore.insert("DefaultLayer");
1198  mPropertyIgnore.insert("FadeSkin");
1199  mPropertyIgnore.insert("FadeLayer");
1200  mPropertyIgnore.insert("SkinButton");
1201  mPropertyIgnore.insert("HeightButton");
1202  mPropertyIgnore.insert("SkinList");
1203  mPropertyIgnore.insert("SkinButtonEmpty");
1204  mPropertyIgnore.insert("WidthSeparator");
1205  mPropertyIgnore.insert("SkinSeparator");
1206  mPropertyIgnore.insert("TrackSkin");
1207  mPropertyIgnore.insert("TrackWidth");
1208  mPropertyIgnore.insert("TrackMin");
1209  mPropertyIgnore.insert("TrackStep");
1210  mPropertyIgnore.insert("TrackFill");
1211  mPropertyIgnore.insert("OffsetBar");
1212  mPropertyIgnore.insert("ButtonSkin");
1213  mPropertyIgnore.insert("EmptyBarSkin");
1214  mPropertyIgnore.insert("TrackRangeMargins");
1215  mPropertyIgnore.insert("MinTrackSize");
1216  mPropertyIgnore.insert("MainMove");
1217  mPropertyIgnore.insert("LevelOffset");
1218  mPropertyIgnore.insert("State");
1219 
1220  mSkinRename["StaticImage"] = "ImageBox";
1221  mSkinRename["StaticText"] = "TextBox";
1222  mSkinRename["HScroll"] = "ScrollBarH";
1223  mSkinRename["VScroll"] = "ScrollBarV";
1224  mSkinRename["ItemBoxH"] = "ItemBox";
1225  mSkinRename["ItemBoxV"] = "ItemBox";
1226  mSkinRename["VSlider"] = "SliderV";
1227  mSkinRename["HSlider"] = "SliderH";
1228  mSkinRename["Progress"] = "ProgressBar";
1229  mSkinRename["ProgressFill"] = "ProgressBarFill";
1230  mSkinRename["List"] = "ListBox";
1231  mSkinRename["MultiList"] = "MultiListBox";
1232  mSkinRename["Edit"] = "EditBox";
1233  mSkinRename["EditStretch"] = "EditBoxStretch";
1234  mSkinRename["EditEmpty"] = "EditBoxEmpty";
1235  mSkinRename["RadioBox"] = "RadioButton";
1236  mSkinRename["Tab"] = "TabControl";
1237  mSkinRename["WordWrap"] = "WordWrapEmpty";
1238  mSkinRename["WordWrapSimple"] = "WordWrapEmpty";
1239  mSkinRename["ButtonSmall"] = "Button";
1240  mSkinRename["ButtonImageText"] = "ButtonImage";
1241 
1242  mSkinRename["TileClient"] = "ClientTileSkin";
1243  mSkinRename["DefaultClient"] = "ClientDefaultSkin";
1244  mSkinRename["Panel"] = "PanelSkin";
1245  mSkinRename["PanelSmall"] = "PanelSkin";
1246  mSkinRename["Separator1"] = "SepUpVSkin";
1247  mSkinRename["Separator2"] = "SepDownVSkin";
1248  mSkinRename["Separator3"] = "SepUpHSkin";
1249  mSkinRename["Separator4"] = "SepDownHSkin";
1250  mSkinRename["MarkerWhite"] = "WhiteSkin";
1251  mSkinRename["ButtonLeft"] = "ButtonLeftSkin";
1252  mSkinRename["ButtonRight"] = "ButtonRightSkin";
1253  mSkinRename["ButtonUp"] = "ButtonUpSkin";
1254  mSkinRename["ButtonDown"] = "ButtonDownSkin";
1255  mSkinRename["ButtonV"] = "ButtonAcceptSkin";
1256  mSkinRename["ButtonX"] = "ButtonCloseSkin";
1257  mSkinRename["ButtonMinusPlus"] = "ButtonExpandSkin";
1258 #endif // MYGUI_DONT_USE_OBSOLETE
1259  }
1260 
1261  std::string BackwardCompatibility::getPropertyRename(const std::string& _propertyName)
1262  {
1263 #ifndef MYGUI_DONT_USE_OBSOLETE
1264  MapString::const_iterator item = mPropertyRename.find(_propertyName);
1265  if (item != mPropertyRename.end())
1266  return (*item).second;
1267 #endif // MYGUI_DONT_USE_OBSOLETE
1268  return _propertyName;
1269  }
1270 
1271  std::string BackwardCompatibility::getFactoryRename(const std::string& _categoryName, const std::string& _factoryName)
1272  {
1273 #ifndef MYGUI_DONT_USE_OBSOLETE
1274  if (_categoryName == "Widget")
1275  {
1276  if (_factoryName == "HScroll")
1277  {
1278  MYGUI_LOG(Warning, "HScroll factory is deprecated, use " << ScrollBar::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1279  }
1280  else if (_factoryName == "VScroll")
1281  {
1282  MYGUI_LOG(Warning, "VScroll factory is deprecated, use " << ScrollBar::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1283  }
1284  else if (_factoryName == "RenderBox")
1285  {
1286  MYGUI_LOG(Warning, "RenderBox factory is deprecated, use " << Canvas::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1287  }
1288  else if (_factoryName == "Sheet")
1289  {
1290  MYGUI_LOG(Warning, "Sheet factory is deprecated, use " << TabItem::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1291  }
1292  else if (_factoryName == "StaticImage")
1293  {
1294  MYGUI_LOG(Warning, "StaticImage factory is deprecated, use " << ImageBox::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1295  }
1296  else if (_factoryName == "StaticText")
1297  {
1298  MYGUI_LOG(Warning, "StaticText factory is deprecated, use " << TextBox::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1299  }
1300  else if (_factoryName == "Progress")
1301  {
1302  MYGUI_LOG(Warning, "Progress factory is deprecated, use " << ProgressBar::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1303  }
1304  else if (_factoryName == "List")
1305  {
1306  MYGUI_LOG(Warning, "List factory is deprecated, use " << ListBox::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1307  }
1308  else if (_factoryName == "Edit")
1309  {
1310  MYGUI_LOG(Warning, "Edit factory is deprecated, use " << EditBox::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1311  }
1312  else if (_factoryName == "Tab")
1313  {
1314  MYGUI_LOG(Warning, "Tab factory is deprecated, use " << TabControl::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1315  }
1316  else if (_factoryName == "MultiList")
1317  {
1318  MYGUI_LOG(Warning, "MultiList factory is deprecated, use " << MultiListBox::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1319  }
1320  else if (_factoryName == "MenuCtrl")
1321  {
1322  MYGUI_LOG(Warning, "MenuCtrl factory is deprecated, use " << MenuControl::getClassTypeName() << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1323  }
1324  }
1325 #endif // MYGUI_DONT_USE_OBSOLETE
1326  return _factoryName;
1327  }
1328 
1329  std::string BackwardCompatibility::getSkinRename(const std::string& _skinName)
1330  {
1331 #ifndef MYGUI_DONT_USE_OBSOLETE
1332  MapString::iterator item = mSkinRename.find(_skinName);
1333  if (item != mSkinRename.end())
1334  {
1335  MYGUI_LOG(Warning, (*item).first << " skin is deprecated, use " << (*item).second << " [" << LayoutManager::getInstance().getCurrentLayout() << "]");
1336  return (*item).second;
1337  }
1338 #endif // MYGUI_DONT_USE_OBSOLETE
1339  return _skinName;
1340  }
1341 
1343  {
1344 #ifndef MYGUI_DONT_USE_OBSOLETE
1345  mPropertyRename.clear();
1346 #endif // MYGUI_DONT_USE_OBSOLETE
1347  }
1348 
1350  {
1351 #ifndef MYGUI_DONT_USE_OBSOLETE
1353  std::string widgetCategory = MyGUI::WidgetManager::getInstance().getCategoryName();
1354  factory.registerFactory<HScroll>(widgetCategory);
1355  factory.registerFactory<VScroll>(widgetCategory);
1356  factory.registerFactory<Canvas>(widgetCategory, "RenderBox");
1357  factory.registerFactory<TabItem>(widgetCategory, "Sheet");
1358  factory.registerFactory<ImageBox>(widgetCategory, "StaticImage");
1359  factory.registerFactory<TextBox>(widgetCategory, "StaticText");
1360  factory.registerFactory<ProgressBar>(widgetCategory, "Progress");
1361  factory.registerFactory<ListBox>(widgetCategory, "List");
1362  factory.registerFactory<EditBox>(widgetCategory, "Edit");
1363  factory.registerFactory<TabControl>(widgetCategory, "Tab");
1364  factory.registerFactory<MultiListBox>(widgetCategory, "MultiList");
1365  factory.registerFactory<MenuControl>(widgetCategory, "MenuCtrl");
1366 #endif // MYGUI_DONT_USE_OBSOLETE
1367  }
1368 
1369 } // namespace MyGUI