Code directory changes

This commit is contained in:
Vulpovile
2021-03-04 21:48:29 -08:00
parent 8bf27c6412
commit 12843a0890
87 changed files with 224 additions and 510 deletions

92
src/include/Application.h Normal file
View File

@@ -0,0 +1,92 @@
#pragma once
#include <G3DAll.h>
#include "PropertyWindow.h"
#include "TextButtonInstance.h"
#include "ImageButtonInstance.h"
#include "CameraController.h"
#include "IEBrowser.h"
#include "Mouse.h"
#include "Tool.h"
//#include "GuiRoot.h"
class TextButtonInstance;
class ImageButtonInstance;
class PartInstance;
class CameraController;
class Application { // : public GApp {
public:
Application(HWND parentWindow);
void Boop();
virtual ~Application() {}
virtual void exitApplication();
virtual void onInit();
virtual void onLogic();
virtual void onNetwork();
virtual void onSimulation(RealTime rdt, SimTime sdt, SimTime idt);
virtual void onGraphics(RenderDevice* rd);
virtual void onUserInput(UserInput* ui);
virtual void onCleanup();
void clearInstances();
void navigateToolbox(std::string);
PartInstance* makePart();
void drawButtons(RenderDevice* rd);
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c);
void makeFlag(Vector3 &vec, RenderDevice* &rd);
std::vector<Instance*> getSelection();
void deleteInstance();
void run();
void QuitApp();
void resizeWithParent(HWND parentWindow);
void onCreate(HWND parentWindow);
void onKeyPressed(int key);
void onKeyUp(int key);
void onMouseLeftPressed(HWND hwnd,int x, int y);
void onMouseLeftUp(RenderDevice* renderDevice, int x, int y);
void onMouseRightPressed(int x, int y);
void onMouseRightUp(int x, int y);
void onMouseMoved(int x, int y);
void onMouseWheel(int x, int y, short delta);
void setFocus(bool isFocused);
int getMode();
CameraController cameraController;
UserInput* userInput;
PropertyWindow* _propWindow;
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
RenderDevice* getRenderDevice();
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
void setMode(int mode);
Tool * tool;
void changeTool(Tool *);
Mouse mouse;
private:
bool mouseMoveState;
RenderDevice* renderDevice;
//void initGUI();
HWND _hWndMain;
SkyRef sky;
bool quit;
bool mouseOnScreen;
bool rightButtonHolding;
void main();
GWindow* _window;
HWND _hwndToolbox;
HWND _buttonTest;
HWND _hwndRenderer;
DataModelInstance* _dataModel;
G3D::TextureRef shadowMap;
std::string _title;
bool _dragging;
int _mode;
GAppSettings _settings;
double lightProjX, lightProjY, lightProjNear, lightProjFar;
IEBrowser* webBrowser;
protected:
Stopwatch m_graphicsWatch;
Stopwatch m_logicWatch;
Stopwatch m_networkWatch;
Stopwatch m_userInputWatch;
Stopwatch m_simulationWatch;
Stopwatch m_waitWatch;
};

23
src/include/ArrowTool.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
#include "tool.h"
class ArrowTool :
public Tool
{
public:
ArrowTool(void); //OnSelect?
~ArrowTool(void); //OnDeselect?
virtual void onButton1MouseDown(Mouse);
virtual void onButton1MouseUp(Mouse);
virtual void onMouseMoved(Mouse mouse);
virtual void onSelect(Mouse mouse);
virtual void onKeyDown(int key);
virtual void onKeyUp(int key);
private:
bool lctrlDown;
bool rctrlDown;
int mouseDownStartx;
int mouseDownStarty;
bool dragging;
bool mouseDown;
};

11
src/include/AudioPlayer.h Normal file
View File

@@ -0,0 +1,11 @@
#include <G3DAll.h>
#pragma once
class AudioPlayer
{
public:
AudioPlayer(void);
~AudioPlayer(void);
static void playSound(std::string);
static void init();
};

View File

@@ -0,0 +1,26 @@
#pragma once
#include "instance.h"
#include "ButtonListener.h"
class ButtonListener;
class Instance;
class BaseButtonInstance : public Instance
{
public:
BaseButtonInstance(void);
virtual ~BaseButtonInstance(void);
virtual void render(RenderDevice* rd);
virtual void drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown);
virtual bool mouseInButton(float, float, RenderDevice* rd);
virtual void onMouseClick();
void setButtonListener(ButtonListener*);
bool floatBottom;
bool floatRight;
bool floatCenter;
volatile bool disabled;
bool selected;
protected:
bool mouseInArea(float, float, float, float, float, float);
class ButtonListener* listener;
};

View File

@@ -0,0 +1,8 @@
#pragma once
#include <Mshtmhst.h>
class BrowserCallHandler : IDocHostUIHandler
{
public:
BrowserCallHandler(void);
~BrowserCallHandler(void);
};

View File

@@ -0,0 +1,22 @@
#pragma once
//#include "Application.h"
#include "BaseButtonInstance.h"
class BaseButtonInstance;
class ButtonListener
{
public:
ButtonListener();
~ButtonListener(void);
virtual void onButton1MouseClick(BaseButtonInstance*);
bool doDelete;
//virtual void onMouseOver(); //TODO
//virtual void onMouseOut(); //TODO
//virtual void onButton1MouseDown(); //TODO
//virtual void onButton1MouseUp(); //TODO
//virtual void onButton2MouseClick(); //TODO
//virtual void onButton2MouseDown(); //TODO
//virtual void onButton2MouseUp(); //TODO
//What to do now...
};

View File

@@ -0,0 +1,7 @@
#pragma once
#include "ButtonListener.h"
class CameraButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -0,0 +1,47 @@
#pragma once
#include <G3DAll.h>
#include "Instance.h"
#include "Globals.h"
#include <string>
#define CAM_ZOOM_MIN 0.1f
#define CAM_ZOOM_MAX 100.f
class Application;
class CameraController {
public:
CameraController();
G3D::CoordinateFrame getCoordinateFrame();
void setFrame(const CoordinateFrame& cf);
void lookAt(const Vector3& position);
void refreshZoom(const CoordinateFrame& frame);
void pan(CoordinateFrame* frame,float spdX,float spdY);
void panLock(CoordinateFrame* frame,float spdX,float spdY);
void update(Application* app);
void centerCamera(Instance* selection);
void panLeft();
void panRight();
void tiltUp();
void tiltDown();
void Zoom(short delta);
bool onMouseWheel(int x, int y, short delta);
GCamera* getCamera();
private:
Vector3 translation;
Vector3 focusPosition;
float yaw;
float pitch;
float moveRate;
float zoom;
bool forwards;
bool backwards;
bool left;
bool right;
bool rightButtonHolding;
POINT oldDesktopMouse;
GCamera g3dCamera;
std::string cameraSound;
};

View File

@@ -0,0 +1,57 @@
#pragma once
#include "WorkspaceInstance.h"
#include "LevelInstance.h"
#include "PartInstance.h"
#include "rapidxml/rapidxml.hpp"
#include "GuiRootInstance.h"
class GuiRootInstance;
class DataModelInstance :
public Instance
{
public:
DataModelInstance(void);
~DataModelInstance(void);
void setMessage(std::string);
void setMessageBrickCount();
void clearMessage();
bool debugGetOpen();
bool getOpen();
bool load(const char* filename,bool clearObjects);
bool readXMLFileStream(std::ifstream* file);
void drawMessage(RenderDevice*);
WorkspaceInstance* getWorkspace();
LevelInstance * getLevel();
std::string message;
std::string _loadedFileName;
bool showMessage;
G3D::GFontRef font;
GuiRootInstance* getGuiRoot();
//float mousex;
//float mousey;
//Vector2 getMousePos();
//void setMousePos(int x,int y);
//void setMousePos(Vector2 pos);
//bool mouseButton1Down;
PartInstance* makePart();
void clearLevel();
void toggleRun();
bool isRunning();
#if _DEBUG
void modXMLLevel(float modY);
#endif
private:
bool isBrickCount;
bool scanXMLObject(rapidxml::xml_node<>* node);
rapidxml::xml_node<>* getNode(rapidxml::xml_node<> * node,const char* name );
float getFloatValue(rapidxml::xml_node<> * node,const char* name);
bool _successfulLoad;
std::string _errMsg;
bool _legacyLoad;
float _modY;
WorkspaceInstance* workspace;
LevelInstance * level;
GuiRootInstance* guiRoot;
bool running;
};

