FrontPage  Index  Search  Changes  RSS  wikifarm  Login

Phi_sym.rb

概要

Apolloの各クラスに「xx_sym」というタイプの属性を、ぼちぼちと、追加しているファイルです。

「xx_sym」型の属性に関してはSymHash.rbをご覧ください。


依存性

  1. Apollo 専用です。
  2. SymHash.rb
  3. Hash_tree.rb
  4. Enumerable_to_hash.rb

利用者


実行見本:


コメントがありましたらどうぞ

  • 2006-06-26 (月) 12:13:57 take_tk : 公開時にエンバグしてしまった。
(comment plugin is disabled).

説明


ソース:

Phi_sym.rb

#! ruby -Ks
#-- Phi_sym.rb .. require "phi" に対応する名前。Phi クラスではない。
#-- Phi_sym.pi
#
# 2007-07-20(金) PrintDialog関係追加
# 2006-06-26(月)
# 2006-06-23(金) 公開・・エンバグしてしまった。require "rdb" をコメントアウトした。のでエラーが出るようになった。
# 2003-05-27(火) この頃初期バージョン作成。

unless defined?(@Phi_sym_defined)
@Phi_sym_defined = true

require "SymHash"

#### require "phi" ####

require "phi"

module Phi

  CONFLICT_FT1 = [:comp,:curr,:double,:extended,:single]  # FloatType
  CONFLICT_SS1 = [:shift,:alt,:ctrl,:left,:right,:middle,:double]  # ShiftState
  CONFLICT_PO1 = [:print_to_file,:page_nums,:selection,:warning,:help,:disable_print_to_file] # PrintDialog#options
  CONFLICT_PO3 = [:portrait, :landscape]
  CONFLICT_BS1 = [:none, :single, :sizeable, :dialog, :tool_window, :size_tool_win] # TFormBorderStyle
  CONFLICT_CS1 = [:lbutton_down, :clicked, :palette, :reading_state,
          :alignment_needed, :focusing, :creating, :paint_copy,
          :custom_paint, :destroying_handle, :docking]
  CONFLICT_FS1 = [:normal, :mdichild, :mdiform, :stay_on_top] # Form#form_style
  CONFLICT_VK1 = [:hangul, :hanja]
  CONFLICT_MB1 = [:left, :right, :middle] # TMouseButton cf. TMsgDlgBtn

  attr_sym :vk,                Phi , /^VK_/ , [] , CONFLICT_VK1 # dummy for Phi::Control.vk_
  def self.vk_to_sym(vk)
    self.vk_sym_hash.to_sym(vk)
  end
  def self.vk_to_num(num)
    self.vk_sym_hash.to_num(num)
  end

  class Control
    attr_sym :align,             Phi , /^AL_/
    attr_sym :anchors,           Phi , /^AK_/
    attr_sym :border_style,      Phi , /^BS_/ , CONFLICT_BS1
    attr_sym :control_state,     Phi , "TControlState = (csLButtonDown, csClicked, csPalette, csReadingState, csAlignmentNeeded, csFocusing, csCreating, csPaintCopy, csCustomPaint, csDestroyingHandle, csDocking)" # , :debug

    attr_sym :cursor,            Phi , /^CR_/
    attr_sym :drag_mode,         Phi , /^DM_/  # may conflict with default_monitor
    attr_sym :drag_kind,         Phi , "TDragKind = (dkDrag, dkDock)"
    attr_sym :color,             Phi , /^CL_/ ,[], [:dk_gray, :lt_gray]
    attr_sym :fixed_color,       Phi , /^CL_/ ,[], [:dk_gray, :lt_gray]
    attr_sym :help_type,         Phi , "THelpType = (htKeyword, htContext)"
    attr_sym :ime_mode,          Phi , "TImeMode = (imDisable, imClose, imOpen, imDontCare, imSAlpha, imAlpha, imHira, imSKata, imKata, imChinese, imSHanguel, imHanguel)"
    #
    def on_mouse_move_sym=(v)
      self.on_mouse_move = proc do |sender, shift, x, y|
        shift_sym  = sender.shift_sym_hash.to_sym(shift)
        v.call(sender, shift_sym, x, y)
      end
    end
    def on_mouse_down_sym=(v)
      self.on_mouse_down = proc do |sender, button, shift, x, y|
        shift_sym  = sender.shift_sym_hash.to_sym(shift)
        button_sym = sender.mouse_button_sym_hash.to_sym(button)
        v.call(sender, button_sym, shift_sym, x, y)
      end
    end

    # 問題あり。
    # Crtl+X と特殊キーとを区別できない。
    # 特殊キーは問題ないが、Ctrl+X を特殊キーと判断してしまう。
    # Ctrl+X で特殊キーに該当するものがない場合には数値で返る。
    # 戻り値が、 文字列、シンボル、整数のいろいろになる。
    # 漢字が泣き別れになる。
    # 単純に数値で返して、key.chr で調べろ、か?
    # 13 は :return なのか、Ctrl+M なのか?
    def on_key_press_sym=(v)
      self.on_key_press = proc do |sender, key|
        key_sym = (key < " "[0]) ? Phi.vk_sym_hash.to_sym(key) : key.chr
        v.call(sender, key_sym)
      end
    end
  end

  class Pen
    attr_sym :color,             Phi , /^CL_/ ,[], [:dk_gray, :lt_gray]
  end

  class Edit
    attr_sym :ime_mode,          Phi , /^IM_/
  end

  class Font
    attr_sym :color,             Phi , /^CL_/ ,[], [:dk_gray, :lt_gray]
    attr_sym :pitch,             Phi , /^FP_/ ,[]
    attr_sym :style,             Phi , "TFontStyle = (fsBold, fsItalic, fsUnderline, fsStrikeOut);"
  end

  class CustomGrid
    attr_sym :display_options,   Phi , "TDisplayOption = (doColumnTitles, doAutoColResize, doKeyColFixed)" # , :debug
    attr_sym :options,             Phi , "TGridOption = (goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected, goRowSizing, goColSizing, goRowMoving, goColMoving, goEditing, goTabs, goRowSelect, goAlwaysShowEditor, goThumbTracking)" # , :debug
  end

  class Form
    attr_sym :border_icons, Phi , "TBorderIcon = (biSystemMenu, biMinimize, biMaximize, biHelp)"
    attr_sym :border_style, Phi , /^BS_/ , CONFLICT_BS1
    attr_sym :form_style,   Phi , /^FS_/ , CONFLICT_FS1 # may conflict with default_monitor
    attr_sym :position,     Phi , /^PO_/ , [], CONFLICT_PO3
    attr_sym :window_state, Phi , /^WS_/
    attr_sym :modal_result, Phi , /^MR_/
    def show_modal_sym
      modal_result_sym_hash.to_sym(show_modal)
    end
  end
  class Button
    attr_sym :modal_result, Phi , /^MR_/
  end
