#include <string> #include <stdlib.h> #include <objgfx40.h> #include <vContext.h> #include <sStyle.h> vContext::vContext(vContext * parent) { pContext = parent; realView = new ogSurface(); curX = curY = width = height = 0; attached = false; return; } // vContext::vContext vContext * vContext::Attach(vContext * context) { cContexts.push_back(context); return context; } // vContext::Attach bool vContext::DeleteStyle(const std::string styleKey) { /* * vContext::DeleteStyle() * returns true if style existed and was deleted * returns false if style didn't exist (or wasn't deleted) */ sStyle * tmpStyle = styles[styleKey]; styles.erase(styleKey); delete tmpStyle; return (NULL == tmpStyle) ? false : true; } // vContext::DeleteStyle vContext * vContext::Detach(vContext * context) { cContexts.remove(context); return context; } // vContext::Detach void vContext::Draw(void) { return; } // vContext::Draw sStyle * vContext::GetStyle(const std::string styleKey) { /* * GetStyle() * retreives a style out of the style map using the styleKey string * If no style is present in this node, check the parent */ sStyle * tmpStyle = styles[styleKey]; if ((NULL == tmpStyle) && (NULL != pContext)) { return pContext->GetStyle(styleKey); } // if return tmpStyle; } // vContext::GetStyle void vContext::SetPos(int32 newX, int32 newY) { /* * vContext::SetPos() * Sets new position relative to parent's upper left corner */ // I really should detach from the parent here curX = newX; curY = newY; // and reattach to parent here return; } // vContext::SetPos void vContext::SetSize(uInt32 newWidth, uInt32 newHeight) { width = newWidth; height = newHeight; } // vContext::SetSize void vContext::SetStyle(const std::string styleKey, sStyle * style) { // I probably should check to see if a style exists before setting it // if the style is null, then just exit out without setting it if (NULL == style) return; // set the new style styles[styleKey] = style; } // vContext::SetStyle vContext::~vContext(void) { delete realView; pContext = NULL; curX = curY = 0; return; } // vContext::~vContext