View File

@@ -0,0 +1,6 @@
#include "ButtonListener.h"
class DeleteListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

23
src/include/Enum.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
namespace Enum
{
namespace SurfaceType
{
enum Value {
Smooth, Snaps, Inlets, Glue, Weld, Spawn, Hinge, Motor, Bumps
};
}
namespace Shape
{
enum Value {
Ball = 0, Block = 1, Cylinder = 2
};
}
namespace Controller
{
enum Value {
Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0
};
}
}

16
src/include/Enums.h Normal file
View File

@@ -0,0 +1,16 @@
#ifdef UENUMS
#ifndef ENUM_H
#define ENUM_H
static enum BinType {GameTool, Grab, Clone, Hammer};
static enum ControllerType {None, KeyboardRight, KeyboardLeft, Joypad1, Joypad2, Chase, Flee};
//static enum JointType {UNK0, WeldJoint, SnapJoint, UNK3, Rotate, RotateP, RotateV, GlueJoint, UNK8, UNK9, None};
static enum ActionType {Nothing, Pause, Lose, Draw, Win};
static enum AffectType {NoChange, Increase, Decrease};
static enum InputType {NoInput, LeftTread, RightTread, Steer, Throtle, UpDown, Action1, Action2, Action3, Action4, Action5, Constant, Sin};
//static enum SurfaceConstraint {None, Hinge, SteppingMotor, Motor};
static enum SurfaceType{Smooth, Snaps, Inlets, Glue, Weld, Spawn, Hinge, Motor, Bumps};
static enum SoundType {NoSound, Boing, Bomb, Break, Click, Clock, Slingshot, Page, Ping, Snap, Splat, Step, StepOn, Swoosh, Victory};
static enum PartType {Ball, Block, Cylinder};
static enum KeywordFilterType {Include, Exclude};
#endif
#endif

View File

@@ -0,0 +1,6 @@
#pragma once
#include <string>
void OnError(int err, std::string msg = "");
void MessageBoxStr(std::string msg);
void MessageBoxStream(std::stringstream msg);

View File

@@ -0,0 +1,7 @@
#pragma once
#include "ButtonListener.h"
class GUDButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

39
src/include/Globals.h Normal file
View File

@@ -0,0 +1,39 @@
#pragma once
#include "DataModelInstance.h"
class Application;
class Globals
{
public:
Globals(void);
~Globals(void);
static DataModelInstance* dataModel;
static bool showMouse;
static POINT mousepoint;
static bool useMousePoint;
static const int gen;
static const int major;
static const int minor;
static const int patch;
static G3D::TextureRef surface;
static int surfaceId;
static const std::string g_PlaceholderName;
static COLORREF g_acrCustClr[16]; //Will be dynamic later
};
extern std::vector<Instance*> postRenderStack;
extern std::vector<Instance*> g_selectedInstances;
extern bool running;
extern DataModelInstance* g_dataModel;
extern Application* g_usableApp;
extern GFontRef g_fntdominant;
extern GFontRef g_fntlighttrek;
extern COLORREF g_acrCustClr[16]; //Will be dynamic later
extern std::string cameraSound;
extern std::string clickSound;
extern std::string dingSound;
const std::string g_PlaceholderName = "Dygysphere";

View File

@@ -0,0 +1,16 @@
#pragma once
#include "PartInstance.h"
class GroupInstance :
public PVInstance
{
public:
GroupInstance(void);
~GroupInstance(void);
GroupInstance(const GroupInstance &oinst);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
std::vector<Instance *> unGroup();
PartInstance * primaryPart;
void render(RenderDevice * r);
};

View File

@@ -0,0 +1,24 @@
#pragma once
#include "Instance.h"
class ImageButtonInstance;
class TextButtonInstance;
class GuiRootInstance : public Instance
{
public:
GuiRootInstance();
GuiRootInstance::~GuiRootInstance();
TextButtonInstance* makeTextButton();
void drawButtons(RenderDevice* rd);
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage, G3D::TextureRef overImage, G3D::TextureRef downImage, G3D::TextureRef disableImage);
void renderGUI(G3D::RenderDevice* rd, double fps);
void setDebugMessage(std::string msg, G3D::RealTime msgTime);
void update();
bool mouseInGUI(G3D::RenderDevice* renderDevice,int x,int y);
void onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y);
private:
std::string _message;
G3D::RealTime _messageTime;
};

28
src/include/IEBrowser.h Normal file
View File

@@ -0,0 +1,28 @@
//#include "WindowFunctions.h"
#pragma once
#include "Globals.h"
#pragma once
#include <mshtml.h>
#include <exdisp.h>
#include <Mshtmhst.h>
#include "IEDispatcher.h"
#include "AudioPlayer.h"
class IEBrowser {
public:
IEBrowser(HWND attachHWnd);
~IEBrowser(void);
bool navigateSyncURL(wchar_t* url);
HRESULT doExternal(std::wstring funcName,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR* pDispParams,
VARIANT FAR* pVarResult,
EXCEPINFO FAR* pExcepInfo,
unsigned int FAR* puArgErr);
private:
IWebBrowser2* webBrowser;
HWND hwnd;
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include "oaidl.h"
//DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F);
class IEDispatcher : public IDispatch
{
/*
EXTERN_C const IID IID_IDispatch;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("B323F8E0-2E68-11D0-90EA-00AA0060F86F")
IEDispatcher : public IDispatch
{
*/
public:
IEDispatcher(void);
~IEDispatcher(void);
HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject);
ULONG STDMETHODCALLTYPE IEDispatcher::AddRef();
ULONG STDMETHODCALLTYPE IEDispatcher::Release();
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo);
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **);
HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *);
HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
};
//#endif

View File

@@ -0,0 +1,27 @@
#pragma once
#include "BaseButtonInstance.h"
class BaseButtonInstance;
class ImageButtonInstance : public BaseButtonInstance
{
public:
//ImageButtonInstance(G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
~ImageButtonInstance(void);
void drawObj(RenderDevice*, Vector2, bool);
Vector2 size;
Vector2 position;
G3D::TextureRef image;
int openGLID;
G3D::TextureRef image_ovr;
int openGLID_ovr;
G3D::TextureRef image_dn;
int openGLID_dn;
G3D::TextureRef image_ds;
int openGLID_ds;
bool mouseInButton(float, float, RenderDevice*);
};

37
src/include/Instance.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#include <G3DAll.h>
#include "propertyGrid.h"
#include "map"
class Instance
{
public:
bool canDelete;
Instance(void);
Instance(const Instance&);
virtual ~Instance(void);
std::string name;
virtual void render(RenderDevice*);
virtual void update();
std::vector<Instance*> children; // All children.
std::string getClassName();
Instance* findFirstChild(std::string);
std::vector<Instance* > getChildren();
std::vector<Instance* > getAllChildren();
virtual void setParent(Instance*);
void setName(std::string newName);
void addChild(Instance*);
void removeChild(Instance*);
void clearChildren();
Instance* getParent();
virtual Instance* clone() const { return new Instance(*this); }
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
int listicon;
protected:
std::string className;
Instance* parent; // Another pointer.
PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type, TCHAR choices[] = NULL);
private:
static const std::map<std::string, Instance> g_logLevelsDescriptions;
};

View File

@@ -0,0 +1,16 @@
#pragma once
#include "instance.h"
class LevelInstance :
public Instance
{
public:
LevelInstance(void);
~LevelInstance(void);
float timer;
int score;
virtual std::vector<PROPGRIDITEM> getProperties();
std::string winMessage;
std::string loseMessage;
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
};

View File

