? Midori-OS: API DEF reference ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Space-Restriction Challenge QSP Phase Ends on March 26!

Midori-OS: API DEF reference

This is a small reference page for Midori API. So you can continue the development without looking at the HELP app.

FUNCTIONS

General Usage

Initializes data on the window array, to render a window with the given parameters. Returns the ID of the generated window. ARGUMENTS: UNIQUE: Boolean that handles "instances" of the app. If enabled, only one window can render the app, and any attempt to open the same app again will show a error: TYPE: type of window to draw. 1 renders a window with a banner and canvas. 0 renders a window similar to a tooltip (grey and no banner). FNAME$: Name of the DEF to execute. On each frame, this DEF will be called. Be sure it has the correct format with the correct parameters. BANNERCOLOR: if TYPE equals 1, this sets the color of the banner. Any color code works. Use -1 to use the default color (blue). BCKCOLOR: if TYPE equals 1, this sets the color of the canvas. Any color code works. Use -1 to use the default color (white). POSX: Initial coordinate of the app on the X axis. When this function is executed, it will render the app on this given coordinate. POSY: Initial coordinate of the app on the Y axis. When this function is executed, it will render the app on this given coordinate. SIZEX: width in pixels of the app. If TYPE equals 1, it will set a minimun width which is determined by the length of NAME$. If the value is -1, it will render the app on fullscreen. SIZEY: height in pixels of the app. The minimum height is 32 pixels. If the value is -1, it will render the app on fullscreen. ID=APP_WINDOW_INIT(TYPE,FNAME$,NAME$,BANNERCOLOR,BCKCOLOR,POSX,POSY,SIZEX,SIZEY) Since the DEF returns the ID, you could manipulate that ID out of the DEF. Deletes data from the window array based on the provided window ID. It also resets app globals to their default value. This do not resets custom globals. ARGUMENTS: ID: ID of the window to destroy. APP_WINDOW_DESTROY ID Adds drag functionality to the window. The drag is done like any normal OS (hold left-click on the window banner, then move the cursor). This can (oddly) also be used with windows whose TYPE is 0. ARGUMENTS: ID: ID of the window to perform the drag. CRX: Cursor X coordinates. This is generated by GETPOINTERXY. CRX: Cursor Y coordinates. This is generated by GETPOINTERXY. STARTX: Start X coordinate of the window canvas. This is one of the parameters of template DEF. STARTY: Start Y coordinate of the window canvas. This is one of the parameters of template DEF. ENDX: End X coordinate of the window canvas. This is one of the parameters of template DEF. APP_DRAG ID,CRX,CRY,STARTX,STARTY,ENDX Creates a hitbox at the top-right side of the window, which executes APP_WINDOW_DESTROY when clicked. This is commonly used with windows whose TYPE equals 1. ARGUMENTS: ID: ID of the window to close. CRX: Cursor X coordinates. This is generated by GETPOINTERXY. CRX: Cursor Y coordinates. This is generated by GETPOINTERXY. STARTY: Start Y coordinate of the window canvas. This is one of the parameters of template DEF. ENDX: End X coordinate of the window canvas. This is one of the parameters of template DEF. APP_CLOSE_FUNC ID,CRX,CRY,STARTY,ENDX Function similar to APP_CLOSE_FUNC, but suspends the program instead. A program suspended stop its execution at the very moment it was suspended, it does not executes on the background. ARGUMENTS: ID: WID of the window to close. CRX: Cursor X coordinates. This is generated by GETPOINTERXY. CRX: Cursor Y coordinates. This is generated by GETPOINTERXY. STARTY: Start Y coordinate of the window canvas. This is one of the parameters of template DEF. ENDX: End X coordinate of the window canvas. This is one of the parameters of template DEF. APP_MINIMIZE WID, CRX, CRY, STARTY, ENDX Since v1.0 Function that checks if the window is at the "focus" of the user. Returns TRUE if the window with the ID is on focus, FALSE otherwise. This is commonly used to avoid stuff like clicks through windows. See the Example below. ARGUMENTS: ID: ID of the window to check the focus. A=ON_FOCUS(ID) EXAMPLES: IF ON_FOCUS(ID) && __ABTN2=#L THEN 'Goes here if user clicks, ONLY if the window is on focus. ENDIF Function that returns the pressed key from the keyboard. It works exactly as SmileBASIC's INKEY$() function. ARGUMENTS: none A$=GETKEY$() Function that returns TRUE on the first frame the app starts execution, and returns FALSE on the next subsequent frames the app is running. ARGUMENTS: ID: ID of the window. A=ON_OPEN(ID) EXAMPLES: TEMPLATE.PKG already has it. Is useful to initialize custom data: IF ON_OPEN(WID) THEN FILL DEF_ARRAY,0 'Custom GLOBAL ENDIF Since v1.0 Function that returns rendering information from a window based on the provided Window ID. ARGUMENTS: ID: ID of the window. RESULT: BNCL: Color of the Banner BNKCL: Color of the background POSX: Position of the window on the X axis. POSY: Position of the window on the X axis. SIZEX: Width of the window SIZEY: Height of the window TYPE: Type of window (1 or 0) If the window does not exist, all arguments returns -2. APP_WINDOW_INFO WID OUT BNCL, BCKCL, POSX, POSY, SIZEX, SIZEY, TYPE Since v1.0 Function that returns TRUE if there exist a window with the given Window ID. FALSE otherwise. ARGUMENTS: ID: ID of the window. A=IS_RUNNING(WID) Since v1.0

