mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-07 14:25:17 -04:00
Add SetTitle, use std::string for window title
This commit is contained in:
parent
c89ec85164
commit
7357952e5a
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
namespace SDL2pp {
|
namespace SDL2pp {
|
||||||
|
|
||||||
Window::Window(const char* title, int x, int y, int w, int h, Uint32 flags) {
|
Window::Window(const std::string& title, int x, int y, int w, int h, Uint32 flags) {
|
||||||
if ((window_ = SDL_CreateWindow(title, x, y, w, h, flags)) == nullptr)
|
if ((window_ = SDL_CreateWindow(title.c_str(), x, y, w, h, flags)) == nullptr)
|
||||||
throw Exception("SDL_CreateWindow failed");
|
throw Exception("SDL_CreateWindow failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +64,10 @@ int Window::GetHeight() const {
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::SetTitle(const std::string& title) {
|
||||||
|
SDL_SetWindowTitle(window_, title.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Window* Window::Get() const {
|
SDL_Window* Window::Get() const {
|
||||||
return window_;
|
return window_;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#ifndef SDL2PP_WINDOW_HH
|
#ifndef SDL2PP_WINDOW_HH
|
||||||
#define SDL2PP_WINDOW_HH
|
#define SDL2PP_WINDOW_HH
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <SDL2/SDL_stdinc.h>
|
#include <SDL2/SDL_stdinc.h>
|
||||||
|
|
||||||
#include <SDL2pp/Point.hh>
|
#include <SDL2pp/Point.hh>
|
||||||
@ -35,7 +37,7 @@ private:
|
|||||||
SDL_Window* window_;
|
SDL_Window* window_;
|
||||||
|
|
||||||
public:
|
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();
|
virtual ~Window();
|
||||||
|
|
||||||
Window(const Window& other) = delete;
|
Window(const Window& other) = delete;
|
||||||
@ -47,6 +49,8 @@ public:
|
|||||||
int GetWidth() const;
|
int GetWidth() const;
|
||||||
int GetHeight() const;
|
int GetHeight() const;
|
||||||
|
|
||||||
|
void SetTitle(const std::string& title);
|
||||||
|
|
||||||
SDL_Window* Get() const;
|
SDL_Window* Get() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user