<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: scroll code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 11 Oct 2008 21:27:49 GMT</pubDate>
    <description>DZone Snippets: scroll code</description>
    <item>
      <title>Adding a 2nd level menu to a Ruby Maemo application</title>
      <link>http://snippets.dzone.com/posts/show/6216</link>
      <description>Here is a script to run a Ruby Maemo application which has a scroll bar and a 2nd level menu box.  The first level menu box would be application's control menu box.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#! /usr/bin/env ruby&lt;br /&gt;#file: menu2.rb&lt;br /&gt;&lt;br /&gt;#require 'gtk'&lt;br /&gt;require 'hildon'&lt;br /&gt;&lt;br /&gt;program = Hildon::Program.instance&lt;br /&gt;&lt;br /&gt;#window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)&lt;br /&gt;window = program.add_window Hildon::Window.new&lt;br /&gt;&lt;br /&gt;mbar = Gtk::MenuBar.new&lt;br /&gt;filemitem = Gtk::MenuItem.new('File')&lt;br /&gt;filemitem.show&lt;br /&gt;filemenu = Gtk::Menu.new&lt;br /&gt;item1 = Gtk::MenuItem.new('Open')&lt;br /&gt;item1.show&lt;br /&gt;filemenu.add item1&lt;br /&gt;item2 = Gtk::MenuItem.new('Save')&lt;br /&gt;item2.show&lt;br /&gt;filemenu.add item2&lt;br /&gt;item3 = Gtk::MenuItem.new('Quit')&lt;br /&gt;item3.show&lt;br /&gt;filemenu.add item3&lt;br /&gt;filemitem.set_submenu filemenu&lt;br /&gt;mbar.append filemitem&lt;br /&gt;mbar.show&lt;br /&gt;&lt;br /&gt;vadj = Gtk::Adjustment.new(0,0,0,0,0,0)&lt;br /&gt;&lt;br /&gt;vs = Gtk::VScrollbar.new(vadj)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;hbox = Gtk::HBox.new(false, 0)&lt;br /&gt;&lt;br /&gt;hbox.pack_start vs, false, false, 0&lt;br /&gt;&lt;br /&gt;vbox = Gtk::VBox.new(false, 0)&lt;br /&gt;vbox.pack_start mbar, false, false, 0&lt;br /&gt;vbox.pack_start hbox, true, true, 0&lt;br /&gt;vbox.show&lt;br /&gt;&lt;br /&gt;window.add vbox&lt;br /&gt;&lt;br /&gt;vs.show&lt;br /&gt;hbox.show&lt;br /&gt;window.show&lt;br /&gt;Gtk.main&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You can see from the &lt;a href="http://twitxr.com/image/107128/"&gt;output on the N800&lt;/a&gt; [twitxr.com] as I selected an item from the menu box'.&lt;br /&gt;&lt;br /&gt;Resources:&lt;br /&gt; - &lt;a href="http://snippets.dzone.com/posts/show/6214"&gt;Adding a text entry box in a Ruby Maemo application&lt;/a&gt; [dzone.com]&lt;br /&gt; - &lt;a href="http://ruby-gnome.sourceforge.net/programming/menu.html"&gt;Ruby/Gtk Programming&lt;/a&gt; [sourceforge.net]</description>
      <pubDate>Tue, 07 Oct 2008 15:57:31 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/6216</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Using the mousewheel to zoom in or out an SVG document</title>
      <link>http://snippets.dzone.com/posts/show/5337</link>
      <description>This code was originally copied from &lt;a href="http://adomas.org/javascript-mouse-wheel/"&gt;Mouse wheel programming in JavaScript&lt;/a&gt; [adomas.org]. I replaced about 5 lines of code to get the mousewheel controlling the zoom feature in the &lt;a href="http://snippets.dzone.com/posts/show/5336"&gt;makeZoom.svg&lt;/a&gt; [dzone.com] file.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  /** This is high-level function; REPLACE IT WITH YOUR CODE.&lt;br /&gt; * It must react to delta being more/less than zero.&lt;br /&gt; */&lt;br /&gt;function zoomInOut(delta) {&lt;br /&gt;	if (delta &gt;= 0)&lt;br /&gt;		zoomIn()&lt;br /&gt;	else&lt;br /&gt;		zoomOut()&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function wheel(event){&lt;br /&gt;	var delta = 0;&lt;br /&gt;	if (!event) event = window.event;&lt;br /&gt;	if (event.wheelDelta) {&lt;br /&gt;		delta = event.wheelDelta/120; &lt;br /&gt;		if (window.opera) delta = -delta;&lt;br /&gt;	} else if (event.detail) {&lt;br /&gt;		delta = -event.detail/3;&lt;br /&gt;	}&lt;br /&gt;	if (delta)&lt;br /&gt;		zoomInOut(delta);&lt;br /&gt;        if (event.preventDefault)&lt;br /&gt;                event.preventDefault();&lt;br /&gt;        event.returnValue = false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Initialization code. */&lt;br /&gt;if (window.addEventListener)&lt;br /&gt;	window.addEventListener('DOMMouseScroll', wheel, false);&lt;br /&gt;window.onmousewheel = document.onmousewheel = wheel;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 08 Apr 2008 16:14:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5337</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>mouse scroll-wheel events</title>
      <link>http://snippets.dzone.com/posts/show/1195</link>
      <description>&lt;code&gt;&lt;br /&gt;; mouse-wheel scroll events&lt;br /&gt;view/new layout [&lt;br /&gt;	b: box "A Box" forest feel [&lt;br /&gt;		engage: func [face action event] [&lt;br /&gt;			if action = 'scroll-line [&lt;br /&gt;				print ["Scroll line" event/offset]&lt;br /&gt;			]&lt;br /&gt;			if action = 'scroll-page [ ; Ctrl+wheel&lt;br /&gt;				print ["scroll page" event/offset]&lt;br /&gt;			]&lt;br /&gt;		]&lt;br /&gt;	]&lt;br /&gt;]&lt;br /&gt;focus b&lt;br /&gt;do-events&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 19 Jan 2006 03:07:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1195</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
  </channel>
</rss>
