Example #1
0
void Themed::ReadTheme()
{
	int q = theme.Find(ToLower(GetClass()));
	if(q < 0) return;
	ClassTheme& cm = theme[q];
	ThemeProperties tm(cm.data.property, cm.data.image, true);
	Properties(tm);
	Ctrl *p = dynamic_cast<Ctrl *>(this);
	if(p)
		for(Ctrl *q = p->GetFirstChild(); q; q = q->GetNext()) {
			Themed *t = dynamic_cast<Themed *>(q);
			if(t) {
				int i = cm.child.Find(t->GetClass());
				if(i >= 0) {
					ThemeProperties tm(cm.child[i].property, cm.child[i].image, true);
					t->Properties(tm);
				}
				i = cm.child.Find(t->id);
				if(i >= 0) {
					q->SetPos(cm.child[i].pos);
					ThemeProperties tm(cm.child[i].property, cm.child[i].image, true);
					t->Properties(tm);
				}
			}
		}
}
Example #2
0
void Themed::WriteTheme()
{
	if(IsNull(sWriteDir))
		return;
	RealizeDirectory(sWriteDir);
	String imgdir = AppendFileName(sWriteDir, GetClass() + ".image");
	FileOut out(AppendFileName(sWriteDir, GetClass() + ".class"));
	VectorMap<String, String> prop;
	VectorMap<String, Image> img;
	ThemeProperties tm(prop, img, false);
	Properties(tm);
	RealizeDirectory(imgdir);
	SaveImages(imgdir, NULL, img);
	SaveProp(out, prop, "");
	Ctrl *p = dynamic_cast<Ctrl *>(this);
	if(p)
		for(Ctrl *q = p->GetFirstChild(); q; q = q->GetNext()) {
			Themed *t = dynamic_cast<Themed *>(q);
			if(t && t->id.GetCount()) {
//				prop.Clear();
//				ThemeProperties tm(prop, img, false);
//				t->Properties(tm);
				out << t->id;
				Ctrl::LogPos pos = q->GetPos();
				switch(pos.x.GetAlign()) {
				case Ctrl::LEFT:   out << Format(" left %d, %d", pos.x.GetA(), pos.x.GetB()); break;
				case Ctrl::RIGHT:  out << Format(" right %d, %d", pos.x.GetA(), pos.x.GetB()); break;
				case Ctrl::SIZE:   out << Format(" hsize %d, %d", pos.x.GetA(), pos.x.GetB()); break;
				case Ctrl::CENTER: out << Format(" hcenter %d, %d", pos.x.GetB(), pos.x.GetA()); break;
				}
				switch(pos.y.GetAlign()) {
				case Ctrl::TOP:    out << Format(" top %d, %d", pos.y.GetA(), pos.y.GetB()); break;
				case Ctrl::BOTTOM: out << Format(" bottom %d, %d", pos.y.GetA(), pos.y.GetB()); break;
				case Ctrl::SIZE:   out << Format(" vsize %d, %d", pos.y.GetA(), pos.y.GetB()); break;
				case Ctrl::CENTER: out << Format(" vcenter %d, %d", pos.y.GetB(), pos.y.GetA()); break;
				}
				out << "\r\n";
//				SaveProp(out, prop, "   ");
			}
		}
}