@@ -0,0 +1,8 @@
#pragma once
#include "buttonlistener.h"
class MenuButtonListener :
public ButtonListener
{
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -0,0 +1,11 @@
#pragma once
#include "ButtonListener.h"
#define CURSOR 0
#define ARROWS 1
#define RESIZE 2
class ModeSelectionListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

32
src/include/Mouse.h Normal file
View File

@@ -0,0 +1,32 @@
#pragma once
#include "PartInstance.h"
#pragma once
#include "WorkspaceInstance.h"
struct MousePoint{
Vector3 position;
PartInstance * target;
MousePoint(Vector3 pos, PartInstance * targ)
{
position = pos;
target = targ;
}
};
#pragma once
class Mouse
{
public:
Mouse();
~Mouse(void);
int x, y;
int oldx, oldy;
PartInstance * getTarget();
MousePoint getPositionAndPart(std::vector<Instance *> ignore = std::vector<Instance *>());
Vector3 getPosition(std::vector<Instance *> ignore = std::vector<Instance *>());
bool isMouseOnScreen();
bool isMouseDown();
void setMouseDown(bool mouseDown);
private:
bool mouseDown;
};

34
src/include/PVInstance.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include "instance.h"
#include "enum.h"
class PVInstance :
public Instance
{
public:
PVInstance(void);
~PVInstance(void);
PVInstance(const PVInstance &oinst);
virtual void postRender(RenderDevice* rd);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
bool nameShown;
bool controllerFlagShown;
Enum::Controller::Value controller;
protected:
static G3D::Color3 getControllerColor(int controller)
{
switch(controller)
{
case Enum::Controller::KeyboardLeft:
return Color3::red();
case Enum::Controller::KeyboardRight:
return Color3::blue();
case Enum::Controller::Chase:
return Color3::black();
case Enum::Controller::Flee:
return Color3::yellow();
}
return Color3::gray();
}
};

View File

@@ -0,0 +1,85 @@
#pragma once
#include "PVInstance.h"
#include "Enum.h"
#define _USE_MATH_DEFINES
#include <cmath>
#define NEW_BOX_RENDER
class PartInstance : public PVInstance
{
public:
PartInstance(void);
PartInstance(const PartInstance &oinst);
Instance* clone() const { return new PartInstance(*this); }
virtual void PartInstance::postRender(RenderDevice* rd);
~PartInstance(void);
virtual void render(RenderDevice*);
Enum::SurfaceType::Value top;
Enum::SurfaceType::Value front;
Enum::SurfaceType::Value right;
Enum::SurfaceType::Value back;
Enum::SurfaceType::Value left;
Enum::SurfaceType::Value bottom;
Enum::Shape::Value shape;
CoordinateFrame cFrame;
Color3 color;
Vector3 getPosition();
Vector3 getVelocity();
Vector3 getRotVelocity();
void setParent(Instance* parent);
void setPosition(Vector3);
void setVelocity(Vector3);
bool collides(PartInstance * part);
void setRotVelocity(Vector3);
CoordinateFrame getCFrame();
void setCFrame(CoordinateFrame);
Box getBox();
Sphere getSphere();
Box getScaledBox();
CoordinateFrame getCFrameRenderBased();
Vector3 getSize();
void setSize(Vector3);
void setShape(Enum::Shape::Value shape);
bool canCollide;
bool anchored;
bool collides(Box);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
#ifdef NEW_BOX_RENDER
void addVertex(Vector3 vertexPos,Color3 color);
void addNormals(Vector3 normal);
void addSingularNormal(Vector3 normal);
void addTriangle(Vector3 vertexPos,Vector3 vertexPos2, Vector3 vertexPos3);
void addQuad(Vector3 v1,Vector3 v2, Vector3 v3, Vector3 v4);
void genSmoothNormals(int);
void addSmoothTriangle(Vector3 vertexPos,Vector3 vertexPos2, Vector3 vertexPos3);
void makeSmoothFace(int vertex1, int vertex2, int vertex3);
void addPlus(Vector3 v1);
void addPlus2(Vector3 v1);
void debugPrintVertexIDs(RenderDevice* rd, GFontRef font, Matrix3 camRot);
void makeFace(int vertex1, int vertex2, int vertex3);
void fromArrays(float verts[], float norms[], float ind[], unsigned int countVN, unsigned int countInd);
bool isUniqueVertex(Vector3 pos);
#endif
private:
Vector3 position;
Vector3 size;
Vector3 velocity;
Vector3 rotVelocity;
float _bevelSize;
int _parseVert;
int _debugTimer;
std::vector<Vector3> _debugUniqueVertices;
#ifdef NEW_BOX_RENDER
std::vector<GLfloat> _vertices;
std::vector<GLfloat> _normals;
#else
GLfloat _vertices[96];
#endif
std::vector<GLushort> _indices;
bool changed;
Box itemBox;
GLuint glList;
};

View File

@@ -0,0 +1,17 @@
#pragma once
#include "Instance.h"
class PropertyWindow {
public:
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);
bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance);
void UpdateSelected(Instance *);
void ClearProperties();
void onResize();
void refreshExplorer(Instance* selectedInstance);
HWND _hwndProp;
private:
HWND _propGrid;
HWND _explorerComboBox;
void _resize();
};

View File

@@ -0,0 +1,7 @@
#pragma once
#include "ButtonListener.h"
class RotateButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -0,0 +1,6 @@
#pragma once
#include <string>
std::string Convert (float number);
std::string ExePath();
std::string GetFileInPath(std::string file);

View File

@@ -0,0 +1,35 @@
#pragma once
#include "BaseButtonInstance.h"
class TextButtonInstance : public BaseButtonInstance
{
public:
TextButtonInstance(void);
~TextButtonInstance(void);
void setAllColorsSame();
Vector2 boxBegin;
Vector2 boxEnd;
Vector2 fontLocationRelativeTo;
Color4 textColor;
Color4 textOutlineColor;
Color4 boxColor;
Color4 boxOutlineColor;
Color4 textColorOvr;
Color4 textOutlineColorOvr;
Color4 boxColorOvr;
Color4 boxOutlineColorOvr;
Color4 textColorDn;
Color4 textOutlineColorDn;
Color4 boxColorDn;
Color4 boxOutlineColorDn;
Color4 textColorDis;
Color4 textOutlineColorDis;
Color4 boxColorDis;
Color4 boxOutlineColorDis;
bool centeredWithinBox;
std::string title;
G3D::GFontRef font;
bool visible;
int textSize;
void drawObj(RenderDevice*, Vector2, bool);
bool mouseInButton(float, float, RenderDevice*);
};

View File

