Windows refactors

This commit is contained in:
Jack Andersen
2015-08-30 17:40:58 -10:00
parent f9c4ed0761
commit 49771b0e15
13 changed files with 261 additions and 194 deletions

View File

@@ -1,5 +1,5 @@
#ifndef IRUNLOOP_HPP
#define IRUNLOOP_HPP
#ifndef IAPPLICATION_HPP
#define IAPPLICATION_HPP
#include <memory>
#include <string>
@@ -15,7 +15,7 @@ class IApplication;
struct IApplicationCallback
{
virtual void appQuitting(IApplication*) {}
virtual void appFilesOpen(IApplication*, const std::vector<std::string>&) {}
virtual void appFilesOpen(IApplication*, const std::vector<SystemString>&) {}
};
class IApplication
@@ -44,37 +44,37 @@ public:
virtual EPlatformType getPlatformType() const=0;
virtual void pump()=0;
virtual const std::string& getUniqueName() const=0;
virtual const std::string& getFriendlyName() const=0;
virtual const std::string& getProcessName() const=0;
virtual const std::vector<std::string>& getArgs() const=0;
virtual const SystemString& getUniqueName() const=0;
virtual const SystemString& getFriendlyName() const=0;
virtual const SystemString& getProcessName() const=0;
virtual const std::vector<SystemString>& getArgs() const=0;
/* Constructors/initializers for sub-objects */
virtual IWindow* newWindow(const std::string& title)=0;
virtual IWindow* newWindow(const SystemString& title)=0;
};
std::unique_ptr<IApplication>
ApplicationBootstrap(IApplication::EPlatformType platform,
IApplicationCallback& cb,
const std::string& uniqueName,
const std::string& friendlyName,
const std::string& pname,
const std::vector<std::string>& args,
const SystemString& uniqueName,
const SystemString& friendlyName,
const SystemString& pname,
const std::vector<SystemString>& args,
bool singleInstance=true);
extern IApplication* APP;
static inline std::unique_ptr<IApplication>
ApplicationBootstrap(IApplication::EPlatformType platform,
IApplicationCallback& cb,
const std::string& uniqueName,
const std::string& friendlyName,
int argc, const char** argv,
const SystemString& uniqueName,
const SystemString& friendlyName,
int argc, const SystemChar** argv,
bool singleInstance=true)
{
if (APP)
return std::unique_ptr<IApplication>();
std::vector<std::string> args;
std::vector<SystemString> args;
for (int i=1 ; i<argc ; ++i)
args.push_back(argv[i]);
return ApplicationBootstrap(platform, cb, uniqueName, friendlyName, argv[0], args, singleInstance);
@@ -82,4 +82,4 @@ ApplicationBootstrap(IApplication::EPlatformType platform,
}
#endif // IRUNLOOP_HPP
#endif // IAPPLICATION_HPP

View File

@@ -1,7 +1,7 @@
#ifndef IWINDOW_HPP
#define IWINDOW_HPP
#include <string>
#include "System.hpp"
namespace boo
{
@@ -123,8 +123,8 @@ public:
virtual void showWindow()=0;
virtual void hideWindow()=0;
virtual std::string getTitle()=0;
virtual void setTitle(const std::string& title)=0;
virtual SystemString getTitle()=0;
virtual void setTitle(const SystemString& title)=0;
virtual void setWindowFrameDefault()=0;
virtual void getWindowFrame(float& xOut, float& yOut, float& wOut, float& hOut) const=0;

25
include/boo/System.hpp Normal file
View File

@@ -0,0 +1,25 @@
#ifndef BOO_SYSTEM_HPP
#define BOO_SYSTEM_HPP
#include <string>
namespace boo
{
#ifdef _WIN32
using SystemString = std::wstring;
using SystemChar = wchar_t;
# ifndef _S
# define _S(val) L ## val
# endif
#else
using SystemString = std::string;
using SystemChar = char;
# ifndef _S
# define _S(val) val
# endif
#endif
}
#endif

View File

@@ -11,7 +11,9 @@
#include <stdio.h>
#ifdef _WIN32
#define _WIN32_LEAN_AND_MEAN 1
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#include <Dbt.h>
#endif
@@ -163,7 +165,7 @@ public:
{
PDEV_BROADCAST_HDR dbh = (PDEV_BROADCAST_HDR)lParam;
PDEV_BROADCAST_DEVICEINTERFACE dbhi = (PDEV_BROADCAST_DEVICEINTERFACE)lParam;
CDeviceFinder* finder = instance();
DeviceFinder* finder = instance();
if (!finder)
return 0;