Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module winglib.controls;
- private import core.runtime;
- private import core.sys.windows.windows;
- private import std.stdio;
- private import winglib.fonts;
- /// A base class for all controls
- class Control {
- import winglib.window : Window;
- import winglib.enums : ControlType ;
- /// Set the text of control
- @property void text(string value) {this.mText = value ;}
- /// Returns the control text
- @property string text() {return this.mText ;}
- /// Set the width of the control
- @property void width(int value) {this.mWidth = value ;}
- /// Return the width of control
- @property int width() {return this.mWidth ;}
- /// Set the height of control
- @property void height(int value) {this.mHeight = value ; }
- /// Returns the height of control
- @property int height() {return this.mHeight ;}
- /// Set the X position of control
- @property void xPos(int value) {this.mXpos = value ;}
- /// Return the x position of control
- @property int xPos() {return this.mXpos ; }
- /// Set the y position of control
- @property void yPos(int value) {this.mYpos = value ;}
- /// Returns the y position of control
- @property int yPos() {return this.mYpos ;}
- /// Returns the window handle
- @property HWND handle() {return this.mHandle ;}
- /// Set the name of the control
- @property void name(string value) {this.mName = value ;}
- /// Return the name of control
- @property string name() {return this.mName ; }
- ///
- @property void parent(Window value) {this.mParent = value ;}
- ///
- @property Window parent() {return this.mParent ;}
- @property ControlType controlType() {return this.mControlType;}
- @property Font font() {return this.mFont;}
- @property void font(Font value) {
- this.mFont = value;
- if(this.misHandleCreated) {
- this.setFont(); // This will create a font handle and send the WM_SETFONT msg to control/window.
- }
- }
- @property bool isHandleCreated() {return this.misHandleCreated;}
- //-------------------------------------------------------------------
- void hide(){ ShowWindow(this.mHandle, SW_HIDE);}
- void show(){ShowWindow(this.mHandle, SW_SHOW);}
- protected void setFont() {
- import winglib.commons : sendMsg;
- HFONT fontHandle = createFontHandle(this.mHandle,
- this.mFont.name,
- this.mFont.size,
- this.mFont.fontWeight,
- this.mFont.italics,
- this.mFont.underline);
- sendMsg(this.mHandle, WM_SETFONT, fontHandle, true);
- }
- //-------------------------------------------------------------
- protected :
- string mText ;
- int mWidth ;
- int mHeight ;
- int mXpos ;
- int mYpos ;
- HWND mHandle ;
- string mName ;
- Window mParent ;
- Font mFont;
- bool misHandleCreated;
- ControlType mControlType;
- }
Add Comment
Please, Sign In to add comment