Adds window flags and attributes

This commit is contained in:
Atul R 2019-08-10 22:15:41 +02:00
parent 19068f5d38
commit a5b0bbcb28
5 changed files with 66 additions and 3 deletions

View File

@ -163,6 +163,21 @@ Napi::Value testAttribute(const Napi::CallbackInfo& info){ \
bool isOn = this->instance->testAttribute(static_cast<Qt::WidgetAttribute>(attributeId)); \
return Napi::Boolean::New(env, isOn); \
} \
Napi::Value setWindowOpacity(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
float opacity = info[0].As<Napi::Number>().FloatValue(); \
this->instance->setWindowOpacity(opacity); \
return env.Null(); \
} \
Napi::Value setWindowFlag(const Napi::CallbackInfo& info){ \
Napi::Env env = info.Env(); \
Napi::HandleScope scope(env); \
int windowType = info[0].As<Napi::Number>().Int32Value(); \
bool switchOn = info[1].As<Napi::Boolean>().Value(); \
this->instance->setWindowFlag(static_cast<Qt::WindowType>(windowType), switchOn); \
return env.Null(); \
} \
#endif //QWIDGET_WRAPPED_METHODS_DECLARATION
@ -192,5 +207,7 @@ Napi::Value testAttribute(const Napi::CallbackInfo& info){ \
InstanceMethod("size",&WidgetWrapName::size), \
InstanceMethod("setAttribute",&WidgetWrapName::setAttribute), \
InstanceMethod("testAttribute",&WidgetWrapName::testAttribute), \
InstanceMethod("setWindowOpacity",&WidgetWrapName::setWindowOpacity), \
InstanceMethod("setWindowFlag",&WidgetWrapName::setWindowFlag), \
#endif // QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE

View File

@ -4,6 +4,41 @@ export enum AspectRatioMode {
"KeepAspectRatioByExpanding"
}
export enum WindowType {
Widget = 0x00000000,
Window = 0x00000001,
Dialog = 0x00000002,
Sheet = 0x00000004,
Popup = 0x00000008,
Desktop = 0x00000010,
SubWindow = 0x00000012,
ForeignWindow = 0x00000020,
CoverWindow = 0x00000040,
MSWindowsFixedSizeDialogHint = 0x00000100,
MSWindowsOwnDC = 0x00000200,
BypassWindowManagerHint = 0x00000400,
FramelessWindowHint = 0x00000800,
NoDropShadowWindowHint = 0x40000000,
CustomizeWindowHint = 0x02000000,
WindowTitleHint = 0x00001000,
WindowSystemMenuHint = 0x00002000,
WindowMinimizeButtonHint = 0x00004000,
WindowMaximizeButtonHint = 0x00008000,
WindowCloseButtonHint = 0x08000000,
WindowContextHelpButtonHint = 0x00010000,
MacWindowToolBarButtonHint = 0x10000000,
WindowFullscreenButtonHint = 0x80000000,
BypassGraphicsProxyWidget = 0x20000000,
WindowShadeButtonHint = 0x00020000,
WindowStaysOnTopHint = 0x00040000,
WindowStaysOnBottomHint = 0x04000000,
WindowTransparentForInput = 0x00080000,
WindowOverridesSystemGestures = 0x00100000,
WindowDoesNotAcceptFocus = 0x00200000,
MaximizeUsingFullscreenGeometryHint = 0x00400000,
WindowType_Mask = 0x000000ff
}
export enum WidgetAttribute {
WA_AcceptDrops = 78,
WA_AlwaysShowToolTips = 84,

View File

@ -28,7 +28,12 @@ export class QPixmap extends Component {
height: number,
aspectRatioMode?: AspectRatioMode
): QPixmap => {
const nativePixmap = this.native.scaled(width, height, aspectRatioMode);
let nativePixmap;
if (aspectRatioMode) {
nativePixmap = this.native.scaled(width, height, aspectRatioMode);
} else {
nativePixmap = this.native.scaled(width, height);
}
return new QPixmap(nativePixmap);
};
}

View File

@ -3,7 +3,7 @@ import { NodeLayout } from "../../QtWidgets/QLayout";
import { EventWidget, BaseWidgetEvents } from "../../core/EventWidget";
import { NativeElement } from "../../core/Component";
import { FlexLayout } from "../../core/FlexLayout";
import { WidgetAttribute } from "../../QtEnums";
import { WidgetAttribute, WindowType } from "../../QtEnums";
import {
applyStyleSheet,
StyleSheet,
@ -85,6 +85,12 @@ export abstract class NodeWidget extends EventWidget {
testAttribute = (attribute: WidgetAttribute): boolean => {
return this.native.testAttribute(attribute);
};
setWindowOpacity = (opacity: Number) => {
this.native.setWindowOpacity(opacity);
};
setWindowFlag = (windowType: WindowType, switchOn: boolean) => {
return this.native.setWindowFlag(windowType, switchOn);
};
}
export class QWidget extends NodeWidget {

View File

@ -1,5 +1,5 @@
// enums
export { AspectRatioMode } from "./QtEnums";
export { AspectRatioMode, WidgetAttribute, WindowType } from "./QtEnums";
export { QApplication } from "./QtGui/QApplication";
export { QWidget, QWidgetEvents } from "./QtGui/QWidget";
export { QPixmap } from "./QtGui/QPixmap";