program align,1.0(100) ! test alignment options for static & button text !------------------------------------------------------------------------ !{Edit History} ! 18-11-2007 --- 100 --- Jack McGregor ! Created to demonstrate static text and button alignment options ! ! ++include ashinc:ashell.def ! define standard WIN32 WINSTYLE flags used for button vertical alignment define BS_TOP = &h00000400 define BS_BOTTOM = &h00000800 define BS_VCENTER = &h00000C00 ! define standard WIN32 WINSTYLE flag used for static vertical centering define SS_CENTERIMAGE = &h0200 ! center text vertically, or image in both axes ! define standard WIN32 WINSTYLE flag to make edge of control visible define WS_THICKFRAME = &h040000 ! creates a raised panel effect define MBF_HCENTER = &h00C0 ! MBF_RTJUST_MBF_LFJUST map1 ctype,b,4 map1 text$,s,40 map1 exitcode,f map1 winstyle,b,4 ? tab(-1,0);"Alignment options for static text and buttons (see tooltips)" ! STATIC ALIGNMENT OPTIONS ------------------------------------------------- ! display 6 static text controls, each 3 rows high to show alignment ! -------------------------------------------------------------------------- ctype = MBF_STATIC+MBF_KBD winstyle = 0 ! left, top call do'control(3000,1,6000,21, ctype+MBF_LFJUST, "Top Left", "", winstyle, & "CTYPE=MBF_STATIC+MBF_LFJUST") ! center, top call do'control(3000,25,6000,45, ctype, "Top Center (Default)", "", winstyle, & "CTYPE=MBF_STATIC") ! right, top call do'control(3000,49,6000,69, ctype+MBF_RTJUST, "Top Right", "", winstyle, & "CTYPE=MBF_STATIC+MBF_RTJUST") ! left, vcenter winstyle = SS_CENTERIMAGE call do'control(7000,1,10000,21, ctype+MBF_LFJUST, "Vcenter Left", "", winstyle, & "CTYPE=MBF_STATIC+MBF_LFJUST; WINSTYLE=SS_CENTERIMAGE") ! hcenter, vcenter call do'control(7000,25,10000,45, ctype, "Vcenter, Hcenter", "", winstyle, & "CTYPE=MBF_STATIC; WINSTYLE=SS_CENTERIMAGE") ! right, vcenter call do'control(7000,49,10000,69, ctype+MBF_RTJUST, "Vcenter Right", "", winstyle, & "CTYPE=MBF_STATIC+MBF_RTJUST; WINSTYLE=SS_CENTERIMAGE") ! BUTTON ALIGNMENT OPTIONS ------------------------------------------------- ! display 9 button controls, each 2 rows high to show alignment ! -------------------------------------------------------------------------- ctype = MBF_BUTTON+MBF_KBD winstyle = BS_TOP ! call do'control(11000,1,13000,21, ctype+MBF_LFJUST, "Top Left", "", & winstyle, & "CTYPE=MBF_BUTTON+MBF_LFJUST; WINSTYLE=BS_TOP") ! center, top call do'control(11000,25,13000,45, ctype, "Top Center", "", winstyle, & "CTYPE=MBF_BUTTON; WINSTYLE=BS_TOP") ! right, top call do'control(11000,49,13000,69, ctype+MBF_RTJUST, "Top Right", "", winstyle, & "CTYPE=MBF_BUTTON+MBF_RTJUST; WINSTYLE=BS_TOP") winstyle = BS_VCENTER ! vertical centering (default, same as 0) ! call do'control(14000,1,16000,21, ctype+MBF_LFJUST, "Vcenter Left", "", & winstyle, & "CTYPE=MBF_BUTTON+MBF_LFJUST; WINSTYLE=BS_VCENTER(default)") ! center, top call do'control(14000,25,16000,45, ctype, "Vcenter Hcenter (default)", "", winstyle, & "CTYPE=MBF_BUTTON; WINSTYLE=BS_VCENTER(default)") ! right, top call do'control(14000,49,16000,69, ctype+MBF_RTJUST, "Vcenter Right", "", winstyle, & "CTYPE=MBF_BUTTON+MBF_RTJUST; WINSTYLE=BS_VCENTER(default)") winstyle = BS_BOTTOM ! call do'control(17000,1,19000,21, ctype+MBF_LFJUST, "Bottom Left", "", & winstyle, & "CTYPE=MBF_BUTTON+MBF_LFJUST; WINSTYLE=BS_BOTTOM") ! center, top call do'control(17000,25,19000,45, ctype, "Bottom Center", "", winstyle, & "CTYPE=MBF_BUTTON; WINSTYLE=BS_BOTTOM") ! right, top call do'control(17000,49,19000,69, ctype+MBF_RTJUST, "Bottom Right", "", winstyle, & "CTYPE=MBF_BUTTON+MBF_RTJUST; WINSTYLE=BS_BOTTOM") ! create an exit button xcall AUI, AUI_CONTROL, CTLOP_ADD, "exitbtn", "Exit", MBST_ENABLE, & MBF_BUTTON+MBF_KBD, "VK_ESC", NUL_FUNC$, NUL_CSTATUS, 22,30,23,40 ? tab(-1,29); ! turn cursor off (looks better) do ! wait for an event xcall AUI, AUI_EVENTWAIT, 0, 0, exitcode, EVW_NOFOCUS+EVW_DESCEND loop until exitcode = 1 ? tab(-1,0); ! (easy way to release all the resources) ? tab(-1,28); ! turn cursor back on End End !-------------------------------------------------------------------------- ! Procedure to display a single control (button or static) ! Params: ! srow,scol,erow,ecol [num, in] - coordinates ! ctype [b4, in] - flags ! text$ [string, in] - text for control ! parentid$ [string,in] - id of parent control ! winstyle [b4, in] - winstyle flags ! tooltip$ [string, in] - tooltip !-------------------------------------------------------------------------- Procedure do'control(srow as b2, scol as b2, erow as b2, ecol as b2, & ctype as b4, text$ as s80, parentid$ as s24, & winstyle as b4, tooltip$ as s80) Static map1 s_bgc, i, 4, NUL_BGC if ctype and MBF_STATIC then if s_bgc = NUL_BGC then s_bgc = &h0aabbcc else s_bgc = s_bgc + &h080402 endif else s_bgc = NUL_BGC endif xcall AUI, AUI_CONTROL, CTLOP_ADD, NUL_CTLID, text$, MBST_ENABLE, & ctype, "VK_F1", NUL_FUNC$, NUL_CSTATUS, & srow,scol,erow,ecol,NUL_FGC,s_bgc,NUL_FONTATTR,NUL_FONTSCALE, & NUL_FONTFACE$, tooltip$, parentid$, & NUL_WINCLASS$, winstyle End Procedure