new types and classes
This commit is contained in:
parent
20df39ee4e
commit
9a3a1b084a
26 changed files with 1324 additions and 2 deletions
|
|
@ -0,0 +1,7 @@
|
|||
export * from "./constants";
|
||||
export * from "./enums";
|
||||
export * from "./structs";
|
||||
export * from "./types";
|
||||
export * from "./widgets";
|
||||
|
||||
export { BaseWidget, NativeClasses, Pixmap } from "./milsko";
|
||||
14
lib/milsko.ts
Normal file
14
lib/milsko.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// @ts-ignore
|
||||
import binding from "node-gyp-build";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
BaseWidgetConstructor,
|
||||
MwNativeClasses,
|
||||
PixmapConstructor
|
||||
} from "./types";
|
||||
|
||||
export const BaseWidget: BaseWidgetConstructor = binding.BaseWidget;
|
||||
export const NativeClasses: MwNativeClasses = binding.Classes;
|
||||
export const Pixmap: PixmapConstructor = binding.Pixmap;
|
||||
|
||||
export default binding(join(__dirname, ".."));
|
||||
|
|
@ -23,7 +23,9 @@ export interface MwRGB {
|
|||
blue: number;
|
||||
}
|
||||
|
||||
export interface MwMouse {}
|
||||
export interface MwMouse {
|
||||
point: MwPoint;
|
||||
}
|
||||
|
||||
export interface MwVulkanConfig {
|
||||
apiVersion: number;
|
||||
|
|
|
|||
208
lib/types.ts
Normal file
208
lib/types.ts
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
import { MwCLIPBOARD, MwCOORDINATE } from "./enums";
|
||||
import { MwPoint, MwRect } from "./structs";
|
||||
|
||||
export type MwClass = object & { __brand: "MwClass" };
|
||||
|
||||
/**
|
||||
* `BaseWidget` represents the lowest level form of widgets before the native layer.
|
||||
* This class contains the fundamental native methods shared by all widgets.
|
||||
*/
|
||||
export interface BaseWidget {
|
||||
area: MwRect;
|
||||
isPending: boolean;
|
||||
parent: BaseWidget;
|
||||
children: BaseWidget[];
|
||||
name: string;
|
||||
cursorCoord: MwPoint;
|
||||
screenSize: MwRect;
|
||||
coordinateType: MwCOORDINATE;
|
||||
nativeClass: MwClass;
|
||||
|
||||
/**
|
||||
* Sets new position and size to this widget
|
||||
* @param area New rect
|
||||
*/
|
||||
setArea(area: MwRect): this;
|
||||
|
||||
/**
|
||||
* Moves this widget to an absolute position
|
||||
* @param x X position
|
||||
* @param y Y position
|
||||
*/
|
||||
move(x: number, y: number): this;
|
||||
|
||||
/**
|
||||
* Changes the size dimension of this widget
|
||||
* @param width New width
|
||||
* @param height New height
|
||||
*/
|
||||
resize(width: number, height: number): this;
|
||||
|
||||
/**
|
||||
* Runs a single step through the event loop
|
||||
* @returns Wether the step was successful
|
||||
*/
|
||||
step(): boolean;
|
||||
|
||||
/**
|
||||
* Start the main loop on this widget
|
||||
*/
|
||||
loop(): this;
|
||||
|
||||
/**
|
||||
* Show/hide this widget
|
||||
* @param toggle Wether the widget is shown
|
||||
*/
|
||||
show(toggle: boolean): this;
|
||||
|
||||
/**
|
||||
* Hides the cursor when being hovered over this widget
|
||||
*/
|
||||
hideCursor(): this;
|
||||
|
||||
/**
|
||||
* Grabs the pointer and pins it to the center of this widget
|
||||
* @param toggle Wether the pointer is grabbed
|
||||
*/
|
||||
grabPointer(toggle: boolean): this;
|
||||
|
||||
/**
|
||||
* Focus this widget
|
||||
*/
|
||||
focus(): this;
|
||||
|
||||
/**
|
||||
* Adds this widget to the tick handler list
|
||||
*/
|
||||
addTickList(): this;
|
||||
|
||||
/**
|
||||
* Forces this widget to render
|
||||
*/
|
||||
forceRender(): this;
|
||||
|
||||
/**
|
||||
* Reparents this widget to a new parent
|
||||
* @param widget New parent
|
||||
*/
|
||||
reparent(widget: BaseWidget): this;
|
||||
|
||||
/**
|
||||
* Adds another widget as child of this one
|
||||
* @param widgets Widgets to add
|
||||
*/
|
||||
addChild(...widgets: BaseWidget[]): this;
|
||||
|
||||
/**
|
||||
* Destroys this widget
|
||||
*/
|
||||
destroy(): null;
|
||||
|
||||
/**
|
||||
* Queues this widget to get clipboard content.
|
||||
* This is ignored in backends that aren't or X11/Wayland.
|
||||
* @param type Clipboard type to get, if you are unsure just use `MwCLIPBOARD_MAIN`
|
||||
*/
|
||||
getClipboard(type: MwCLIPBOARD): undefined;
|
||||
|
||||
/**
|
||||
* Sets a value to an integer property by its key
|
||||
* @param key Prefixed property key
|
||||
* @param value Value to assign to property
|
||||
*/
|
||||
setInteger(key: string, value: number): this;
|
||||
|
||||
/**
|
||||
* Sets a value to a string property by its key
|
||||
* @param key Prefixed property key
|
||||
* @param value Value to assign to property
|
||||
*/
|
||||
setString(key: string, value: string): this;
|
||||
|
||||
/**
|
||||
* Sets the value of a void* property by its key.
|
||||
* You most likely shouldn't use this unless you are extending BaseWidget
|
||||
* @param key Prefixed property key
|
||||
*/
|
||||
setVoid(key: string, value: unknown): this;
|
||||
|
||||
/**
|
||||
* Gets the value of an integer property by its key
|
||||
* @param key Prefixed property key
|
||||
*/
|
||||
getInteger(key: string): number;
|
||||
|
||||
/**
|
||||
* Gets the value of a string property by its key
|
||||
* @param key Prefixed property key
|
||||
*/
|
||||
getString(key: string): string;
|
||||
|
||||
/**
|
||||
* Gets the value of a void* property by its key.
|
||||
* You most likely shouldn't use this unless you are extending BaseWidget
|
||||
* @param key Prefixed property key
|
||||
*/
|
||||
getVoid(key: string): unknown;
|
||||
}
|
||||
|
||||
export interface BaseWidgetConstructor {
|
||||
new (cls: MwClass | null, options: WidgetOptions): BaseWidget;
|
||||
}
|
||||
|
||||
export interface MwNativeClasses {
|
||||
Box: MwClass;
|
||||
Button: MwClass;
|
||||
CheckBox: MwClass;
|
||||
Entry: MwClass;
|
||||
Frame: MwClass;
|
||||
Image: MwClass;
|
||||
Label: MwClass;
|
||||
ListBox: MwClass;
|
||||
Menu: MwClass;
|
||||
NumberEntry: MwClass;
|
||||
ScrollBar: MwClass;
|
||||
SubMenu: MwClass;
|
||||
SubWindow: MwClass;
|
||||
Viewport: MwClass;
|
||||
Window: MwClass;
|
||||
ProgressBar: MwClass;
|
||||
RadioBox: MwClass;
|
||||
ComboBox: MwClass;
|
||||
TreeView: MwClass;
|
||||
}
|
||||
|
||||
export interface Pixmap {
|
||||
size: MwRect;
|
||||
|
||||
/**
|
||||
* Get the raw data of this pixmap
|
||||
*/
|
||||
getRaw(): Buffer;
|
||||
|
||||
/**
|
||||
* Updates this pixmap using raw data
|
||||
* @param data Image data to update
|
||||
*/
|
||||
reloadRaw(data: Buffer | ArrayBuffer): void;
|
||||
}
|
||||
|
||||
export interface PixmapOptions {
|
||||
data?: Buffer;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
export interface PixmapConstructor {
|
||||
new (cls: BaseWidget, options?: PixmapOptions): Pixmap;
|
||||
}
|
||||
|
||||
export interface WidgetOptions {
|
||||
name?: string;
|
||||
parent?: BaseWidget;
|
||||
children?: BaseWidget[];
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
268
lib/widget.ts
Normal file
268
lib/widget.ts
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
import { BaseWidget } from "./milsko";
|
||||
import { Pixmap } from "./types";
|
||||
|
||||
export class Widget extends BaseWidget {
|
||||
public setX(value: number): this {
|
||||
return this.setInteger("Ix", value);
|
||||
}
|
||||
|
||||
get x(): number {
|
||||
return this.getInteger("Ix");
|
||||
}
|
||||
|
||||
set x(value: number) {
|
||||
this.setInteger("Ix", value);
|
||||
}
|
||||
|
||||
public setY(value: number): this {
|
||||
return this.setInteger("Iy", value);
|
||||
}
|
||||
|
||||
get y(): number {
|
||||
return this.getInteger("Iy");
|
||||
}
|
||||
|
||||
set y(value: number) {
|
||||
this.setInteger("Iy", value);
|
||||
}
|
||||
|
||||
public setWidth(value: number): this {
|
||||
return this.setInteger("Iwidth", value);
|
||||
}
|
||||
|
||||
get width(): number {
|
||||
return this.getInteger("Iwidth");
|
||||
}
|
||||
|
||||
set width(value: number) {
|
||||
this.setInteger("Iwidth", value);
|
||||
}
|
||||
|
||||
public setHeight(value: number): this {
|
||||
return this.setInteger("Iheight", value);
|
||||
}
|
||||
|
||||
get height(): number {
|
||||
return this.getInteger("Iheight");
|
||||
}
|
||||
|
||||
set height(value: number) {
|
||||
this.setInteger("Iheight", value);
|
||||
}
|
||||
|
||||
public setModernLook(value: boolean): this {
|
||||
return this.setInteger("ImodernLook", +value);
|
||||
}
|
||||
|
||||
get modernLook(): boolean {
|
||||
return this.getInteger("ImodernLook") != 0;
|
||||
}
|
||||
|
||||
set modernLook(value: boolean) {
|
||||
this.setInteger("ImodernLook", +value);
|
||||
}
|
||||
|
||||
public setBorderWidth(value: number): this {
|
||||
return this.setInteger("IborderWidth", value);
|
||||
}
|
||||
|
||||
get borderWidth(): number {
|
||||
return this.getInteger("IborderWidth");
|
||||
}
|
||||
|
||||
set borderWidth(value: number) {
|
||||
this.setInteger("IborderWidth", value);
|
||||
}
|
||||
|
||||
public setRatio(value: number): this {
|
||||
return this.setInteger("Iratio", value);
|
||||
}
|
||||
|
||||
get ratio(): number {
|
||||
return this.getInteger("Iratio");
|
||||
}
|
||||
|
||||
set ratio(value: number) {
|
||||
this.setInteger("Iratio", value);
|
||||
}
|
||||
|
||||
public setFixedSize(value: number): this {
|
||||
return this.setInteger("IfixedSize", value);
|
||||
}
|
||||
|
||||
get fixedSize(): number {
|
||||
return this.getInteger("IfixedSize");
|
||||
}
|
||||
|
||||
set fixedSize(value: number) {
|
||||
this.setInteger("IfixedSize", value);
|
||||
}
|
||||
|
||||
public setBitmapFont(value: boolean): this {
|
||||
return this.setInteger("IbitmapFont", +value);
|
||||
}
|
||||
|
||||
get bitmapFont(): boolean {
|
||||
return this.getInteger("IbitmapFont") != 0;
|
||||
}
|
||||
|
||||
set bitmapFont(value: boolean) {
|
||||
this.setInteger("IbitmapFont", +value);
|
||||
}
|
||||
|
||||
public setForceInverted(value: boolean): this {
|
||||
return this.setInteger("IforceInverted", +value);
|
||||
}
|
||||
|
||||
get forceInverted(): boolean {
|
||||
return this.getInteger("IforceInverted") != 0;
|
||||
}
|
||||
|
||||
set forceInverted(value: boolean) {
|
||||
this.setInteger("IforceInverted", +value);
|
||||
}
|
||||
|
||||
public setIsRounded(value: boolean): this {
|
||||
return this.setInteger("IisRounded", +value);
|
||||
}
|
||||
|
||||
get isRounded(): boolean {
|
||||
return this.getInteger("IisRounded") != 0;
|
||||
}
|
||||
|
||||
set isRounded(value: boolean) {
|
||||
this.setInteger("IisRounded", +value);
|
||||
}
|
||||
|
||||
public setDarkTheme(value: boolean): this {
|
||||
return this.setInteger("IdarkTheme", +value);
|
||||
}
|
||||
|
||||
get darkTheme(): boolean {
|
||||
return this.getInteger("IdarkTheme") != 0;
|
||||
}
|
||||
|
||||
set darkTheme(value: boolean) {
|
||||
this.setInteger("IdarkTheme", +value);
|
||||
}
|
||||
|
||||
public setUseMonospace(value: boolean): this {
|
||||
return this.setInteger("IuseMonospace", +value);
|
||||
}
|
||||
|
||||
get useMonospace(): boolean {
|
||||
return this.getInteger("IuseMonospace") != 0;
|
||||
}
|
||||
|
||||
set useMonospace(value: boolean) {
|
||||
this.setInteger("IuseMonospace", +value);
|
||||
}
|
||||
|
||||
public setDarkThemeAutomatic(value: boolean): this {
|
||||
return this.setInteger("IdarkThemeAutomatic", +value);
|
||||
}
|
||||
|
||||
get darkThemeAutomatic(): boolean {
|
||||
return this.getInteger("IdarkThemeAutomatic") != 0;
|
||||
}
|
||||
|
||||
set darkThemeAutomatic(value: boolean) {
|
||||
this.setInteger("IdarkThemeAutomatic", +value);
|
||||
}
|
||||
|
||||
public setWaitMS(value: number): this {
|
||||
return this.setInteger("IwaitMS", value);
|
||||
}
|
||||
|
||||
get waitMS(): number {
|
||||
return this.getInteger("IwaitMS");
|
||||
}
|
||||
|
||||
set waitMS(value: number) {
|
||||
this.setInteger("IwaitMS", value);
|
||||
}
|
||||
|
||||
public setBackground(value: string): this {
|
||||
return this.setString("Sbackground", value);
|
||||
}
|
||||
|
||||
get background(): string {
|
||||
return this.getString("Sbackground");
|
||||
}
|
||||
|
||||
set background(value: string) {
|
||||
this.setString("Sbackground", value);
|
||||
}
|
||||
|
||||
public setSubBackground(value: string): this {
|
||||
return this.setString("SsubBackground", value);
|
||||
}
|
||||
|
||||
get subBackground(): string {
|
||||
return this.getString("SsubBackground");
|
||||
}
|
||||
|
||||
set subBackground(value: string) {
|
||||
this.setString("SsubBackground", value);
|
||||
}
|
||||
|
||||
public setTitleBackground(value: string): this {
|
||||
return this.setString("StitleBackground", value);
|
||||
}
|
||||
|
||||
get titleBackground(): string {
|
||||
return this.getString("StitleBackground");
|
||||
}
|
||||
|
||||
set titleBackground(value: string) {
|
||||
this.setString("StitleBackground", value);
|
||||
}
|
||||
|
||||
public setForeground(value: string): this {
|
||||
return this.setString("Sforeground", value);
|
||||
}
|
||||
|
||||
get foreground(): string {
|
||||
return this.getString("Sforeground");
|
||||
}
|
||||
|
||||
set foreground(value: string) {
|
||||
this.setString("Sforeground", value);
|
||||
}
|
||||
|
||||
public setSubForeground(value: string): this {
|
||||
return this.setString("SsubForeground", value);
|
||||
}
|
||||
|
||||
get subForeground(): string {
|
||||
return this.getString("SsubForeground");
|
||||
}
|
||||
|
||||
set subForeground(value: string) {
|
||||
this.setString("SsubForeground", value);
|
||||
}
|
||||
|
||||
public setTitleForeground(value: string): this {
|
||||
return this.setString("StitleForeground", value);
|
||||
}
|
||||
|
||||
get titleForeground(): string {
|
||||
return this.getString("StitleForeground");
|
||||
}
|
||||
|
||||
set titleForeground(value: string) {
|
||||
this.setString("StitleForeground", value);
|
||||
}
|
||||
|
||||
public setBackgroundPixmap(value: Pixmap): this {
|
||||
return this.setVoid("VbackgroundPixmap", value);
|
||||
}
|
||||
|
||||
get backgroundPixmap(): Pixmap {
|
||||
return this.getVoid("VbackgroundPixmap") as Pixmap;
|
||||
}
|
||||
|
||||
set backgroundPixmap(value: Pixmap) {
|
||||
this.setVoid("VbackgroundPixmap", value);
|
||||
}
|
||||
}
|
||||
69
lib/widgets/box.ts
Normal file
69
lib/widgets/box.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class Box extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Box, options);
|
||||
}
|
||||
|
||||
public setOrientation(value: number): this {
|
||||
return this.setInteger("Iorientation", value);
|
||||
}
|
||||
|
||||
get orientation(): number {
|
||||
return this.getInteger("Iorientation");
|
||||
}
|
||||
|
||||
set orientation(value: number) {
|
||||
this.setInteger("Iorientation", value);
|
||||
}
|
||||
|
||||
public setMargin(value: number): this {
|
||||
return this.setInteger("Imargin", value);
|
||||
}
|
||||
|
||||
get margin(): number {
|
||||
return this.getInteger("Imargin");
|
||||
}
|
||||
|
||||
set margin(value: number) {
|
||||
this.setInteger("Imargin", value);
|
||||
}
|
||||
|
||||
public setPadding(value: number): this {
|
||||
return this.setInteger("Ipadding", value);
|
||||
}
|
||||
|
||||
get padding(): number {
|
||||
return this.getInteger("Ipadding");
|
||||
}
|
||||
|
||||
set padding(value: number) {
|
||||
this.setInteger("Ipadding", value);
|
||||
}
|
||||
|
||||
public setHasBorder(value: boolean): this {
|
||||
return this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
get hasBorder(): boolean {
|
||||
return this.getInteger("IhasBorder") != 0;
|
||||
}
|
||||
|
||||
set hasBorder(value: boolean) {
|
||||
this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
public setInverted(value: boolean): this {
|
||||
return this.setInteger("Iinverted", +value);
|
||||
}
|
||||
|
||||
get inverted(): boolean {
|
||||
return this.getInteger("Iinverted") != 0;
|
||||
}
|
||||
|
||||
set inverted(value: boolean) {
|
||||
this.setInteger("Iinverted", +value);
|
||||
}
|
||||
}
|
||||
69
lib/widgets/button.ts
Normal file
69
lib/widgets/button.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions, Pixmap } from "../types";
|
||||
|
||||
export class Button extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Button, options);
|
||||
}
|
||||
|
||||
public setPixmap(value: Pixmap): this {
|
||||
return this.setVoid("Vpixmap", value);
|
||||
}
|
||||
|
||||
get pixmap(): Pixmap {
|
||||
return this.getVoid("Vpixmap") as Pixmap;
|
||||
}
|
||||
|
||||
set pixmap(value: Pixmap) {
|
||||
this.setVoid("Vpixmap", value);
|
||||
}
|
||||
|
||||
public setText(value: string): this {
|
||||
return this.setString("Stext", value);
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return this.getString("Stext");
|
||||
}
|
||||
|
||||
set text(value: string) {
|
||||
this.setString("Stext", value);
|
||||
}
|
||||
|
||||
public setFlat(value: boolean): this {
|
||||
return this.setInteger("Iflat", +value);
|
||||
}
|
||||
|
||||
get flat(): boolean {
|
||||
return this.getInteger("Iflat") != 0;
|
||||
}
|
||||
|
||||
set flat(value: boolean) {
|
||||
this.setInteger("Iflat", +value);
|
||||
}
|
||||
|
||||
public setPadding(value: number): this {
|
||||
return this.setInteger("Ipadding", value);
|
||||
}
|
||||
|
||||
get padding(): number {
|
||||
return this.getInteger("Ipadding");
|
||||
}
|
||||
|
||||
set padding(value: number) {
|
||||
this.setInteger("Ipadding", value);
|
||||
}
|
||||
|
||||
public setFillArea(value: number): this {
|
||||
return this.setInteger("IfillArea", value);
|
||||
}
|
||||
|
||||
get fillArea(): number {
|
||||
return this.getInteger("IfillArea");
|
||||
}
|
||||
|
||||
set fillArea(value: number) {
|
||||
this.setInteger("IfillArea", value);
|
||||
}
|
||||
}
|
||||
21
lib/widgets/checkbox.ts
Normal file
21
lib/widgets/checkbox.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class CheckBox extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.CheckBox, options);
|
||||
}
|
||||
|
||||
public setChecked(value: boolean): this {
|
||||
return this.setInteger("Ichecked", +value);
|
||||
}
|
||||
|
||||
get checked(): boolean {
|
||||
return this.getInteger("Ichecked") != 0;
|
||||
}
|
||||
|
||||
set checked(value: boolean) {
|
||||
this.setInteger("Ichecked", +value);
|
||||
}
|
||||
}
|
||||
33
lib/widgets/combobox.ts
Normal file
33
lib/widgets/combobox.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class ComboBox extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.ComboBox, options);
|
||||
}
|
||||
|
||||
public setAreaShown(value: number): this {
|
||||
return this.setInteger("IareaShown", value);
|
||||
}
|
||||
|
||||
get areaShown(): number {
|
||||
return this.getInteger("IareaShown");
|
||||
}
|
||||
|
||||
set areaShown(value: number) {
|
||||
this.setInteger("IareaShown", value);
|
||||
}
|
||||
|
||||
public setValue(value: number): this {
|
||||
return this.setInteger("Ivalue", value);
|
||||
}
|
||||
|
||||
get value(): number {
|
||||
return this.getInteger("Ivalue");
|
||||
}
|
||||
|
||||
set value(value: number) {
|
||||
this.setInteger("Ivalue", value);
|
||||
}
|
||||
}
|
||||
33
lib/widgets/entry.ts
Normal file
33
lib/widgets/entry.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class Entry extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Entry, options);
|
||||
}
|
||||
|
||||
public setText(value: string): this {
|
||||
return this.setString("Stext", value);
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return this.getString("Stext");
|
||||
}
|
||||
|
||||
set text(value: string) {
|
||||
this.setString("Stext", value);
|
||||
}
|
||||
|
||||
public setHideInput(value: boolean): this {
|
||||
return this.setInteger("IhideInput", +value);
|
||||
}
|
||||
|
||||
get hideInput(): boolean {
|
||||
return this.getInteger("IhideInput") != 0;
|
||||
}
|
||||
|
||||
set hideInput(value: boolean) {
|
||||
this.setInteger("IhideInput", +value);
|
||||
}
|
||||
}
|
||||
33
lib/widgets/frame.ts
Normal file
33
lib/widgets/frame.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class Frame extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Frame, options);
|
||||
}
|
||||
|
||||
public setHasBorder(value: boolean): this {
|
||||
return this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
get hasBorder(): boolean {
|
||||
return this.getInteger("IhasBorder") != 0;
|
||||
}
|
||||
|
||||
set hasBorder(value: boolean) {
|
||||
this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
public setInverted(value: boolean): this {
|
||||
return this.setInteger("Iinverted", +value);
|
||||
}
|
||||
|
||||
get inverted(): boolean {
|
||||
return this.getInteger("Iinverted") != 0;
|
||||
}
|
||||
|
||||
set inverted(value: boolean) {
|
||||
this.setInteger("Iinverted", +value);
|
||||
}
|
||||
}
|
||||
57
lib/widgets/image.ts
Normal file
57
lib/widgets/image.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions, Pixmap } from "../types";
|
||||
|
||||
export class Image extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Image, options);
|
||||
}
|
||||
|
||||
public setPixmap(value: Pixmap): this {
|
||||
return this.setVoid("Vpixmap", value);
|
||||
}
|
||||
|
||||
get pixmap(): Pixmap {
|
||||
return this.getVoid("Vpixmap") as Pixmap;
|
||||
}
|
||||
|
||||
set pixmap(value: Pixmap) {
|
||||
this.setVoid("Vpixmap", value);
|
||||
}
|
||||
|
||||
public setHasBorder(value: boolean): this {
|
||||
return this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
get hasBorder(): boolean {
|
||||
return this.getInteger("IhasBorder") != 0;
|
||||
}
|
||||
|
||||
set hasBorder(value: boolean) {
|
||||
this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
public setInverted(value: boolean): this {
|
||||
return this.setInteger("Iinverted", +value);
|
||||
}
|
||||
|
||||
get inverted(): boolean {
|
||||
return this.getInteger("Iinverted") != 0;
|
||||
}
|
||||
|
||||
set inverted(value: boolean) {
|
||||
this.setInteger("Iinverted", +value);
|
||||
}
|
||||
|
||||
public setFillArea(value: number): this {
|
||||
return this.setInteger("IfillArea", value);
|
||||
}
|
||||
|
||||
get fillArea(): number {
|
||||
return this.getInteger("IfillArea");
|
||||
}
|
||||
|
||||
set fillArea(value: number) {
|
||||
this.setInteger("IfillArea", value);
|
||||
}
|
||||
}
|
||||
19
lib/widgets/index.ts
Normal file
19
lib/widgets/index.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export { Box } from "./box";
|
||||
export { Button } from "./button";
|
||||
export { CheckBox } from "./checkbox";
|
||||
export { Entry } from "./entry";
|
||||
export { Frame } from "./frame";
|
||||
export { Image } from "./image";
|
||||
export { Label } from "./label";
|
||||
export { ListBox } from "./listbox";
|
||||
export { Menu } from "./menu";
|
||||
export { NumberEntry } from "./numberentry";
|
||||
export { ScrollBar } from "./scrollbar";
|
||||
export { SubMenu } from "./submenu";
|
||||
export { Viewport } from "./viewport";
|
||||
export { Window } from "./window";
|
||||
export { ProgressBar } from "./progressbar";
|
||||
export { RadioBox } from "./radiobox";
|
||||
export { ComboBox } from "./combobox";
|
||||
export { TreeView } from "./treeview";
|
||||
export { SubWindow } from "./subwindow";
|
||||
81
lib/widgets/label.ts
Normal file
81
lib/widgets/label.ts
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class Label extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Label, options);
|
||||
}
|
||||
|
||||
public setText(value: string): this {
|
||||
return this.setString("Stext", value);
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return this.getString("Stext");
|
||||
}
|
||||
|
||||
set text(value: string) {
|
||||
this.setString("Stext", value);
|
||||
}
|
||||
|
||||
public setAlignment(value: number): this {
|
||||
return this.setInteger("Ialignment", value);
|
||||
}
|
||||
|
||||
get alignment(): number {
|
||||
return this.getInteger("Ialignment");
|
||||
}
|
||||
|
||||
set alignment(value: number) {
|
||||
this.setInteger("Ialignment", value);
|
||||
}
|
||||
|
||||
public setBold(value: boolean): this {
|
||||
return this.setInteger("Ibold", +value);
|
||||
}
|
||||
|
||||
get bold(): boolean {
|
||||
return this.getInteger("Ibold") != 0;
|
||||
}
|
||||
|
||||
set bold(value: boolean) {
|
||||
this.setInteger("Ibold", +value);
|
||||
}
|
||||
|
||||
public setSevenSegment(value: boolean): this {
|
||||
return this.setInteger("IsevenSegment", +value);
|
||||
}
|
||||
|
||||
get sevenSegment(): boolean {
|
||||
return this.getInteger("IsevenSegment") != 0;
|
||||
}
|
||||
|
||||
set sevenSegment(value: boolean) {
|
||||
this.setInteger("IsevenSegment", +value);
|
||||
}
|
||||
|
||||
public setLength(value: number): this {
|
||||
return this.setInteger("Ilength", value);
|
||||
}
|
||||
|
||||
get length(): number {
|
||||
return this.getInteger("Ilength");
|
||||
}
|
||||
|
||||
set length(value: number) {
|
||||
this.setInteger("Ilength", value);
|
||||
}
|
||||
|
||||
public setLeftPadding(value: number): this {
|
||||
return this.setInteger("IleftPadding", value);
|
||||
}
|
||||
|
||||
get leftPadding(): number {
|
||||
return this.getInteger("IleftPadding");
|
||||
}
|
||||
|
||||
set leftPadding(value: number) {
|
||||
this.setInteger("IleftPadding", value);
|
||||
}
|
||||
}
|
||||
45
lib/widgets/listbox.ts
Normal file
45
lib/widgets/listbox.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class ListBox extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.ListBox, options);
|
||||
}
|
||||
|
||||
public setLeftPadding(value: number): this {
|
||||
return this.setInteger("IleftPadding", value);
|
||||
}
|
||||
|
||||
get leftPadding(): number {
|
||||
return this.getInteger("IleftPadding");
|
||||
}
|
||||
|
||||
set leftPadding(value: number) {
|
||||
this.setInteger("IleftPadding", value);
|
||||
}
|
||||
|
||||
public setHasHeading(value: boolean): this {
|
||||
return this.setInteger("IhasHeading", +value);
|
||||
}
|
||||
|
||||
get hasHeading(): boolean {
|
||||
return this.getInteger("IhasHeading") != 0;
|
||||
}
|
||||
|
||||
set hasHeading(value: boolean) {
|
||||
this.setInteger("IhasHeading", +value);
|
||||
}
|
||||
|
||||
public setSingleClickSelectable(value: boolean): this {
|
||||
return this.setInteger("IsingleClickSelectable", +value);
|
||||
}
|
||||
|
||||
get singleClickSelectable(): boolean {
|
||||
return this.getInteger("IsingleClickSelectable") != 0;
|
||||
}
|
||||
|
||||
set singleClickSelectable(value: boolean) {
|
||||
this.setInteger("IsingleClickSelectable", +value);
|
||||
}
|
||||
}
|
||||
9
lib/widgets/menu.ts
Normal file
9
lib/widgets/menu.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class Menu extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Menu, options);
|
||||
}
|
||||
}
|
||||
21
lib/widgets/numberentry.ts
Normal file
21
lib/widgets/numberentry.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class NumberEntry extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.NumberEntry, options);
|
||||
}
|
||||
|
||||
public setText(value: string): this {
|
||||
return this.setString("Stext", value);
|
||||
}
|
||||
|
||||
get text(): string {
|
||||
return this.getString("Stext");
|
||||
}
|
||||
|
||||
set text(value: string) {
|
||||
this.setString("Stext", value);
|
||||
}
|
||||
}
|
||||
45
lib/widgets/progressbar.ts
Normal file
45
lib/widgets/progressbar.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class ProgressBar extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.ProgressBar, options);
|
||||
}
|
||||
|
||||
public setMinValue(value: number): this {
|
||||
return this.setInteger("IminValue", value);
|
||||
}
|
||||
|
||||
get minValue(): number {
|
||||
return this.getInteger("IminValue");
|
||||
}
|
||||
|
||||
set minValue(value: number) {
|
||||
this.setInteger("IminValue", value);
|
||||
}
|
||||
|
||||
public setMaxValue(value: number): this {
|
||||
return this.setInteger("ImaxValue", value);
|
||||
}
|
||||
|
||||
get maxValue(): number {
|
||||
return this.getInteger("ImaxValue");
|
||||
}
|
||||
|
||||
set maxValue(value: number) {
|
||||
this.setInteger("ImaxValue", value);
|
||||
}
|
||||
|
||||
public setValue(value: number): this {
|
||||
return this.setInteger("Ivalue", value);
|
||||
}
|
||||
|
||||
get value(): number {
|
||||
return this.getInteger("Ivalue");
|
||||
}
|
||||
|
||||
set value(value: number) {
|
||||
this.setInteger("Ivalue", value);
|
||||
}
|
||||
}
|
||||
21
lib/widgets/radiobox.ts
Normal file
21
lib/widgets/radiobox.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class RadioBox extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.RadioBox, options);
|
||||
}
|
||||
|
||||
public setChecked(value: boolean): this {
|
||||
return this.setInteger("Ichecked", +value);
|
||||
}
|
||||
|
||||
get checked(): boolean {
|
||||
return this.getInteger("Ichecked") != 0;
|
||||
}
|
||||
|
||||
set checked(value: boolean) {
|
||||
this.setInteger("Ichecked", +value);
|
||||
}
|
||||
}
|
||||
81
lib/widgets/scrollbar.ts
Normal file
81
lib/widgets/scrollbar.ts
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class ScrollBar extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.ScrollBar, options);
|
||||
}
|
||||
|
||||
public setShowArrows(value: boolean): this {
|
||||
return this.setInteger("IshowArrows", +value);
|
||||
}
|
||||
|
||||
get showArrows(): boolean {
|
||||
return this.getInteger("IshowArrows") != 0;
|
||||
}
|
||||
|
||||
set showArrows(value: boolean) {
|
||||
this.setInteger("IshowArrows", +value);
|
||||
}
|
||||
|
||||
public setAreaShown(value: number): this {
|
||||
return this.setInteger("IareaShown", value);
|
||||
}
|
||||
|
||||
get areaShown(): number {
|
||||
return this.getInteger("IareaShown");
|
||||
}
|
||||
|
||||
set areaShown(value: number) {
|
||||
this.setInteger("IareaShown", value);
|
||||
}
|
||||
|
||||
public setValue(value: number): this {
|
||||
return this.setInteger("Ivalue", value);
|
||||
}
|
||||
|
||||
get value(): number {
|
||||
return this.getInteger("Ivalue");
|
||||
}
|
||||
|
||||
set value(value: number) {
|
||||
this.setInteger("Ivalue", value);
|
||||
}
|
||||
|
||||
public setMinValue(value: number): this {
|
||||
return this.setInteger("IminValue", value);
|
||||
}
|
||||
|
||||
get minValue(): number {
|
||||
return this.getInteger("IminValue");
|
||||
}
|
||||
|
||||
set minValue(value: number) {
|
||||
this.setInteger("IminValue", value);
|
||||
}
|
||||
|
||||
public setMaxValue(value: number): this {
|
||||
return this.setInteger("ImaxValue", value);
|
||||
}
|
||||
|
||||
get maxValue(): number {
|
||||
return this.getInteger("ImaxValue");
|
||||
}
|
||||
|
||||
set maxValue(value: number) {
|
||||
this.setInteger("ImaxValue", value);
|
||||
}
|
||||
|
||||
public setOrientation(value: number): this {
|
||||
return this.setInteger("Iorientation", value);
|
||||
}
|
||||
|
||||
get orientation(): number {
|
||||
return this.getInteger("Iorientation");
|
||||
}
|
||||
|
||||
set orientation(value: number) {
|
||||
this.setInteger("Iorientation", value);
|
||||
}
|
||||
}
|
||||
21
lib/widgets/submenu.ts
Normal file
21
lib/widgets/submenu.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class SubMenu extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.SubMenu, options);
|
||||
}
|
||||
|
||||
public setLeftPadding(value: number): this {
|
||||
return this.setInteger("IleftPadding", value);
|
||||
}
|
||||
|
||||
get leftPadding(): number {
|
||||
return this.getInteger("IleftPadding");
|
||||
}
|
||||
|
||||
set leftPadding(value: number) {
|
||||
this.setInteger("IleftPadding", value);
|
||||
}
|
||||
}
|
||||
33
lib/widgets/subwindow.ts
Normal file
33
lib/widgets/subwindow.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions, Pixmap } from "../types";
|
||||
|
||||
export class SubWindow extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.SubWindow, options);
|
||||
}
|
||||
|
||||
public setIconPixmap(value: Pixmap): this {
|
||||
return this.setVoid("ViconPixmap", value);
|
||||
}
|
||||
|
||||
get iconPixmap(): Pixmap {
|
||||
return this.getVoid("ViconPixmap") as Pixmap;
|
||||
}
|
||||
|
||||
set iconPixmap(value: Pixmap) {
|
||||
this.setVoid("ViconPixmap", value);
|
||||
}
|
||||
|
||||
public setTitle(value: string): this {
|
||||
return this.setString("Stitle", value);
|
||||
}
|
||||
|
||||
get title(): string {
|
||||
return this.getString("Stitle");
|
||||
}
|
||||
|
||||
set title(value: string) {
|
||||
this.setString("Stitle", value);
|
||||
}
|
||||
}
|
||||
33
lib/widgets/treeview.ts
Normal file
33
lib/widgets/treeview.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class TreeView extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.TreeView, options);
|
||||
}
|
||||
|
||||
public setLeftPadding(value: number): this {
|
||||
return this.setInteger("IleftPadding", value);
|
||||
}
|
||||
|
||||
get leftPadding(): number {
|
||||
return this.getInteger("IleftPadding");
|
||||
}
|
||||
|
||||
set leftPadding(value: number) {
|
||||
this.setInteger("IleftPadding", value);
|
||||
}
|
||||
|
||||
public setSingleClickSelectable(value: boolean): this {
|
||||
return this.setInteger("IsingleClickSelectable", +value);
|
||||
}
|
||||
|
||||
get singleClickSelectable(): boolean {
|
||||
return this.getInteger("IsingleClickSelectable") != 0;
|
||||
}
|
||||
|
||||
set singleClickSelectable(value: boolean) {
|
||||
this.setInteger("IsingleClickSelectable", +value);
|
||||
}
|
||||
}
|
||||
9
lib/widgets/viewport.ts
Normal file
9
lib/widgets/viewport.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { WidgetOptions } from "../types";
|
||||
|
||||
export class Viewport extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Viewport, options);
|
||||
}
|
||||
}
|
||||
82
lib/widgets/window.ts
Normal file
82
lib/widgets/window.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import { NativeClasses } from "../milsko";
|
||||
import { Widget } from "../widget";
|
||||
import { MwSizeHints } from "../structs";
|
||||
import { WidgetOptions, Pixmap } from "../types";
|
||||
|
||||
export class Window extends Widget {
|
||||
constructor(options: WidgetOptions) {
|
||||
super(NativeClasses.Window, options);
|
||||
}
|
||||
|
||||
public setTitle(value: string): this {
|
||||
return this.setString("Stitle", value);
|
||||
}
|
||||
|
||||
get title(): string {
|
||||
return this.getString("Stitle");
|
||||
}
|
||||
|
||||
set title(value: string) {
|
||||
this.setString("Stitle", value);
|
||||
}
|
||||
|
||||
public setMain(value: boolean): this {
|
||||
return this.setInteger("Imain", +value);
|
||||
}
|
||||
|
||||
get main(): boolean {
|
||||
return this.getInteger("Imain") != 0;
|
||||
}
|
||||
|
||||
set main(value: boolean) {
|
||||
this.setInteger("Imain", +value);
|
||||
}
|
||||
|
||||
public setIconPixmap(value: Pixmap): this {
|
||||
return this.setVoid("ViconPixmap", value);
|
||||
}
|
||||
|
||||
get iconPixmap(): Pixmap {
|
||||
return this.getVoid("ViconPixmap") as Pixmap;
|
||||
}
|
||||
|
||||
set iconPixmap(value: Pixmap) {
|
||||
this.setVoid("ViconPixmap", value);
|
||||
}
|
||||
|
||||
public setSizeHints(value: MwSizeHints): this {
|
||||
return this.setVoid("VsizeHints", value);
|
||||
}
|
||||
|
||||
get sizeHints(): MwSizeHints {
|
||||
return this.getVoid("VsizeHints") as MwSizeHints;
|
||||
}
|
||||
|
||||
set sizeHints(value: MwSizeHints) {
|
||||
this.setVoid("VsizeHints", value);
|
||||
}
|
||||
|
||||
public setHasBorder(value: boolean): this {
|
||||
return this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
get hasBorder(): boolean {
|
||||
return this.getInteger("IhasBorder") != 0;
|
||||
}
|
||||
|
||||
set hasBorder(value: boolean) {
|
||||
this.setInteger("IhasBorder", +value);
|
||||
}
|
||||
|
||||
public setInverted(value: boolean): this {
|
||||
return this.setInteger("Iinverted", +value);
|
||||
}
|
||||
|
||||
get inverted(): boolean {
|
||||
return this.getInteger("Iinverted") != 0;
|
||||
}
|
||||
|
||||
set inverted(value: boolean) {
|
||||
this.setInteger("Iinverted", +value);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ const structsOut = createWriteStream("lib/structs.ts");
|
|||
const enumsOut = createWriteStream("lib/enums.ts");
|
||||
const constantsOut = createWriteStream("lib/constants.ts");
|
||||
const widgetOut = createWriteStream("lib/widget.ts");
|
||||
const widgetsIndexOut = createWriteStream("lib/widgets/index.ts");
|
||||
|
||||
function toCamelCase(input) {
|
||||
const split = input.split("_");
|
||||
|
|
@ -250,7 +251,7 @@ function scanWidgets(root) {
|
|||
const lines = [];
|
||||
|
||||
const widgetFile = createWriteStream(
|
||||
join("lib/widgets/", toCamelCase(widgetName) + ".ts")
|
||||
join("lib/widgets/", widgetName.toLowerCase() + ".ts")
|
||||
);
|
||||
|
||||
// scan properties
|
||||
|
|
@ -310,8 +311,15 @@ function scanWidgets(root) {
|
|||
widgetFile.write(line);
|
||||
}
|
||||
|
||||
widgetsIndexOut.write(
|
||||
"export { " + widgetName + " } from \"./" +
|
||||
widgetName.toLowerCase() + "\"\n"
|
||||
);
|
||||
|
||||
widgetFile.close();
|
||||
}
|
||||
|
||||
widgetsIndexOut.close();
|
||||
}
|
||||
|
||||
function isArray(tagName) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue