; MastermindUI.jlogo - Partial User Interface For Mastermind  (Lesson 12 - Predicates)
; ------------------

;Symbolic Constants
;------------------

; SETPENCOLOR inputs
to black
  output 0
  end
to blue
  output 1
  end
to green
  output 2
  end
to orange
  output 14
  end
to red
  output 4
  end
to violet
  output 13
  end
to white
  output 7
  end
to yellow
  output 6
  end

; SETHEADING inputs
to north
  output 0
  end
to east
  output 90
  end
to south
  output 180
  end
to west
  output 270
  end

; SETLABELFONT input
to sansSerif
  output 4
  end


; General Purpose Procedures
; --------------------------

; output the input number divided by two
to half :num
  output quotient :num 2
  end

; draw a rectangle given its dimensions and location
; its sides are oriented north-south and east-west
; the turtle's current pen width and color are used
to drawRect :leftX :bottomY :width :height
  penup  setxy :leftX :bottomY  pendown  setheading north
  repeat 2 [forward :height right 90 forward :width right 90]
  end

; draw a solid rectangle given its dimensions and location
; its sides are oriented north-south and east-west
; the rectangle is painted with the current pen color
to fillRect :leftX :bottomY :width :height
  penup  setxy :leftX (sum :bottomY (half :height))
  setpensize :height setheading east
  pendown forward :width
  end

; output TRUE if a point is in a rectangle, otherwise output FALSE
; point is a sentence, an x and y coordinate pair
; the bottom-left corner of the rectangle is at leftX, bottomY
; inputs width and height specify its size
to inRect? :point :leftX :bottomY :width :height
  ; ...
  end


; outputs TRUE if the most recent mouse click was within the
; bounds of a specified rectangle, otherwise it outputs FALSE
; the bottom-left corner of the rectangle is at leftX, bottomY
; inputs width and height specify its size
to mouseInRect? :leftX :bottomY :height :width
  ; ...
  end


; Color Choice Box Stuff
; ----------------------------

; width/length of a color choice box
to colorChoiceSize
  output 50
  end
; height of the line of color choice boxes
to colorChoicesHeight
  output product 6 colorChoiceSize
  end
; width of the line of color choice boxes
to colorChoicesWidth
  output colorChoiceSize
  end
; X coordinate of left edge of line of color choice boxes
to colorChoicesLeftX
  output -125
  end
; X coordinate of middle of the line of color choice boxes
to colorChoicesMiddleX
  output (difference (sum colorChoicesLeftX (half colorChoiceSize)) 1)
  end
; Y coordinate of top edge of the line of color choice boxes
to colorChoicesTopY
  output product 3 colorChoiceSize
  end
; Y coordinate of bottom edge of the red choice box
to redChoiceBottomY
  output difference colorChoicesTopY colorChoiceSize
  end
; Y coordinate of bottom edge of the orange choice box
to orangeChoiceBottomY
  output difference redChoiceBottomY colorChoiceSize
  end
; Y coordinate of bottom edge of the yellow choice box
to yellowChoiceBottomY
  output difference orangeChoiceBottomY colorChoiceSize
  end
; Y coordinate of bottom edge of the green choice box
to greenChoiceBottomY
  output difference yellowChoiceBottomY colorChoiceSize
  end
; Y coordinate of bottom edge of the blue choice box
to blueChoiceBottomY
  output difference greenChoiceBottomY colorChoiceSize
  end
; Y coordinate of bottom edge of the violet choice box
to violetChoiceBottomY
  output difference blueChoiceBottomY colorChoiceSize
  end
; Y coordinate of bottom edge of the line of color choice boxes
to colorChoicesBottomY
  output violetChoiceBottomY
  end

; draw the line of color choice boxes
to paintColorChoices
  ; ...
  end

; given that the most recent mouse click occured within the bounds of
; the line of color choice boxes, output the color that was selected
to clickedColorChoice
  ; ...
  end


; Big Box Stuff
; -------------

; width/length of the big box that gets filled with color
to bigBoxSize
  output 100
  end
; Y coordinate of bottom edge of the big box
to bigBoxBottomY
  output 0
  end
; X coordinate of left edge of the big box
to bigBoxLeftX
  output 0
  end
; X coordinate of middle of the big box
to bigBoxMiddleX
  output sum bigBoxLeftX (half bigBoxSize)
  end

; draw the big box, filled with the color supplied as an input
to paintBigBox :color
  ; ...
  end



; Clear Button Stuff
; ------------------

; height of the clear button
to clearButtonHeight
  output 30
  end
; width of the clear button
to clearButtonWidth
  output 100
  end
; Y coordinate of bottom edge of the clear button
to clearButtonBottomY
  output -80
  end
; X coordinate of left edge of the clear button
to clearButtonLeftX
  output 0
  end
; label for the button - its name
to clearButtonName
  output "|Clear Box|
  end
; text height of the button's label/name
to clearButtonLabelHeight
  output 14
  end

; draw the Clear Box button
to paintClearButton
  ; ...
  end

; User Interaction Stuff
; ----------------------

; handle mouse click which occurred in the line of color choice boxes
to colorChoice
  ; ...
  end

; handle mouse click on the [Clear Box] button
to clearButton
  ; ...
  end

; handle a mouse click event
to mouseClicked
  ; ...
  end

; MAIN
; ----
to main
  hideturtle home clean
  paintBigBox white
  paintClearButton
  paintColorChoices
  end

main