keep WINDOWS **************************************************************** * ChemiGS * **************************************************************** * A Drawing Program for Chemical Structures * * (c) 1992-93 by Urs Hochstrasser * * Buendtenweg 6 * * 5105 AUENSTEIN (SWITZERLAND) * **************************************************************** * Module WINDOWS **************************************************************** * * USES ... * mcopy windows.macros copy equates.asm **************************************************************** * * Window stuff * DrawToolWin start Tool window content draw defProc using Globals phd save caller's DP phb save caller's Data Bank phk Data Bank := Pgm Bank plb * ph4 #0 * ~LoadResource #rPicture,#kToolPicID * pl4 toolPic * ~DrawPicture toolPic,#destRect ~DrawControls gToolWin lda gToolID jsl HiliteSelection plb restore caller's Data Bank pld restore caller's DP rtl *ToolPic ds 4 *destRect dc i2'0' top 13 * dc i2'0' left 2 * dc i2'179' bottom 31 45 156 * dc i2'64' right 512 626 UpdateToolWin entry ~BeginUpdate gToolWin jsl DrawToolWin ~EndUpdate gToolWin rts HiliteSelection entry * --------------------------------------- * Input : Tool Number in A * Output: none * Action: Invert Tool in Toolbar * --------------------------------------- stz xOffset initialize x offset for tool hilite cmp #11 bcc left ldy #32 it's in the right column sty xOffset sec sbc #11 left asl a Tool number * 16 -> y coordinate asl a asl a asl a clc *** New: adc TBOffset *** New: add title Bar offset sta yOffset clc adc #15 hilight is 15 pixels high sta bottom lda xOffset clc adc #30 ...and 30 wide sta right ~InvertRect #myRect rtl myrect anop yOffset ds 2 xOffset ds 2 bottom ds 2 right ds 2 end DrawEaster start using Globals ~BeginUpdate gEasterWin ~DrawControls gEasterWin ~EndUpdate gEasterWin rtl end DrawDataContent start Data Window content draw defProc using Globals phd save caller's DP phb save caller's Data Bank phk Data Bank := Pgm Bank plb jsr displayIt in 'TOOLS' plb restore caller's Data Bank pld restore caller's DP rtl end DrawInfoBar start using Globals theWindow equ 6 Offset to the infoBar owner window infoRefCon equ theWindow+4 Offset to the window's infoBarRefCon infoRect equ infoRefCon+4 Offset to the infoBar's enclosing RECT phd save current DP tsc tcd switch to DP in stack ldy #0 *** new: save InfoRect into gInfoRect lda [14],y sta gInfoRect iny iny lda [14],y sta gInfoRect+2 iny iny lda [14],y sta gInfoRect+4 iny iny lda [14],y sta gInfoRect+6 *** end new * ------------------- individual routine ----------------- * ph4 #0 * ~LoadResource #rPicture,#kButtonBarID * pl4 btnPic besser in InfoRefCon speichern * ~DrawPicture btnPic,#btnRect * ------------------- Remove input parameters from stack ply pull original DP, save in y lda 2,s Move RTL addr down over inp parms sta 14,s lda 0,s sta 12,s tsc now move SP over inp parms clc adc #12 add number input parm bytes to SP tcs and reset stack tya restore original DP tcd rtl back to Window Mgr btnRect dc i2'13,2,30,552' destRect for Button Bar (0,0,16,549) btnPic ds 4 end HandleInfo start * using Globals * ~StartInfoDrawing #gInfoRect,gDataWin * ~EndInfoDrawing rts end HandleRuler start using Globals * ~StartDrawing gEditWindow move4 gMainEvt+owhere,myPoint ~GlobalToLocal #myPoint pha ~PtInRect #myPoint,#XRect pla beq l1 ~InvertRect #XRect l1 pha ~PtInRect #myPoint,#OKRect pla beq l2 ~InvertRect #OKRect l2 pha ~PtInRect #myPoint,#EditRect pla beq l3 ~InvertRect #EditRect l3 pha ~PtInRect #myPoint,#DirRect pla beq l4 ~InvertRect #DirRect l4 pha ~PtInRect #myPoint,#PSRect pla beq l5 ~InvertRect #PSRect l5 pha ~PtInRect #myPoint,#CRect pla beq l6 ~InvertRect #CRect l6 pha ~PtInRect #myPoint,#HRect pla beq l7 ~InvertRect #HRect l7 pha ~PtInRect #myPoint,#ORect pla beq l8 ~InvertRect #ORect l8 pha ~PtInRect #myPoint,#NRect pla beq l9 ~InvertRect #NRect l9 pha ~PtInRect #myPoint,#SRect pla beq l10 ~InvertRect #SRect l10 pha ~PtInRect #myPoint,#PRect pla beq l11 ~InvertRect #PRect l11 pha ~PtInRect #myPoint,#PopRect pla beq l12 ~InvertRect #PopRect l12 anop * ~SetOrigin #0,#0 rts myPoint ds 4 theWindow ds 4 XRect dc i2'16,8,27,30' OKRect dc i2'16,32,27,54' EditRect dc i2'16,56,27,180' DirRect dc i2'16,182,27,204' PSRect dc i2'16,211,27,245' CRect dc i2'16,247,27,269' HRect dc i2'16,271,27,293' ORect dc i2'16,295,27,317' NRect dc i2'16,319,27,341' SRect dc i2'16,343,27,365' PRect dc i2'16,367,27,387' PopRect dc i2'16,396,27,546' end *GetDataMem start Get Memory for File Data * using Globals * ph4 #0 * ~NewHandle gMemSize,gMyID,#0,#0 * sta gToolErr * pl4 gDataHandle * rts * end remember to check for errors on return! OpenWindow start using Globals jsr EndText * jsr SetTheFont *wirkts? ph4 #0 ~NewWindow2 #0,#0,#0,#0,#RefIsResource,#kDataWID,#rWindParam1 pl4 gDataWin ph4 #0 ~GetPort pl4 thePort lda fCacheWins bne ow1 brl noCache ow1 anop ph4 #0 ~NewHandle #$10000,gMyID,#attrLocked,#0 sta gToolErr pl4 picHandle jsr Error bcc offPok2 stz fCacheWins * Could not allocate Mem -> no cache brl noCache offPok2 ph4 #0 ~NewHandle #170,gMyID,#attrLocked,#0 sta gToolErr pl4 theHandle jsr Error bcc offPok stz fCacheWins * Could not allocate Mem -> no cache brl noCache offPok anop _Deref picHandle,ptrToPixImage _Deref theHandle,gOffPort ~OpenPort gOffPort init offscreen port (becomes current) lda masterSCB sta portSCB ~SetPortLoc #locInfo sta gToolErr * jsr Error * ~GetPortRect #cleanRect sta gToolErr * jsr Error * ~SetSolidBackPat #$F sta gToolErr * * ~SysBeep jsr Error * ~EraseRect #cleanRect ~PenNormal noCache anop lda #-kRulerH sta gYoffset stz gXoffset lda #kDataWidth sta gDocW lda #kDataHeigth sta gDocH ~StartDrawing gDataWin ~SetPort thePort ***************** THIS STUFF NEVER USED ***************************** * ph4 #0 * ~LoadResource #rPicture,#kButtonBarID * pl4 btnPic * ~DrawPicture btnPic,#btnRect * ~PenNormal * ~MoveTo #portRect+2,#15 draw ruler's border line * ~LineTo #portRect+6,#15 * ~SetOrigin #0,#0 * ~SetInfoDraw #DrawInfoBar,gDataWin * ~SetDataSize #kDataWidth,#kDataHeigth,gDataWin * ~SetScroll #64,#32,gDataWin ~SetContentDraw #DrawDataContent,gDataWin ~SetWTitle gTitlePtr,gDataWin ph4 #0 ~GetCtlHandleFromID gDataWin,#TEditID pl4 LEditH * henriks code * lda LEditH * ldy LEditH+2 * brk 0 ph4 #0 ~GetCtlHandleFromID gDataWin,#hScrlID pl4 hScrollH ph4 #0 ~GetCtlHandleFromID gDataWin,#vScrlID pl4 vScrollH ph4 #0 ~GetCtlHandleFromID gDataWin,#MountnID pl4 MountnH ph4 #0 ~GetCtlHandleFromID gDataWin,#SizeBxID pl4 sizeBoxH ph4 #0 ~GetCtlHandleFromID gDataWin,#TBarCID inactive ToolBar Pict Ctl pl4 TBarH jsr SetMinGrow Set minV,minH in ctlData of SizeBox ~HideControl LEditH **** TEControl Record = TERecord !!! **** * _SetField LEditH,#$C8,#KeyFilter,#4 ~ShowWindow gDataWin * ~SysBeep rts portRect ds 8 btnRect dc i2'0,0,17,639' destRect for Button Bar (0,0,16,549) btnPic ds 4 most recent: 0,0,17,550 thePort ds 4 theRgn ds 4 cleanRect ds 8 theHandle ds 4 end SetMinGrow start using Globals ~SetCtlTitle #$00CC0044,sizeBoxH ;LoWrd=minH=68; HiWrd=minW=204 rts end DrawTopWindow start * ~SetForeColor #0 * ~SolidPattern #0,myPattern * ~SetPenPat myPattern * ~SetPenSize #1,#1 * ~FrameOval #myRect * ~SetFontID #0 * ~SetPenMode #modeForeCopy * ~MoveTo #150,#200 * ~DrawCString #myString rts myPattern ds 32 myRect dc i2'10' top dc i2'10' left dc i2'388' bottom dc i2'580' right myString dc c'Hello, old friend!!!',h'0D00' end HandleContent start using Globals using Version **only for easter window cmp4 gTaskDta,gToolWin bne l1 jsr doTool rts l1 anop cmp4 gTaskDta,gDataWin beq sameDataWin jsr SelDataWin bra exit sameDataWin anop jsr doDataWin in Module TOOLS exit rts SelDataWin entry jsr EndText ph4 #0 ~GetWRefCon gDataWin pl4 theHandle sta gToolErr **** test ~PtrToHand #FileInfo,theHandle,#FInfoSize sta gToolErr **** test ~SelectWindow gTaskDta if not tool window, hilight it ph4 #0 ~GetWRefCon gTaskDta pl4 theHandle ~HandToPtr theHandle,#FileInfo,#FInfoSize * move4 gTaskDta,gDataWin **** eigentlich ueberfluessig... jsr Error **** test jsr EndText rts doTool anop it's the Tool window, so handle it lda gToolID sta oldToolID ph4 #0 ~GetPort pl4 tmpPort ~SetPort gToolWin move4 gMainEvt+owhere,myPoint ~GlobalToLocal #myPoint lda myPoint cmp TBOffset if myPoint < TBOffset: in Tool Title bcc doTTitle cmp #178 is it past the last window bcs doEaster brl l3 doEaster ph4 #0 ~FrontWindow pl4 theWindow lda theWindow cmp gEasterWin bne notInFront lda theWindow+2 cmp gEasterWin+2 bne notInFront brl l4 doTTitle anop Handle Tool Title rts notInFront ~BringToFront gEasterWin l4 ~ShowHide #1,gEasterWin ~StartDrawing gEasterWin ******************************************** START OF TEST STUFF **** ~MoveTo #0,#8 ~DrawString #testTitle ~DrawString gTitlePtr ~MoveTo #0,#20 lda fSaved beq tst1 ~DrawString #fsStr tst1 ~MoveTo #0,#28 lda fNamed beq tst2 ~DrawString #fnStr tst2 ~MoveTo #0,#36 lda fFullAccess beq tst3 ~DrawString #ffStr tst3 ~MoveTo #0,#44 lda fOpened beq tst4 ~DrawString #foStr tst4 ~MoveTo #0,#52 ~MoveTo #0,#60 ~Int2Hex gRefNum,#rfStr+10,#4 ~DrawString #rfStr ~MoveTo #0,#68 ~Int2Hex gDataWNum,#wnStr+15,#4 ~DrawString #wnStr ~MoveTo #0,#76 *** new... ~Int2Dec dPortRect,#prString+11,#5,#1 ~Int2Dec dPortRect+2,#prString+17,#5,#1 ~Int2Dec dPortRect+4,#prString+23,#5,#1 ~Int2Dec dPortRect+6,#prString+29,#5,#1 ~DrawString #prString ~MoveTo #0,#84 ~Int2Dec winW,#wwhString+9,#5,#1 ~Int2Dec winH,#wwhString+15,#5,#1 ~DrawString #wwhString *** ...end new ~MoveTo #0,#160 ~DrawString #VersionStr ***************************************** END OF TEST STUFF **** * ~DrawControls gEasterWin ~SetOrigin #0,#0 loop pha ~StillDown #0 pla bne loop ~ShowHide #0,gEasterWin brl exit2 l3 anop myPoint y coordinate of mouse loc sec sbc TBOffset * New: substract Title Bar offset lsr a divide by 8 -> offset into jsr-Table lsr a lsr a lsr a sta gToolID asl a tax lda myPoint+2 x coordinate cmp #32 is it in the right column? bcc ok no txa clc adc #22 'offset offset' for right column lsr a sta gToolID ok lda oldToolID jsl HiliteSelection lda gToolID jsl HiliteSelection jsr DoTheTool exit2 ~SetPort tmpPort jsr UpdateToolWin update hilight rts testTitle dw 'FILE INFO ON: ' fsStr dw 'SAVED' fnStr dw 'NAMED' ffStr dw 'FULL ACCESS' foStr dw 'OPENED' rfStr dw 'RefNum: ' wnStr dw 'Open Windows: ' prString dw 'PortRect: , , , ' wwhString dw 'winW,H: , ' doTheTool entry lda gToolID asl a tax jsr (toolTable,x) lda gToolID cmp #TextToolID beq textOk jsr EndText textOK anop rts HandTool entry jsr HandCursor rts EraseTool entry jsr EraseCursor rts SingleBTool entry jsr CrossCursor rts DoubleBTool entry jsr CrossCursor rts HatchBTool entry jsr CrossCursor rts WedgeBTool entry jsr CrossCursor rts MarqueeTool entry jsr ArrowCursor ~InitCursor rts TextTool entry jsr TextCursor rts DottedBTool entry jsr CrossCursor rts TripleBTool entry jsr CrossCursor rts WHatchTool entry jsr CrossCursor rts CChainTool entry jsr CrossCursor rts toolTable anop *------------------------------------------------- dc i2'HandTool' 0 dc i2'EraseTool' 1 dc i2'SingleBTool' 2 dc i2'DoubleBTool' 3 dc i2'HatchBTool' 4 dc i2'WedgeBTool' 5 dc i2'doCycloPropane' 6 dc i2'doCycloPentane' 7 dc i2'doCycloHexane' 8 dc i2'doBenzene' 9 dc i2'doSeat' 10 * -------------------------------------------- dc i2'MarqueeTool' 11 dc i2'TextTool' 12 dc i2'DottedBTool' 13 dc i2'TripleBTool' 14 dc i2'WHatchTool' 15 dc i2'CChainTool' 16 dc i2'doCycloButane' 17 dc i2'doCycloPentane2' 18 dc i2'doBenzene2' 19 dc i2'doWheeland' 20 dc i2'doBasin' 21 dc i2'Ignore' dummy dc i2'Ignore' dummy tmpPort ds 4 myPoint ds 4 theWindow ds 4 theHandle ds 4 testit ~SysBeep rts end