Add SetTitle, use std::string for window title

This commit is contained in:
Dmitry Marakasov 2014-02-03 05:00:36 +04:00
parent c89ec85164
commit 7357952e5a
2 changed files with 11 additions and 3 deletions

View File

@ -26,8 +26,8 @@
namespace SDL2pp {
Window::Window(const char* title, int x, int y, int w, int h, Uint32 flags) {
if ((window_ = SDL_CreateWindow(title, x, y, w, h, flags)) == nullptr)
Window::Window(const std::string& title, int x, int y, int w, int h, Uint32 flags) {
if ((window_ = SDL_CreateWindow(title.c_str(), x, y, w, h, flags)) == nullptr)
throw Exception("SDL_CreateWindow failed");
}
@ -64,6 +64,10 @@ int Window::GetHeight() const {
return h;
}
void Window::SetTitle(const std::string& title) {
SDL_SetWindowTitle(window_, title.c_str());
}
SDL_Window* Window::Get() const {
return window_;
}

View File

@ -22,6 +22,8 @@
#ifndef SDL2PP_WINDOW_HH
#define SDL2PP_WINDOW_HH
#include <string>
#include <SDL2/SDL_stdinc.h>
#include <SDL2pp/Point.hh>
@ -35,7 +37,7 @@ private:
SDL_Window* window_;
public:
Window(const char* title, int x, int y, int w, int h, Uint32 flags);
Window(const std::string& title, int x, int y, int w, int h, Uint32 flags);
virtual ~Window();
Window(const Window& other) = delete;
@ -47,6 +49,8 @@ public:
int GetWidth() const;
int GetHeight() const;
void SetTitle(const std::string& title);
SDL_Window* Get() const;
};