Complete a few APIs for getters.
This commit is contained in:
Родитель
d06472b092
Коммит
100c4a426b
|
@ -193,6 +193,18 @@ v8::Handle<v8::Value> Window::SetMinimumSize(const v8::Arguments &args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetMinimumSize(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
||||
gfx::Size size = self->window_->GetMinimumSize();
|
||||
v8::Handle<v8::Array> ret = v8::Array::New(2);
|
||||
ret->Set(0, v8::Integer::New(size.width()));
|
||||
ret->Set(1, v8::Integer::New(size.height()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetMaximumSize(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
@ -205,6 +217,18 @@ v8::Handle<v8::Value> Window::SetMaximumSize(const v8::Arguments &args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::GetMaximumSize(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
||||
gfx::Size size = self->window_->GetMaximumSize();
|
||||
v8::Handle<v8::Array> ret = v8::Array::New(2);
|
||||
ret->Set(0, v8::Integer::New(size.width()));
|
||||
ret->Set(1, v8::Integer::New(size.height()));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetResizable(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
@ -216,6 +240,13 @@ v8::Handle<v8::Value> Window::SetResizable(const v8::Arguments &args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsResizable(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
||||
return v8::Boolean::New(self->window_->IsResizable());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetAlwaysOnTop(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
@ -227,6 +258,13 @@ v8::Handle<v8::Value> Window::SetAlwaysOnTop(const v8::Arguments &args) {
|
|||
return v8::Undefined();
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::IsAlwaysOnTop(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
||||
return v8::Boolean::New(self->window_->IsAlwaysOnTop());
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
|
||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
||||
|
@ -496,9 +534,13 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
|
|||
NODE_SET_PROTOTYPE_METHOD(t, "setSize", SetSize);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getSize", GetSize);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setMinimumSize", SetMinimumSize);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getMinimumSize", GetMinimumSize);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setMaximumSize", SetMaximumSize);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getMaximumSize", GetMaximumSize);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setResizable", SetResizable);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "isResizable", IsResizable);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setAlwaysOnTop", SetAlwaysOnTop);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "isAlwaysOnTop", IsAlwaysOnTop);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setPosition", SetPosition);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "getPosition", GetPosition);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "setTitle", SetTitle);
|
||||
|
|
|
@ -47,9 +47,13 @@ class Window : public EventEmitter {
|
|||
static v8::Handle<v8::Value> SetSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetMinimumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetMinimumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetMaximumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetMaximumSize(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetResizable(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsResizable(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetAlwaysOnTop(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> IsAlwaysOnTop(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetPosition(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> GetPosition(const v8::Arguments &args);
|
||||
static v8::Handle<v8::Value> SetTitle(const v8::Arguments &args);
|
||||
|
|
|
@ -56,9 +56,13 @@ class NativeWindow : public content::WebContentsDelegate {
|
|||
virtual void SetSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size GetSize() = 0;
|
||||
virtual void SetMinimumSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size GetMinimumSize() = 0;
|
||||
virtual void SetMaximumSize(const gfx::Size& size) = 0;
|
||||
virtual gfx::Size GetMaximumSize() = 0;
|
||||
virtual void SetResizable(bool resizable) = 0;
|
||||
virtual bool IsResizable() = 0;
|
||||
virtual void SetAlwaysOnTop(bool top) = 0;
|
||||
virtual bool IsAlwaysOnTop() = 0;
|
||||
virtual void SetPosition(const std::string& position) = 0;
|
||||
virtual void SetPosition(const gfx::Point& position) = 0;
|
||||
virtual gfx::Point GetPosition() = 0;
|
||||
|
|
|
@ -33,9 +33,13 @@ class NativeWindowMac : public NativeWindow {
|
|||
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
||||
virtual gfx::Size GetSize() OVERRIDE;
|
||||
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
||||
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
||||
virtual void SetMaximumSize(const gfx::Size& size) OVERRIDE;
|
||||
virtual gfx::Size GetMaximumSize() OVERRIDE;
|
||||
virtual void SetResizable(bool resizable) OVERRIDE;
|
||||
virtual bool IsResizable() OVERRIDE;
|
||||
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
|
||||
virtual bool IsAlwaysOnTop() OVERRIDE;
|
||||
virtual void SetPosition(const std::string& position) OVERRIDE;
|
||||
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
|
||||
virtual gfx::Point GetPosition() OVERRIDE;
|
||||
|
|
|
@ -224,12 +224,26 @@ void NativeWindowMac::SetMinimumSize(const gfx::Size& size) {
|
|||
[window() setContentMinSize:[content convertSize:min_size toView:nil]];
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::GetMinimumSize() {
|
||||
NSView* content = [window() contentView];
|
||||
NSSize min_size = [content convertSize:[window() contentMinSize]
|
||||
fromView:nil];
|
||||
return gfx::Size(min_size.width, min_size.height);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMaximumSize(const gfx::Size& size) {
|
||||
NSSize max_size = NSMakeSize(size.width(), size.height());
|
||||
NSView* content = [window() contentView];
|
||||
[window() setContentMaxSize:[content convertSize:max_size toView:nil]];
|
||||
}
|
||||
|
||||
gfx::Size NativeWindowMac::GetMaximumSize() {
|
||||
NSView* content = [window() contentView];
|
||||
NSSize max_size = [content convertSize:[window() contentMaxSize]
|
||||
fromView:nil];
|
||||
return gfx::Size(max_size.width, max_size.height);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetResizable(bool resizable) {
|
||||
if (resizable) {
|
||||
[[window() standardWindowButton:NSWindowZoomButton] setEnabled:YES];
|
||||
|
@ -240,10 +254,18 @@ void NativeWindowMac::SetResizable(bool resizable) {
|
|||
}
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsResizable() {
|
||||
return [window() styleMask] & NSResizableWindowMask;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAlwaysOnTop(bool top) {
|
||||
[window() setLevel:(top ? NSFloatingWindowLevel : NSNormalWindowLevel)];
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsAlwaysOnTop() {
|
||||
return [window() level] == NSFloatingWindowLevel;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetPosition(const std::string& position) {
|
||||
if (position == "center")
|
||||
[window() center];
|
||||
|
|
Загрузка…
Ссылка в новой задаче