@@ -0,0 +1,87 @@
#pragma once
#include <G3DAll.h>
#include <map>
class TextureHandler
{
public:
TextureHandler(void);
~TextureHandler(void);
static int getTextureVolatile(std::string str)
{
if(!volTex[str].isNull())
{
volExp[str] = G3D::System::time();
return volTex[str]->openGLID();
}
else
{
G3D::TextureRef tex = G3D::Texture::fromFile(str);
volExp[str] = G3D::System::time();
volTex[str] = tex;
return tex->openGLID();
}
}
static int getTexturePermanent(std::string str)
{
if(!permTex[str].isNull())
{
return permTex[str]->openGLID();
}
else
{
G3D::TextureRef tex = G3D::Texture::fromFile(str);
permTex[str] = tex;
return tex->openGLID();
}
}
static void flushVolatile()
{
std::map<std::string, G3D::RealTime>::iterator it;
for (it=volExp.begin(); it!=volExp.end(); ++it)
{
if(it->second < G3D::System::time() - 3)
{
volTex[it->first]->~Texture();
volTex.erase(it->first);
volExp.erase(it->first);
//it->second->~ReferenceCountedPointer();
}
}
}
static void dispose()
{
std::map<std::string, G3D::TextureRef>::iterator it;
for (it=volTex.begin(); it!=volTex.end(); ++it)
{
it->second->~Texture();
//it->second->~ReferenceCountedPointer();
}
for (it=permTex.begin(); it!=permTex.end(); ++it)
{
it->second->~Texture();
//it->second->~ReferenceCountedPointer();
}
permTex.clear();
volTex.clear();
}
static void remove(std::string str)
{
if(!volTex[str].isNull())
{
volTex[str]->~Texture();
//volTex[str]->~ReferenceCountedPointer();
volTex.erase(str);
}
if(!permTex[str].isNull())
{
permTex[str]->~Texture();
//permTex[str]->~ReferenceCountedPointer();
permTex.erase(str);
}
}
private:
static std::map<std::string, G3D::TextureRef> volTex;
static std::map<std::string, G3D::RealTime> volExp;
static std::map<std::string, G3D::TextureRef> permTex;
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include "imagebuttoninstance.h"
class ToggleImageButtonInstance : public ImageButtonInstance
{
public:
//ImageButtonInstance(G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
ToggleImageButtonInstance(G3D::TextureRef newImage,G3D::TextureRef overImage = NULL,
G3D::TextureRef downImage = NULL,
G3D::TextureRef disableImage = NULL,
G3D::TextureRef newImage2 = NULL,
G3D::TextureRef overImage2 = NULL,
G3D::TextureRef downImage2 = NULL,
G3D::TextureRef disableImage2 = NULL);
~ToggleImageButtonInstance(void);
void drawObj(RenderDevice*, Vector2, bool);
bool checked;
G3D::TextureRef image2;
int openGLID2;
G3D::TextureRef image_ovr2;
int openGLID2_ovr;
G3D::TextureRef image_dn2;
int openGLID2_dn;
G3D::TextureRef image_ds2;
int openGLID2_ds;
};

34
src/include/Tool.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include "TextureHandler.h"
#pragma once
#include <G3DAll.h>
#pragma once
#include "Mouse.h"
#pragma once
#include "Globals.h"
#pragma once
#include "StringFunctions.h"
#pragma once
class Tool
{
public:
Tool(void);
~Tool(void);
virtual void onButton1MouseDown(Mouse); //yes
virtual void onButton2MouseDown(Mouse); //yes
virtual void onButton3MouseDown(Mouse); //no
virtual void onButton1MouseUp(Mouse);//yes
virtual void onButton2MouseUp(Mouse);//yes
virtual void onButton3MouseUp(Mouse); //no
virtual void onMouseMoved(Mouse);//yes
virtual void onSelect(Mouse);//yes
virtual void onDeselect(Mouse);//yes
virtual void onMouseScroll(Mouse);//Kinda
virtual void onKeyDown(int);//yes
virtual void onKeyUp(int);//yes
virtual int getCursorId();//yes
protected:
virtual void setCursor(std::string);
private:
std::string cursorString;
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include "buttonlistener.h"
#pragma once
#include <G3DAll.h>
class ToolbarListener : public ButtonListener
{
public:
void onButton1MouseClick(BaseButtonInstance* button);
void addButtonRef(BaseButtonInstance* button);
private:
std::vector<BaseButtonInstance*> btns;
};

View File

@@ -0,0 +1,4 @@
#pragma once
#include <windows.h>
bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance);

View File

@@ -0,0 +1,12 @@
#pragma once
#include "GroupInstance.h"
#include "PartInstance.h"
class WorkspaceInstance :
public GroupInstance
{
public:
WorkspaceInstance(void);
~WorkspaceInstance(void);
std::vector<PartInstance *> partObjects;
};

198
src/include/ax.h Normal file
View File

@@ -0,0 +1,198 @@
// AX.H
#pragma once
#include "Globals.h"
#include <mshtmhst.h>
#include <string>
#pragma once
#include "IEBrowser.h"
// messages
#define AX_QUERYINTERFACE (WM_USER + 1)
#define AX_INPLACE (WM_USER + 2)
#define AX_GETAXINTERFACE (WM_USER + 3)
#define AX_CONNECTOBJECT (WM_USER + 4)
#define AX_DISCONNECTOBJECT (WM_USER + 5)
#define AX_SETDATAADVISE (WM_USER + 6)
#define AX_DOVERB (WM_USER + 7)
// Registration function
ATOM AXRegister();
// Class AXClientSide
class AXClientSite :
public IOleClientSite,
public IDispatch,
public IAdviseSink,
public IOleInPlaceSite,
public IOleInPlaceFrame,
public IDocHostUIHandler
{
protected:
int refNum;
public:
HWND Window;
HWND Parent;
HMENU Menu;
bool InPlace;
bool ExternalPlace;
bool CalledCanInPlace;
class AX* ax;
// MyClientSite Methods
AXClientSite();
virtual ~AXClientSite();
STDMETHODIMP_(void) OnDataChange2(FORMATETC*);
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID iid,void**ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IOleClientSite methods
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(DWORD dwA,DWORD dwW,IMoniker**pm);
STDMETHODIMP GetContainer(IOleContainer**pc);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL f);
STDMETHODIMP RequestNewObjectLayout();
// IDDocHandler methods
STDMETHODIMP ShowContextMenu(
/* [in] */ DWORD dwID,
/* [in] */ POINT *ppt,
/* [in] */ IUnknown *pcmdtReserved,
/* [in] */ IDispatch *pdispReserved);
STDMETHODIMP GetHostInfo(
/* [out][in] */ DOCHOSTUIINFO *pInfo);
STDMETHODIMP ShowUI(
/* [in] */ DWORD dwID,
/* [in] */ IOleInPlaceActiveObject *pActiveObject,
/* [in] */ IOleCommandTarget *pCommandTarget,
/* [in] */ IOleInPlaceFrame *pFrame,
/* [in] */ IOleInPlaceUIWindow *pDoc);
STDMETHODIMP HideUI( void);
STDMETHODIMP UpdateUI( void);
STDMETHODIMP OnDocWindowActivate(
/* [in] */ BOOL fActivate);
STDMETHODIMP OnFrameWindowActivate(
/* [in] */ BOOL fActivate);
STDMETHODIMP ResizeBorder(
/* [in] */ LPCRECT prcBorder,
/* [in] */ IOleInPlaceUIWindow *pUIWindow,
/* [in] */ BOOL fRameWindow);
STDMETHODIMP TranslateAccelerator(
/* [in] */ LPMSG lpMsg,
/* [in] */ const GUID *pguidCmdGroup,
/* [in] */ DWORD nCmdID);
STDMETHODIMP GetOptionKeyPath(
/* [out] */ LPOLESTR *pchKey,
/* [in] */ DWORD dw);
STDMETHODIMP GetDropTarget(
/* [in] */ IDropTarget *pDropTarget,
/* [out] */ IDropTarget **ppDropTarget);
STDMETHODIMP GetExternal(
/* [out] */ IDispatch **ppDispatch);
STDMETHODIMP TranslateUrl(
/* [in] */ DWORD dwTranslate,
/* [in] */ OLECHAR *pchURLIn,
/* [out] */ OLECHAR **ppchURLOut);
STDMETHODIMP FilterDataObject(
/* [in] */ IDataObject *pDO,
/* [out] */ IDataObject **ppDORet);
// IAdviseSink methods
STDMETHODIMP_(void) OnDataChange(FORMATETC *pFormatEtc,STGMEDIUM *pStgmed);
STDMETHODIMP_(void) OnViewChange(DWORD dwAspect,LONG lIndex);
STDMETHODIMP_(void) OnRename(IMoniker * pmk);
STDMETHODIMP_(void) OnSave();
STDMETHODIMP_(void) OnClose();
// IOleInPlaceSite methods
STDMETHODIMP GetWindow(HWND *p);
STDMETHODIMP ContextSensitiveHelp(BOOL);
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(IOleInPlaceFrame** ppFrame,IOleInPlaceUIWindow **ppDoc,LPRECT r1,LPRECT r2,LPOLEINPLACEFRAMEINFO o);
STDMETHODIMP Scroll(SIZE s);
STDMETHODIMP OnUIDeactivate(int);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT);
// IOleInPlaceFrame methods
STDMETHODIMP GetBorder(LPRECT l);
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS);
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS w);
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*pV,LPCOLESTR s);
STDMETHODIMP InsertMenus(HMENU h,LPOLEMENUGROUPWIDTHS x);
STDMETHODIMP SetMenu(HMENU h,HOLEMENU hO,HWND hw);
STDMETHODIMP RemoveMenus(HMENU h);
STDMETHODIMP SetStatusText(LPCOLESTR t);
STDMETHODIMP EnableModeless(BOOL f);
STDMETHODIMP TranslateAccelerator(LPMSG,WORD);
std::wstring m_lastExternalName;
// IDispatch Methods
HRESULT _stdcall GetTypeInfoCount(unsigned int * pctinfo);
HRESULT _stdcall GetTypeInfo(unsigned int iTInfo,LCID lcid,ITypeInfo FAR* FAR* ppTInfo);
HRESULT _stdcall GetIDsOfNames(REFIID riid,OLECHAR FAR* FAR*,unsigned int cNames,LCID lcid,DISPID FAR* );
HRESULT _stdcall Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS FAR* pDispParams,VARIANT FAR* pVarResult,EXCEPINFO FAR* pExcepInfo,unsigned int FAR* puArgErr);
};
// Class AX
class AX
{
public:
AX(char* clsid);
CLSID GetCLSID();
~AX();
void Init(char* clsid);
void Clean();
AXClientSite Site;
IID* iid;
IOleObject* OleObject;
IStorage* Storage;
IViewObject* View;
IDataObject* Data;
IUnknown* Unk;
IOleInPlaceActiveObject* Pao;
//AX_CONNECTSTRUCT* tcs;
bool AddMenu;
DWORD AdviseToken;
DWORD DAdviseToken[100];
private:
CLSID clsid;
};

