/* Overview.rexx (ClipArt Version), 26.08.95 Jörg Richter */

ARG book

OPTIONS RESULTS

thumbsize = 140

ADDRESS DataBase

GetMaskSize
size = result
width = WORD(size,1)
height = WORD(size,2)

xoff = (width-((width%thumbsize)*thumbsize))%2
yoff = 30

LoadGadgets "Clipart/IdxGadgets/"
Display Off

doit = 1
stext = "Bitte wählen Sie ..."

DO FOREVER
  IF doit = 1 THEN DO
    Current
    nr = result
    CALL Overview
  END
  WaitCommand stext
  command = result
  stext = "Bitte wählen Sie ..."
  doit = 0
  IF WORDS(command) > 1 THEN DO
    mx = WORD(command,1)
    my = WORD(command,2)
    qual = WORD(command,3)
    Current
    ds = result
    IF qual = 10 THEN DO /* Gadget */
      IF mx = 1 THEN DO /* <- */
        command = 79
      END
      IF mx = 2 THEN /* -> */
        command = 78
      IF mx = 9 THEN DO /* Abbruch */
        Goto nr
        Call Cancel
      END
      IF mx > 2 & mx < 8 THEN DO
        WaitCommand "Bitte wählen Sie das Bild aus ..."
        command = result
        IF WORDS(command) > 1 THEN DO
          IF mx = 3 THEN qual = 0
          IF mx = 4 THEN qual = 2
          IF mx = 5 THEN qual = 3 /* DTP */
          IF mx = 6 THEN qual = 9 /* Info */
          IF mx = 7 THEN qual = 1
          mx = WORD(command,1)
          my = WORD(command,2)
        END
      END /* IF mx > 2 */
      IF mx = 8 THEN command = 95 /* Inhalt */
    END /* IF qual = 10 */
    IF qual < 10 THEN DO
      my = my - ((my-yoff)%thumbsize)*10
      select = nr + (mx-xoff)%thumbsize + ((my-yoff)%thumbsize)*(width%thumbsize)
      Goto select
      SELECT
        WHEN qual = 0 THEN
          Execute 1
        WHEN qual = 1 THEN DO /* SHIFT */
          Call Cancel
          END
        WHEN qual = 2 THEN DO /* CTRL */
          p1 = (mx-xoff)%thumbsize
          p2 = (my-yoff)%thumbsize
          Mark
          IF RC = 5 THEN DO
            BoxFill p1*thumbsize+xoff+thumbsize-8 p2*thumbsize+yoff+10*(p2+1)-4 5 5 1
            stext = "Clip markiert"
            END
          ELSE DO
            BoxFill p1*thumbsize+xoff+thumbsize-8 p2*thumbsize+yoff+10*(p2+1)-4 5 5 2
            stext = "Clip demarkiert"
            END
          END
        WHEN qual = 3 THEN DO /* AMIGA */
          GetData $F1
          data = result
          pos = LastPos("/",data)
          CopyToClip LEFT(data,pos) || D2C(10) || SubStr(data,pos+1,Length(data)-pos)
          stext = " Clipname ins Klemmbrett kopiert"
          END
        WHEN qual = 9 THEN DO /* Info */
          GetData $F2
          fsize = result
          GetData $F3
          psize = result
          stext = "Dateilänge: " || fsize || " KBytes     Bildgröße: " || psize
          END
        OTHERWISE

      END /* SELECT */
      Goto ds
      command = 999
    END /* IF qual < 10 */
  END /* IF WORDS */
  IF command = 27 | command = 0 THEN DO /* ESC */
    Goto nr
    Call Cancel
    END
  IF command = 79 THEN DO /* <- */
    Current
    ds = result
    IF nr > 1 THEN DO
      go = nr - (width%thumbsize)*(height%thumbsize)
      IF go < 1 THEN go = 1
      DO WHILE ds > go
        LeftOne
        ds = ds - 1
        IF ds = nr-1 THEN DO
          GetData $F4
          old = result
          pos = LastPos("/",old)
          old = SubStr(old,1,pos)
        END
        IF ds < nr-1 THEN DO
          GetData $F4
          name = result
          pos = LastPos("/",name)
          IF COMPARE(SubStr(name,1,pos),old) ~= 0 THEN DO
            ds = go
            RightOne
          END
        END
      END /* DO WHILE */
      doit = 1
    END /* IF nr > 1 */
  END /* IF command = 79 */
  IF command = 78 | command = 32 THEN /* -> */
    doit = 1
  IF command = 95 THEN DO /* HELP */
    Display On
    ADDRESS COMMAND 'SYS:Rexxc/Rx Clipart/Book ' || book
    Display Off
    doit = 1
  END /* IF command = 95 */
END /* DO FOREVER */

EXIT


ShowPicture:

ARG xx yy .

GetData $F4
name = result
pos = LastPos("/",name)
IF COMPARE(SubStr(name,1,pos),old) ~= 0 THEN DO
  x = width
  y = height
  LeftOne
  END
ELSE DO
  LoadPic name xx yy CENTER
  Box xx+13 yy+13 124 124 1
  SetFont helvetica.font 11 0
  Text xx+12 yy+11 1 UPPER(SubStr(name,pos+1,Length(name)-pos))
  SetFont RESET 0
  IsMarked
  IF RC = 0 THEN
    BoxFill xx+thumbsize-8 yy+6 5 5 1
END

RETURN


Overview:

x = xoff
y = yoff
GetData $F1
title = result
pos = LastPos("/",title)
BoxFill 1 1 width-1 height-1 2
SetFont Helvetica.font 15 0
Text xoff+13 20 1 SubStr(title,1,pos-1)
SetFont RESET 0
Line xoff+13 23 width-xoff-38 0 1
GetData $F4
old = result
pos = LastPos("/",old)
old = SubStr(old,1,pos)

weiter = 1

DO WHILE weiter = 1

  CALL ShowPicture x y
  x = x + thumbsize
  IF x > width-thumbsize THEN DO
    IF y < height-(thumbsize*2) THEN DO
      x = xoff
      y = y + thumbsize + 10
      END
    ELSE
      weiter = 0
    END
  RightOne
  IF RC ~= 0 THEN
    weiter = 0

END

RETURN


Cancel:

Display On
LoadGadgets RESET
Show NEW
EXIT

