/* GUI utilities by Gustav Larsson gee@pyro.nu */ //#include "stdafx.h" #include "GUI.h" #include "../ps/Parser.h" using namespace std; //-------------------------------------------------------- // Help Classes/Structs for the GUI implementation //-------------------------------------------------------- CClientArea::CClientArea() : pixel(0,0,0,0), percent(0,0,0,0) { } CClientArea::CClientArea(const CStr &Value) { SetClientArea(Value); } CRect CClientArea::GetClientArea(const CRect &parent) { CRect client; // This should probably be cached and not calculated all the time for every object. client.left = parent.left + int(float((parent.right-parent.left)*percent.left)/100.f) + pixel.left; client.top = parent.top + int(float((parent.bottom-parent.top)*percent.top)/100.f) + pixel.top; client.right = parent.left + int(float((parent.right-parent.left)*percent.right)/100.f) + pixel.right; client.bottom = parent.top + int(float((parent.bottom-parent.top)*percent.bottom)/100.f) + pixel.bottom; return client; } bool CClientArea::SetClientArea(const CStr &Value) { // Get value in STL string format string _Value = (const TCHAR*)Value; // This might lack incredible speed, but since all XML files // are read at startup, reading 100 client areas will be // negligible in the loading time. // Setup parser to parse the value CParser parser; // One of the for values: // will give outputs like (in argument): // (200) <== no percent, just the first $value // (200) (percent) <== just the percent // (200) (percent) (100) <== percent PLUS pixel // (200) (percent) (-100) <== percent MINUS pixel // (200) (percent) (100) (-100) <== Both PLUS and MINUS are used, INVALID string one_value = "_$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]"; string four_values = one_value + "$arg(delim)" + one_value + "$arg(delim)" + one_value + "$arg(delim)" + one_value + "$arg(delim)_"; // it's easier to just end with another delimiter parser.InputTaskType("ClientArea", four_values); CParserLine line; line.ParseString(parser, _Value); if (!line.m_ParseOK) return false; int arg_count[4]; // argument counts for the four values int arg_start[4] = {0,0,0,0}; // location of first argument, [0] is alwasy 0 // Divide into the four piles (delimiter is an argument named "delim") for (int i=0, valuenr=0; isecond; } const IGUIObject * CInternalCGUIAccessorBase::GetObjectPointer(const CGUI &GUIinstance, const CStr &Object) { // if (!GUIinstance.ObjectExists(Object)) // return NULL; return GUIinstance.m_pAllObjects.find(Object)->second; }