392
src/include/propertyGrid.h Normal file
View File

@@ -0,0 +1,392 @@
//////////////////////////////////////////////////////////////////////////////
///
/// @file propertyGrid.h
///
/// @brief A property grid control in Win32 SDK C.
///
/// @author David MacDermot
///
/// @par Comments:
/// This source is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
///
/// @date 2-27-16
///
/// @todo
///
/// @bug
///
//////////////////////////////////////////////////////////////////////////////
//DWM 1.8: Added Message PG_FLATCHECKS and associated macroes
#ifndef PROPERTYGRID_H
#define PROPERTYGRID_H
/****************************************************************************/
// Public Messages
// List box message subset handled by the property grid.
// LB_ADDSTRING - PropGrid_AddItem()
// LB_DELETESTRING - PropGrid_DeleteItem()
// LB_GETCOUNT - PropGrid_GetCount()
// LB_GETCURSEL - PropGrid_GetCurSel()
// LB_GETHORIZONTALEXTENT - PropGrid_GetHorizontalExtent()
// LB_GETITEMDATA - PropGrid_GetItemData()
// LB_GETITEMHEIGHT - PropGrid_GetItemHeight()
// LB_GETITEMRECT - PropGrid_GetItemRect()
// LB_GETSEL - PropGrid_GetSel()
// LB_RESETCONTENT - PropGrid_ResetContent()
// LB_SETCURSEL - PropGrid_SetCurSel()
// LB_SETHORIZONTALEXTENT - PropGrid_SetHorizontalExtent()
// LB_SETITEMDATA - PropGrid_SetItemData()
// LB_SETITEMHEIGHT - PropGrid_SetItemHeight()
/// @name Property grid specific messages.
/// @{
#define PG_EXPANDCATALOGS WM_USER + 0x01 ///<PropGrid_ExpandCatalogs()
#define PG_COLLAPSECATALOGS WM_USER + 0x02 ///<PropGrid_CollapseCatalogs()
#define PG_SHOWTOOLTIPS WM_USER + 0x03 ///<PropGrid_ShowToolTips()
#define PG_SHOWPROPERTYDESC WM_USER + 0x04 ///<PropGrid_ShowPropertyDescriptions()
#define PG_FLATCHECKS WM_USER + 0x05 ///<PropGrid_SetFlatStyleChecks()
/// @}
/****************************************************************************/
// Property item types
#define PIT_EDIT 0 ///< Property item type: Edit
#define PIT_COMBO 1 ///< Property item type: Dropdownlist
#define PIT_EDITCOMBO 2 ///< Property item type: Dropdown(editable)
#define PIT_STATIC 3 ///< Property item type: Not editable text
#define PIT_COLOR 4 ///< Property item type: Color
#define PIT_FONT 5 ///< Property item type: Font
#define PIT_FILE 6 ///< Property item type: File select dialog
#define PIT_FOLDER 7 ///< Property item type: Folder select dialog
#define PIT_CHECK 8 ///< Property item type: BOOL
#define PIT_IP 9 ///< Property item type: IP Address
#define PIT_DATE 10 ///< Property item type: Date
#define PIT_TIME 11 ///< Property item type: Time
#define PIT_DATETIME 12 ///< Property item type: Date & Time
#define PIT_CATALOG 99 ///< Property item type: Catalog
/****************************************************************************/
// Public structures and notifications
/// @var PROPGRIDFDITEM
/// @brief A property grid file dialog item object
/// @var LPPROPGRIDFDITEM
/// @brief Pointer to a property grid file dialog item
/// @struct tagPROPGRIDFDITEM
/// @brief This is additional data associated with a property grid file dialog item
typedef struct tagPROPGRIDFDITEM {
LPTSTR lpszDlgTitle; ///< Dialog title
LPTSTR lpszFilePath; ///< Initial path
LPTSTR lpszFilter; ///< Double null terminated filter string
LPTSTR lpszDefExt; ///< Default extension
} PROPGRIDFDITEM, *LPPROPGRIDFDITEM;
/// @var PROPGRIDFONTITEM
/// @brief A property grid font item object
/// @var LPPROPGRIDFONTITEM
/// @brief Pointer to a property grid font item
/// @struct tagPROPGRIDFONTITEM
/// @brief This is additional data associated with a property grid font item
typedef struct tagPROPGRIDFONTITEM {
LOGFONT logFont; ///< Logical font struct
COLORREF crFont; ///< Text color
} PROPGRIDFONTITEM, *LPPROPGRIDFONTITEM;
/// @var PROPGRIDITEM
/// @brief A property grid item object
/// @var LPPROPGRIDITEM
/// @brief Pointer to a property grid item
/// @struct tagPROPGRIDITEM
/// @brief This is the data associated with a property grid item
typedef struct tagPROPGRIDITEM {
LPTSTR lpszCatalog; ///< Catalog (group) name
LPTSTR lpszPropName; ///< Property (item) name
LPTSTR lpszzCmbItems; ///< Double null terminated list of strings
LPTSTR lpszPropDesc; ///< Property (item) description
LPARAM lpCurValue; ///< Property (item) value
INT iItemType; ///< Property (item) type identifier
} PROPGRIDITEM, *LPPROPGRIDITEM;
/// @var NMPROPGRID
/// @brief A property grid notification message data object
/// @var LPNMPROPGRID
/// @brief Pointer to property grid notification message data
/// @struct tagNMPROPGRID
/// @brief This is the data associated with a property grid notification
typedef struct tagNMPROPGRID {
NMHDR hdr; ///< Notification message header
INT iIndex; ///< Index of a property grid item
} NMPROPGRID, *LPNMPROPGRID;
#define PGN_PROPERTYCHANGE WM_USER + 0x2A ///<property grid Property changed notification message
/****************************************************************************/
/// @name Macroes
/// @{
/// @def PropGrid_AddItem(hwndCtl,lpItem)
///
/// @brief Add an item to a property grid. Items are appended to their respective
/// catalogs.
///
/// @param hwndCtl The handle of a property grid.
/// @param lpItem Pointer to a property grid item.
///
/// @returns The zero-based index of the item in the list box. If an error occurs,
/// the return value is LB_ERR. If there is insufficient space to store
/// the new string, the return value is LB_ERRSPACE.
#define PropGrid_AddItem(hwndCtl,lpItem) ((int)(DWORD)SendMessage((hwndCtl),LB_ADDSTRING,0,(LPARAM)(lpItem)))
/// @def PropGrid_DeleteItem(hwndCtl,index)
///
/// @brief Deletes the item at the specified location in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item to delete.
///
/// @returns A count of the items remaining in the grid. The return value is
/// LB_ERR if the index parameter specifies an index greater than the
/// number of items in the list.
#define PropGrid_DeleteItem(hwndCtl,index) ((int)(DWORD)SendMessage((hwndCtl),LB_DELETESTRING,(WPARAM)(int)(index),0))
/// @def PropGrid_Enable(hwndCtl,fEnable)
///
/// @brief Enables or disables a property grid control.
///
/// @param hwndCtl The handle of a property grid.
/// @param fEnable TRUE to enable the control, or FALSE to disable it.
///
/// @returns No return value.
#define PropGrid_Enable(hwndCtl,fEnable) EnableWindow((hwndCtl),(fEnable))
/// @def PropGrid_GetCount(hwndCtl)
///
/// @brief Gets the number of items in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The number of items.
#define PropGrid_GetCount(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETCOUNT,0,0))
/// @def PropGrid_GetCurSel(hwndCtl)
///
/// @brief Gets the index of the currently selected item in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The zero-based index of the selected item. If there is no selection,
/// the return value is LB_ERR.
#define PropGrid_GetCurSel(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETCURSEL,0,0))
/// @def PropGrid_GetHorizontalExtent(hwndCtl)
///
/// @brief Gets the width that a property grid can be scrolled horizontally
/// (the scrollable width).
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The scrollable width, in pixels, of the property grid.
#define PropGrid_GetHorizontalExtent(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETHORIZONTALEXTENT,0,0))
/// @def PropGrid_GetItemData(hwndCtl,index)
///
/// @brief Gets the PROPGRIDITEM associated with the specified property grid item.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item.
///
/// @returns A pointer to a PROPGRIDITEM object.
#define PropGrid_GetItemData(hwndCtl,index) ((LPPROPGRIDITEM)(DWORD_PTR)SendMessage((hwndCtl),LB_GETITEMDATA,(WPARAM)(int)(index),0))
/// @def PropGrid_GetItemHeight(hwndCtl)
///
/// @brief Retrieves the height of all items in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The height, in pixels, of the items, or LB_ERR if an error occurs.
#define PropGrid_GetItemHeight(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETITEMHEIGHT,(WPARAM)0,0))
/// @def PropGrid_GetItemRect(hwndCtl,index,lprc)
///
/// @brief Gets the dimensions of the rectangle that bounds a property grid item
/// as it is currently displayed in the property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item in the property grid.
/// @param lprc A pointer to a RECT structure that receives the client
/// coordinates for the item in the property grid.
///
/// @returns If an error occurs, the return value is LB_ERR.
#define PropGrid_GetItemRect(hwndCtl,index,lprc) ((int)(DWORD)SendMessage((hwndCtl),LB_GETITEMRECT,(WPARAM)(int)(index),(LPARAM)(RECT*)(lprc)))
/// @def PropGrid_GetSel(hwndCtl,index)
///
/// @brief Gets the selection state of an item.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item.
///
/// @returns If the item is selected, the return value is greater than zero;
/// otherwise, it is zero. If an error occurs, the return value is LB_ERR.
#define PropGrid_GetSel(hwndCtl,index) ((int)(DWORD)SendMessage((hwndCtl),LB_GETSEL,(WPARAM)(int)(index),0))
/// @def PropGrid_ResetContent(hwndCtl)
///
/// @brief Removes all items from a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The return value is not meaningful.
#define PropGrid_ResetContent(hwndCtl) ((BOOL)(DWORD)SendMessage((hwndCtl),LB_RESETCONTENT,0,0))
/// @def PropGrid_SetCurSel(hwndCtl,index)
///
/// @brief Sets the currently selected item in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item to select, or <20>1 to clear the selection.
///
/// @returns If an error occurs, the return value is LB_ERR. If the index
/// parameter is <20>1, the return value is LB_ERR even though no error occurred.
#define PropGrid_SetCurSel(hwndCtl,index) ((int)(DWORD)SendMessage((hwndCtl),LB_SETCURSEL,(WPARAM)(int)(index),0))
/// @def PropGrid_SetHorizontalExtent(hwndCtl,cxExtent)
///
/// @brief Set the width by which a property grid can be scrolled horizontally
/// (the scrollable width). If the width of the property grid is smaller
/// than this value, the horizontal scroll bar horizontally scrolls items
/// in the property grid. If the width of the property grid is equal to or
/// greater than this value, the horizontal scroll bar is hidden.
///
/// @param hwndCtl The handle of a property grid.
/// @param cxExtent The number of pixels by which the list box can be scrolled.
///
/// @returns No return value.
#define PropGrid_SetHorizontalExtent(hwndCtl,cxExtent) ((void)SendMessage((hwndCtl),LB_SETHORIZONTALEXTENT,(WPARAM)(int)(cxExtent),0))
/// @def PropGrid_SetItemData(hwndCtl,index,data)
///
/// @brief Sets the PROPGRIDITEM associated with the specified property grid item.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item.
/// @param data The item data to set.
///
/// @returns If an error occurs, the return value is LB_ERR.
#define PropGrid_SetItemData(hwndCtl,index,data) ((int)(DWORD)SendMessage((hwndCtl),LB_SETITEMDATA,(WPARAM)(int)(index),(LPARAM)(data)))
/// @def PropGrid_SetItemHeight(hwndCtl,cy)
///
/// @brief Sets the height of all items in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param cy The height of the items, in pixels.
///
/// @returns If the height is invalid, the return value is LB_ERR.
#define PropGrid_SetItemHeight(hwndCtl,cy) ((int)(DWORD)SendMessage((hwndCtl),LB_SETITEMHEIGHT,(WPARAM)0,MAKELPARAM((cy),0)))
/// @def PropGrid_ExpandCatalogs(hwndCtl, lpszzCatalogs)
///
/// @brief Expand certain specified catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param lpszzCatalogs The list of catalog names each terminated by a null (\\0).
///
/// @returns No return value.
#define PropGrid_ExpandCatalogs(hwndCtl, lpszzCatalogs) ((void)SendMessage((hwndCtl),PG_EXPANDCATALOGS,(WPARAM)0,(LPARAM)(lpszzCatalogs)))
/// @def PropGrid_ExpandAllCatalogs(hwndCtl)
///
/// @brief Expand all catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns No return value.
#define PropGrid_ExpandAllCatalogs(hwndCtl) ((void)SendMessage((hwndCtl),PG_EXPANDCATALOGS,(WPARAM)0,(LPARAM)NULL))
/// @def PropGrid_CollapseCatalogs(hwndCtl, lpszzCatalogs)
///
/// @brief Collapse certain specified catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param lpszzCatalogs The catalog names each terminated by a null (\\0).
///
/// @returns No return value.
#define PropGrid_CollapseCatalogs(hwndCtl, lpszzCatalogs) ((void)SendMessage((hwndCtl),PG_COLLAPSECATALOGS,(WPARAM)0,(LPARAM)(lpszzCatalogs)))
/// @def PropGrid_CollapseAllCatalogs(hwndCtl)
///
/// @brief Collapse all catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns No return value.
#define PropGrid_CollapseAllCatalogs(hwndCtl) ((void)SendMessage((hwndCtl),PG_COLLAPSECATALOGS,(WPARAM)0,(LPARAM)NULL))
/// @def PropGrid_ShowToolTips(hwndCtl,fShow)
///
/// @brief Show or hide tooltips in the property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param fShow TRUE for tooltips; FALSE do not show tooltips.
///
/// @returns No return value.
#define PropGrid_ShowToolTips(hwndCtl,fShow) ((void)SendMessage((hwndCtl),PG_SHOWTOOLTIPS,(WPARAM)(fShow),(LPARAM)0L))
/// @def PropGrid_ShowPropertyDescriptions(hwndCtl,fShow)
///
/// @brief Show or hide the property discription pane in the property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param fShow TRUE for descriptions; FALSE do not show discription pane.
///
/// @returns No return value.
#define PropGrid_ShowPropertyDescriptions(hwndCtl,fShow) ((void)SendMessage((hwndCtl),PG_SHOWPROPERTYDESC,(WPARAM)(fShow),(LPARAM)0L))
/// @def PropGrid_SetFlatStyleChecks(hwndCtl, fFlat)
///
/// @brief Sets the appearance of the checkboxes.
///
/// @param hwndCtl The handle of a property grid.
/// @param fFlat TRUE for flat checkboxes, or FALSE for standard checkboxes.
///
/// @returns No return value.
#define PropGrid_SetFlatStyleChecks(hwndCtl, fFlat) \
((void)SendMessage((hwndCtl),PG_FLATCHECKS,(WPARAM)(BOOL) (fFlat),(LPARAM)0L))
/// @def PropGrid_ItemInit(pgi)
///
/// @brief Initialize an item struct.
///
/// @param pgi The PROPGRIDITEM struct.
///
/// @returns No return value.
#define PropGrid_ItemInit(pgi) \
(pgi.lpszCatalog = NULL, pgi.lpszPropName = NULL, \
pgi.lpszzCmbItems = NULL, pgi.lpszPropDesc = NULL, \
pgi.lpCurValue = 0, pgi.iItemType = 0)
/// @}
/****************************************************************************/
// Exported function prototypes
ATOM InitPropertyGrid(HINSTANCE hInstance);
HWND New_PropertyGrid(HWND hParent, DWORD dwID);
#endif //PROPERTYGRID_H

