program TSTCBZ2,1.0(105) ! show chkbox alignment options (enhanced) !---------------------------------------------------------------------- !Simple test/demo of checkboxes showing alignment options (both with !AUI,AUI_CONTROL and INFLD ! !Compile with COMPLP TSTCBZ2/M !---------------------------------------------------------------------- !EDIT HISTORY ![100] 18-Feb-05 Created /jdm ![101] February 11, 2006 03:04 PM Edited by joaquin ! Minor update to query/display values ![102] December 3, 2006 03:04 PM Edited by joaquin ! Add |G to the INFLD TYPE codes (don't assume it is set globally) ![103] December 22, 2006 04:25 PM Edited by joaquin ! Change checkbox #6 to a 3state ![104] March 17, 2007 10:08 PM Edited by joaquin ! Add MBF_MAXBUTTON (for testing) ![105] February 9, 2010 08:13 AM Edited by joaquin ! Remove dialog !---------------------------------------------------------------------- MAP1 STATE,F,6,0 MAP1 CMD$,S,32 MAP1 STATUS,F MAP1 X,F MAP1 A$,S,1 MAP1 WARNMSG$,S,300 MAP1 A,F MAP1 I,F MAP1 ROW,F MAP1 DLGID,B,2 MAP1 GRPID1,B,2 MAP1 GRPID2,B,2 MAP1 CB$(4),S,2 ! used for INFLD checkboxes MAP1 INXCTL,F MAP1 EXITCODE,F MAP1 USEDLG,B,1 ! [105] MAP1 COLOFF,B,1 ! [105] column adjustment for main window version MAP1 DROW,B,1 ! [105] map1 INFCLR ! [105] INFLD colors map2 DFCLR,B,1,-1 ! display fg map2 DBCLR,B,1,-1 ! display bg map2 EFCLR,B,1,-1 ! editing fg map2 EBCLR,B,1,-1 ! editing bg map2 NFCLR,B,1,-1 ! negatives fg map2 NBCLR,B,1,-1 ! negatives bg map2 UFCLR,B,1,-1 ! update fg map2 UBCLR,B,1,-1 ! update bg map2 MFCLR,B,1,-1 ! messages fg map2 MBCLR,B,1,-1 ! messages bg map2 OFCLR,B,1,-1 ! original messages fg map2 OBCLR,B,1,-1 ! original messages bg map2 FFCLR,B,1,-1 ! forms fg map2 FBCLR,B,1,-1 ! forms bg MAP1 CBX MAP2 CB(6),B,1 ! Button control vars MAP1 CBY,@CBX MAP2 CB1,B,1 ! We need to specify ordinary B,1 vars MAP2 CB2,B,1 ! to MIAMEX, at least as of 4.9(885) MAP2 CB3,B,1 MAP2 CB4,B,1 MAP2 CB5,B,1 MAP2 CB6,B,1 CB(1) = 1 ! Set some initial states CB(2) = 0 CB(3) = 1 CB(4) = 0 CB(5) = 1 CB(6) = 2 MAP1 CB2'OLD,B,1 CB2'OLD = CB(2) MAP1 ID(10),b,2 ! [101] use separate ID fields (needed for opcode 5) ++include ashinc:ashell.def ! must be 1.1(76) or higher on error goto TRAP xcall CCON ! enable controlc ? tab(-1,0);"Test checkboxes" input "Enter 0 for main window, 1 for dialog: [0] ",USEDLG ! [105] if USEDLG then ! [105] ! create a nice little dialog... ! (Note that remaining controls will belong by default to the ! dialog if it exists, else the main window) xcall AUI,AUI_CONTROL,CTLOP_ADD,DLGID,"CheckBox Alignment Options", & MBST_ENABLE, MBF_DIALOG+MBF_ALTPOS+MBF_SYSMENU+MBF_MAXBUTTON, & "","",STATUS,3,40,22,68 COLOFF = 1 ! [105] no col adjustment needed else COLOFF = 40 ! [105] move text messages over to avoid conflict ! [105] with fields in main window ? tab(2,1);tab(-1,10); ! [105] endif ! now create two groups within it... xcall AUI,AUI_CONTROL,CTLOP_ADD,GRPID1, & "Checkboxes created with AUI, CONTROL...", & MBST_ENABLE, MBF_GROUPBOX+MBF_LFJUST,"","", & STATUS,2,2,11,27 xcall AUI,AUI_CONTROL,CTLOP_ADD,GRPID2, & "Checkboxes created with INFLD...", & MBST_ENABLE, MBF_GROUPBOX+MBF_LFJUST,"","", & STATUS,12,2,18,27 ? tab(-1,11); ? tab(-1,29); ! turn off cursor (avoids some display bugs) xcall AUI,AUI_CONTROL,CTLOP_ADD,ID(1),"Left Text; Left Justify", & MBST_ENABLE,MBF_CHKBOX+MBF_LFTEXT+MBF_LFJUST,CMD$,CB1, & STATUS,2,2,2,24,67,-2, 0,0,"", "",GRPID1 xcall AUI,AUI_CONTROL,CTLOP_ADD,ID(2),"Left Text; Right Justify", & MBST_ENABLE,MBF_CHKBOX+MBF_LFTEXT+MBF_RTJUST,CMD$,CB2, & STATUS,3,2,3,24,67,-2, 0,0,"", "",GRPID1 ! add a horizontal dividing line for better visibility... xcall AUI,AUI_CONTROL,CTLOP_ADD,0,"",MBST_ENABLE,0,"","", & "",4,2,4,24,-2,-2, 0,0,"", "",GRPID1, & "STATIC",SS_BLACKRECT+SS_SUNKEN xcall AUI,AUI_CONTROL,CTLOP_ADD,ID(3),"Right Text; Left Justify", & MBST_ENABLE,MBF_CHKBOX+MBF_LFJUST,CMD$,CB3, & STATUS,5,2,5,24,67,-2, 0,0,"", "",GRPID1 xcall AUI,AUI_CONTROL,CTLOP_ADD,ID(4),"Right Text; Right Justify", & MBST_ENABLE,MBF_CHKBOX+MBF_RTJUST,CMD$,CB4, & STATUS,6,2,6,24,67,-2, 0,0,"", "",GRPID1 ! add a horizontal dividing line for better visibility... xcall AUI,AUI_CONTROL,CTLOP_ADD,0,"",MBST_ENABLE,0,"","", & "",7,2,7,24,-2,-2, 0,0,"", "",GRPID1, & "STATIC",SS_BLACKRECT+SS_SUNKEN xcall AUI,AUI_CONTROL,CTLOP_ADD,ID(5),"Left Text; Center Justify", & MBST_ENABLE,MBF_CHKBOX+MBF_LFTEXT,CMD$,CB5, & STATUS,8,2,8,24,67,-2, 0,0,"", "",GRPID1 xcall AUI,AUI_CONTROL,CTLOP_ADD,ID(6),"Right Text; Center Justify", & MBST_ENABLE,MBF_3STATE,CMD$,CB6, & STATUS,9,2,9,24,67,-2, 0,0,"", "",GRPID1 ! [103] xcall INFLD,2,2,23,0,"|G||c",CB$(1),INXCTL,GRPID2+1,2,EXITCODE, & 0,0,-1,-1,-1,"Left Text; Left Justify" xcall INFLD,3,2,23,0,"|G||c|J",CB$(2),INXCTL,GRPID2+1,2,EXITCODE, & 0,0,-1,-1,-1,"Left Text; Right Justify" ! add a horizontal dividing line for better visibility... xcall AUI,AUI_CONTROL,CTLOP_ADD,0,"",MBST_ENABLE,0,"","", & "",4,2,4,24,-2,-2, 0,0,"", "",GRPID2, & "STATIC",SS_BLACKRECT+SS_SUNKEN xcall INFLD,5,2,23,0,"|G||cR",CB$(1),INXCTL,GRPID2+1,2,EXITCODE, & 0,0,-1,-1,-1,"Right Text; Left Justify" xcall INFLD,6,2,23,0,"|G||cR|J",CB$(2),INXCTL,GRPID2+1,2,EXITCODE, & 0,0,-1,-1,-1,"Right Text; Right Justify",INFCLR xcall AUI,AUI_CONTROL,CTLOP_ADD,0,"OK", & MBST_ENABLE,MBF_BUTTON+MBF_KBD,"%VK_ENTER%","", & STATUS,19,22,19,27 ! now wait for the user to hit the ok button ! we could do this with EVENTWAIT, or INFLD, but in this case ! it would be even simpler to just use xcall ACCEPN xcall NOECHO ? tab(-1,29); ! turn cursor off OKLOOP: xcall ACCEPN,A if A#13 goto OKLOOP OKDONE: xcall ECHO ? tab(-1,28); ! cursor back on QUERY: ! query the checkboxes and display the values DROW = 3 ! [105] ? tab(DROW,COLOFF);"Querying checkboxes..." ! [105] add tab(DROW,COLOFF) DROW = DROW + 1 ! [105] ! first, the non-INFLD ones: these are easy because we ! have the control ID numbers in ID(x) ? tab(DROW,COLOFF);"Non-INFLD checkboxes:" DROW = DROW + 1 ! [105] for I = 1 to 6 ? tab(DROW,COLOFF);" ID";ID(I);": "; DROW = DROW + 1 ! [105] xcall AUI,AUI_CONTROL,CTLOP_QRYCB,ID(I),"",0,0,"","",STATUS ? STATUS next I ? DROW = DROW + 1 ! [105] ? tab(DROW,COLOFF);"INFLD checkboxes: " DROW = DROW + 1 ! [105] ! for these, we have to first use opcode CTLOP_GETID to get the ! control ID (using the original coordinates). Also note that ! we must specify the parent ID (GRPID2) or the coordinates ! won't match for I = 7 to 10 if I <= 8 then ROW = I-5 else ROW = I-4 xcall AUI,AUI_CONTROL,CTLOP_GETID,0,"",0,0,"","", & STATUS,ROW,2,ROW,24,-2,-2,0,0,"","",GRPID2 if STATUS > 0 then ID(I) = STATUS else ? tab(DROW,COLOFF);"Unable to get ID of INFLD checkbox" DROW = DROW + 1 ! [105] endif ? tab(DROW,COLOFF);" ID";ID(I);": "; xcall AUI,AUI_CONTROL,CTLOP_QRYCB,ID(I),"",0,0,"","",STATUS ? STATUS DROW = DROW + 1 next I ? DROW = DROW + 1 ! [105] ? tab(23,1); stop if USEDLG then ! [105] ! now delete the dialog xcall AUI,AUI_CONTROL,CTLOP_DEL,DLGID else ? tab(-1,0); endif end TRAP: ? tab(22,1);tab(-1,10);"Error #";ERR(0) ? tab(-1,28); ! turn cursor back on xcall ECHO end