end # module Phi for "phi"

#### require "dialogs" ####

require "dialogs"

module Phi

  class OpenDialog
    attr_sym :options,  Phi, /^OF_/
  end

  class FindDialog
    attr_sym :options,  Phi, /^FR_/
  end

  class PrintDialog
    attr_sym :options,     Phi, "TPrintDialogOption = (poPrintToFile, poPageNums, poSelection, poWarning, poHelp, poDisablePrintToFile);"
    attr_sym :print_range, Phi, "TPrintRange = (prAllPages, prSelection, prPageNums);" # , :debug
  end

  class ColorDialog
    attr_sym :options,  Phi, /^CD_/
    attr_sym :color,    Phi , /^CL_/ ,[], [:dk_gray, :lt_gray]
  end

  class Screen
    attr_sym :cursor,  Phi, /^CR_/
  end



end # module Phi for "dialogs"

#### require "rdb/rdb" ####

require "rdb/rdb" #=> rdb_sym.rb

module Phi
  class DataSet
    attr_sym :state , Phi , /^DS_/  # 2003-07-07(月)
  end

  class Field
    attr_sym :data_type, Phi , /^FT_/, [], CONFLICT_FT1 # , :debug
  end

  CONFLICT_SS2 = [:none, :horizontal, :vertical, :both] # scroll_bars
  class DBGrid
    attr_sym :options,  Phi , /^DG_/
    attr_sym :scroll_bars,  Phi , /^SS_/ , CONFLICT_SS2 # , :debug
  end

  class ColumnTitle
    attr_sym :alignment,  Phi , /^TA_/
    attr_sym :color,      Phi , /^CL_/ ,[], [:dk_gray, :lt_gray]
  end
end # module Phi for "rdb"

end # unless defined?(@@Phi_sym_defined)

###################

if __FILE__ == $0
  form = Phi::Form.new
  c = Phi::Edit.new form
  puts Phi::Control.color_sym_hash.tree
end

Last modified:2006/06/26 12:13:57
Keyword(s):
References:[SymHash.rb]