CWindowBase

How to create a window class

If you succeed in compiling a window script , it generate the window binary file and the base file for using the window.

For example

#include "wr.h"
WINDOW(TEST) {
  ID = 255_000_00001;
  STYLE = NOTITLEBAR|ANCHOR_CENTER;
  POSITION = 0,-100;
  SIZE = 512,256;
};

TEXTBOX(Message) {
  ID = 000_000_00010;
  POSITION = 100,-80;
  CAPTION = 000_111_00020;
  EDIT = 255,2;
  SIZE = 380, 64;
};

CTestBase.cs is automatically generated after the compilation of CTest.wra .

public class TESTBase : CWindowBase {
    public const uint windowId = 4278190081;  // 255_000_00001
        static public TEST create(CWindowBase cParent = null) {
        return CWindowMgr.Instance.create<TEST>(windowId,cParent);
  }
  public const uint TEXTBOX_Message = 10;     // 000_000_00010
};

You make a window class that inherits CTestBase .

public class TEST : TestBase {
   :
};

Then ,when actually create the window, as follows .

TEST test = TEST.create();
  • The callback that reach to each window object

class CWindowBase

A window is composed by many controls.

If you perform operations as touch and drag to controls, the callback function in this window is called.

It enumerates callback functions that a window can receive.

You need to create new class which is inherited the class that is generated when you compile the script window. And you override callback functions in this new class.

virtual void onCreate ()

called immediately after the window has been initialized.

virtual void onUpdate ()

Called before each control update.

virtual void onAfterUpdate ()

Called after each control update.

virtual void onPreRender (CWindowRenderer cRenderer)

Called before each control render.

virtual onRender (CWindowRenderer cRenderer)

Called after each control render.

virtual Boolean onClose (Int32 iCloseInfo)

Called when the window is closed.

  • true: close window

  • false: Stop closing window

virtual void onClick (CWinCtrlBase cCtrl)

Control is pressed.

virtual void onHold (CWinCtrlBase cCtrl)

Control is hold.

virtual void onClickEnter (CWinCtrlBase cCtrl)

Input of edit box is confirmed.

virtual void onClick (CWinCtrlBase cCtrl, CRichTextOne cText)

A part of the rich text is pressed

virtual void onBeginDrag (CWinCtrlBase cCtrl, Vector2 pos)

The control is dragged. called once first when it is dragged.

virtual void onDrag (CWinCtrlBase cCtrl, Vector2 pos)

The control is being dragged. kept calling while dragging.

You can tell which direction a scrollable control has been dragged by onDrag.However, STYLE must have SCROLL_LOCK .onDrag can detect the direction of the drag.Note that DRAG does not affect these controls.

virtual Boolean onDragRender (CWinCtrlBase cCtrl, Transform transform)

When a control is being dragged, called the render timing. If not overridden, the control is rendered normally.

The return value has the following meaning:

  • true: Renders a duplicate of the control being dragged.

  • false: Do not render duplicates of the controls being dragged.

virtual void onDrop (CWinCtrlBase cCtrl, CWindowBase cDragWindow, CWinCtrlBase cDragCtrl)

When the control being dragged is released, it is called on the window containing the control that exists under the released location.

virtual void onDropGround (CWinCtrlBase cCtrl)

Called when control being dragged is released in empty space.

It is also called when the window containing the control being dragged has disappeared, just before the disappearance.

virtual void onOK (Int32 msgBoxWinID)

OK button was pressed in the message window that was created as a child window.

virtual void onNext (Int32 msgBoxWinID)

Next button was pressed in the message window that was created as a child window.

virtual void onYes (Int32 msgBoxWinID)

Yes button was pressed in the message window that was created as a child window.

virtual void onNo (Int32 msgBoxWinID)

No button was pressed in the message window that was created as a child window.

virtual void onCancel (Int32 msgBoxWinID)

Cancel button was pressed in the message window that was created as a child window.