Utilities

Function that draws a button, and returns TRUE if the user clicks the button (BUTTON(3)). ARGUMENTS: X: Position on the X axis to place the button. Y: Position on the Y axis to place the button. W: Width of the button, in pixels. H: Height of the button, in pixels. PLACEHOLDER$: Text to draw inside the button. CRX: Cursor X coordinates. This is generated by GETPOINTERXY. CRY: Cursor Y coordinates. This is generated by GETPOINTERXY. A=BTN_BOX(X,Y,W,H,PLACEHOLDER$,CRX,CRY) EXAMPLES: Since BTN_BOX() returns TRUE when clicked, if you want to trigger an action it would be like this. IF BTN_BOX(X,Y,W,H,PLACEHOLDER$,CRX,CRY) THEN 'User clicked the button ENDIF Since v1.0 Function that spawn an Alert window, showing the provided message and title. ARGUMENTS: WID: ID of the window that invoked the alert. TITLE$: Title of the Alert window. MESSAGE$: Message to show on the window. SPAWN_ALERT WID, TITLE$, MESSAGE$ Since v1.0 Function that spawn a simple text form. The result of the form is stored at position 255 of the window that invoked the form. ARGUMENTS: WID: ID of the window that invoked the alert. PLACEHOLDER$: Text above the form that serves as a guide. SPAWN_TEXTFORM WID, PLACEHOLDER$ EXAMPLES: When submitted, the text of the form is stored on position 255 of the window that invoked the form. For example, if the window that invoked the form is 5, the result will be stored on VARS_STR$[5,255]. To check if the form was submitted or not, just simply check if VARS_STR$[WID,255] has something: IF LEN(VARS_STR$[WID,255]) THEN 'User submitted the form ENDIF Since v1.0

Cursor functions

Change the graphics of the cursor to its default graphic (pointer). ARGUMENTS: none CURSOR_DEFAULT Change the graphics of the cursor to a pointing hand. Useful to indicate links and buttons. ARGUMENTS: none CURSOR_CLICKABLE Change the graphics of the cursor to a text selector. ARGUMENTS: none CURSOR_TEXT Returns the XY coordinates of the cursor on screen. ARGUMENTS: none GETPOINTERXY OUT X, Y

App globals

Gets/sets information for the app to use outside the DEFs, this one holds numeric (either int of float). VARS_NUM is a 2D array which can be conveniently used by apps to store data. APP_WINDOW_DESTROY resets all the data from the window. Up to 256 slots can be used by a single app. ARGUMENTS: ID: ID of the window. SLOT: slot to set or get data from. VARS_NUM[ID,SLOT] EXAMPLES: 'Get data from slot 0 VAR L=VARS_NUM[ID,0] 'Set data to slot 0 VARS_NUM[ID,0]=L Gets/sets information for the app to use outside the DEFs, this one holds strings. VARS_STR$ is a 2D array which can be conveniently used by apps to store data. APP_WINDOW_DESTROY resets all the data from the window. Up to 256 slots can be used by a single app. ARGUMENTS: ID: ID of the window. SLOT: slot to set or get data from. VARS_STR$[ID,SLOT] EXAMPLES: 'Get data from slot 0 VAR D$=VARS_STR$[ID,0] 'Set data to slot 0 VARS_NUM$[ID,0]=D$

System globals

Variable that is used to get information from the buttons, regardless of the lag. EXAMPLES: IF __ABTN2==#L THEN 'Enters here if user clicks. ENDIF Boolean that enables/disables Window Fast Draw. Window Fast Draw is a mode that draws windows on a minimalistic way with less instructions. Can improve perfomace by a bit. Boolean that enables/disables sounds when opening and closing apps. Boolean that enables/disables sounds when touching the keyboard. Boolean that enables/disables cursor movement with the left stick. Variable that handles the color of the background. Variable that tells Midori to shut down. Depending on the value, it can either shutdown or reset. EXAMPLES: __SYSTEMSHUT=1 'Shutdown __SYSTEMSHUT=2 'Restart Variable that holds the button ID that will act as Left Click. Since v1.0 Variable that holds the button ID that will act as Right Click. Since v1.0 Variable that holds the button ID that will act as Enter. Since v1.0 Variable that holds the button ID that will act as Delete. Since v1.0
Author
Autz64
Updated
Rating
5 votes
Categories
Keywords
  • Midori
  • mock-OS
  • OS
  • Midori-OS
  • Autz
0 Comment(s)