View File

@@ -0,0 +1,52 @@
Use of this software is granted under one of the following two licenses,
to be chosen freely by the user.
1. Boost Software License - Version 1.0 - August 17th, 2003
===============================================================================
Copyright (c) 2006, 2007 Marcin Kalicinski
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
2. The MIT License
===============================================================================
Copyright (c) 2006, 2007 Marcin Kalicinski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED
#define RAPIDXML_ITERATORS_HPP_INCLUDED
// Copyright (C) 2006, 2009 Marcin Kalicinski
// Version 1.13
// Revision $DateTime: 2009/05/13 01:46:17 $
//! \file rapidxml_iterators.hpp This file contains rapidxml iterators
#include "rapidxml.hpp"
namespace rapidxml
{
//! Iterator of child nodes of xml_node
template<class Ch>
class node_iterator
{
public:
typedef typename xml_node<Ch> value_type;
typedef typename xml_node<Ch> &reference;
typedef typename xml_node<Ch> *pointer;
typedef std::ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
node_iterator()
: m_node(0)
{
}
node_iterator(xml_node<Ch> *node)
: m_node(node->first_node())
{
}
reference operator *() const
{
assert(m_node);
return *m_node;
}
pointer operator->() const
{
assert(m_node);
return m_node;
}
node_iterator& operator++()
{
assert(m_node);
m_node = m_node->next_sibling();
return *this;
}
node_iterator operator++(int)
{
node_iterator tmp = *this;
++this;
return tmp;
}
node_iterator& operator--()
{
assert(m_node && m_node->previous_sibling());
m_node = m_node->previous_sibling();
return *this;
}
node_iterator operator--(int)
{
node_iterator tmp = *this;
++this;
return tmp;
}
bool operator ==(const node_iterator<Ch> &rhs)
{
return m_node == rhs.m_node;
}
bool operator !=(const node_iterator<Ch> &rhs)
{
return m_node != rhs.m_node;
}
private:
xml_node<Ch> *m_node;
};
//! Iterator of child attributes of xml_node
template<class Ch>
class attribute_iterator
{
public:
typedef typename xml_attribute<Ch> value_type;
typedef typename xml_attribute<Ch> &reference;
typedef typename xml_attribute<Ch> *pointer;
typedef std::ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
attribute_iterator()
: m_attribute(0)
{
}
attribute_iterator(xml_node<Ch> *node)
: m_attribute(node->first_attribute())
{
}
reference operator *() const
{
assert(m_attribute);
return *m_attribute;
}
pointer operator->() const
{
assert(m_attribute);
return m_attribute;
}
attribute_iterator& operator++()
{
assert(m_attribute);
m_attribute = m_attribute->next_attribute();
return *this;
}
attribute_iterator operator++(int)
{
attribute_iterator tmp = *this;
++this;
return tmp;
}
attribute_iterator& operator--()
{
assert(m_attribute && m_attribute->previous_attribute());
m_attribute = m_attribute->previous_attribute();
return *this;
}
attribute_iterator operator--(int)
{
attribute_iterator tmp = *this;
++this;
return tmp;
}
bool operator ==(const attribute_iterator<Ch> &rhs)
{
return m_attribute == rhs.m_attribute;
}
bool operator !=(const attribute_iterator<Ch> &rhs)
{
return m_attribute != rhs.m_attribute;
}
private:
xml_attribute<Ch> *m_attribute;
};
}
#endif