virtual void onRecreatedRenderTexture (UInt32 mRenderTextureId)

It is called when a render texture disappears due to some event. However, since the automatic reset is performed by the system, it is not necessary to override the automatic reset.

  • Window property/method

I explain the accessible methods and properties of CWindowBase.

virtual Boolean onBeginRenderIcon (CWinCtrlRenderIcon icon)

Start rendering to the icon. CWinCtrlRenderIcon is called only when the window contains it.

Meaning of the return value of this function.

  • If you returns true, this control will render to the texture.

  • On the other hand, if you return a false, it does not render. And onEndRenderIcon is not called.

virtual Boolean onEndRenderIcon (CWinCtrlRenderIcon icon)

Called when rendering is finished. CWinCtrlRenderIcon is called only when the window contains it.

Meaning of the return value of this function.

  • If you return a true, rendering of the next frame is continued( onBeginRenderIcon is called at the next frame. ).

  • On the other hand, If you return a false, It is not rendered in the next frame.

If you want to resume the stopped rendering , you set the needToRender to true.

void close (Int32 iCloseInfo = 0)

Call when you want to close a window. iCloseInfo is passed as a parameter to onClose.

WinCtrl find<WinCtrl> (UInt32 id)

Find the control with that ID.

CWinCtrlBase find (UInt32 id)

Find the control with that ID.

UInt32 id { get; set; }

Get/Set the window ID.

CWindowBase child { get; }

return child window.

CWindowBase parent { get; }

return parent window.

e_LayerId layer { get; set; }

Get/Set rendering layer.

Int32 priority { get; set; }

Get/Set drawing priority.

UInt32 texid { get; set; }

return the default texture id of this window.

Single x { get; set; }
Single y { get; set; }

Get/Set window coordinate

Vector2 position { get; set; }

Get/Set window coordinate

Transform transform { get; }

Get transform of this window.

Vector2 scale { get; set; }

Get/Set x,y scale of this window.

e_Anchor anchor { get; set; }

Get/Set the display position anchor setting.

Single width { get; set; }
Single height { get; set; }

Get/Set this window size.

Vector2 size { get; set; }

Get/Set this window size.

Single screenWidth { get; set; }
Single screenHeight { get; set; }

Get/Set this window screen size.

String caption { get; set; }

Get/Set a title bar’s caption of this window.

WinColor captionColor { get; set; }

Get/Set a title bar’s color fo this window.

Vector2 captionOffset { get; set; }

Get/Set a title bar’s caption offset of this window.

WinColor color { get; set; }

Get/Set this window color. this color is all affect all contorl under the window.

e_WinStyle style { get; set; }

Get this window style.

e_WinStyle priorityStyle { get; set; }

Get/Set this window priority style.

Boolean hide { get; set; }
  • true

Hide window.

  • false

How to create a window class

Boolean disable { get; set; }
  • true

Stop a window from functioning and dim the window.

  • false

Display the window normally.

if stop a window from functioning, it won’t respond when you touch it.

Boolean isClose { get; }

True if the window is during close animation.

Boolean isLoaded { get; }

True if textures are being imported.

Boolean isFade { get; }

True if the window is fade-in/fade-out.

  • Other overridable methods

CWindowBase has overridable methods other than callback. You need to override when you want to customize the fade animation when creating the window or closing the window.

protected virtual void startFade (e_FadeState eState)

Called when a fade begins.The fade-in/fade-out can be determined by looking at e _ FadeState.Perform the initialization required for fade processing.

  • e_FadeState.Open

Fade-In

  • e_FadeState.Close

Fade-Out

protected virtual Boolean doFade (e_FadeState eState)

Called during fade.

  • true

Fading

  • false

Fade End

When the fade is finished, you need to return false.

Also, when e_FadeState.None is passed, it should return false.

  • e_FadeState.None

No Fading.

  • e_FadeState.Open

Fading In

  • e_FadeState.Close

Fading Out