[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/src/layout pgxmllayoutloader.cpp,1.1,1.2
From: |
Alexander Pipelka <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/src/layout pgxmllayoutloader.cpp,1.1,1.2 |
Date: |
Thu, 27 Jun 2002 11:37:46 -0400 |
Update of /cvsroot/paragui/paragui/src/layout
In directory subversions:/tmp/cvs-serv26167/src/layout
Modified Files:
pgxmllayoutloader.cpp
Log Message:
more work on the XML layout loader.
basic factory integration.
Index: pgxmllayoutloader.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/src/layout/pgxmllayoutloader.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** pgxmllayoutloader.cpp 27 Jun 2002 14:37:12 -0000 1.1
--- pgxmllayoutloader.cpp 27 Jun 2002 15:37:44 -0000 1.2
***************
*** 2,9 ****
#include "pgxmllayoutloader.h"
#include "pgwidget.h"
! #include "pgfilearchive.h"
#include "pglog.h"
#include "expat.h"
#include <stack>
--- 2,11 ----
#include "pgxmllayoutloader.h"
#include "pgwidget.h"
! #include "pgapplication.h"
#include "pglog.h"
#include "expat.h"
+ #include "pgfactory.h"
+
#include <stack>
***************
*** 69,73 ****
}
-
void PG_XMLTag::Log() {
PG_LogMSG("Tagname: %s", name.c_str());
--- 71,74 ----
***************
*** 80,83 ****
--- 81,193 ----
}
+ PG_Rect PG_XMLTag::GetRect(const char* name, PG_Widget* parent) {
+ PG_Rect result;
+
+ std::string value = taglist[name];
+
+ if(value.empty()) {
+ return result;
+ }
+
+ SDL_Surface *screen = PG_Application::GetScreen();
+ char* parm;
+ char *d;
+ char tmp[16];
+ int i=0;
+ int mx;
+ int r[4];
+
+ r[0] = r[1] = r[2] = r[3] = 0;
+ parm = strdup(value.c_str());
+
+ for(d = strtok(parm,","); d != NULL; d = strtok(NULL,",")) {
+ if(parent == NULL) {
+ mx = ((i%2)==0) ? screen->w : screen->h;
+ } else {
+ mx = ((i%2)==0) ? parent->w : parent->h;
+ }
+
+ if( sscanf(d, "%d%[%]", & r[i], tmp) == 2 )
+ r[i] = (int) ((float)r[i]*mx/100);
+
+ if(r[i]<0)
+ r[i] = mx+r[i];
+
+ i++;
+ }
+ result.SetRect(r[0], r[1], r[2], r[3]);
+ free(parm);
+
+ return result;
+ }
+
+ int PG_XMLTag::GetInt(const char* name) {
+ return atoi(taglist[name].c_str());
+ }
+
+ int PG_XMLTag::GetAlignment(const char* name) {
+ int result = -1;
+ std::string value = taglist[name];
+
+ if (value == "left")
+ result = PG_TA_LEFT;
+ if (value == "right")
+ result = PG_TA_RIGHT;
+ if (value == "center")
+ result = PG_TA_CENTER;
+
+ if (result == -1) {
+ PG_LogWRN("Unknown align type %s !", value.c_str());
+ }
+
+ return result;
+ }
+
+ int PG_XMLTag::GetBackmode(const char* name) {
+ int result = BKMODE_TILE;
+ std::string value = taglist[name];
+
+ if (value == "tile")
+ result = BKMODE_TILE;
+ if (value == "stretch")
+ result = BKMODE_STRETCH;
+ if (value == "h3tile")
+ result = BKMODE_3TILEH;
+ if (value == "v3tile")
+ result = BKMODE_3TILEV;
+
+ return result;
+ }
+
+ PG_Gradient* PG_XMLTag::GetGradient(const char* name) {
+ std::string value = taglist[name];
+ int r1,g1,b1,r2,g2,b2,r3,g3,b3,r4,g4,b4;
+
+ if(value.empty()) {
+ return NULL;
+ }
+
+
sscanf(value.c_str(),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&r1,&g1,&b1,&r2,&g2,&b2,&r3,&g3,&b3,&r4,&g4,&b4);
+
+ PG_Gradient* result = new PG_Gradient;
+ result->colors[0].r = r1;
+ result->colors[0].g = g1;
+ result->colors[0].b = b1;
+
+ result->colors[1].r = r2;
+ result->colors[1].g = g2;
+ result->colors[1].b = b2;
+
+ result->colors[2].r = r3;
+ result->colors[2].g = g3;
+ result->colors[2].b = b3;
+
+ result->colors[3].r = r4;
+ result->colors[3].g = g4;
+ result->colors[3].b = b4;
+
+ return result;
+ }
+
bool PG_XMLLayoutLoaderBase::Load(PG_Widget* parent, const char* filename) {
***************
*** 180,183 ****
--- 290,300 ----
PG_LogMSG("> handleStartTag");
tag.Log();
+
+ if(tag.section == BODY) {
+ PG_Widget* widget = PG_Factory::CreateObject(tag.name);
+ if(widget == NULL) {
+ PG_LogWRN("Unknown factory object '%s' !!!",
tag.name.c_str());
+ }
+ }
return true;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/src/layout pgxmllayoutloader.cpp,1.1,1.2,
Alexander Pipelka <address@hidden> <=
- Prev by Date:
[paragui-cvs] CVS: paragui/include pgxmllayoutloader.h,1.1,1.2
- Next by Date:
[paragui-cvs] CVS: paragui/include Makefile.am,1.10,1.11 pgbutton.h,1.7,1.8 pgwidget.h,1.14,1.15 pgxmllayoutloader.h,1.2,1.3
- Previous by thread:
[paragui-cvs] CVS: paragui/include pgxmllayoutloader.h,1.1,1.2
- Next by thread:
[paragui-cvs] CVS: paragui/include Makefile.am,1.10,1.11 pgbutton.h,1.7,1.8 pgwidget.h,1.14,1.15 pgxmllayoutloader.h,1.2,1.3
- Index(es):