#! ruby
require 'phi'
include Phi
require 'prev'

form = Form.new

sbox = ScrollBox.new form
sbox.align = Phi::AL_CLIENT

prev = PrevX.new sbox
prev.set_bounds 0,0,1,1

btn = Button.new form, :btn, 'draw'
btn.set_bounds 200,10,100,25

prev.zoom_scale = 50

btn.on_click = proc do
  prev.doc do
    # フォントの設定
    font = prev.canvas.font
    font.name = 'ＭＳ 明朝'
    font.size = 16
    font.style = []

    # テキストの出力
    prev.text_out 100, 100, 'プレビュー'

    # ペンの設定
    pen = prev.canvas.pen
    pen.width = prev.pen_width 10
    pen.style = Phi::PS_SOLID
    brush = prev.canvas.brush
    brush.style = Phi::BS_CLEAR

    # 長方形を描く
    prev.rectangle 300, 300, 1000, 1000

    # 斜め線を描く
    prev.move_to 300, 300
    prev.line_to 1000, 1000
  end
end

form.show

Phi.mainloop