View File

@@ -0,0 +1,421 @@
#ifndef RAPIDXML_PRINT_HPP_INCLUDED
#define RAPIDXML_PRINT_HPP_INCLUDED
// Copyright (C) 2006, 2009 Marcin Kalicinski
// Version 1.13
// Revision $DateTime: 2009/05/13 01:46:17 $
//! \file rapidxml_print.hpp This file contains rapidxml printer implementation
#include "rapidxml.hpp"
// Only include streams if not disabled
#ifndef RAPIDXML_NO_STREAMS
#include <ostream>
#include <iterator>
#endif
namespace rapidxml
{
///////////////////////////////////////////////////////////////////////
// Printing flags
const int print_no_indenting = 0x1; //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.
///////////////////////////////////////////////////////////////////////
// Internal
//! \cond internal
namespace internal
{
///////////////////////////////////////////////////////////////////////////
// Internal character operations
// Copy characters from given range to given output iterator
template<class OutIt, class Ch>
inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)
{
while (begin != end)
*out++ = *begin++;
return out;
}
// Copy characters from given range to given output iterator and expand
// characters into references (&lt; &gt; &apos; &quot; &amp;)
template<class OutIt, class Ch>
inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)
{
while (begin != end)
{
if (*begin == noexpand)
{
*out++ = *begin; // No expansion, copy character
}
else
{
switch (*begin)
{
case Ch('<'):
*out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('>'):
*out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('\''):
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');
break;
case Ch('"'):
*out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('&'):
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';');
break;
default:
*out++ = *begin; // No expansion, copy character
}
}
++begin; // Step to next character
}
return out;
}
// Fill given output iterator with repetitions of the same character
template<class OutIt, class Ch>
inline OutIt fill_chars(OutIt out, int n, Ch ch)
{
for (int i = 0; i < n; ++i)
*out++ = ch;
return out;
}
// Find character
template<class Ch, Ch ch>
inline bool find_char(const Ch *begin, const Ch *end)
{
while (begin != end)
if (*begin++ == ch)
return true;
return false;
}
///////////////////////////////////////////////////////////////////////////
// Internal printing operations
// Print node
template<class OutIt, class Ch>
inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
// Print proper node type
switch (node->type())
{
// Document
case node_document:
out = print_children(out, node, flags, indent);
break;
// Element
case node_element:
out = print_element_node(out, node, flags, indent);
break;
// Data
case node_data:
out = print_data_node(out, node, flags, indent);
break;
// CDATA
case node_cdata:
out = print_cdata_node(out, node, flags, indent);
break;
// Declaration
case node_declaration:
out = print_declaration_node(out, node, flags, indent);
break;
// Comment
case node_comment:
out = print_comment_node(out, node, flags, indent);
break;
// Doctype
case node_doctype:
out = print_doctype_node(out, node, flags, indent);
break;
// Pi
case node_pi:
out = print_pi_node(out, node, flags, indent);
break;
// Unknown
default:
assert(0);
break;
}
// If indenting not disabled, add line break after node
if (!(flags & print_no_indenting))
*out = Ch('\n'), ++out;
// Return modified iterator
return out;
}
// Print children of the node
template<class OutIt, class Ch>
inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())
out = print_node(out, child, flags, indent);
return out;
}
// Print attributes of the node
template<class OutIt, class Ch>
inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)
{
for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())
{
if (attribute->name() && attribute->value())
{
// Print attribute name
*out = Ch(' '), ++out;
out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);
*out = Ch('='), ++out;
// Print attribute value using appropriate quote type
if (find_char<Ch, Ch('"')>(attribute->value(), attribute->value() + attribute->value_size()))
{
*out = Ch('\''), ++out;
out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('"'), out);
*out = Ch('\''), ++out;
}
else
{
*out = Ch('"'), ++out;
out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\''), out);
*out = Ch('"'), ++out;
}
}
}
return out;
}
// Print data node
template<class OutIt, class Ch>
inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_data);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
return out;
}
// Print data node
template<class OutIt, class Ch>
inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_cdata);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'); ++out;
*out = Ch('!'); ++out;
*out = Ch('['); ++out;
*out = Ch('C'); ++out;
*out = Ch('D'); ++out;
*out = Ch('A'); ++out;
*out = Ch('T'); ++out;
*out = Ch('A'); ++out;
*out = Ch('['); ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch(']'); ++out;
*out = Ch(']'); ++out;
*out = Ch('>'); ++out;
return out;
}
// Print element node
template<class OutIt, class Ch>
inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_element);
// Print element name and attributes, if any
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
out = copy_chars(node->name(), node->name() + node->name_size(), out);
out = print_attributes(out, node, flags);
// If node is childless
if (node->value_size() == 0 && !node->first_node())
{
// Print childless node tag ending
*out = Ch('/'), ++out;
*out = Ch('>'), ++out;
}
else
{
// Print normal node tag ending
*out = Ch('>'), ++out;
// Test if node contains a single data node only (and no other nodes)
xml_node<Ch> *child = node->first_node();
if (!child)
{
// If node has no children, only print its value without indenting
out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
}
else if (child->next_sibling() == 0 && child->type() == node_data)
{
// If node has a sole data child, only print its value without indenting
out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);
}
else
{
// Print all children with full indenting
if (!(flags & print_no_indenting))
*out = Ch('\n'), ++out;
out = print_children(out, node, flags, indent + 1);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
}
// Print node end
*out = Ch('<'), ++out;
*out = Ch('/'), ++out;
out = copy_chars(node->name(), node->name() + node->name_size(), out);
*out = Ch('>'), ++out;
}
return out;
}
// Print declaration node
template<class OutIt, class Ch>
inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
// Print declaration start
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('?'), ++out;
*out = Ch('x'), ++out;
*out = Ch('m'), ++out;
*out = Ch('l'), ++out;
// Print attributes
out = print_attributes(out, node, flags);
// Print declaration end
*out = Ch('?'), ++out;
*out = Ch('>'), ++out;
return out;
}
// Print comment node
template<class OutIt, class Ch>
inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_comment);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('!'), ++out;
*out = Ch('-'), ++out;
*out = Ch('-'), ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch('-'), ++out;
*out = Ch('-'), ++out;
*out = Ch('>'), ++out;
return out;
}
// Print doctype node
template<class OutIt, class Ch>
inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_doctype);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('!'), ++out;
*out = Ch('D'), ++out;
*out = Ch('O'), ++out;
*out = Ch('C'), ++out;
*out = Ch('T'), ++out;
*out = Ch('Y'), ++out;
*out = Ch('P'), ++out;
*out = Ch('E'), ++out;
*out = Ch(' '), ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch('>'), ++out;
return out;
}
// Print pi node
template<class OutIt, class Ch>
inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_pi);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('?'), ++out;
out = copy_chars(node->name(), node->name() + node->name_size(), out);
*out = Ch(' '), ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch('?'), ++out;
*out = Ch('>'), ++out;
return out;
}
}
//! \endcond
///////////////////////////////////////////////////////////////////////////
// Printing
//! Prints XML to given output iterator.
//! \param out Output iterator to print to.
//! \param node Node to be printed. Pass xml_document to print entire document.
//! \param flags Flags controlling how XML is printed.
//! \return Output iterator pointing to position immediately after last character of printed text.
template<class OutIt, class Ch>
inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)
{
return internal::print_node(out, &node, flags, 0);
}
#ifndef RAPIDXML_NO_STREAMS
//! Prints XML to given output stream.
//! \param out Output stream to print to.
//! \param node Node to be printed. Pass xml_document to print entire document.
//! \param flags Flags controlling how XML is printed.
//! \return Output stream.
template<class Ch>
inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)
{
print(std::ostream_iterator<Ch>(out), node, flags);
return out;
}
//! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.
//! \param out Output stream to print to.
//! \param node Node to be printed.
//! \return Output stream.
template<class Ch>
inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)
{
return print(out, node);
}
#endif
}
#endif

