home *** CD-ROM | disk | FTP | other *** search
- /* ScrollingWindows.c */
- /* 21 Mar 1996 20:04:25 */
-
- #ifndef BACKUP_INCLUDE
- #include "IncludeAll.c"
- #endif
- #include "Backup.h"
- #include "Backup_proto.h"
-
-
- /* aus Backup_Window.c */
- extern APTR vi; /* VisualInfo */
- extern struct DrawInfo *myDrawInfo;
- extern struct Screen *WBScreen;
-
-
- static struct RastPort *SW_GetRp(struct ScrollingWindow *sWin);
- static void SW_InternalLine(struct ScrollingWindow *sWin, char *TextLine, size_t Length,
- short Line,
- short FgColor, short BgColor, BOOL italic,
- short Indent);
-
-
- static struct RastPort *SW_GetRp(struct ScrollingWindow *sWin)
- {
- return sWin->Requester ? sWin->Requester->ReqLayer->rp : sWin->Host->RPort;
- }
-
-
- void SW_cls(struct ScrollingWindow *sWin)
- {
- struct RastPort *rp = SW_GetRp(sWin);
-
- EraseRect(rp, sWin->Left, sWin->Top,
- sWin->Left+sWin->Width, sWin->Top+sWin->Height);
- }
-
-
- /* Ab Cursorpos. bis Zeilenende löschen */
- void SW_ClrEol(struct ScrollingWindow *sWin)
- {
- unsigned short xstart, ystart, xend, yend;
- struct RastPort *rp = SW_GetRp(sWin);
-
- xstart = max(sWin->Left, min(sWin->LastX, sWin->Left+sWin->Width));
- xend = min(sWin->Left+sWin->Width, sWin->Left+sWin->Width);
-
- yend = min(sWin->LastY + 2, sWin->Top+sWin->Height);
- ystart = max(sWin->Top, min(yend - sWin->sFont->tf_YSize, sWin->Top+sWin->Height));
-
- if (yend > ystart && xend > xstart)
- EraseRect(rp, xstart, ystart, xend, yend-1);
- }
-
-
- /* Ab Cursorpos. bis Schirmende löschen */
- void SW_ClrEos(struct ScrollingWindow *sWin)
- {
- unsigned short ymin;
-
- SW_ClrEol(sWin);
-
- ymin = sWin->LastY + 2;
-
- if (ymin < sWin->Top + sWin->Height && ymin >= sWin->Top)
- {
- EraseRect(SW_GetRp(sWin), sWin->Left, ymin,
- sWin->Left + sWin->Width,
- sWin->Top + sWin->Height);
- }
- }
-
-
- void SW_Scroll(struct ScrollingWindow *sWin, short Lines)
- {
- struct RastPort *rp = SW_GetRp(sWin);
-
- SetBPen(rp, myDrawInfo->dri_Pens[BACKGROUNDPEN]);
- SetDrMd(rp, JAM2);
- ScrollRaster(rp,
- 0, Lines * sWin->sFont->tf_YSize, // dx, dy
- sWin->Left, 1 + sWin->Top + 2, // xmin, ymin
- sWin->Left + sWin->Width, // xmax
- 1 + sWin->Top + sWin->Lines * sWin->sFont->tf_YSize + 1 // ymax
- );
- }
-
-
- void SW_WindowLine(struct ScrollingWindow *sWin, char *TextLine, size_t Length, short Line,
- BOOL mark, BOOL Select, BOOL cMark, short Indent)
- {
- SW_InternalLine(sWin, TextLine, Length,
- Line,
- Select ? 2 : 1, mark ? 3 : 0, cMark,
- Indent);
- }
-
-
- static void SW_InternalLine(struct ScrollingWindow *sWin, char *TextLine, size_t Length,
- short Line,
- short FgColor, short BgColor, BOOL italic,
- short Indent)
- {
- struct TextExtent tExt;
- struct RastPort *rp;
- ULONG n;
- short Top;
- const LeftBorder = 2;
- const TopBorder = 2;
-
- if (Line < 0 || Line >= sWin->Lines)
- return;
- if (!sWin->Host)
- return;
-
- rp = SW_GetRp(sWin);
- Top = 1 + Line * sWin->sFont->tf_YSize;
-
- SetFont(rp, sWin->sFont);
-
- if (sWin->FirstColumn < Length)
- {
- size_t TotalLength;
-
- TextLine += sWin->FirstColumn;
- TotalLength = Length;
-
- Move(rp, sWin->Left + LeftBorder + Indent,
- sWin->Top + TopBorder + Top + sWin->sFont->tf_Baseline);
-
- n = TextFit(rp, TextLine, TotalLength,
- &tExt, NULL, 1, sWin->Width - LeftBorder - Indent, sWin->Height);
-
- SetAPen(rp, FgColor);
- SetBPen(rp, BgColor);
- Text(rp, TextLine, n);
-
- sWin->LastX = rp->cp_x;
- }
- else
- {
- sWin->LastX = sWin->Left + LeftBorder;
- }
- sWin->LastY = sWin->Top + TopBorder + Top + sWin->sFont->tf_YSize;
-
- SetAPen(rp, BgColor);
-
- if (Indent)
- {
- // vom linken Rand bis Indent auffüllen
- RectFill(rp, sWin->Left + LeftBorder,
- sWin->Top + TopBorder + Top,
- sWin->Left + LeftBorder + Indent - 1,
- sWin->LastY - 1);
- }
- /* Zeile bis zum rechten Rand auffüllen */
- RectFill(rp, sWin->LastX,
- sWin->Top + TopBorder + Top,
- sWin->Left + sWin->Width - LeftBorder - 1,
- sWin->LastY - 1);
-
- sWin->LastX = sWin->Left + sWin->Width - 1;
- sWin->LastY -= 2;
- }
-
-
-