/* Copyright (C) 2011, Stephane Bisaro, aka iri License : you can do what you want with this source code This code is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ /* How to create a no-square window in Scol with the 2dGraphic API ? This API is the most commonly used to build this style of window. 1 - Create a window. You must set the flag to WN_TRANSPARENCY. 2 - Add in the window a container. 3 - Load or create an AlphaBitmap to the background. Either a transparency color or an alpha layer or both to define the transparent zone and the opaque zone. Black and white are often used. 4 - Add a CompBitmap object with this background in the container 5 - Set the function _SETcontainerTransparency 6 - Paint the container The flag WN_TRANSPARENCY is imperative, otherwise the window doesn't transparent. Usually, others falgs are useless. Of course, in this case, you must code all user interactions : close and move window for example. In this example, click in the window to close it et destroy the VM. */ /* The user has clicked in the window (the background) : all resources and objects are destroyed and the VM is closed Prototype : fun [ObjContainer [ObjWin CompBitmap AlphaBitmap] I I I I] I */ fun CBclick (objcontainer, user_parameter, xclick, yclick, btnmouse, maskmouse)= let user_parameter -> [window background png] in ( _DScompBitmap background; _DSalphaBitmap png; _DScontainer objcontainer; _DSwindow window; _closemachine );; /* Main function. See comment above Prototype : fun [] I */ fun main ()= _showconsole; let _CRwindow _channel nil 50 50 405 336 WN_TRANSPARENCY " Examples > Window > Nosquare" -> window in // the flag NO_BORDER remove the ... border (the line) around the container because this is visible otherwise let _CRcontainerFromObjWin _channel window 0 0 405 336 CO_CHILDINSIDE|CO_NOBORDER 0 "" -> container in let _LDalphaBitmap _channel _checkpack "tutorials/window/nosquare.png" -> png in let _CRcompBitmap _channel container nil [0 0] OBJ_ENABLE|OBJ_VISIBLE OBJ_CONTAINER_CLICK png 0 0 405 336 -> background in ( _CBcontainerClick container @CBclick [window background png]; _SETcontainerTransparency container 0xffffff nil WN_TRANS_COLOR; _PAINTcontainer container; 0 );;