wrb 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README +28 -0
- data/Rakefile +66 -0
- data/bin/wrb +41 -0
- data/bin/wrb.bat +6 -0
- data/ext/rwin/aatree.c +192 -0
- data/ext/rwin/aatree.h +55 -0
- data/ext/rwin/extconf.rb +47 -0
- data/ext/rwin/rw_api.c +2058 -0
- data/ext/rwin/rw_devices.c +215 -0
- data/ext/rwin/rw_gdiplus.h +278 -0
- data/ext/rwin/rw_graphics.c +1583 -0
- data/ext/rwin/rw_resources.c +1988 -0
- data/ext/rwin/rw_ubfuncs.c +281 -0
- data/ext/rwin/rw_windows.c +1936 -0
- data/ext/rwin/rwin.c +451 -0
- data/ext/rwin/rwin.h +442 -0
- data/lib/rwin.rb +820 -0
- data/lib/wrb.rb +20 -0
- data/lib/wrb/applications/frmdesigner/angle.cur +0 -0
- data/lib/wrb/applications/frmdesigner/angle2.cur +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Button.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Button.rb +34 -0
- data/lib/wrb/applications/frmdesigner/controls/Checkbox.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Checkbox.rb +10 -0
- data/lib/wrb/applications/frmdesigner/controls/Combobox.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Combobox.rb +88 -0
- data/lib/wrb/applications/frmdesigner/controls/ComboboxEx.rb +97 -0
- data/lib/wrb/applications/frmdesigner/controls/Comboboxex.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/DateTimePicker.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/DateTimePicker.rb +11 -0
- data/lib/wrb/applications/frmdesigner/controls/Edit.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Edit.rb +8 -0
- data/lib/wrb/applications/frmdesigner/controls/Groupbox.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Groupbox.rb +9 -0
- data/lib/wrb/applications/frmdesigner/controls/Hotkeyctrl.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Hotkeyctrl.rb +9 -0
- data/lib/wrb/applications/frmdesigner/controls/Imagelist.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Imagelist.rb +115 -0
- data/lib/wrb/applications/frmdesigner/controls/Listbox.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Listbox.rb +77 -0
- data/lib/wrb/applications/frmdesigner/controls/Listview.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Listview.rb +157 -0
- data/lib/wrb/applications/frmdesigner/controls/Menu.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Menu.rb +198 -0
- data/lib/wrb/applications/frmdesigner/controls/Menubar.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Menubar.rb +9 -0
- data/lib/wrb/applications/frmdesigner/controls/MonthCalender.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Monthcalender.rb +9 -0
- data/lib/wrb/applications/frmdesigner/controls/Panel.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Panel.rb +30 -0
- data/lib/wrb/applications/frmdesigner/controls/Progressbar.rb +10 -0
- data/lib/wrb/applications/frmdesigner/controls/Radiobutton.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Radiobutton.rb +13 -0
- data/lib/wrb/applications/frmdesigner/controls/Rebar.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Rebar.rb +162 -0
- data/lib/wrb/applications/frmdesigner/controls/Splitter.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Splitter.rb +66 -0
- data/lib/wrb/applications/frmdesigner/controls/Static.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Static.rb +9 -0
- data/lib/wrb/applications/frmdesigner/controls/Statusbar.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Statusbar.rb +103 -0
- data/lib/wrb/applications/frmdesigner/controls/Tabctrl.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Tabctrl.rb +136 -0
- data/lib/wrb/applications/frmdesigner/controls/Timer.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Timer.rb +36 -0
- data/lib/wrb/applications/frmdesigner/controls/Toolbar.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Toolbar.rb +165 -0
- data/lib/wrb/applications/frmdesigner/controls/Trackbar.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Trackbar.rb +34 -0
- data/lib/wrb/applications/frmdesigner/controls/Treeview.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Treeview.rb +107 -0
- data/lib/wrb/applications/frmdesigner/controls/Updown.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/Updown.rb +31 -0
- data/lib/wrb/applications/frmdesigner/controls/default.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/progressbar.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/controls/unselect.bmp +0 -0
- data/lib/wrb/applications/frmdesigner/fddialogs.rb +87 -0
- data/lib/wrb/applications/frmdesigner/fdesign.rb +1315 -0
- data/lib/wrb/applications/frmdesigner/fdmodules.rb +1394 -0
- data/lib/wrb/applications/frmdesigner/fdparseform.rb +197 -0
- data/lib/wrb/applications/frmdesigner/img13.bmp +0 -0
- data/lib/wrb/base.rb +1294 -0
- data/lib/wrb/combocommon.rb +77 -0
- data/lib/wrb/commctrlconst.rb +139 -0
- data/lib/wrb/commdlg.rb +77 -0
- data/lib/wrb/components/animate.rb +114 -0
- data/lib/wrb/components/bitmap.rb +116 -0
- data/lib/wrb/components/button.rb +134 -0
- data/lib/wrb/components/canvas.rb +266 -0
- data/lib/wrb/components/checkbox.rb +118 -0
- data/lib/wrb/components/choosecolordlg.rb +87 -0
- data/lib/wrb/components/choosefontdlg.rb +142 -0
- data/lib/wrb/components/clipboard.rb +174 -0
- data/lib/wrb/components/combobox.rb +282 -0
- data/lib/wrb/components/comboboxex.rb +574 -0
- data/lib/wrb/components/cursor.rb +91 -0
- data/lib/wrb/components/datetimepicker.rb +197 -0
- data/lib/wrb/components/ddeclient.rb +180 -0
- data/lib/wrb/components/ddeserver.rb +131 -0
- data/lib/wrb/components/dialog.rb +228 -0
- data/lib/wrb/components/edit.rb +412 -0
- data/lib/wrb/components/font.rb +35 -0
- data/lib/wrb/components/form.rb +65 -0
- data/lib/wrb/components/groupbox.rb +122 -0
- data/lib/wrb/components/header.rb +479 -0
- data/lib/wrb/components/hotkeyctrl.rb +72 -0
- data/lib/wrb/components/icon.rb +109 -0
- data/lib/wrb/components/imagelist.rb +396 -0
- data/lib/wrb/components/inifile.rb +97 -0
- data/lib/wrb/components/listbox.rb +149 -0
- data/lib/wrb/components/listview.rb +1467 -0
- data/lib/wrb/components/menu.rb +592 -0
- data/lib/wrb/components/menubar.rb +84 -0
- data/lib/wrb/components/monthcalender.rb +164 -0
- data/lib/wrb/components/openfilenamedlg.rb +147 -0
- data/lib/wrb/components/pager.rb +199 -0
- data/lib/wrb/components/panel.rb +103 -0
- data/lib/wrb/components/picture.rb +55 -0
- data/lib/wrb/components/printdlg.rb +148 -0
- data/lib/wrb/components/printdlgex.rb +117 -0
- data/lib/wrb/components/printer.rb +97 -0
- data/lib/wrb/components/progressbar.rb +140 -0
- data/lib/wrb/components/radiobutton.rb +49 -0
- data/lib/wrb/components/rebar.rb +830 -0
- data/lib/wrb/components/registry.rb +408 -0
- data/lib/wrb/components/richedit.rb +1181 -0
- data/lib/wrb/components/savefilenamedlg.rb +27 -0
- data/lib/wrb/components/scintilla.rb +1298 -0
- data/lib/wrb/components/scrollbar.rb +239 -0
- data/lib/wrb/components/splitter.rb +494 -0
- data/lib/wrb/components/static.rb +198 -0
- data/lib/wrb/components/statusbar.rb +490 -0
- data/lib/wrb/components/tabctrl.rb +686 -0
- data/lib/wrb/components/timer.rb +117 -0
- data/lib/wrb/components/toolbar.rb +1107 -0
- data/lib/wrb/components/tooltip.rb +651 -0
- data/lib/wrb/components/trackbar.rb +298 -0
- data/lib/wrb/components/treeview.rb +845 -0
- data/lib/wrb/components/updown.rb +198 -0
- data/lib/wrb/ddeml.rb +241 -0
- data/lib/wrb/documents/animate.html +46 -0
- data/lib/wrb/documents/bitmap.html +69 -0
- data/lib/wrb/documents/button.html +78 -0
- data/lib/wrb/documents/canvas.html +137 -0
- data/lib/wrb/documents/checkbox.html +77 -0
- data/lib/wrb/documents/choosecolordlg.html +29 -0
- data/lib/wrb/documents/choosefontdlg.html +31 -0
- data/lib/wrb/documents/clipboard.html +31 -0
- data/lib/wrb/documents/combobox.html +117 -0
- data/lib/wrb/documents/comboboxex.html +139 -0
- data/lib/wrb/documents/control.html +53 -0
- data/lib/wrb/documents/cursor.html +45 -0
- data/lib/wrb/documents/datetimepicker.html +70 -0
- data/lib/wrb/documents/ddeclient.html +33 -0
- data/lib/wrb/documents/ddeserver.html +26 -0
- data/lib/wrb/documents/dialog.html +78 -0
- data/lib/wrb/documents/edit.html +169 -0
- data/lib/wrb/documents/empty.html +11 -0
- data/lib/wrb/documents/favicon.png +0 -0
- data/lib/wrb/documents/font.html +38 -0
- data/lib/wrb/documents/form.html +63 -0
- data/lib/wrb/documents/groupbox.html +57 -0
- data/lib/wrb/documents/header.html +85 -0
- data/lib/wrb/documents/hotkeyctrl.html +42 -0
- data/lib/wrb/documents/icon.html +45 -0
- data/lib/wrb/documents/imagelist.html +101 -0
- data/lib/wrb/documents/images/button.png +0 -0
- data/lib/wrb/documents/images/checkbox.png +0 -0
- data/lib/wrb/documents/images/combobox.png +0 -0
- data/lib/wrb/documents/images/comboboxex.png +0 -0
- data/lib/wrb/documents/images/datetimepicker.png +0 -0
- data/lib/wrb/documents/images/edit.png +0 -0
- data/lib/wrb/documents/images/groupbox.png +0 -0
- data/lib/wrb/documents/images/hotkeyctrl.png +0 -0
- data/lib/wrb/documents/images/listbox.png +0 -0
- data/lib/wrb/documents/images/listview.png +0 -0
- data/lib/wrb/documents/images/menu.png +0 -0
- data/lib/wrb/documents/images/menubar.png +0 -0
- data/lib/wrb/documents/images/monthcalender.png +0 -0
- data/lib/wrb/documents/images/progressbar.png +0 -0
- data/lib/wrb/documents/images/radiobutton.png +0 -0
- data/lib/wrb/documents/images/rebar.png +0 -0
- data/lib/wrb/documents/images/richedit.png +0 -0
- data/lib/wrb/documents/images/splitter.png +0 -0
- data/lib/wrb/documents/images/static.png +0 -0
- data/lib/wrb/documents/images/statusbar.png +0 -0
- data/lib/wrb/documents/images/tabctrl.png +0 -0
- data/lib/wrb/documents/images/toolbar.png +0 -0
- data/lib/wrb/documents/images/tooltip.png +0 -0
- data/lib/wrb/documents/images/trackbar.png +0 -0
- data/lib/wrb/documents/images/treeview.png +0 -0
- data/lib/wrb/documents/images/updown.png +0 -0
- data/lib/wrb/documents/index.html +155 -0
- data/lib/wrb/documents/inifile.html +36 -0
- data/lib/wrb/documents/license.txt +22 -0
- data/lib/wrb/documents/listbox.html +96 -0
- data/lib/wrb/documents/listview.html +277 -0
- data/lib/wrb/documents/make_doc.rb +596 -0
- data/lib/wrb/documents/menu.html +144 -0
- data/lib/wrb/documents/menubar.html +54 -0
- data/lib/wrb/documents/monthcalender.html +48 -0
- data/lib/wrb/documents/openfilenamedlg.html +36 -0
- data/lib/wrb/documents/pager.html +63 -0
- data/lib/wrb/documents/panel.html +32 -0
- data/lib/wrb/documents/picture.html +48 -0
- data/lib/wrb/documents/printdlg.html +35 -0
- data/lib/wrb/documents/printdlgex.html +35 -0
- data/lib/wrb/documents/printer.html +40 -0
- data/lib/wrb/documents/progressbar.html +69 -0
- data/lib/wrb/documents/radiobutton.html +51 -0
- data/lib/wrb/documents/rebar.html +143 -0
- data/lib/wrb/documents/registry.html +36 -0
- data/lib/wrb/documents/richedit.html +232 -0
- data/lib/wrb/documents/samples/editimg.bmp +0 -0
- data/lib/wrb/documents/samples/editimg.iml +0 -0
- data/lib/wrb/documents/samples/fileimg.bmp +0 -0
- data/lib/wrb/documents/samples/fileimg.iml +0 -0
- data/lib/wrb/documents/samples/sample_button.rb +21 -0
- data/lib/wrb/documents/samples/sample_checkbox.rb +18 -0
- data/lib/wrb/documents/samples/sample_combobox.rb +18 -0
- data/lib/wrb/documents/samples/sample_comboboxex.rb +23 -0
- data/lib/wrb/documents/samples/sample_datetimepicker.rb +11 -0
- data/lib/wrb/documents/samples/sample_edit.rb +25 -0
- data/lib/wrb/documents/samples/sample_groupbox.rb +19 -0
- data/lib/wrb/documents/samples/sample_hotkeyctrl.rb +12 -0
- data/lib/wrb/documents/samples/sample_listbox.rb +12 -0
- data/lib/wrb/documents/samples/sample_listview.rb +32 -0
- data/lib/wrb/documents/samples/sample_menu.rb +21 -0
- data/lib/wrb/documents/samples/sample_menubar.rb +23 -0
- data/lib/wrb/documents/samples/sample_monthcalender.rb +11 -0
- data/lib/wrb/documents/samples/sample_progressbar.rb +14 -0
- data/lib/wrb/documents/samples/sample_radiobutton.rb +14 -0
- data/lib/wrb/documents/samples/sample_rebar.rb +25 -0
- data/lib/wrb/documents/samples/sample_richedit.rb +60 -0
- data/lib/wrb/documents/samples/sample_splitter.rb +33 -0
- data/lib/wrb/documents/samples/sample_static.rb +15 -0
- data/lib/wrb/documents/samples/sample_statusbar.rb +17 -0
- data/lib/wrb/documents/samples/sample_tabctrl.rb +19 -0
- data/lib/wrb/documents/samples/sample_toolbar.rb +29 -0
- data/lib/wrb/documents/samples/sample_tooltip.rb +50 -0
- data/lib/wrb/documents/samples/sample_trackbar.rb +30 -0
- data/lib/wrb/documents/samples/sample_treeview.rb +19 -0
- data/lib/wrb/documents/samples/sample_updown.rb +18 -0
- data/lib/wrb/documents/samples/sampleimg16.iml +0 -0
- data/lib/wrb/documents/samples/sampleimg32.iml +0 -0
- data/lib/wrb/documents/samples/samplemg16.png +0 -0
- data/lib/wrb/documents/samples/samplemg32.png +0 -0
- data/lib/wrb/documents/samples/wrb.ico +0 -0
- data/lib/wrb/documents/savefilenamedlg.html +19 -0
- data/lib/wrb/documents/scrollbar.html +60 -0
- data/lib/wrb/documents/splitter.html +96 -0
- data/lib/wrb/documents/static.html +84 -0
- data/lib/wrb/documents/statusbar.html +110 -0
- data/lib/wrb/documents/tabctrl.html +151 -0
- data/lib/wrb/documents/timer.html +43 -0
- data/lib/wrb/documents/toolbar.html +181 -0
- data/lib/wrb/documents/tooltip.html +131 -0
- data/lib/wrb/documents/trackbar.html +107 -0
- data/lib/wrb/documents/treeview.html +210 -0
- data/lib/wrb/documents/updown.html +85 -0
- data/lib/wrb/documents/wincontrol.html +258 -0
- data/lib/wrb/documents/window.html +499 -0
- data/lib/wrb/documents/wrb.css +228 -0
- data/lib/wrb/gmem.rb +26 -0
- data/lib/wrb/imecommon.rb +59 -0
- data/lib/wrb/listcommon.rb +185 -0
- data/lib/wrb/lzss.rb +126 -0
- data/lib/wrb/scrollinfo.rb +142 -0
- data/lib/wrb/toplevelcommon.rb +634 -0
- metadata +315 -0
|
@@ -0,0 +1,1394 @@
|
|
|
1
|
+
# FormDesigner
|
|
2
|
+
|
|
3
|
+
require 'wrb'
|
|
4
|
+
module WR
|
|
5
|
+
API.defun "EnumChildWindows(HWND, HPROC, LPARAM)"
|
|
6
|
+
API.defun "GetWindow(HWND hwnd, UINT uCmd)"
|
|
7
|
+
GW_CHILD = 5
|
|
8
|
+
|
|
9
|
+
class Infobox < Window
|
|
10
|
+
InfoBoxFont = Font.new('MS UIGothic', 12)
|
|
11
|
+
|
|
12
|
+
class InfoGr < RWin::Canvas
|
|
13
|
+
def draw(bkcolor, txt)
|
|
14
|
+
SetFont(InfoBoxFont)
|
|
15
|
+
SetBkColor(bkcolor)
|
|
16
|
+
DrawText(txt, 0, 0, 100, 12)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def initialize(parent)
|
|
21
|
+
@_classname = "RUBYWIN"
|
|
22
|
+
self.style = WS_BORDER | WS_POPUP
|
|
23
|
+
self.visible = false
|
|
24
|
+
@_x = @_y = @_w = @_h = 0
|
|
25
|
+
@_parent = parent
|
|
26
|
+
@_idcmd = 0
|
|
27
|
+
register_event(WM_PAINT, '_paint', 'c', InfoGr)
|
|
28
|
+
@info_text = ''
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def _paint(gr)
|
|
32
|
+
gr.draw(@bkcolor, @info_text)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def show_info(obj, wh=nil)
|
|
36
|
+
parent = obj.parent
|
|
37
|
+
sx, sy = obj.screenpos()
|
|
38
|
+
obj_w, obj_h = obj.windowsize
|
|
39
|
+
if wh
|
|
40
|
+
@info_text = "#{obj_w}, #{obj_h}"
|
|
41
|
+
@bkcolor = 0xffffdd
|
|
42
|
+
else
|
|
43
|
+
@info_text = "#{obj.x}, #{obj.y}"
|
|
44
|
+
@bkcolor = 0xddffff
|
|
45
|
+
end
|
|
46
|
+
_w, _h = nil
|
|
47
|
+
InfoGr.draw(self){|gr|
|
|
48
|
+
gr.SetFont(InfoBoxFont)
|
|
49
|
+
_w, _h = gr.GetTextExtent(@info_text)
|
|
50
|
+
}
|
|
51
|
+
w, h = windowsize
|
|
52
|
+
self.move(sx-_w, sy-_h, _w+2, _h+1)
|
|
53
|
+
self.visible = SW_SHOWNA
|
|
54
|
+
refresh
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class HandleWin < Window
|
|
59
|
+
Arrow = Cursor[IDC_ARROW]
|
|
60
|
+
SizeNESW = Cursor[IDC_SIZENESW]
|
|
61
|
+
SizeNS = Cursor[IDC_SIZENS]
|
|
62
|
+
SizeNWSE = Cursor[IDC_SIZENWSE]
|
|
63
|
+
SizeWE = Cursor[IDC_SIZEWE]
|
|
64
|
+
|
|
65
|
+
API.loadlib 'gdi32'
|
|
66
|
+
API.defun 'CreateRectRgn(int left, int top, int right, int bottom)'
|
|
67
|
+
API.defun 'CombineRgn(HRGN dest, HRGN src1, HRGN src2, int Combinemode)'
|
|
68
|
+
API.defun 'SetWindowRgn(HWND hwnd, HRGN hRgn, BOOL bRedraw)'
|
|
69
|
+
API.defun 'DeleteObject(HANDLE handle)'
|
|
70
|
+
|
|
71
|
+
RGN_OR = 2
|
|
72
|
+
RGN_DIFF = 4
|
|
73
|
+
|
|
74
|
+
attr_accessor :border
|
|
75
|
+
|
|
76
|
+
def initialize(obj, parent, first_selection=nil)
|
|
77
|
+
@_classname = "RUBYWIN"
|
|
78
|
+
@_parent = parent
|
|
79
|
+
@_x = @_y = @_w = @_h = 0
|
|
80
|
+
self.style = WS_VISIBLECHILD
|
|
81
|
+
self.exstyle = WS_EX_TOPMOST
|
|
82
|
+
register_event(WM_LBUTTONDOWN, '_lbuttondown', 'xh')
|
|
83
|
+
@target = obj
|
|
84
|
+
register_event(WM_SIZE, '_resize', 'xh')
|
|
85
|
+
register_event(WM_MOUSEMOVE, '_mousemove', 'xh')
|
|
86
|
+
register_event(WM_PAINT, '_paint', 'c', HandleGr)
|
|
87
|
+
@first_selection = first_selection
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
private
|
|
91
|
+
def _lbuttondown(x, y)
|
|
92
|
+
return unless @first_selection
|
|
93
|
+
@target.resize_start(hoobartest(x, y))
|
|
94
|
+
self.visible=false
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def _mousemove(x, y)
|
|
98
|
+
return unless @first_selection
|
|
99
|
+
hoobarpos2cursor(hoobartest(x, y))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def hoobarpos2cursor(pos)
|
|
103
|
+
case pos
|
|
104
|
+
when 1, 2
|
|
105
|
+
APP.SetCursor(SizeNWSE)
|
|
106
|
+
when 3, 4
|
|
107
|
+
APP.SetCursor(SizeNESW)
|
|
108
|
+
when 5, 6
|
|
109
|
+
APP.SetCursor(SizeWE)
|
|
110
|
+
when 7, 8
|
|
111
|
+
APP.SetCursor(SizeNS)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def hoobartest(x, y)
|
|
116
|
+
w, h = windowsize
|
|
117
|
+
c = w/2
|
|
118
|
+
m = h/2
|
|
119
|
+
if (0<=x && x<=5) && (0<=y && y<=5)
|
|
120
|
+
1
|
|
121
|
+
elsif (w-5<=x && x<=w) && (h-5<=y && y<=h)
|
|
122
|
+
2
|
|
123
|
+
elsif (w-5<=x && x<=w) && (0<=y && y<=5)
|
|
124
|
+
3
|
|
125
|
+
elsif (0<=x && x<=5) && (h-5<=y && y<=h)
|
|
126
|
+
4
|
|
127
|
+
elsif (0<=x && x<=5) && (m-3<=y && y<=m+2)
|
|
128
|
+
5
|
|
129
|
+
elsif (w-5<=x && x<=w) && (m-3<=y && y<=m+2)
|
|
130
|
+
6
|
|
131
|
+
elsif (c-3<=x && x<=c+2) && (0<=y && y<=5)
|
|
132
|
+
7
|
|
133
|
+
elsif (c-3<=x && x<=c+2) && (h-5<=y && y<=h)
|
|
134
|
+
8
|
|
135
|
+
else
|
|
136
|
+
nil
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def _resize(w, h)
|
|
141
|
+
if @border
|
|
142
|
+
_resize_border(w, h)
|
|
143
|
+
else
|
|
144
|
+
_resize_handle(w, h)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def _resize_border(w, h)
|
|
149
|
+
hrgn = API.CreateRectRgn(0, 0, 1, 1)
|
|
150
|
+
hr1 = API.CreateRectRgn(0, 0, w, h)
|
|
151
|
+
hr2 = API.CreateRectRgn(1, 1, w-1, h-1)
|
|
152
|
+
API.CombineRgn(hrgn, hr1, hr2, RGN_DIFF)
|
|
153
|
+
API.DeleteObject(hr1)
|
|
154
|
+
API.DeleteObject(hr2)
|
|
155
|
+
API.SetWindowRgn(self._hwnd, hrgn, 1)
|
|
156
|
+
refresh if self.visible
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def _resize_handle(w, h)
|
|
160
|
+
c = w/2
|
|
161
|
+
m = h/2
|
|
162
|
+
hrgn = API.CreateRectRgn(0, 0, 1, 1)
|
|
163
|
+
|
|
164
|
+
hr12 = API.CreateRectRgn(0, 0, 1, 1)
|
|
165
|
+
hr1 = API.CreateRectRgn(0, 0, 5, 5)
|
|
166
|
+
hr2 = API.CreateRectRgn(w-5, 0, w, 5)
|
|
167
|
+
API.CombineRgn(hr12, hr1, hr2, RGN_OR)
|
|
168
|
+
API.DeleteObject(hr1)
|
|
169
|
+
API.DeleteObject(hr2)
|
|
170
|
+
|
|
171
|
+
hr34 = API.CreateRectRgn(0, 0, 1, 1)
|
|
172
|
+
hr3 = API.CreateRectRgn(0, h-5, 5, h)
|
|
173
|
+
hr4 = API.CreateRectRgn(w-5, h-5, w, h)
|
|
174
|
+
API.CombineRgn(hr34, hr3, hr4, RGN_OR)
|
|
175
|
+
API.DeleteObject(hr3)
|
|
176
|
+
API.DeleteObject(hr4)
|
|
177
|
+
|
|
178
|
+
hr1234 = API.CreateRectRgn(0, 0, 1, 1)
|
|
179
|
+
API.CombineRgn(hr1234, hr12, hr34, RGN_OR)
|
|
180
|
+
API.DeleteObject(hr12)
|
|
181
|
+
API.DeleteObject(hr34)
|
|
182
|
+
|
|
183
|
+
hr56 = API.CreateRectRgn(0, 0, 1, 1)
|
|
184
|
+
hr5 = API.CreateRectRgn(c-3, 0, c+2, 5)
|
|
185
|
+
hr6 = API.CreateRectRgn(c-3, h-5, c+2, h)
|
|
186
|
+
API.CombineRgn(hr56, hr5, hr6, RGN_OR)
|
|
187
|
+
API.DeleteObject(hr5)
|
|
188
|
+
API.DeleteObject(hr6)
|
|
189
|
+
|
|
190
|
+
hr78 = API.CreateRectRgn(0, 0, 1, 1)
|
|
191
|
+
hr7 = API.CreateRectRgn(0, m-3, 5, m+2)
|
|
192
|
+
hr8 = API.CreateRectRgn(w-5, m-3, w, m+2)
|
|
193
|
+
API.CombineRgn(hr78, hr7, hr8, RGN_OR)
|
|
194
|
+
API.DeleteObject(hr7)
|
|
195
|
+
API.DeleteObject(hr8)
|
|
196
|
+
|
|
197
|
+
hr5678 = API.CreateRectRgn(0, 0, 1, 1)
|
|
198
|
+
API.CombineRgn(hr5678, hr56, hr78, RGN_OR)
|
|
199
|
+
API.DeleteObject(hr56)
|
|
200
|
+
API.DeleteObject(hr78)
|
|
201
|
+
|
|
202
|
+
API.CombineRgn(hrgn, hr1234, hr5678, RGN_OR)
|
|
203
|
+
API.DeleteObject(hr1234)
|
|
204
|
+
API.DeleteObject(hr5678)
|
|
205
|
+
|
|
206
|
+
API.SetWindowRgn(self._hwnd, hrgn, 1)
|
|
207
|
+
refresh if self.visible
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
class HandleGr < RWin::Canvas
|
|
211
|
+
def draw(obj, border, first_selection)
|
|
212
|
+
obj_w, obj_h = obj.windowsize
|
|
213
|
+
if border
|
|
214
|
+
SetPen(0xff0000)
|
|
215
|
+
Rectangle(0, 0, obj_w, obj_h)
|
|
216
|
+
return
|
|
217
|
+
end
|
|
218
|
+
if first_selection
|
|
219
|
+
SetBrush(0xffffff)
|
|
220
|
+
else
|
|
221
|
+
SetBrush(0xafafaf)
|
|
222
|
+
end
|
|
223
|
+
Rectangle(0, 0, 5, 5)
|
|
224
|
+
Rectangle(obj_w-5, 0, obj_w, 5)
|
|
225
|
+
Rectangle(0, obj_h-5, 5, obj_h)
|
|
226
|
+
Rectangle(obj_w-5, obj_h-5, obj_w, obj_h)
|
|
227
|
+
Rectangle(obj_w/2-3, 0, obj_w/2+2, 5)
|
|
228
|
+
Rectangle(obj_w/2-3, obj_h-5, obj_w/2+2, obj_h)
|
|
229
|
+
Rectangle(0, obj_h/2-3, 5, obj_h/2+2)
|
|
230
|
+
Rectangle(obj_w-5, obj_h/2-3, obj_w, obj_h/2+2)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def _paint(gr)
|
|
235
|
+
gr.draw(self, @border, @first_selection)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
module ModFDCommon
|
|
240
|
+
if (RWin::X64 rescue nil)
|
|
241
|
+
API.defun "ChildWindowFromPoint(hwnd, point)"
|
|
242
|
+
def __hittest(sx, sy) # Argument is not pointer but 64bits integer
|
|
243
|
+
pt = API::POINT[*ScreenToClient(sx, sy)]
|
|
244
|
+
cwnd = API.ChildWindowFromPoint(self._hwnd, (pt.y<<32) + pt.x)
|
|
245
|
+
r = APP.hwnd2ref(cwnd)
|
|
246
|
+
if r!=self && r.respond_to?(:controls)
|
|
247
|
+
r = r.__hittest(sx, sy)
|
|
248
|
+
end
|
|
249
|
+
return r
|
|
250
|
+
end
|
|
251
|
+
else
|
|
252
|
+
API.defun "ChildWindowFromPoint(hwnd, x, y)" # Convers 64bis integer to 2 DWORDs
|
|
253
|
+
def __hittest(sx, sy)
|
|
254
|
+
pt = API::POINT[*ScreenToClient(sx, sy)]
|
|
255
|
+
cwnd = API.ChildWindowFromPoint(self._hwnd, pt.x, pt.y)
|
|
256
|
+
r = APP.hwnd2ref(cwnd)
|
|
257
|
+
if r!=self && r.respond_to?(:controls)
|
|
258
|
+
r = r.__hittest(sx, sy)
|
|
259
|
+
end
|
|
260
|
+
return r
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def parse_template4out(ctrl, cmd, tp, defval=nil)
|
|
265
|
+
atr = ctrl.__send__(cmd.intern)
|
|
266
|
+
return '' if atr == defval
|
|
267
|
+
if (c=ctrl.class) < WinControl # ; dpp self, cmd, atr
|
|
268
|
+
if (f=c::FDConfig["#{cmd}_out".intern])
|
|
269
|
+
return f.call(ctrl, atr)
|
|
270
|
+
elsif (f=c::FDConfig["#{cmd}_get".intern])
|
|
271
|
+
return f.call(ctrl, atr)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
if atr.is_a?(Font)
|
|
275
|
+
ar = [atr.facename, atr.height, atr.attrstr]
|
|
276
|
+
ar.delete("")
|
|
277
|
+
return sprintf("%p", ar)
|
|
278
|
+
elsif tp && tp.size>1 && atr.respond_to?(:to_a)
|
|
279
|
+
atr = atr.to_a
|
|
280
|
+
end
|
|
281
|
+
if !atr.is_a?(Array)
|
|
282
|
+
case tp
|
|
283
|
+
when 'h'
|
|
284
|
+
sprintf("%#x", atr)
|
|
285
|
+
when 'n'
|
|
286
|
+
atr.respond_to?(:name) ? "_#{atr.name}" : atr.to_s
|
|
287
|
+
when 'a'
|
|
288
|
+
atr ? sprintf("%p", atr.to_a) : ''
|
|
289
|
+
else
|
|
290
|
+
sprintf("%p", atr)
|
|
291
|
+
end
|
|
292
|
+
else #; dpp ctrl, cmd, tp, atr
|
|
293
|
+
tp = tp.split(',')[0]
|
|
294
|
+
return sprintf("%p", atr) if tp=='a'
|
|
295
|
+
r = []
|
|
296
|
+
tp.size.times{|i|
|
|
297
|
+
c = tp[i]
|
|
298
|
+
case c
|
|
299
|
+
when 'h'
|
|
300
|
+
r << sprintf("%#x", atr[i])
|
|
301
|
+
when 'n'
|
|
302
|
+
r << (atr[i].respond_to?(:name) ? "_#{atr[i].name}" : atr[i].to_s)
|
|
303
|
+
else
|
|
304
|
+
r << sprintf("%p", atr[i])
|
|
305
|
+
end
|
|
306
|
+
}
|
|
307
|
+
"[#{r.join(", ")}]"
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def index_of_src(lns, lsrc)
|
|
312
|
+
lsrc_id = lsrc.__id__
|
|
313
|
+
lns.index{|i| i.__id__==lsrc_id}
|
|
314
|
+
end
|
|
315
|
+
module_function :index_of_src
|
|
316
|
+
|
|
317
|
+
def style2symbols
|
|
318
|
+
r = []
|
|
319
|
+
st = self.style
|
|
320
|
+
altmask = self.class::FDConfig[:altanate_mask] || []
|
|
321
|
+
self.class::WinStyles.each{|k, v|
|
|
322
|
+
m = altmask.find{|i| i&v>0 || (i&1>0 && v==0)}
|
|
323
|
+
if m
|
|
324
|
+
next r << k if v==(st&m)
|
|
325
|
+
else
|
|
326
|
+
r << k if v==(v&st)
|
|
327
|
+
end
|
|
328
|
+
}
|
|
329
|
+
r
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def __fd_set_items_srcs(lns, curln, indent, ar)
|
|
333
|
+
if @__fd_items_srcs
|
|
334
|
+
__fd_delete_items_srcs(lns)
|
|
335
|
+
else
|
|
336
|
+
extend ModFDItemsSrcLine
|
|
337
|
+
end
|
|
338
|
+
ar.each{|i|
|
|
339
|
+
lns[curln+=1, 0] = (s=indent+i+"\n")
|
|
340
|
+
@__fd_items_srcs << [indent.size, i.size, s]
|
|
341
|
+
}
|
|
342
|
+
curln
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
def __fd_delete_items_srcs(lns)
|
|
346
|
+
return unless @__fd_items_srcs
|
|
347
|
+
@__fd_items_srcs.each{|i|
|
|
348
|
+
col, len, lsrc = i
|
|
349
|
+
lns.delete(lsrc)
|
|
350
|
+
}
|
|
351
|
+
@__fd_items_srcs.clear
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
module ModFDSrcLine
|
|
356
|
+
attr_accessor :binded_obj
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
module ModFDAttrSrcLine
|
|
360
|
+
attr_accessor :__fd_src
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
module ModFDItemsSrcLine
|
|
364
|
+
attr_accessor :__fd_items_src
|
|
365
|
+
attr_reader :__fd_items_srcs
|
|
366
|
+
def self.extended(obj)
|
|
367
|
+
obj.__fd_items_srcs_init
|
|
368
|
+
end
|
|
369
|
+
def __fd_items_srcs_init()
|
|
370
|
+
@__fd_items_srcs = []
|
|
371
|
+
end
|
|
372
|
+
def __fd_items_src=(asrc) #; dpp asrc
|
|
373
|
+
@__fd_items_src = asrc
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
module ModControlHook
|
|
378
|
+
FDAttributes = ['class', ['name', 'm']]
|
|
379
|
+
|
|
380
|
+
module ModControlChildHook
|
|
381
|
+
include RC
|
|
382
|
+
def self.extended(obj) obj.__extended end
|
|
383
|
+
def __extended()
|
|
384
|
+
if (handle=API.GetWindow(_hwnd, GW_CHILD)) != 0
|
|
385
|
+
cct = WinControl.new_from_handle(handle)
|
|
386
|
+
cct.extend ModControlChildHook
|
|
387
|
+
end
|
|
388
|
+
self.SetWindowSubclass
|
|
389
|
+
@_toplevelwin = get_toplevel_win
|
|
390
|
+
register_event(WM_LBUTTONDOWN, '__fd_lbuttondown', 'ih')
|
|
391
|
+
register_event(WM_RBUTTONDOWN, '__fd_rbuttondown', 'ih')
|
|
392
|
+
register_event(WM_MOUSEMOVE, '__fd_mousemove', 'ii')
|
|
393
|
+
end
|
|
394
|
+
def __fd_lbuttondown(wp, x, y)
|
|
395
|
+
parent.SendMessage(WM_LBUTTONDOWN, wp, MAKELPARAM(x+self.x, y+self.y))
|
|
396
|
+
CancelDefWindowProc
|
|
397
|
+
end
|
|
398
|
+
def __fd_rbuttondown(stat, x, y)
|
|
399
|
+
x, y = @_toplevelwin.ScreenToClient(*self.ClientToScreen(x, y))
|
|
400
|
+
@_toplevelwin.show_popup(x, y)
|
|
401
|
+
CancelDefWindowProc
|
|
402
|
+
end
|
|
403
|
+
def __fd_mousemove(wp, lp)
|
|
404
|
+
return unless wp==1
|
|
405
|
+
parent.SendMessage(WM_MOUSEMOVE, wp, lp)
|
|
406
|
+
CancelDefWindowProc
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
@@childproc ||= lambda{|handle|
|
|
411
|
+
WinControl.new_from_handle(handle).extend(ModControlChildHook)
|
|
412
|
+
return 1
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
include ModAutoloading
|
|
416
|
+
include RC
|
|
417
|
+
include ModFDCommon
|
|
418
|
+
def self.extended(obj) obj.__extended end
|
|
419
|
+
|
|
420
|
+
attr_reader :__fd_written, :__fd_events
|
|
421
|
+
attr_accessor :_ox, :_oy , :_toplevelwin, :__fd_src, :__fd_items_src, :__fd_tmp_parent_str
|
|
422
|
+
|
|
423
|
+
def font()
|
|
424
|
+
hf = SendMessage(RC::WM_GETFONT, 0, 0)
|
|
425
|
+
pf = parent.SendMessage(RC::WM_GETFONT, 0, 0)
|
|
426
|
+
if hf!=0 && pf==hf
|
|
427
|
+
:parent
|
|
428
|
+
else
|
|
429
|
+
super
|
|
430
|
+
end
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def __extended()
|
|
434
|
+
@_toplevelwin = get_toplevel_win
|
|
435
|
+
API.EnumChildWindows(_hwnd, @@childproc, 0) if self.class::FDConfig[:need_childhook]
|
|
436
|
+
set_subclass #; dpp self, caller[0, 3]
|
|
437
|
+
register_event(WM_DESTROY, '__fd_destroy')
|
|
438
|
+
|
|
439
|
+
unless self.class::FDConfig[:no_hookwndproc]
|
|
440
|
+
unregister_event(WM_MOUSEMOVE)
|
|
441
|
+
register_event(WM_LBUTTONDOWN, '__fd_lbuttondown', 'ih')
|
|
442
|
+
register_event(WM_LBUTTONUP, '__fd_lbuttonup', 'ih')
|
|
443
|
+
register_event(WM_RBUTTONDOWN, '__fd_rbuttondown', 'ih')
|
|
444
|
+
register_event(WM_RBUTTONUP, '__fd_rbuttonup', 'ih')
|
|
445
|
+
register_event(WM_MOUSEMOVE, '__fd_mousemove', 'ih')
|
|
446
|
+
end
|
|
447
|
+
@__fd_events = self.class::DefaultEvents.dup || []
|
|
448
|
+
# @__fd_items_srcs = {}
|
|
449
|
+
# @__fd_items_srcs = []
|
|
450
|
+
self
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
def __fd_lbuttondown(stat, x, y) #; dpp self, x, y
|
|
454
|
+
SetCapture()
|
|
455
|
+
@_ox = x
|
|
456
|
+
@_oy = y
|
|
457
|
+
@_toplevelwin.ignore_mousemove = nil
|
|
458
|
+
cx, cy = clientpos
|
|
459
|
+
if self.respond_to?(:controls) && $fd_main_frm.selected_klass #; dpp self, cx, cy
|
|
460
|
+
# @_toplevelwin.add_fd_selected_ctrl(cx+x, cy+y, self, self.parent)
|
|
461
|
+
@_toplevelwin.add_fd_selected_ctrl(x, y, self, self.parent)
|
|
462
|
+
else
|
|
463
|
+
@_toplevelwin.__added_control_ = nil
|
|
464
|
+
@_toplevelwin.move_start(cx+x, cy+y, self, stat==9)
|
|
465
|
+
end
|
|
466
|
+
CancelDefWindowProc
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def __fd_lbuttonup(stat, x, y)
|
|
470
|
+
@_toplevelwin.move_end()
|
|
471
|
+
$fd_main_frm.selected_klass = nil
|
|
472
|
+
pr = parent
|
|
473
|
+
pr.SendMessage(WM_SIZE, 0, MAKELPARAM(*pr.clientsize))
|
|
474
|
+
ReleaseCapture()
|
|
475
|
+
CancelDefWindowProc
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def __fd_rbuttondown(stat, x, y)
|
|
479
|
+
x, y = @_toplevelwin.ScreenToClient(*self.ClientToScreen(x, y))
|
|
480
|
+
@_toplevelwin.move_start(x, y, self, stat==9)
|
|
481
|
+
@_toplevelwin.show_popup(x, y)
|
|
482
|
+
CancelDefWindowProc
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
def __fd_mousemove(stat, x, y)
|
|
486
|
+
return unless (stat&1)==1
|
|
487
|
+
return if @_toplevelwin.ignore_mousemove
|
|
488
|
+
@_toplevelwin.moving(x+self.x, y+self.y, stat) unless @_toplevelwin._resizing_
|
|
489
|
+
CancelDefWindowProc
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def __fd_destroy()#; dpp self, @_toplevelwin
|
|
493
|
+
return if @__fd_skip_destroy_event
|
|
494
|
+
return unless @_toplevelwin
|
|
495
|
+
if lns=@_toplevelwin.__fd_src[:lines]
|
|
496
|
+
if @__fd_src
|
|
497
|
+
col, len, lsrc = @__fd_src
|
|
498
|
+
lns.delete_if{|i| i.__id__ == lsrc.__id__}
|
|
499
|
+
end
|
|
500
|
+
if @__fd_items_src && (lns=@_toplevelwin.__fd_src[:lines])
|
|
501
|
+
col, len, lsrc = @__fd_items_src
|
|
502
|
+
lns.delete_if{|i| i.__id__ == lsrc.__id__}
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
if @__fd_items_srcs && !@__fd_items_srcs.empty? && (lns=@_toplevelwin.__fd_src[:lines])
|
|
506
|
+
@__fd_items_srcs.each{|v|
|
|
507
|
+
col, len, lsrc = v
|
|
508
|
+
lns.delete_if{|i| i.__id__==lsrc.__id__}
|
|
509
|
+
}
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
def __fd_attributes__()
|
|
515
|
+
FDAttributes.dup + (self.class::FDConfig[:attributes] || [])
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
def to_hsh()
|
|
519
|
+
cfg = self.class::FDConfig
|
|
520
|
+
attrs1 = {'caption'=>'s', 'position'=>'ii', 'size'=>'ii'}
|
|
521
|
+
attrs2 = cfg[:attributes].dup
|
|
522
|
+
at = []
|
|
523
|
+
attrs2.reject!{|i| attrs1[i[0]] ? at << i[0] : nil}
|
|
524
|
+
s = "#{self.class.to_s.split('::').last}["
|
|
525
|
+
ar = [name]
|
|
526
|
+
ar << caption if at.index('caption') && !caption.empty?
|
|
527
|
+
if cfg[:size_out]
|
|
528
|
+
ar.concat position + cfg[:size_out].call(self, size)
|
|
529
|
+
elsif margin
|
|
530
|
+
ar.concat margin.origin
|
|
531
|
+
else
|
|
532
|
+
ar.concat position + (at.index('size') ? size : cfg[:default_size])
|
|
533
|
+
end
|
|
534
|
+
ar.compact!
|
|
535
|
+
s << sprintf("%p", ar).tr('[]', '') #; dp "@%x", style
|
|
536
|
+
sts = style & ~(self.class::DefaultWindowStyle | WS_VISIBLECHILD | WS_CLIPSIBLINGS)
|
|
537
|
+
sts &= ~__fd_style_mask_cond.to_i if respond_to?(:__fd_style_mask_cond)
|
|
538
|
+
s << sprintf(", %#x", sts) if sts!=0
|
|
539
|
+
hsh = {:_attr_base=>s}
|
|
540
|
+
attrs2.each{|k, tp, defval|
|
|
541
|
+
s = parse_template4out(self, k, tp, defval)
|
|
542
|
+
hsh[k] = (s.nil?||s.is_a?(String)) ? s.to_s : sprintf("%p", s)
|
|
543
|
+
}
|
|
544
|
+
hsh.delete("font") if hsh["font"]==":parent" && parent.inheritfont==true
|
|
545
|
+
hsh
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
def __fd_recreate()
|
|
549
|
+
@_caption = self.caption
|
|
550
|
+
@_x, @_y = self.position
|
|
551
|
+
@_w, @_h = self.size
|
|
552
|
+
@_parent = self.parent
|
|
553
|
+
@_idcmd = self.idcmd
|
|
554
|
+
@_style = self.style
|
|
555
|
+
@_exstyle = self.exstyle
|
|
556
|
+
@_font = font.is_a?(Font) && font.external? ? nil : font
|
|
557
|
+
@_visible = self.visible; #Defined in ModParent
|
|
558
|
+
unregister_event(WM_SIZE, "__resize__")
|
|
559
|
+
GC.disable
|
|
560
|
+
@__fd_skip_destroy_event = true
|
|
561
|
+
self.close()
|
|
562
|
+
@__fd_skip_destroy_event = nil
|
|
563
|
+
self.create()
|
|
564
|
+
GC.enable
|
|
565
|
+
parent.__fd_child_recreated(self) if parent.respond_to?(:__fd_child_recreated) #Uses Rebar
|
|
566
|
+
API.EnumChildWindows(_hwnd, @@childproc, 0) if self.class::FDConfig[:need_childhook]
|
|
567
|
+
self
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
def __fd_to_str_core(lns)
|
|
571
|
+
s = ""
|
|
572
|
+
self.to_hsh.each{|k, v|
|
|
573
|
+
case k
|
|
574
|
+
when :_attr_base
|
|
575
|
+
s << v
|
|
576
|
+
when 'font'
|
|
577
|
+
if (ft=SendMessage(WM_GETFONT,0,0))!=@default_hfont
|
|
578
|
+
if ft==parent.SendMessage(WM_GETFONT,0,0)
|
|
579
|
+
s << ", :font=>:parent"
|
|
580
|
+
else
|
|
581
|
+
s << ", :font=>#{v}"
|
|
582
|
+
end
|
|
583
|
+
end
|
|
584
|
+
else
|
|
585
|
+
s << ", :#{k}=>#{v}" unless v.empty?
|
|
586
|
+
end
|
|
587
|
+
}
|
|
588
|
+
evs = self.__fd_events - self.class::DefaultEvents
|
|
589
|
+
s << sprintf(", :events=>%p", evs) unless evs.empty?
|
|
590
|
+
s << "]"
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
def __fd_get_parents_str()
|
|
594
|
+
if @__fd_tmp_parent_str
|
|
595
|
+
s = @__fd_tmp_parent_str
|
|
596
|
+
@__fd_tmp_parent_str = nil
|
|
597
|
+
return s
|
|
598
|
+
end
|
|
599
|
+
return "_" if parent==@_toplevelwin && !@_owner
|
|
600
|
+
ps = (po=@_owner||parent).__fd_get_parents_str
|
|
601
|
+
ps=="_" ? "_" + po.name.to_s : ps + "._" + po.name.to_s
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
def __fd_get_parents_str2()
|
|
605
|
+
s = __fd_get_parents_str()
|
|
606
|
+
s=='_' ? s+name.to_s : s+"._#{name}"
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
def __fd_set_items_src(obj, lns, curln, indent, s)# ; dpp obj, curln, s
|
|
610
|
+
if obj.respond_to?(:__fd_items_src) && obj.__fd_items_src
|
|
611
|
+
col, len, lsrc = obj.__fd_items_src
|
|
612
|
+
lsrc[col, len] = s
|
|
613
|
+
obj.__fd_items_src[1] = s.size
|
|
614
|
+
else
|
|
615
|
+
obj.extend ModFDItemsSrcLine
|
|
616
|
+
obj.__fd_items_src = [indent.size, s.size, s=indent+s]
|
|
617
|
+
s.extend(ModFDSrcLine).binded_obj = obj
|
|
618
|
+
lns[curln, 0] = s+"\n"
|
|
619
|
+
end
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
def __fd_delete_items_src(obj, lns)
|
|
623
|
+
if obj.respond_to?(:__fd_items_src) && obj.__fd_items_src
|
|
624
|
+
col, len, lsrc = obj.__fd_items_src
|
|
625
|
+
lns.delete(lsrc)
|
|
626
|
+
obj.__fd_items_src = nil
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
def __fd_modify_src(lns, curln, indent)
|
|
631
|
+
if @__fd_src
|
|
632
|
+
col, len, lsrc, lcount = @__fd_src
|
|
633
|
+
ps = __fd_get_parents_str
|
|
634
|
+
str = ps + (ps=='_' ? "<< " : " << ") + __fd_to_str_core(lns)
|
|
635
|
+
if lcount.to_i > 1
|
|
636
|
+
str << "\n"
|
|
637
|
+
lsrc[col, len] = str
|
|
638
|
+
lns.slice!(curln+1, lcount-1)
|
|
639
|
+
else
|
|
640
|
+
lsrc[col, len] = str
|
|
641
|
+
end
|
|
642
|
+
curln = index_of_src(lns, lsrc)
|
|
643
|
+
raise "failed to get index of #{lsrc}" unless curln # for debugging
|
|
644
|
+
if respond_to?(:__fd_output_items)
|
|
645
|
+
curln = __fd_output_items(lns, curln, indent)
|
|
646
|
+
# elsif set_items_src = self.class::FDConfig[:have_items]
|
|
647
|
+
# curln = set_items_src.call(self, lns, curln, indent)
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
@__fd_src[1] = str.size
|
|
651
|
+
controls.each{|i|
|
|
652
|
+
curln = i.__fd_modify_src(lns, curln, indent)
|
|
653
|
+
} if self.class::FDConfig[:have_controls]
|
|
654
|
+
else # Added control
|
|
655
|
+
curln = __fd_to_str(lns, curln, indent)
|
|
656
|
+
end
|
|
657
|
+
curln
|
|
658
|
+
end
|
|
659
|
+
|
|
660
|
+
def __fd_to_str(lns, curln, indent)
|
|
661
|
+
ps = __fd_get_parents_str
|
|
662
|
+
str = indent + ps + (ps=='_' ? "<< " : " << ") + __fd_to_str_core(lns) + "\n"
|
|
663
|
+
@__fd_src = [indent.size, str.size-indent.size-1, str]
|
|
664
|
+
str.extend(ModFDSrcLine).binded_obj = self
|
|
665
|
+
lns[curln+=1, 0] = str
|
|
666
|
+
|
|
667
|
+
if respond_to?(:__fd_output_items)
|
|
668
|
+
curln = __fd_output_items(lns, curln, indent)
|
|
669
|
+
# elsif set_items_src = self.class::FDConfig[:have_items]
|
|
670
|
+
# curln = set_items_src.call(self, lns, curln, indent)
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
fdcfg = self.class::FDConfig
|
|
674
|
+
controls._each{|i| curln = i.__fd_to_str(lns, curln, indent)} if fdcfg[:have_controls]
|
|
675
|
+
curln
|
|
676
|
+
end
|
|
677
|
+
end # ModControlHook
|
|
678
|
+
|
|
679
|
+
module ModToplevelHook
|
|
680
|
+
FDAttributes = [['class', 'c'], ['size', 'ii'], ['clientsize', 'ii'], ['caption', 's', ''], ['transparency', 'i'], ['transparentcolor', 'h'], ['font','sis,t'], ['inheritfont', 'sis,t']]
|
|
681
|
+
|
|
682
|
+
include ModAutoloading
|
|
683
|
+
include RC
|
|
684
|
+
include ModFDCommon
|
|
685
|
+
attr_reader :selected_controls, :_resizing_, :toplevel_mousepos, :__fd_idcmd_hash,
|
|
686
|
+
:__fd_written, :__fd_src, :__fd_events
|
|
687
|
+
attr_accessor :ignore_mousemove, :__added_control_
|
|
688
|
+
|
|
689
|
+
def self.extended(obj)
|
|
690
|
+
obj.__fd_init_this_module
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
def initialize()
|
|
694
|
+
__fd_init_this_module
|
|
695
|
+
end
|
|
696
|
+
|
|
697
|
+
def __fd_init_this_module()
|
|
698
|
+
register_event(WM_LBUTTONDOWN, '__fd_lbuttondown', 'ih')
|
|
699
|
+
register_event(WM_LBUTTONUP, '__fd_lbuttonup', 'ih')
|
|
700
|
+
register_event(WM_RBUTTONDOWN, '__fd_rbuttondown', 'ih')
|
|
701
|
+
register_event(WM_MOUSEMOVE, '__fd_mousemove', 'ih')
|
|
702
|
+
register_event(WM_PARENTNOTIFY, '__fd_parentnotify', 'ih')
|
|
703
|
+
register_event(WM_SIZE, '__fd_resize', 'ih')
|
|
704
|
+
register_event(WM_SETCURSOR, '__fd_setcursor', 'ih')
|
|
705
|
+
register_event(WM_ACTIVATE, '__fd_activate', 'ii')
|
|
706
|
+
register_event(WM_MOVE, '__fd_move', 'xh')
|
|
707
|
+
register_event(WM_SIZE, '__fd_size', 'xh') unless self.is_a?(RWin::Dialog)
|
|
708
|
+
register_event(WM_CLOSE, '__fd_close')
|
|
709
|
+
|
|
710
|
+
@_font = ModToplevelWin::DefaultFont
|
|
711
|
+
@_inheritfont = true
|
|
712
|
+
@selected_controls = []
|
|
713
|
+
@handles = []
|
|
714
|
+
@cut_buff = []
|
|
715
|
+
@undo_buff = []
|
|
716
|
+
|
|
717
|
+
@_prvx = @_prvy = 0
|
|
718
|
+
@_steps = [5, 4, 3, nil] # Shift, Ctrl, Shift+Ctrl, None
|
|
719
|
+
@move_step = 5
|
|
720
|
+
@size_step = 4
|
|
721
|
+
@__fd_events = []
|
|
722
|
+
|
|
723
|
+
@__fd_idcmd_hash = {}
|
|
724
|
+
@__fd_popup1 = Menu[ :popup1,
|
|
725
|
+
# :undo1, "Undo\tCtrl+Z",
|
|
726
|
+
# :redo1, "Redo\tCtrl+Y",
|
|
727
|
+
# :sep1,
|
|
728
|
+
# :cut1, "Cut\tCtrl+X",
|
|
729
|
+
# :copy1, "Copy\tCtrl+C",
|
|
730
|
+
# :paste1, "Paste\tCtrl+V",
|
|
731
|
+
:delete1, "Delete\tDelete",
|
|
732
|
+
:sep,
|
|
733
|
+
Menu[:justify, 'Justify',
|
|
734
|
+
:justify, 'left',
|
|
735
|
+
:justify, 'Top',
|
|
736
|
+
:justify, 'Right',
|
|
737
|
+
:justify, 'Bottom']]
|
|
738
|
+
controls.each{|i| i.extend(i.is_a?(RWin::Window) ? ModControlHook : ModResourceHook) }
|
|
739
|
+
@__fd_src = {}
|
|
740
|
+
@__fd_defstylemask = self.class::WinStyles.to_a.inject(0){|r, v| r | v[1]}
|
|
741
|
+
@__fd_ctrls_buff = []
|
|
742
|
+
# dp "@%#x", @__fd_defstyles
|
|
743
|
+
end
|
|
744
|
+
|
|
745
|
+
def register_event(*args)
|
|
746
|
+
if args.size>4 && args[1] == WM_COMMAND && args[2]==BN_CLICKED
|
|
747
|
+
@__fd_idcmd_hash[args[0]] = args[3].sub(/_clicked$/, '')
|
|
748
|
+
end
|
|
749
|
+
super
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
def created()
|
|
753
|
+
@_keyaccels = nil
|
|
754
|
+
@__fd_popup1._set_owner(self)
|
|
755
|
+
@__fd_popup1.createpopup
|
|
756
|
+
@infobox = Infobox.new(self).create()
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
def opened(arg) # for Dialog
|
|
760
|
+
created()
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
def __fd_move(*)
|
|
764
|
+
$fd_main_frm.move(x+w, y) if active?
|
|
765
|
+
end
|
|
766
|
+
|
|
767
|
+
def __fd_size(*)
|
|
768
|
+
if active?
|
|
769
|
+
$fd_main_frm.move(x+w, y)
|
|
770
|
+
else
|
|
771
|
+
self.move($fd_main_frm.x-w, y)
|
|
772
|
+
end
|
|
773
|
+
end
|
|
774
|
+
|
|
775
|
+
def __fd_close()
|
|
776
|
+
CancelDefWindowProc
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
def _toplevelwin()
|
|
780
|
+
self
|
|
781
|
+
end
|
|
782
|
+
|
|
783
|
+
def pos_from_toplevel(obj)
|
|
784
|
+
cx, cy = obj.clientpos
|
|
785
|
+
if obj.parent && obj.parent.parent
|
|
786
|
+
px, py = pos_from_toplevel(obj.parent)
|
|
787
|
+
cx += px
|
|
788
|
+
cy += py
|
|
789
|
+
end
|
|
790
|
+
[cx, cy]
|
|
791
|
+
end
|
|
792
|
+
|
|
793
|
+
def get_allnames(ctrls, ar) #dpp caller, ctrls, ctrls._accessors
|
|
794
|
+
ctrls._accessors.keys.inject(ar){|a, k| a << k.to_s} if ctrls._accessors
|
|
795
|
+
ctrls.each{|i|
|
|
796
|
+
get_allnames(i.controls, ar) if i.respond_to?(:controls)
|
|
797
|
+
if i.respond_to?(:_accessors) && i._accessors
|
|
798
|
+
i._accessors.keys.inject(ar){|a, k| a << k.to_s}
|
|
799
|
+
end
|
|
800
|
+
}
|
|
801
|
+
ar
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
def suffixed_name(nm) #; dpp caller, nm
|
|
805
|
+
base = nm.sub(/\d+$/, '')
|
|
806
|
+
suffix = $~[0].to_i
|
|
807
|
+
allnames = get_allnames(self.controls, [])
|
|
808
|
+
while allnames.index(base + suffix.to_s)
|
|
809
|
+
suffix += 1
|
|
810
|
+
end
|
|
811
|
+
base + suffix.to_s
|
|
812
|
+
end
|
|
813
|
+
|
|
814
|
+
def add_fd_selected_ctrl(x, y, target, prnt)# ; dpp x, y, target, prnt
|
|
815
|
+
klass = $fd_main_frm.selected_klass
|
|
816
|
+
conf = klass::FDConfig
|
|
817
|
+
w, h = conf[:default_size] || [80, 24]
|
|
818
|
+
defcap = klass.to_s.sub(/.*::/, '')
|
|
819
|
+
name = conf[:default_name] || defcap.downcase
|
|
820
|
+
name = suffixed_name(name + "1").intern
|
|
821
|
+
capt = conf[:default_caption] || name.to_s.capitalize
|
|
822
|
+
ct = klass.new(name, capt, x, y, w, h)
|
|
823
|
+
if target.is_a?(Window) && target.respond_to?(:__fd_add_ctrl)
|
|
824
|
+
target.__fd_add_ctrl(x, y, ct)
|
|
825
|
+
elsif target.is_a?(Window) && (prc=target.class::FDConfig[:add_ctl2target])
|
|
826
|
+
return unless prc.call(x, y, target, ct)
|
|
827
|
+
else
|
|
828
|
+
target << ct
|
|
829
|
+
end
|
|
830
|
+
ct.extend(ModControlHook)
|
|
831
|
+
ct.__fd_init_this_ctrl() if ct.respond_to?(:__fd_init_this_ctrl)
|
|
832
|
+
# (pr=ct.class::FDConfig[:init_ctrl]) && pr.call(ct)
|
|
833
|
+
ct._ox = 0
|
|
834
|
+
ct._oy = 0
|
|
835
|
+
prnt.SendMessage(WM_SIZE, 0, MAKELPARAM(*prnt.clientsize))
|
|
836
|
+
$fd_main_frm.update_attributes(ct)
|
|
837
|
+
$fd_main_frm.selected_klass = nil
|
|
838
|
+
$fd_main_frm.modified = true
|
|
839
|
+
@__added_control_ = true
|
|
840
|
+
# ct.SetCapture
|
|
841
|
+
move_start(x, y, ct)
|
|
842
|
+
@infobox.show_info(ct)
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
def show_popup(x, y)
|
|
846
|
+
TrackPopupMenu(@__fd_popup1, x, y)
|
|
847
|
+
end
|
|
848
|
+
|
|
849
|
+
API.defun "GetKeyState(nvirtkey)"
|
|
850
|
+
VK_CONTROL = 0x11
|
|
851
|
+
|
|
852
|
+
def __fd_parentnotify(wparam, x, y)
|
|
853
|
+
case wparam
|
|
854
|
+
when WM_LBUTTONDOWN
|
|
855
|
+
@ignore_mousemove = true
|
|
856
|
+
@toplevel_mousepos = [x, y]
|
|
857
|
+
state = (API.GetKeyState(VK_CONTROL) & 0x80) == 0x80 ? 9 : 0
|
|
858
|
+
end
|
|
859
|
+
end
|
|
860
|
+
|
|
861
|
+
def __fd_activate(st, hwnd)
|
|
862
|
+
return if st==0
|
|
863
|
+
x, y = APP.GetCursorPos()
|
|
864
|
+
if (obj=__hittest(x, y)) && obj!=self
|
|
865
|
+
# obj.SendMessage(WM_LBUTTONDOWN, 1, MAKELPARAM(*obj.ScreenToClient(x, y)))
|
|
866
|
+
return CancelDefWindowProc
|
|
867
|
+
end
|
|
868
|
+
return unless $fd_main_frm.forms #SEGV escapement.
|
|
869
|
+
$fd_main_frm.forms.each{|i| i.select_control_from_main(nil)}
|
|
870
|
+
$fd_main_frm.frm = self
|
|
871
|
+
$fd_main_frm.update_attributes(self)
|
|
872
|
+
$fd_main_frm.update_lvrs2
|
|
873
|
+
$fd_main_frm.update_hierarchy
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
def __fd_lbuttondown(stat, x, y)
|
|
877
|
+
sx, sy = ClientToScreen(x, y)
|
|
878
|
+
@__added_control_ = nil
|
|
879
|
+
if (obj=__hittest(sx, sy)) && (obj!=self) # Tabctrl etc
|
|
880
|
+
return if obj.is_a?(HandleWin)
|
|
881
|
+
if $fd_main_frm.selected_klass
|
|
882
|
+
cx, cy = pos_from_toplevel(obj)
|
|
883
|
+
if obj.respond_to?(:controls)
|
|
884
|
+
add_fd_selected_ctrl(x-cx, y-cy, obj.controls, obj) #; dpp obj, x, y, cx, cy
|
|
885
|
+
elsif obj.respond_to?(:<<)
|
|
886
|
+
add_fd_selected_ctrl(x-cx, y-cy, obj, obj)
|
|
887
|
+
end
|
|
888
|
+
else
|
|
889
|
+
obj_x, obj_y = obj.clientpos
|
|
890
|
+
obj._ox = x - obj_x
|
|
891
|
+
obj._oy = y - obj_y
|
|
892
|
+
move_start(x, y, obj, stat==9)
|
|
893
|
+
end
|
|
894
|
+
else
|
|
895
|
+
@handles.each{|i| i.close}.clear
|
|
896
|
+
@selected_controls.clear
|
|
897
|
+
add_fd_selected_ctrl(x, y, controls, self) if $fd_main_frm.selected_klass
|
|
898
|
+
$fd_main_frm.update_hierarchy
|
|
899
|
+
refresh
|
|
900
|
+
end
|
|
901
|
+
@__currentpos = sx, sy
|
|
902
|
+
CancelDefWindowProc
|
|
903
|
+
end
|
|
904
|
+
|
|
905
|
+
def __fd_lbuttonup(stat, x, y)
|
|
906
|
+
resize_end if @_resizing_
|
|
907
|
+
# @__added_control_ = nil
|
|
908
|
+
move_end #if @_moving_
|
|
909
|
+
$fd_main_frm.selected_klass = nil
|
|
910
|
+
end
|
|
911
|
+
|
|
912
|
+
def __fd_rbuttondown(stat, x, y)
|
|
913
|
+
__fd_lbuttondown(1, x, y)
|
|
914
|
+
show_popup(x, y)
|
|
915
|
+
CancelDefWindowProc
|
|
916
|
+
end
|
|
917
|
+
|
|
918
|
+
def __fd_mousemove(stat, x, y)
|
|
919
|
+
return if (stat&1)!=1
|
|
920
|
+
if @_resizing_
|
|
921
|
+
resizing(x, y, stat)
|
|
922
|
+
else
|
|
923
|
+
moving(x, y, stat)
|
|
924
|
+
end
|
|
925
|
+
end
|
|
926
|
+
|
|
927
|
+
def __fd_resize(f, w, h)
|
|
928
|
+
@selected_controls.each_with_index{|obj, i|
|
|
929
|
+
@handles[i].move(obj.x-5, obj.y-5, obj.w+10, obj.h+10) if obj.margin
|
|
930
|
+
}
|
|
931
|
+
end
|
|
932
|
+
|
|
933
|
+
def __fd_setcursor(hwnd, hittest, msg)
|
|
934
|
+
return unless hittest == 1
|
|
935
|
+
return unless $fd_main_frm.selected_klass
|
|
936
|
+
APP.SetCursor $fd_main_frm.selected_cursor
|
|
937
|
+
CancelDefWindowProc
|
|
938
|
+
end
|
|
939
|
+
|
|
940
|
+
def resize_start(n)
|
|
941
|
+
@_resizing_ = n
|
|
942
|
+
@_hide_handles = true
|
|
943
|
+
@_resize_start = true
|
|
944
|
+
@handles[0].border = true
|
|
945
|
+
@handles[0].visible = true
|
|
946
|
+
SetCapture()
|
|
947
|
+
end
|
|
948
|
+
|
|
949
|
+
def resizing(sx, sy, stat)
|
|
950
|
+
return unless @_resizing_
|
|
951
|
+
o = @selected_controls[0]
|
|
952
|
+
target = o.respond_to?(:_owner) ? o._owner : o.parent # for Groupbox
|
|
953
|
+
rx, ry = target.ScreenToClient(*self.ClientToScreen(sx, sy))
|
|
954
|
+
step = @_steps[(stat-5)/4]
|
|
955
|
+
case @_resizing_
|
|
956
|
+
when 1 # top, left
|
|
957
|
+
x = rx
|
|
958
|
+
y = ry
|
|
959
|
+
r = o.x + o.w
|
|
960
|
+
b = o.y + o.h
|
|
961
|
+
w = r - rx
|
|
962
|
+
h = b - ry
|
|
963
|
+
if step
|
|
964
|
+
w = (w / step) * step
|
|
965
|
+
h = (h / step) * step
|
|
966
|
+
x = r - w
|
|
967
|
+
y = b - h
|
|
968
|
+
end
|
|
969
|
+
when 2 # bottom, right
|
|
970
|
+
x = o.x
|
|
971
|
+
y = o.y
|
|
972
|
+
w = rx - x
|
|
973
|
+
h = ry - y
|
|
974
|
+
if step
|
|
975
|
+
w = (w / step) * step
|
|
976
|
+
h = (h / step) * step
|
|
977
|
+
end
|
|
978
|
+
when 3 # top, right
|
|
979
|
+
x = o.x
|
|
980
|
+
y = ry
|
|
981
|
+
b = o.y + o.h
|
|
982
|
+
w = rx - x
|
|
983
|
+
h = b - ry
|
|
984
|
+
if step
|
|
985
|
+
w = (w / step) * step
|
|
986
|
+
h = (h / step) * step
|
|
987
|
+
y = b - h
|
|
988
|
+
end
|
|
989
|
+
when 4 # bottom, left
|
|
990
|
+
x = rx
|
|
991
|
+
y = o.y
|
|
992
|
+
r = o.x + o.w
|
|
993
|
+
w = r - rx
|
|
994
|
+
h = ry - y
|
|
995
|
+
if step
|
|
996
|
+
w = (w / step) * step
|
|
997
|
+
h = (h / step) * step
|
|
998
|
+
x = r - w
|
|
999
|
+
end
|
|
1000
|
+
when 5 # mid, left
|
|
1001
|
+
x = rx
|
|
1002
|
+
y = o.y
|
|
1003
|
+
r = o.x + o.w
|
|
1004
|
+
w = r - rx
|
|
1005
|
+
h = o.h
|
|
1006
|
+
if step
|
|
1007
|
+
w = (w / step) * step
|
|
1008
|
+
x = r - w
|
|
1009
|
+
end
|
|
1010
|
+
when 6 # mid, right
|
|
1011
|
+
x = o.x
|
|
1012
|
+
y = o.y
|
|
1013
|
+
w = rx - x
|
|
1014
|
+
h = o.h
|
|
1015
|
+
if step
|
|
1016
|
+
w = (w / step) * step
|
|
1017
|
+
end
|
|
1018
|
+
when 7 # center, top
|
|
1019
|
+
x = o.x
|
|
1020
|
+
y = ry
|
|
1021
|
+
b = o.y + o.h
|
|
1022
|
+
w = o.w
|
|
1023
|
+
h = b - ry
|
|
1024
|
+
if step
|
|
1025
|
+
h = (h / step) * step
|
|
1026
|
+
y = b - h
|
|
1027
|
+
end
|
|
1028
|
+
when 8 # center, bottom
|
|
1029
|
+
x = o.x
|
|
1030
|
+
y = o.y
|
|
1031
|
+
w = o.w
|
|
1032
|
+
h = ry - y
|
|
1033
|
+
if step
|
|
1034
|
+
h = (h / step) * step
|
|
1035
|
+
end
|
|
1036
|
+
else
|
|
1037
|
+
return
|
|
1038
|
+
end
|
|
1039
|
+
o.move(x, y, w, h) if w>=0 && h>=0
|
|
1040
|
+
@handles[0].visible = true
|
|
1041
|
+
cx, cy = o.clientpos
|
|
1042
|
+
@handles[0].move(cx-1, cy-1, w+2, h+2)
|
|
1043
|
+
@infobox.show_info(@selected_controls[0], true)
|
|
1044
|
+
if @_resize_start
|
|
1045
|
+
@infobox.visible = SW_SHOWNA
|
|
1046
|
+
@_resize_start = false
|
|
1047
|
+
end
|
|
1048
|
+
end
|
|
1049
|
+
|
|
1050
|
+
def resize_end()
|
|
1051
|
+
@_resizing_ = nil
|
|
1052
|
+
@_hide_handles = nil
|
|
1053
|
+
unless @selected_controls.empty?
|
|
1054
|
+
@handles[0].border = nil
|
|
1055
|
+
sc = @selected_controls[0]
|
|
1056
|
+
@handles[0].move(sc.x-5, sc.y-5, sc.w+10, sc.h+10)
|
|
1057
|
+
end
|
|
1058
|
+
$fd_main_frm.update_attributes(@selected_controls[0] || self)
|
|
1059
|
+
$fd_main_frm.modified = true
|
|
1060
|
+
ReleaseCapture()
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
def move_start(x, y, obj, adding=nil) #dpp obj, adding
|
|
1064
|
+
@_prvx, @_prvy = x, y
|
|
1065
|
+
if (idx=@selected_controls.index(obj)) || adding #;dpp obj, x, y, @selected_controls
|
|
1066
|
+
if idx && idx>0 && adding
|
|
1067
|
+
@selected_controls.delete_at(idx)
|
|
1068
|
+
@handles[idx].close
|
|
1069
|
+
@handles.delete_at(idx)
|
|
1070
|
+
else
|
|
1071
|
+
@selected_controls.each_with_index{|i, n|
|
|
1072
|
+
dx, dy = 0, 0
|
|
1073
|
+
i._ox = obj.x + obj._ox - i.x - dx
|
|
1074
|
+
i._oy = obj.y + obj._oy - i.y - dy
|
|
1075
|
+
@handles[n].visible = true
|
|
1076
|
+
}
|
|
1077
|
+
end
|
|
1078
|
+
else # !adding
|
|
1079
|
+
@handles.each{|i| i.close}.clear
|
|
1080
|
+
@selected_controls.clear
|
|
1081
|
+
end
|
|
1082
|
+
if @selected_controls.empty? || (!idx && @selected_controls[0].parent == obj.parent)
|
|
1083
|
+
@selected_controls << obj
|
|
1084
|
+
@handles << HandleWin.new(self, obj.parent, @handles.empty?).create()
|
|
1085
|
+
@selected_controls.each_with_index{|i, n|
|
|
1086
|
+
i_x, i_y = i.clientpos #; dpp i, i_x, i_y
|
|
1087
|
+
i_w, i_h = i.windowsize
|
|
1088
|
+
@handles[n].move(i_x-5, i_y-5, i_w+10, i_h+10)
|
|
1089
|
+
@handles[n].visible=true
|
|
1090
|
+
}
|
|
1091
|
+
end
|
|
1092
|
+
refresh
|
|
1093
|
+
# @__moving_ = true
|
|
1094
|
+
end
|
|
1095
|
+
|
|
1096
|
+
def moving(x, y, stat) # x, y is client coordinate of parent window
|
|
1097
|
+
return if stat&1!=1 #; dpp x, y
|
|
1098
|
+
return if @selected_controls.empty? #; dpp x, y, @__added_control_
|
|
1099
|
+
return if $fd_main_frm.selected_klass
|
|
1100
|
+
return if @__added_control_
|
|
1101
|
+
|
|
1102
|
+
c0 = @selected_controls[0]
|
|
1103
|
+
@infobox.show_info(c0)
|
|
1104
|
+
return if @_prvx==x && @_prvy==y
|
|
1105
|
+
@handles.each{|i| i.visible = false}
|
|
1106
|
+
c0x, c0y = c0.clientpos;
|
|
1107
|
+
step = @_steps[(stat-5)/4] #; dpp (stat-5)/4, step
|
|
1108
|
+
@selected_controls.each{|i|
|
|
1109
|
+
i_x, i_y = i.clientpos
|
|
1110
|
+
# i_w, i_h = i.windowsize
|
|
1111
|
+
if i==c0
|
|
1112
|
+
mx = x - i._ox
|
|
1113
|
+
my = y - i._oy
|
|
1114
|
+
if step # Ctrl
|
|
1115
|
+
mx = (mx / step) * step
|
|
1116
|
+
my = (my / step) * step
|
|
1117
|
+
end
|
|
1118
|
+
else
|
|
1119
|
+
mx = c0.x - c0x + i_x
|
|
1120
|
+
my = c0.y - c0y + i_y
|
|
1121
|
+
end
|
|
1122
|
+
i.move(mx, my) # This is client coodinate of i.parent
|
|
1123
|
+
}
|
|
1124
|
+
end
|
|
1125
|
+
|
|
1126
|
+
def move_end()
|
|
1127
|
+
# @__moving_ = nil
|
|
1128
|
+
@infobox.visible = false
|
|
1129
|
+
@selected_controls.each_with_index{|i, n|
|
|
1130
|
+
i_x, i_y = i.clientpos
|
|
1131
|
+
i_w, i_h = i.windowsize
|
|
1132
|
+
@handles[n].move(i_x-5, i_y-5, i_w+10, i_h+10)
|
|
1133
|
+
@handles[n].visible = true
|
|
1134
|
+
}
|
|
1135
|
+
c0 = @selected_controls[0]
|
|
1136
|
+
$fd_main_frm.update_attributes(c0 || self)
|
|
1137
|
+
$fd_main_frm.modified = true unless @selected_controls.empty?
|
|
1138
|
+
refresh
|
|
1139
|
+
end
|
|
1140
|
+
|
|
1141
|
+
def select_control_from_main(ctrl)
|
|
1142
|
+
@selected_controls.clear
|
|
1143
|
+
@handles.each{|i| i.close}.clear
|
|
1144
|
+
return unless ctrl
|
|
1145
|
+
if ctrl!=self
|
|
1146
|
+
ctrl._ox = ctrl._oy = 0
|
|
1147
|
+
@selected_controls << ctrl
|
|
1148
|
+
@handles << HandleWin.new(self, ctrl.parent, true).create()
|
|
1149
|
+
end
|
|
1150
|
+
move_end
|
|
1151
|
+
end
|
|
1152
|
+
|
|
1153
|
+
def justify_clicked(id, accel)
|
|
1154
|
+
c0 = @selected_controls[0]
|
|
1155
|
+
h0 = @handles[0]
|
|
1156
|
+
case @__fd_popup1.justify._index(id)
|
|
1157
|
+
when 0 # left
|
|
1158
|
+
@selected_controls.each_with_index{|i, n|
|
|
1159
|
+
i.x = c0.x
|
|
1160
|
+
@handles[n].x = h0.x
|
|
1161
|
+
}
|
|
1162
|
+
when 1 # top
|
|
1163
|
+
@selected_controls.each_with_index{|i, n|
|
|
1164
|
+
i.y = c0.y
|
|
1165
|
+
@handles[n].y = h0.y
|
|
1166
|
+
}
|
|
1167
|
+
when 2 # right
|
|
1168
|
+
@selected_controls.each_with_index{|i, n|
|
|
1169
|
+
i.x = c0.x + c0.w - i.w
|
|
1170
|
+
@handles[n].x = h0.x + h0.w - @handles[n].w
|
|
1171
|
+
}
|
|
1172
|
+
when 3 # bottom
|
|
1173
|
+
@selected_controls.each_with_index{|i, n|
|
|
1174
|
+
i.y = c0.y + c0.h - i.h
|
|
1175
|
+
@handles[n].y = h0.y + h0.h - @handles[n].h
|
|
1176
|
+
}
|
|
1177
|
+
end
|
|
1178
|
+
refresh
|
|
1179
|
+
end
|
|
1180
|
+
|
|
1181
|
+
def delete1_clicked(id, accel)
|
|
1182
|
+
@selected_controls.each_with_index{|ct, n|
|
|
1183
|
+
# if ct.respond_to?(:__fd_items_src)
|
|
1184
|
+
# frm = ct.get_toplevel_win
|
|
1185
|
+
# lns = frm.__fd_src[:lines]
|
|
1186
|
+
# col, len, lsrc = ct.__fd_items_src
|
|
1187
|
+
# lns.delete_if{|i| i.__id__ == lsrc.__id__}
|
|
1188
|
+
# end
|
|
1189
|
+
ct.__fd_on_delete_this() if ct.respond_to?(:__fd_on_delete_this)
|
|
1190
|
+
ct.delete
|
|
1191
|
+
@handles[n].close
|
|
1192
|
+
}
|
|
1193
|
+
@selected_controls.clear
|
|
1194
|
+
@handles.clear
|
|
1195
|
+
@infobox.hide
|
|
1196
|
+
$fd_main_frm.update_attributes(self)
|
|
1197
|
+
$fd_main_frm.update_hierarchy
|
|
1198
|
+
end
|
|
1199
|
+
|
|
1200
|
+
def to_hsh(all_attr=nil)
|
|
1201
|
+
hsh = {}
|
|
1202
|
+
hsh['class'] = self.class.to_s.split('::')[1]
|
|
1203
|
+
if self.style&@__fd_defstylemask != self.class::DefaultWindowStyle&@__fd_defstylemask
|
|
1204
|
+
st = sprintf("%#x", self.style & 0xffffffff)
|
|
1205
|
+
hsh['style'] = st
|
|
1206
|
+
else
|
|
1207
|
+
hsh['style'] = ''
|
|
1208
|
+
end
|
|
1209
|
+
__fd_attributes__.each{|k, tp, defval| next if k=='class' || k=='clientsize'
|
|
1210
|
+
r = parse_template4out(self, k, tp, defval)
|
|
1211
|
+
hsh[k] = r if all_attr || !r.empty?
|
|
1212
|
+
}
|
|
1213
|
+
if hsh["inheritfont"]=="true" && hsh["font"]
|
|
1214
|
+
hsh["inheritfont"] = hsh["font"]
|
|
1215
|
+
hsh["font"] = ""
|
|
1216
|
+
end
|
|
1217
|
+
hsh['events'] = __fd_events
|
|
1218
|
+
hsh
|
|
1219
|
+
end
|
|
1220
|
+
|
|
1221
|
+
def __fd_attributes__() FDAttributes.dup; end
|
|
1222
|
+
|
|
1223
|
+
private
|
|
1224
|
+
def __fd_get_classname(hsh)
|
|
1225
|
+
ancestor = self.class.ancestors[1].to_s.split('::').last
|
|
1226
|
+
"class #{hsh.delete('class')} < #{ancestor}"
|
|
1227
|
+
end
|
|
1228
|
+
|
|
1229
|
+
public
|
|
1230
|
+
def __fd_modify_src()
|
|
1231
|
+
lns = @__fd_src[:lines] #; STDERR.puts lns
|
|
1232
|
+
lns.compact!
|
|
1233
|
+
hsh = self.to_hsh(true)
|
|
1234
|
+
indent = " " * @__fd_src[:classname][0]*3
|
|
1235
|
+
curln = index_of_src(lns, @__fd_src[:classname][2]) + 1
|
|
1236
|
+
hsh.each{|k, v|
|
|
1237
|
+
if a=@__fd_src[k]
|
|
1238
|
+
col, len, lsrc = a
|
|
1239
|
+
curln = index_of_src(lns, lsrc)
|
|
1240
|
+
if v.empty?
|
|
1241
|
+
@__fd_src[k] = nil
|
|
1242
|
+
lns.delete_at(curln)
|
|
1243
|
+
else
|
|
1244
|
+
s = "self.#{k} = #{v}"
|
|
1245
|
+
lsrc[col, len] = s
|
|
1246
|
+
@__fd_src[k][1] = s.size
|
|
1247
|
+
end
|
|
1248
|
+
elsif k=="class"
|
|
1249
|
+
col, len, lsrc = @__fd_src[:classname]
|
|
1250
|
+
s = "class #{v} < #{self.class.ancestors[1].to_s.split('::')[1]}"
|
|
1251
|
+
lsrc[col, len] = s
|
|
1252
|
+
@__fd_src[:classname][1] = s.size
|
|
1253
|
+
elsif !v.empty?
|
|
1254
|
+
s = "self.#{k} = #{v}"
|
|
1255
|
+
lsrc = "#{indent}#{s}\n"
|
|
1256
|
+
lns[curln+=1, 0] = lsrc
|
|
1257
|
+
lsrc.extend(ModFDSrcLine).binded_obj = k
|
|
1258
|
+
@__fd_src[k] = [indent.size, s.size, lsrc]
|
|
1259
|
+
end
|
|
1260
|
+
}
|
|
1261
|
+
controls.each{|i| #; dpp i.name, lns.size
|
|
1262
|
+
if (a=i.__fd_src)
|
|
1263
|
+
col, len, lsrc = a
|
|
1264
|
+
curln = ModFDCommon.index_of_src(lns, lsrc)
|
|
1265
|
+
curln = i.__fd_modify_src(lns, curln, indent)
|
|
1266
|
+
else #; dpp curln
|
|
1267
|
+
curln = i.__fd_to_str(lns, curln, indent)
|
|
1268
|
+
end
|
|
1269
|
+
}
|
|
1270
|
+
lns
|
|
1271
|
+
end
|
|
1272
|
+
|
|
1273
|
+
def __fd_frm2str(indentlevel, with_start=nil)
|
|
1274
|
+
indent, lv = indentlevel
|
|
1275
|
+
lns = []
|
|
1276
|
+
hsh = self.to_hsh
|
|
1277
|
+
cname = __fd_get_classname(hsh)
|
|
1278
|
+
cs = "#{indent*(lv+=1)}#{cname}\n"
|
|
1279
|
+
lns << cs
|
|
1280
|
+
@__fd_src[:classname] = [indent.size*lv, cname.size, cs]
|
|
1281
|
+
lns << "#{indent*(lv+=1)}def initialize()\n"
|
|
1282
|
+
lv += 1
|
|
1283
|
+
hsh.each{|k, v|
|
|
1284
|
+
unless v.empty?
|
|
1285
|
+
idt = indent*lv
|
|
1286
|
+
s = "self.#{k} = #{v}"
|
|
1287
|
+
str = "#{idt}#{s}\n"
|
|
1288
|
+
@__fd_src[k] = [idt.size, s.size, str]
|
|
1289
|
+
str.extend(ModFDSrcLine).binded_obj = k
|
|
1290
|
+
lns << str
|
|
1291
|
+
end
|
|
1292
|
+
}
|
|
1293
|
+
controls._each{|i| i.__fd_to_str(lns, lns.size, indent*lv)}
|
|
1294
|
+
lns << "#{indent*(lv-=1)}end\n"
|
|
1295
|
+
lns << "\n#{indent*lv}self.start\n" if with_start
|
|
1296
|
+
lns << "#{indent*(lv-=1)}end\n"
|
|
1297
|
+
@__fd_src[:endofclass] = [indent.size*lv, 3, lns.last]
|
|
1298
|
+
indentlevel[1] = lv
|
|
1299
|
+
lns
|
|
1300
|
+
end
|
|
1301
|
+
end # ModToplevelHook
|
|
1302
|
+
|
|
1303
|
+
module ModResourceHook
|
|
1304
|
+
include ModFDCommon
|
|
1305
|
+
attr_accessor :__fd_src
|
|
1306
|
+
FDAttributes = ['class', ['name','m']]
|
|
1307
|
+
def __fd_attributes__()
|
|
1308
|
+
FDAttributes.dup + (self.class::FDConfig[:attributes] || [])
|
|
1309
|
+
end
|
|
1310
|
+
|
|
1311
|
+
def to_hsh()
|
|
1312
|
+
hsh = {}
|
|
1313
|
+
hsh['class'] = self.class.to_s.split('::')[1]
|
|
1314
|
+
__fd_attributes__.each{|k, tp|
|
|
1315
|
+
next if k=='class'
|
|
1316
|
+
(v = (self.__send__(k.intern) rescue nil)) || next
|
|
1317
|
+
hsh[k] = sprintf("%p", v)
|
|
1318
|
+
}
|
|
1319
|
+
hsh
|
|
1320
|
+
end
|
|
1321
|
+
|
|
1322
|
+
def __fd_get_parents_str()
|
|
1323
|
+
return "_" unless respond_to?(:parent)
|
|
1324
|
+
return "_" unless parent.is_a?(Menu)
|
|
1325
|
+
ps = parent.__fd_get_parents_str
|
|
1326
|
+
ps=="_" ? "_" + parent.name.to_s : ps + "._" + parent.name.to_s
|
|
1327
|
+
end
|
|
1328
|
+
|
|
1329
|
+
def __fd_get_parents_str2(child=nil)
|
|
1330
|
+
s = __fd_get_parents_str()
|
|
1331
|
+
if child
|
|
1332
|
+
s=="_" ? "_#{name} " : "#{s}._#{name} "
|
|
1333
|
+
else
|
|
1334
|
+
s=='_' ? s : "#{s} "
|
|
1335
|
+
end
|
|
1336
|
+
end
|
|
1337
|
+
|
|
1338
|
+
def __fd_update_src(lns, curln, indent, s, child=nil)
|
|
1339
|
+
c0 = curln
|
|
1340
|
+
if @__fd_src # modify
|
|
1341
|
+
col, len, lsrc, lcount = @__fd_src
|
|
1342
|
+
curln = ModFDCommon.index_of_src(lns, lsrc)
|
|
1343
|
+
raise "#{self} was failed to get index of \"#{lsrc}\"" unless curln # for debugging
|
|
1344
|
+
lns.slice!(curln+1, lcount-1) if lcount.to_i > 1
|
|
1345
|
+
ar = s.lines
|
|
1346
|
+
s0 = ar.shift
|
|
1347
|
+
s0.chomp!
|
|
1348
|
+
s0[0, 0] = "#{__fd_get_parents_str2(child)}<< "
|
|
1349
|
+
unless ar.empty?
|
|
1350
|
+
s0 << "\n"
|
|
1351
|
+
lns[curln+=1, 0] = ar
|
|
1352
|
+
curln += ar.size-1
|
|
1353
|
+
end
|
|
1354
|
+
lsrc[col, len] = s0
|
|
1355
|
+
@__fd_src[1] = s0.size
|
|
1356
|
+
@__fd_src[3] = ar.size + 1
|
|
1357
|
+
else # insert new
|
|
1358
|
+
ar = s.lines
|
|
1359
|
+
s0 = ar.shift
|
|
1360
|
+
s0.chomp!
|
|
1361
|
+
s0[0, 0] = "#{indent}#{__fd_get_parents_str2(child)}<< "
|
|
1362
|
+
s0 << "\n"
|
|
1363
|
+
@__fd_src = [indent.size, s0.size-indent.size, s0, ar.size+1]
|
|
1364
|
+
s0.extend(ModFDSrcLine).binded_obj = self #; STDERR.puts lns.join
|
|
1365
|
+
lns[curln+=1, 0] = s0 #; dpp curln, lns
|
|
1366
|
+
unless ar.empty?
|
|
1367
|
+
lns[curln+=1, 0] = ar
|
|
1368
|
+
curln += ar.size-1
|
|
1369
|
+
end
|
|
1370
|
+
end #; dpp self.name, c0, curln
|
|
1371
|
+
curln
|
|
1372
|
+
end
|
|
1373
|
+
end
|
|
1374
|
+
|
|
1375
|
+
module ModFormDesigner
|
|
1376
|
+
include ModAutoloading
|
|
1377
|
+
def self.extended(mod)
|
|
1378
|
+
bmpdir = "#{File.dirname(__FILE__)}/controls/"
|
|
1379
|
+
bmpname ="#{bmpdir}#{mod.to_s.sub(/^\w+::/, '').downcase}.bmp"
|
|
1380
|
+
mod.module_eval "FDConfig={}"
|
|
1381
|
+
begin
|
|
1382
|
+
mod::FDConfig[:bitmap] = Bitmap.fromfile(bmpname)
|
|
1383
|
+
rescue
|
|
1384
|
+
mod::FDConfig[:bitmap] = Bitmap.fromfile(bmpdir+'default.bmp')
|
|
1385
|
+
end
|
|
1386
|
+
end
|
|
1387
|
+
end
|
|
1388
|
+
end unless defined?(WR::GW_CHILD)
|
|
1389
|
+
|
|
1390
|
+
module WR
|
|
1391
|
+
require_relative './fdesign.rb'
|
|
1392
|
+
FDMain.start if defined? FDMain
|
|
1393
|
+
end if $0 == __FILE__
|
|
1394
|
+
|