aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/skin/widgets/xuigroupxfade.cpp
blob: c5c7e72b526bc70ad5cdea3827987528847245f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <precomp.h>
#include "xuigroupxfade.h"


#ifndef _WASABIRUNTIME

BEGIN_SERVICES(GroupXFade_Svc);
DECLARE_SERVICE(XuiObjectCreator<GroupXFadeXuiSvc>);
END_SERVICES(GroupXFade_Svc, _GroupXFade_Svc);

#ifdef _X86_
extern "C" { int _link_GroupXFadeXuiSvc; }
#else
extern "C" { int __link_GroupXFadeXuiSvc; }
#endif

#endif


	
XMLParamPair GroupXFade::params[] = {
  {GROUPXFADE_SETGROUP, L"GROUP"},
  {GROUPXFADE_SETGROUP, L"GROUPID"},
  {GROUPXFADE_SETSPEED, L"SPEED"},
	};
GroupXFade::GroupXFade() {
  child[0] = child[1] = NULL;
  curchild = 0;
  myxuihandle = newXuiHandle();
	CreateXMLParameters(myxuihandle);
  speed = 0.25;	
}

void GroupXFade::CreateXMLParameters(int master_handle)
{
	//GROUPXFADE_PARENT::CreateXMLParameters(master_handle);
	int numParams = sizeof(params) / sizeof(params[0]);
	hintNumberOfParams(myxuihandle, numParams);
	for (int i = 0;i < numParams;i++)
		addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);

}

GroupXFade::~GroupXFade() {
  if (child[0]) {
    ifc_window *w = child[0]->guiobject_getRootWnd();
    if (w) WASABI_API_SKIN->group_destroy(w);
  }
  if (child[1]) {
    ifc_window *w = child[1]->guiobject_getRootWnd();
    if (w) WASABI_API_SKIN->group_destroy(w);
  }
}

int GroupXFade::onInit() {
  GROUPXFADE_PARENT::onInit();
  return 1;
}

int GroupXFade::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) {
  if (xuihandle != myxuihandle)
    return GROUPXFADE_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);

  switch(xmlattributeid) {
    case GROUPXFADE_SETGROUP:
      setNewGroup(value);
      return 1;
    case GROUPXFADE_SETSPEED:
      speed = WTOF(value);
      return 1;
    default:
      return 0;
  }
}

int GroupXFade::onResize() {
  GROUPXFADE_PARENT::onResize();
  RECT r;
  getClientRect(&r);
  if (child[curchild]) 
    child[curchild]->guiobject_getRootWnd()->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
  int nextchild = curchild == 1 ? 0 : 1;
  if (child[nextchild]) 
    child[nextchild]->guiobject_getRootWnd()->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
  return 1;
}

void GroupXFade::setNewGroup(const wchar_t *grp) {
  if (child[curchild] && id[curchild].iscaseequal(grp)) return;
  if (child[curchild]) {
    child[curchild]->guiobject_setTargetA(0);
    child[curchild]->guiobject_setTargetSpeed((float)speed);
    child[curchild]->guiobject_gotoTarget();
  }
  int nextchild = curchild == 1 ? 0 : 1;
  if (child[nextchild]) {
    ifc_window *w = child[nextchild]->guiobject_getRootWnd();
    WASABI_API_SKIN->group_destroy(w);
    child[nextchild] = NULL;
  }
  if (grp && *grp) {
    ifc_window *w = WASABI_API_SKIN->group_create(grp);
    if (w) {
      child[nextchild] = w->getGuiObject();
      w->setParent(this);
      w->setStartHidden(1);
      RECT r;
      getClientRect(&r);
      w->setAlpha(0);
      w->init(this);
      w->setVisible(1);
      w->resize(r.left, r.top, r.right-r.left, r.bottom-r.top);
      child[nextchild]->guiobject_setTargetA(255);
      child[nextchild]->guiobject_setTargetSpeed((float)speed);
      child[nextchild]->guiobject_gotoTarget();
      id[nextchild] = grp;
    }
  }
  curchild = nextchild;
}