View File

@@ -0,0 +1,122 @@
#ifndef RAPIDXML_UTILS_HPP_INCLUDED
#define RAPIDXML_UTILS_HPP_INCLUDED
// Copyright (C) 2006, 2009 Marcin Kalicinski
// Version 1.13
// Revision $DateTime: 2009/05/13 01:46:17 $
//! \file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful
//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.
#include "rapidxml.hpp"
#include <vector>
#include <string>
#include <fstream>
#include <stdexcept>
namespace rapidxml
{
//! Represents data loaded from a file
template<class Ch = char>
class file
{
public:
//! Loads file into the memory. Data will be automatically destroyed by the destructor.
//! \param filename Filename to load.
file(const char *filename)
{
using namespace std;
// Open stream
basic_ifstream<Ch> stream(filename, ios::binary);
if (!stream)
throw runtime_error(string("cannot open file ") + filename);
stream.unsetf(ios::skipws);
// Determine stream size
stream.seekg(0, ios::end);
size_t size = stream.tellg();
stream.seekg(0);
// Load data and add terminating 0
m_data.resize(size + 1);
stream.read(&m_data.front(), static_cast<streamsize>(size));
m_data[size] = 0;
}
//! Loads file into the memory. Data will be automatically destroyed by the destructor
//! \param stream Stream to load from
file(std::basic_istream<Ch> &stream)
{
using namespace std;
// Load data and add terminating 0
stream.unsetf(ios::skipws);
m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());
if (stream.fail() || stream.bad())
throw runtime_error("error reading stream");
m_data.push_back(0);
}
//! Gets file data.
//! \return Pointer to data of file.
Ch *data()
{
return &m_data.front();
}
//! Gets file data.
//! \return Pointer to data of file.
const Ch *data() const
{
return &m_data.front();
}
//! Gets file data size.
//! \return Size of file data, in characters.
std::size_t size() const
{
return m_data.size();
}
private:
std::vector<Ch> m_data; // File data
};
//! Counts children of node. Time complexity is O(n).
//! \return Number of children of node
template<class Ch>
inline std::size_t count_children(xml_node<Ch> *node)
{
xml_node<Ch> *child = node->first_node();
std::size_t count = 0;
while (child)
{
++count;
child = child->next_sibling();
}
return count;
}
//! Counts attributes of node. Time complexity is O(n).
//! \return Number of attributes of node
template<class Ch>
inline std::size_t count_attributes(xml_node<Ch> *node)
{
xml_attribute<Ch> *attr = node->first_attribute();
std::size_t count = 0;
while (attr)
{
++count;
attr = attr->next_attribute();
}
return count;
}
}
#endif

7
src/include/resource.h Normal file
View File

@@ -0,0 +1,7 @@
#define IDC_PROPERTYGRID 2000
#define IDC_STATIC 2
#define IDE_EDIT 105
#define IDI_ICON1 102
#define IDB_BITMAP1 103
#define IDD_DIALOG1 104

View File

@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
#define GetHoldKeyState(nVirtKey) (GetKeyState(nVirtKey)>>1)
#define GetKPBool(nVirtKey) (GetKeyState(nVirtKey) & 0x8000)