1#
2#  tkextlib/blt/win_printer.rb
3#
4#      *** Windows only ***
5#
6#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7#
8
9require 'tk'
10require 'tkextlib/blt.rb'
11
12module Tk::BLT
13  class Printer < TkObject
14    extend TkCore
15
16    TkCommandNames = ['::blt::printer'.freeze].freeze
17
18    def self.enum(attribute)
19      simplelist(tk_call('::blt::printer', 'enum', attribute))
20    end
21
22    def self.names(pat=None)
23      simplelist(tk_call('::blt::printer', 'names', pat))
24    end
25
26    def self.open(printer)
27      self.new(printer)
28    end
29
30    #################################
31
32    def initialize(printer)
33      @printer_id = tk_call('::blt::printer', 'open', printer)
34    end
35
36    def close
37      tk_call('::blt::print', 'close', @printer_id)
38      self
39    end
40    def get_attrs(var)
41      tk_call('::blt::print', 'getattrs', @printer_id, var)
42      var
43    end
44    def set_attrs(var)
45      tk_call('::blt::print', 'setattrs', @printer_id, var)
46      self
47    end
48    def snap(win)
49      tk_call('::blt::print', 'snap', @printer_id, win)
50      self
51    end
52    def write(str)
53      tk_call('::blt::print', 'write', @printer_id, str)
54      self
55    end
56    def write_with_title(title, str)
57      tk_call('::blt::print', 'write', @printer_id, title, str)
58      self
59    end
60  end
61end
62