/* 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. */ /* Creation of a slide bar with the 2d graphic api See http://www.scolring.org/files/doc_html/compslidebar_.html */ /* When the value of the slider changes (the user moves the cursor, by example), this reflex is called. The new value is displayed in a text field. Prototype : fun [CompSlideBar [ObjContainer CompText] I] I */ fun CBsliderChanged (objslider, user_parameter, newValue)= let user_parameter -> [container cValue] in ( _SETcompText cValue itoa newValue nil nil CT_END; _PAINTcontainer container; 0 );; /* Before to close the VM, all components and resources are destroyed. Prototype : fun [ObjWin [ObjContainer CompSlideBar CompText AlphaBitmap ObjFont]] I */ fun end (win, user_parameter)= let user_parameter -> [container cSlider cValue alphabitmap font] in ( _DScompSlideBar cSlider; _DScompText cValue; _DScontainer container; _DSalphaBitmap alphabitmap; _DSfont font; _closemachine );; /* Main function The grapic resource for the slider is loaded; A font reference is created; A window and a container are built; A slider bar and a text field are created Few callbacks are defined : - when the window is destroyed; - when the value of the slider has changed */ fun main ()= _showconsole; let _LDalphaBitmap _channel _checkpack "tutorials/slidebar/vslide.png" -> alphabitmap in let _CRfont _channel 14 0 0 "Arial" -> font in let _CRwindow _channel nil 50 50 250 450 WN_MENU " Example : Sliderbar" -> window in let _CRcontainerFromObjWin _channel window 0 0 250 450 CO_CHILDINSIDE 0x888888 "" -> container in let _CRcompSlideBar _channel container nil [10 20] OBJ_ENABLE|OBJ_VISIBLE|SLB_MASK|SLB_ROLLOVER 0 alphabitmap [13 373 386] SLB_VERTICAL 0 100 1 -> cSlider in let _CRcompText _channel container nil [50 20] OBJ_ENABLE|OBJ_VISIBLE|CT_LABEL 0 40 20 "0" font [0 0 0 0] nil nil nil -> cValue in ( _CBwinDestroy window @end [container cSlider cValue alphabitmap font]; _SETcompSlideBarValue cSlider 0; _CBcompSlideBarValue cSlider @CBsliderChanged [container cValue]; _PAINTcontainer container; 0 );;