lordbah@amusing.UUCP (Jeff Van Epps) (05/26/91)
Does anyone have an example using the RealTimeScroll function from req.library? I'm a true novice when it comes to Amiga-specific programming, and I can't get it to work at all. What I'm after is a scrollable text display box, and I thought that this function would make it easier. -------------------------------------------------------------------- Jeff Van Epps uunet!amusing!lordbah
S_ASCHMIDT@iravcl.ira.uka.de (|S| Angela Schmidt) (05/29/91)
In <lordbah.7498@amusing.UUCP> lordbah@amusing.UUCP writes: > Does anyone have an example using the RealTimeScroll function from > req.library? I'm a true novice when it comes to Amiga-specific > programming, and I can't get it to work at all. What I'm after is > a scrollable text display box, and I thought that this function > would make it easier. > > -------------------------------------------------------------------- > Jeff Van Epps uunet!amusing!lordbah Hello! One year ago I had the same problem as you! The documentation of the req.library was too inexact and so I didn't know how to use the function "RealTimeScroll". So I asked a friend to help me and we disassembled the library. With a bit luck, the filerequester of the req.library, which also uses req-scrollbars and softscroll, makes a library-call to use "RealTimeScroll". And he really did it in this way! So the routine must not be called in a private way and I could write these routines, using the calls I've learnt by disassembling the req.library. Note that this is no running code. Only an example, how I solved the problem. There has a lot of stuff been deleted, which you won't need. This code is a part from the disassembler of my diskmonitor "DisKey" (executable in comp.binaries.amiga). o / \ o ---><-8<--8<--8<--8<--8<--8<--8<-->8-->8-->8-->8-->8-->8-->8-><--- o \ / o struct ReqScrollStruct ScrollStruct; struct ScrollBlock ScrollBlock = {0}; struct NewWindow AsmNewWindow = { 0, 11, 640, 245, 0, 1, GADGETDOWN | CLOSEWINDOW | RAWKEY, SMART_REFRESH | ACTIVATE | WINDOWCLOSE | WINDOWDRAG, NULL, &HakenImage, NULL, NULL, NULL, 216, 75, NULL, NULL, WBENCHSCREEN }; void LargeScroll () { /* deleted. Insert your scrolling routine here. Refer to req.doc */ } void LittleScroll (firstlinenum, firstliney, scrollamount, numlines) register long firstlinenum; long firstliney, scrollamount, numlines; { /* deleted. Insert your scrolling routine here. Refer to req.doc */ } void The_main_problem () { register long StartAsm=0; if (ReqBase) { register long count = /* deleted - Number of entries */; { /* Initstuff for ScrollBlock */ register struct ScrollBlock *sb=&ScrollBlock; sb->ArrowUpLt.Activation |= GADGIMMEDIATE | RELVERIFY; sb->ArrowDnRt.Activation |= GADGIMMEDIATE | RELVERIFY; sb->ArrowUpLt.GadgetID=10; sb->ArrowDnRt.GadgetID=11; sb->Prop.Gadget.GadgetID=12; } if ((AsmWindow=(struct Window *) OpenWindow(&AsmNewWindow))==NULL) { /* Error */ return; } else { register struct Gadget *gg, *pressed=0L; register struct Window *asw=AsmWindow; /* Scrollbar will be added */ MakeScrollBar (&ScrollBlock, VERTSLIDER, asw->Height-asw->BorderTop-asw->BorderBottom-2, asw->BorderLeft+2, asw->BorderTop+1); ScrollBlock.Prop.Info.VertBody = SetSize (count, ((asw->Height-asw->BorderTop-1)>>FONTHEIGHTB)); ScrollBlock.Prop.Info.VertPot = SetLocation (count, ((asw->Height-asw->BorderTop-1)>>FONTHEIGHTB), 0); AddGList (asw, &(ScrollBlock.ArrowUpLt), 0, 3, 0L); RefreshGadgets (asw->FirstGadget, asw, NULL); { /* Init ScrollStruct */ register struct ReqScrollStruct *ss=&ScrollStruct; ss->TopEntryNumber=0; /* First number */ ss->NumEntries=count; /* Number of entries */ ss->LineSpacing=FONTHEIGHT; /* Height of one line */ ss->NumLines=((asw->Height-asw->BorderTop-1)>>FONTHEIGHTB); /* Number of entries that can be displayed */ ss->PropGadget=&(ScrollBlock.Prop.Gadget); ss->RedrawAll=LargeScroll; ss->ReadMore=NULL; ss->ScrollAndDraw=LittleScroll; ss->versionnumber=0; ss->rfu1=0; ss->rfu2=0; } LargeScroll (); /* Fill the window with the text */ do { Wait (1L<<asw->UserPort->mp_SigBit); /* Get Message */ while (AsmMsg=(struct IntuiMessage *) GetMsg(asw->UserPort)) { class=AsmMsg->Class; code =AsmMsg->Code; qual =AsmMsg->Qualifier; gg=(struct Gadget *) AsmMsg->IAddress; ReplyMsg (AsmMsg); switch (class) { case GADGETDOWN: /* Which of the three Gadgets was pressed? */ if (gg==&ScrollBlock.ArrowDnRt) { if (ScrollStruct.TopEntryNumber+ScrollStruct.NumLines<ScrollStruct.NumEntries) { ScrollBlock.Prop.Info.VertPot=SetLocation (ScrollStruct.NumEntries, ScrollStruct.NumLines, ScrollStruct.TopEntryNumber+1); NewModifyProp (ScrollStruct.PropGadget, asw, NULL, FREEVERT|AUTOKNOB, NULL, ScrollBlock.Prop.Info.VertPot, NULL, ScrollBlock.Prop.Info.VertBody, 1); RealTimeScroll (&ScrollStruct); } pressed=&ScrollBlock.ArrowDnRt; ModifyIDCMP(asw, GADGETUP | GADGETDOWN | CLOSEWINDOW | INTUITICKS | MOUSEBUTTONS | RAWKEY); } else if (gg==&ScrollBlock.ArrowUpLt) { if (ScrollStruct.TopEntryNumber>0) { ScrollBlock.Prop.Info.VertPot=SetLocation (ScrollStruct.NumEntries, ScrollStruct.NumLines, ScrollStruct.TopEntryNumber-1); NewModifyProp (ScrollStruct.PropGadget, asw, NULL, FREEVERT|AUTOKNOB, NULL, ScrollBlock.Prop.Info.VertPot, NULL, ScrollBlock.Prop.Info.VertBody, 1); RealTimeScroll (&ScrollStruct); } pressed=&ScrollBlock.ArrowUpLt; ModifyIDCMP(asw, GADGETUP | GADGETDOWN | CLOSEWINDOW INTUITICKS | MOUSEBUTTONS | RAWKEY); } else if (gg=&ScrollBlock.Prop.Gadget) RealTimeScroll (&ScrollStruct); break; case INTUITICKS: /* Gadget selected? So scroll! */ if (pressed) { if (((pressed->Flags)&SELECTED)==SELECTED) { int hv = 0; if (pressed==&ScrollBlock.ArrowDnRt) { if (ScrollStruct.TopEntryNumber+ScrollStruct.NumLines<ScrollStruct.NumEntries) hv=1; } else if (pressed==&ScrollBlock.ArrowUpLt) { if (ScrollStruct.TopEntryNumber>0) hv=-1; } if (hv) { ScrollBlock.Prop.Info.VertPot=SetLocation (ScrollStruct.NumEntries, ScrollStruct.NumLines, ScrollStruct.TopEntryNumber+hv); NewModifyProp (ScrollStruct.PropGadget, asw, NULL, FREEVERT|AUTOKNOB, NULL, ScrollBlock.Prop.Info.VertPot, NULL, ScrollBlock.Prop.Info.VertBody, 1); RealTimeScroll (&ScrollStruct); } } } break; case MOUSEBUTTONS: if (code==SELECTUP) { if (pressed) { pressed=0L; ModifyIDCMP (asw, GADGETDOWN | CLOSEWINDOW | RAWKEY); } } break; case GADGETUP: if (pressed) { pressed=0L; ModifyIDCMP (asw, GADGETDOWN | CLOSEWINDOW | RAWKEY); } break; /* You may delete this case if you don't need it! */ case RAWKEY: /* Scrolling with cursor keys */ if (!(code&IECODE_UP_PREFIX)) { register struct ReqScrollStruct *ss=&ScrollStruct; if (isshift (qual)) { register int myscroll=((((asw->Height-asw->BorderTop-1)>>3) - UEBERLAPPZEILE) > 1) ? (((asw->Height-asw->BorderTop-1)>>3) - UEBERLAPPZEILE) : 1; int hv=FALSE; if (code==0x4D) { if (ss->TopEntryNumber+ss->NumLines<ss->NumEntries) { ScrollBlock.Prop.Info.VertPot=SetLocation (ss->NumEntries, ss->NumLines, ss->TopEntryNumber + ( ss->TopEntryNumber+ss->NumLines<ss->NumEntries+myscroll ? myscroll : ss->NumEntries-(ss->TopEntryNumber+ss->NumLines) )); ss->TopEntryNumber += ((ss->TopEntryNumber+ss->NumLines+myscroll) < ss->NumEntries) ? myscroll : ss->NumEntries-(ss->TopEntryNumber+ss->NumLines); hv=TRUE; } } else if (code==0x4C) { if (ss->TopEntryNumber>0) { ScrollBlock.Prop.Info.VertPot=SetLocation (ss->NumEntries, ss->NumLines, ss->TopEntryNumber - ( ss->TopEntryNumber>myscroll ? myscroll : ss->TopEntryNumber)); ss->TopEntryNumber -= ss->TopEntryNumber>myscroll ? myscroll : ss->TopEntryNumber; hv=TRUE; } } if (hv) { NewModifyProp (ss->PropGadget, asw, NULL, FREEVERT|AUTOKNOB, NULL, ScrollBlock.Prop.Info.VertPot, NULL, ScrollBlock.Prop.Info.VertBody, 1); LargeScroll (); } } else { int hv=0; if (code==0x4D) { if (ss->TopEntryNumber+ss->NumLines<ss->NumEntries) hv=1; } else if (code==0x4C) { if (ss->TopEntryNumber>0) hv=-1; } if (hv) { ScrollBlock.Prop.Info.VertPot=SetLocation (ss->NumEntries, ss->NumLines, ss->TopEntryNumber+hv); NewModifyProp (ss->PropGadget, asw, NULL, FREEVERT|AUTOKNOB, NULL, ScrollBlock.Prop.Info.VertPot, NULL, ScrollBlock.Prop.Info.VertBody, 1); RealTimeScroll (ss); } } while ((struct Node *)(&asw->UserPort->mp_MsgList.lh_Head)!=asw->UserPort->mp_MsgList.lh_TailPred) { if ( (((struct IntuiMessage *)(asw->UserPort->mp_MsgList.lh_Head))->Code&(0x4C|IECODE_UP_PREFIX))==0x4C ) ReplyMsg (GetMsg (asw->UserPort)); else break; } } }; } } while (class!=CLOSEWINDOW); } } else { /* Error */ } } ---------------------------------------------------------+--------------------- Angela Schmidt Internet: S_ASchmidt@iravcl.ira.uka.de | // (Nessy in IRC) BITNET: UK8B@DKAUNI2.BITNET | Amiga // Phone: +49 731 712316 & 721 6904-263 | \\ // only 1000 MEZ: (10am-9pm) (12pm-10pm) | \X/ the real one! ---------------------------------------------------------+---------------------