Skip to content

Commit

Permalink
add in samples
Browse files Browse the repository at this point in the history
  • Loading branch information
rdp committed May 15, 2009
1 parent 5039bd3 commit 0ce21dd
Show file tree
Hide file tree
Showing 45 changed files with 2,923 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/swin_example.rb
@@ -0,0 +1,31 @@
require 'swin'

WM_COMMAND = 0x00000111
WS_VISIBLECHILD = 0x50000000
BS_PUSHBUTTON = 0x00000000

RFactory=SWin::LWFactory.new(SWin::Application.hInstance)

mw=RFactory.newwindow(nil)
mw.caption="Window Caption"
mw.move(300,200,400,400)
mw.create

bn=RFactory.newwindow(mw)
bn.classname="BUTTON"
bn.caption="Button1"
bn.etc=1234 #control id
bn.style=WS_VISIBLECHILD | BS_PUSHBUTTON
bn.move 80,50,80,40
bn.create

mw.addEvent WM_COMMAND

def mw.msghandler(msg) #msg has attrs of hWnd,msg,wParam,lParam
if msg.msg==WM_COMMAND then
messageBox "Button Pushed"
end
end

mw.show
SWin::Application.messageloop
12 changes: 12 additions & 0 deletions examples/vrsamples/WHERE_FROM
@@ -0,0 +1,12 @@
these are from http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html#sss which has a link to http://www.osk.3web.ne.jp/~nyasu/vruby/vrsamples.zip

These were extracted from there

The english sample descriptions for them seem to be:
http://www.osk.3web.ne.jp/~nyasu/vruby/samples-e.html

And notes:
"Some scripts file include SJIS-coded Japanese Text. Use -Ks option for ruby."


