static void EntryChosen(struct Control* control, int index) { struct VerticalScrollControl* VBox = (struct VerticalScrollControl*)control->ControlData; struct LowView* LView = (struct LowView*) VBox->ControlData; int count = GetLastHelpTop(0), line, middle; if (count < 2) return; line = (((index * 100) / (VBox->BarY2 - VBox->BarY1)) * count) / 100; // See if the line can be put in the middle of the control middle = (VBox->ylen-2)/2; if (line < middle) { // The line is above the middle of the first screen full LView->top = 0; } else if (PastEndOfHelp(line+1, middle)) { // If not show the last entries with the cursor on the indicated line. LView->top = GetLastHelpTop(VBox->ylen-2); } else { // Put the line in the middle of the control LView->top = line - middle; } FillControl(control, LView->top); VBox->AdjustScrollBar(control, LView->top, GetLastHelpTop(VBox->ylen-2)+1); }
static int OnClick(struct Control* control) { int index; struct VerticalScrollControl* VBox = (struct VerticalScrollControl*)control->ControlData; struct LowView* LView = (struct LowView*) VBox->ControlData; if ((index = CheckHelpClick(control->posx+1, control->posy+1, VBox->xlen-2, VBox->ylen-2, GetPressedX(), GetPressedY(), LView->top)) != -1) { SelectHelpPage(index); FillControl(control, 0); LView->top = 0; return EVENT_ANSWERED; } else return NOT_ANSWERED; }
static int HandleEvent(struct Control* control, int event) { int index; static int PreviousHelpLine = -1; struct VerticalScrollControl* VBox = (struct VerticalScrollControl*)control->ControlData; struct LowView* LView = (struct LowView*) VBox->ControlData; if (control->active) switch (event) { case PAGEDOWN: { int ltop = GetLastHelpTop(VBox->ylen-2); if (ltop != LView->top) { if (PastEndOfHelp(LView->top + VBox->ylen - 2, VBox->ylen-2)) LView->top = ltop; else LView->top += VBox->ylen - 2; FillControl(control, LView->top); } } break; case PAGEUP: if (LView->top != 0) { if (LView->top > VBox->ylen - 2) LView->top -= (VBox->ylen - 2); else LView->top = 0; FillControl(control, LView->top); } break; case HOME: if (LView->top != 0) { LView->top = 0; FillControl(control, LView->top); } break; case END: { int ltop = GetLastHelpTop(VBox->ylen-2); if (LView->top != ltop) { LView->top = ltop; FillControl(control, LView->top); } } break; case TABKEY: { int line; line = CheckHelpTab(LView->top, VBox->ylen-2); if (line != -1) DrawHelpLine(line, control->posx+1, control->posy+1+(line-LView->top), VBox->xlen-1); if ((PreviousHelpLine != -1) && (PreviousHelpLine != line) && (PreviousHelpLine >= LView->top) && (PreviousHelpLine < LView->top+VBox->ylen-2)) DrawHelpLine(PreviousHelpLine, control->posx+1, control->posy+1+(PreviousHelpLine-LView->top), VBox->xlen-2); PreviousHelpLine = line; } break; case ENTERKEY: if ((index = CheckHelpEnter(LView->top, VBox->ylen-2)) != -1) { SelectHelpPage(index); FillControl(control, 0); LView->top = 0; } break; case ALT_F1: { int previous; index = GetHelpIndex(); previous = PreviousHelpIndex(); if (index != previous) { SelectHelpPage(previous); FillControl(control, 0); LView->top = 0; } } default: return NOT_ANSWERED; } VBox->AdjustScrollBar(control, LView->top, GetLastHelpTop(VBox->ylen-2)+1); return EVENT_ANSWERED; }
/*>HandleEvent(APTR object) ------------------------ Dispatch menu events. 12.03.92 Original. 30.03.92 Modified MenuEdit to call OpenFile() directly. 31.03.92 Modified MenuSave to call SaveAsFile() directly. 05.05.92 Added Rexx menu handling 12.06.92 Removed fill grey/hatch items and replaced with requester 02.07.92 Added MenuPalette 13.07.92 Added MenuScrBack 20.07.92 Added DEMO_VERSION conditional 07.08.92 Added RemoveFills() */ HandleEvent(APTR object) { if(object == (APTR)MenuOpen) { OpenFile(object); return(0); } if(object == (APTR)MenuSave) { SaveAsFile(object); return(0); } if(object == (APTR)MenuSaveAs) { SaveAsFile(object); return(0); } if(object == (APTR)MenuEdit) { OpenFile(object); return(0); } if(object == (APTR)MenuPaper) { SetPaper(object); return(0); } if(object == (APTR)MenuSetPens) { SetPens(object); return(0); } if(object == (APTR)MenuPalette) { SetPalette(object); return(0); } if(object == (APTR)MenuScrBack) { ScreenToBack(MyScreen); return(0); } if(object == (APTR)MenuAbout) { About(object); return(0); } if(object == (APTR)MenuQuit) { QuitProgram(object); return(0); } #ifndef DEMO_VERSION if(object == (APTR)MenuPS) { PlotPS(object); return(0); } if(object == (APTR)MenuHPGL) { PlotHPGL(object); return(0); } if(object == (APTR)MenuDR2D) { PlotDR2D(object); return(0); } #endif if(object == (APTR)MenuXY) { StyleXY(object); return(0); } if(object == (APTR)MenuScatter) { StyleScatter(object); return(0); } if(object == (APTR)MenuBar) { StyleBar(object); return(0); } if(object == (APTR)MenuPie) { StylePie(object); return(0); } if(object == (APTR)MenuErrors) { ToggleErrors(object); return(0); } if(object == (APTR)MenuEject) { EjectSlice(object); return(0); } if(object == (APTR)MenuLineSet) { SetLine(object); return(0); } if(object == (APTR)MenuBarSet) { SetBar(object); return(0); } if(object == (APTR)MenuPieSet) { SetPie(object); return(0); } if(object == (APTR)MenuLogX) { ToggleLogX(object); return(0); } if(object == (APTR)MenuLogY) { ToggleLogY(object); return(0); } if(object == (APTR)MenuBoxed) { ToggleBoxed(object); return(0); } if(object == (APTR)MenuGrid) { ToggleGrid(object); return(0); } if(object == (APTR)MenuAxes) { SetAxes(object); return(0); } if(object == (APTR)MenuFZero) { ToggleFZero(object); return(0); } if(object == (APTR)MenuTitle) { SetTitle(object); return(0); } if(object == (APTR)MenuAxTitle) { SetAxTitle(object); return(0); } if(object == (APTR)MenuAxLabel) { SetAxLabel(object); return(0); } if(object == (APTR)MenuKey) { SetKey(object); return(0); } if(object == (APTR)MenuLabel) { SetLabel(object); return(0); } if(object == (APTR)MenuPen) { ChangePen(object); return(0); } if(object == (APTR)MenuFillType) { FillControl(object); return(0); } if(object == (APTR)MenuRegress) { SetRegress(object); return(0); } if(object == (APTR)MenuRobust) { ToggleRobust(object); return(0); } if(object == (APTR)MenuFourier) { SetFourier(object); return(0); } if(object == (APTR)MenuRexxFit) { RexxFit(object); return(0); } if(object == (APTR)MenuRexx) { InstallMacro(object); return(0); } if(object == (APTR)MenuRunRexx) { RunMacro(object); return(0); } if(object == (APTR)MenuDebRexx) { ToggleRexxDeb(object); return(0); } if(object == (APTR)MenuLS1) { SetLineDash(object); return(0); } if(object == (APTR)MenuLS2) { SetLineDash(object); return(0); } if(object == (APTR)MenuLS3) { SetLineDash(object); return(0); } if(object == (APTR)MenuLS4) { SetLineDash(object); return(0); } if(object == (APTR)MenuLS5) { SetLineDash(object); return(0); } if(object == (APTR)MenuLS6) { SetLineDash(object); return(0); } if(object == (APTR)MenuFT1) { SetFillType(object); return(0); } if(object == (APTR)MenuFT2) { SetFillType(object); return(0); } if(object == (APTR)MenuFT3) { SetFillType(object); return(0); } if(object == (APTR)MenuFT4) { SetFillType(object); return(0); } if(object == (APTR)MenuFT5) { SetFillType(object); return(0); } if(object == (APTR)MenuFT6) { SetFillType(object); return(0); } if(object == (APTR)MenuNoFills) { RemoveFills(object); return(0); } return(0); }