There are links to more scripts at http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html#sss
94 changes: 94 additions & 0 deletions examples/vrsamples/samples/Readme.txt
@@ -0,0 +1,94 @@
These are sample script for VisualuRuby Project(temp-name).
You needed VisualuRubyProject's archives to examine them.
See http://www.threeweb.ad.jp/~nyasu/software/vrproject.html .
(Download page is at http://www.threeweb.ad.jp/~nyasu/vruby/vruby/core.html)
I'm sorry that NO english pages are available now.

FILES:
margintest.rb
This is a sample of vrmargin which used in VRTwoPaneFrame and
VRHolizLayoutFrame.
paneltest.rb
The window captures window size changing and moves Groupbox to left and right.
layouttest.rb
This opens three windows which lays their buttons out vertically and
horizontally, and which lays with these combination.
The layout managers handle window-resize event to re-arrange its child windows.
customed.rb
This hooks the control's event into the control itself.
peventtest.rb
This is a sample of handling events of grand-child controls on the panel
which is on the window itself.
subclstest.rb
This makes EditControl Subclass-ed.
gpaneltest.rb
The window draws graphs for drawing sample.
gridtest.rb
This is a test script for grid layout manager.
And this prints current time on the title bar in its idling loop procedure.
comctltest2.rb
This is a Common Control(Listview,Treeview) sample.
menutest.rb
This opens a window which is using menues and handles menu-click events.
dlgtest.rb
You can view bitmap files selected by common dialog invoked
by the menu [File->Open]
dlgbmptest.rb
This is a sample for opening common dialogs.
And test the original VRBitmapPanel control which is displaying bitmap.
ctrlc.rb
This is test script for handling Ctrl-C interrupts.
There are 2 buttons both that starts time consuming process.
The upper button starts the process which are rescued from Ctrl-C,
and the other starts the non-rescued process.
mediatest.rb
This is a sample for VRMMediaViewer to playing multimedia files using MCI.
canvastest.rb
This is sample of drawable bitmap.
Drawing pad window opens.
panetest.rb
This opens a window which has Treeview and Listview separated by movable
separator. I know this is not a beautiful gadget. Are there clever kind and
persons to teach me how to make beautiful one?
droptest.rb
This opens a window with Edit Control.
You can drop text files on this window to view that text file.
Your multi-file dropping opens plural windows.
treelist.rb
Treeview and Listview test like explorer. This can have an argument of
start directory.
fontclock.rb
Font test. This is a clock where you can change the font.
ownerdraw.rb
Owner draw test. A colored rectangle is drawn at the left-top corner of
the button.
ddeexectest.rb
DDE_EXECUTE test. At first, click "connect" button to connect with Netscape.
And select the URL from the combobox to navigate the netscape.
ftest.rb
Change the font of button into big one.
mdlgtest.rb
Sample for using modal dialogs.
tabtest.rb
Sample of using tab control.
richtest.rb
RichEdit control sample to change font,color and style of character.
clipboardtest.rb
Sample about clipboard.
This is an utility making clipboard history.
printer.rb
Sample of using printer.
relaytest.rb
Sample of relaying event from control on a panel to the parent of the panel.
arraytest.rb
Sample using control array with layout manager.
tooltiptest.rb
Sample of using tooltip window.
lframetest.rb
Sample using layout frames.
rebartest.rb
Sample of using rebar control and layoutframes.
paneframetest.rb
Sample of using two-paned frames.
sbtest.rb
Sample of using Scrollbars.
55 changes: 55 additions & 0 deletions examples/vrsamples/samples/arrayctest.rb
@@ -0,0 +1,55 @@
require 'vr/vruby'
require 'vr/vrcontrol'
require 'vr/vrcomctl'
require 'vr/vrlayout'

class MyUpdown < VRPanel
include VRGridLayoutManager
include VRStdControlContainer

def construct # VRUpdown is force to be relocated by VRGridLayoutManager.
setDimension 8,2
addControl VRStatic,"","sample child-control",0,0,8,1
addControl VREdit,"num","0",0,1,7,1
addControl VRUpdown,"updown","0",7,1,1,1,WStyle::UDS_INTBUDDYRIGHT
@updown.setRange(0,10)
end

def num_changed
call_parenthandler "changed",@num.caption.to_i
end
end


class MyForm < VRForm
include VRVertLayoutManager

def construct
self.caption = "sample of Arrayed controls and layout-manager"
addControl VRButton,"exam","exam"

addArrayedControl 1,VRButton,"btn","arrayed button1"
addArrayedControl 2,VRButton,"btn","arrayed button2"

addControl VRStatic,"lbl","the following control's value area is [0-10]"
addControl VRStatic,"ex",""

addArrayedControl 1,MyUpdown,"updown","11"
addArrayedControl 2,MyUpdown,"updown","-11"
end

def exam_clicked
messageBox "normal control clicked"
end

def btn_clicked(index)
messageBox "clicked #{index}","arrayed control"
end

def updown_changed(index,pos)
@ex.caption = "original control no.#{index} changed into #{pos}"
end
end


VRLocalScreen.start(MyForm)
29 changes: 29 additions & 0 deletions examples/vrsamples/samples/axtest.rb
@@ -0,0 +1,29 @@
require 'vr/vractivex'
require 'vr/vrlayout'

class ExplorerAxControl < VRActiveXControl
ACTIVEXCINFO =["SHDocVwCtl.WebBrowser","DWebBrowserEvents"]
end

class MyForm < VRForm
include VRHorizLayoutManager

def construct
addControl ExplorerAxControl,"exp",""

@exp.ole_interface.Navigate("http://www.google.co.jp/")
@exp.add_oleeventhandler("NavigateComplete","completed")
@exp.add_oleeventhandler("TitleChange","titlechange")
end

def exp_titlechange(title)
self.caption=title
end

def exp_completed(url)
puts url
end
end

VRLocalScreen.start(MyForm)

67 changes: 67 additions & 0 deletions examples/vrsamples/samples/balloontest.rb
@@ -0,0 +1,67 @@
#!/usr/bin/env ruby

require 'vr/vrcontrol'
require 'vr/vrlayout'
require 'vr/vrtray'

module MyForm

include VRTrayiconFeasible

LoadIcon= Win32API.new('user32', 'LoadIcon', 'II', 'I')
INFO_ICON= LoadIcon.call(0, 32516)

def construct
@title= addControl(VREdit, 'title', 'Balloon title')
@text= addControl(VREdit, 'text', 'Balloon text')
@info= addControl(VRRadiobutton, 'info_rb', 'Info icon')
@info.check(true)
@warning= addControl(VRRadiobutton, 'warning_rb', 'Warning icon')
@error= addControl(VRRadiobutton, 'error_rb', 'Error icon')
@none= addControl(VRRadiobutton, 'none_rb', 'No icon')
addControl(VRButton, 'show', 'Show balloon')
addControl(VRButton, 'exit', 'Exit')
create_trayicon(INFO_ICON, 'VRuby Balloon Tooltip Test')
end

def exit_clicked
delete_trayicon
self.close
end

def self_trayballoonshow iconid
puts 'Balloon shown!'
end

def self_trayballoonhide iconid
puts 'Balloon hidden!'
end

def self_trayballoontimeout iconid
puts 'Balloon timed out or user dismissed it!'
end

def self_trayballoonclicked iconid
puts 'User clicked inside balloon!'
end

def show_clicked
infoicon= [:info, :warning, :error, :none].inject(NIIF_INFO) do |icon, which|
if instance_variable_get("@#{which}").checked?
VRTrayiconFeasible.const_get("NIIF_#{which.to_s.upcase}")
else
icon
end
end
modify_trayicon5(nil, @title.text, @text.text, infoicon)
end

end

frm= VRLocalScreen.newform
frm.caption= 'Balloon Tooltip Test'
frm.extend(MyForm)
frm.extend(VRVertLayoutManager)
frm.move(100, 100, 300, 200)
frm.create.show
VRLocalScreen.messageloop
73 changes: 73 additions & 0 deletions examples/vrsamples/samples/canvastest.rb
@@ -0,0 +1,73 @@
require 'vr/vrcontrol'
require 'vr/vrhandler'

$white=RGB(0xff,0xff,0xff)
$red=RGB(0xff,0,0)
$blue=RGB(0,0,0xff)
$green=RGB(0,0xff,0)
$black=RGB(0,0,0)

class MyDrawingCanvasPanel < VRCanvasPanel
include VRMouseFeasible

def vrinit
super
@width=0
@col=0
end

def setcolor(col)
@col=col
@canvas.setPen(@col,@width)
end

def setwidth(width)
@width=width
setcolor(@col)
end

def self_lbuttondown(shift,x,y)
if shift==1 then
@canvas.grLineTo(x,y)
else
@canvas.grMoveTo(x,y)
end
refresh
end

end


module MyForm
def construct
self.caption="canvas test"
addControl(MyDrawingCanvasPanel,"cv","canvas",0,0,400,400)
addControl(VRButton,"cc","ColorChange",10,410,100,30)
addControl(VRStatic,"lb","pen width",130,415,80,30)
addControl(VRCombobox,"wd","1",200,410,50,130)
addControl(VRButton,"sv","Save",300,410,100,30)

@cv.createCanvas 400,400
@wd.setListStrings(["1","2","4","8","16"])
@wd.select(0)
end

def cc_clicked
nc=chooseColorDialog
@cv.setcolor(nc) if nc
end

def wd_selchanged
@cv.setwidth( @wd.getString(@wd.selectedIndex).to_i )
end

def sv_clicked
s = SWin::Bitmap.createBitmap *@cv.canvas.infoandbmp
s.saveFile "canvas.bmp"
end
end


VRLocalScreen.showForm(MyForm)
VRLocalScreen.messageloop

0 comments on commit 0ce21dd

Please sign in to comment.