#!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP #!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP

3D
3D Photo Gallery (Part 1)
3D Photo Gallery (Part 2)

Audio
Poor Man's MIDI
Make A Metronome
iPod Tricks (Part 1)
iPod Tricks (Part 2)
iPod Tricks (Part 3)
Laugh Track Machine
Audio Player with Reverb
Shepard Melody
RB Phone Home
Build a Drum Machine

Custom Controls and Windows
Double Click Listbox
Draggable Metal Window
Double Click Canvas
Custom Buttons
Custom Buttons Part II
iTunes-style Listboxes
Custom Controls


General RB
Scrolling Windows
Using Mesage Dialogs
Case-Sensitive Word Finder
Introduction to Stacks
Wiggle Window
JPEG in PDF
Listbox Checkboxes
Background Applications
Listbox Auto-Find
Virtual Volumes
Time Tracker
Software Distribution (Part 1)
Software Distribution (Part 2)
Software Distribution (Part 3)
Software Distribution (Part 4)
Exceptions
Tips and Tricks
Text Clippings Made Easy

Graphics
Drawing a Simple Gradient
The SpriteSurface: Space Game
Image Spinner
Cropping Graphics (Part 1)
Cropping Graphics (Part 2)
Cropping Graphics (Part 3)
Cropping Graphics (Part 4)
Shimmer Graphics
Lissajous Figures
Simple Screen Capture
Vector Graphics
Kaleidoscope Images
Stegonography
Spirals!
Image Table
RB Magnifying Lens
Screen Capture
Color Picker Tutorial

Hacks
Ghost Grab
Speedy Mouse Extension
iTunes Plugins
iTunes Skinner

Mac OS X
Global Hot Key Event (Carbon Events)
Login Welcomer (Carbon Events)
Add/Remove Buttons
Resizable Sheets
Mac OS X Preferences Window
Using Sheets in REALbasic
Build a Bundle (Part 1)
Build a Bundle (Part 2)
Dock Your Passwords
Mac OS X Debugging
REALbasic Mac OS X Icon Tutorial
Animate Your Dock
RB and the Command Line

Menus
Window Menu
Templates Menu
Listbox Menu

Novelty
Guessing Game
Calendar Trivia
Tile Mixer
Zip Code Finder
Happy Valentine's Day
Merlin Simulator (Part 1)
Merlin Simulator (Part 2)
Merlin Simulator (Part 3)
Buzzword Machine
AppleSoft BASIC

Printing
Print to PDF

Registration
Registration Code Validation
Network Registration Codes

Resources
Picture Extractor (Part 1)
Picture Extractor (Part 2)

Serial
Caller ID (Part 1)
Caller ID (Part 2)
Caller ID (Part 3)

Speech
Speech Recognition

Socket Communication
Easy Peer-to-Peer File Sharing
MacPAD Version Checking
Display Web Image In Canvas
HTML IMG Tags
Version Tracking
Even Smarter Instant Messaging
Web Tiler
JavaScript and REALbasic
Stock Ticker (Part I)
Stock Ticker (Part 2)
AIM Mate

XML Manipulation
Simple XML Introduction

Video
Big Brother Video Capture

Note: All articles without a byline were written by Erick Tejkowski. When cleaning the site I removed them because the code differed from page to page, and I have yet to put them back in.

resexc2.gif (20k)




REALbasic for Dummies
by Erick Tejkowski

$19.99 @ Amazon





Files are in Stuffit 6.5 or earlier, or ZIP format.
Download Stuffit Expander

Tell us about a bad link.

Resizable Sheets by Seth Willits
03-20-04




Mac OS X Sheets
Everyone knows that sheets simply rock. While REALbasic sheets have gotten better through the last several updates of REALbasic, one thing they still don't support is being resizable. Well today, we're going to fix that.

Setting Up the Subclass
First off, create a new Window subclass named "ResizableSheet". Next, add events to the class for MouseDown, MouseDrag, MouseUp, Paint, Resized, and Resizing. We'll put code in each of these events in the subclass, so we'll need to create the events so that the instance can use them also. We'll also be doing a little bit of magic to get events to fire in the correct spots. After that, create three new properties, mMouseDown as Boolean, mLastDownX as integer, and mLastDownY as integer. (The "m" prefix stands for "member" by the way. After figuring out what it meant, I adopted this practice from Joe Strout.)

mMouseDown will track whether the instance requested to be notified of MouseDrag and MouseUp events, and the mLastDownX and mLastDownY properties track the last position of the mouse relative to the window during the mouse events.



The MouseDown Event
The first thing we're going to do is check whether the mouse clicked in the region of the grow tab, and set the X and Y properties accordingly. Setting them to -1 means that we're not resizing the window. After this, we call the instance's MouseDown event, setting mMouseDown to the result. Last, we return true since we ALWAYS need to handle the MouseDrag and MouseUp events for our own purposes.

Function MouseDown(X As Integer, Y As Integer) As Boolean

// Save Position Only if inside grow box
if x > self.Width - 16 and y > self.Height - 16 then
mLastDownX = x
mLastDownY = y
else
mLastDownX = -1
mLastDownY = -1
end if

// Call Instance's event
mMouseDown = MouseDown(x, y)

// We MUST return true to handle the drag and user event
return true
End Function



The MouseDrag Event
In this event, we need to check whether we're actually resizing the window (testing for -1 here), and then resize the window, paying attention to the minimum and maximum boundaries of the window. We then call the Resizing event of the instance to notify it that the window is resizing, and save the current mouse position. Outside of the if-statement testing whether we're resizing or not, we test to see if mMouseDown is true, and if it is, we call the MouseDrag event of the instance.

Sub MouseDrag(X As Integer, Y As Integer)
// Only resize if not -1, -1
if mLastDownX <> -1 and mLastDownY <> -1 then

// Resize Window
self.Width = self.Width + x - mLastDownX
self.Height = self.Height + y - mLastDownY

// Must obey minimum size
if self.Width < self.MinWidth then
self.Width = self.MinWidth
end if
if self.Height < self.MinHeight then
self.Height = self.MinHeight
end if

// Must obey maximum size
if self.Width > self.MaxWidth then
self.Width = self.MaxWidth
end if
if self.Height > self.MaxHeight then
self.Height = self.MaxHeight
end if


// Call Resizing Event
Resizing

// Save Position
mLastDownX = x
mLastDownY = y
end if


// If they returned true, then call the event
if mMouseDown then
MouseDrag x, y
end if
End Sub



The MouseUp Event
The MouseUp event is the simplest since all we need to do is test whether we were resizing and if so call the Resized event, always reset the X and Y properties to -1 (to signal we're not resizing any more), and then call the MouseUp event if the instance desires.

Sub MouseUp(X As Integer, Y As Integer)
// Call Resized Event
if mLastDownX <> -1 and mLastDownX <> -1 then
Resized
end if

// Reset to signal we're not resizing
mLastDownX = -1
mLastDownY = -1

// Call it if wanted
if mMouseDown then
MouseUp x, y
end if
End Sub



The Resized Event
When we resize the window in the MouseDrag event, the Resized event of the window is fired each time. Since the Resized event should only fire after the resizing has finished, we only want to call the Resized event if mLastDownX and mLastDownY are -1, meaning that we aren't resizing it from the MouseDrag event.

Sub Resized()
// Only call the resized event if we weren't
// resizing the window ourselves. This prevents
// it from being called while it is resizing
// rather than after the window is resized
if mLastDownX = -1 and mLastDownY = -1 then
Resized
end if
End Sub



The Resizing Event
We always call the Resizing event from here. Even though it should never fire anyway, if it does, we want it to.

Sub Resizing()
Resizing
End Sub



The Paint Event
The last step is actually draw the grow tab. This is not an exact science, so if you wish to improve on this, be my guest, but the difference between the code below and an actual grow box is pretty unnoticable. Just take the code as it is.

Sub Paint(g As Graphics)
Paint g

// Clear it
g.ClearRect 0, 0, g.Width, g.Height


// Draw Grow Tab
g.ForeColor = RGB(180, 180, 180)
g.DrawLine g.Width - 16 + 5, g.Height - 16 + 14, g.Width - 16 + 14, g.Height - 16 + 5
g.DrawLine g.Width - 16 + 9, g.Height - 16 + 14, g.Width - 16 + 14, g.Height - 16 + 9

g.ForeColor = RGB(100, 100, 100)
g.DrawLine g.Width - 16 + 13, g.Height - 16 + 14, g.Width - 16 + 14, g.Height - 16 + 13


g.ForeColor = RGB(114, 114, 114)
g.DrawLine g.Width - 16 + 5, g.Height - 16 + 14, g.Width - 16 + 14, g.Height - 16 + 5
g.DrawLine g.Width - 16 + 9, g.Height - 16 + 14, g.Width - 16 + 14, g.Height - 16 + 9

g.ForeColor = RGB(60, 60, 60)
g.DrawLine g.Width - 16 + 13, g.Height - 16 + 14, g.Width - 16 + 14, g.Height - 16 + 13
End Sub



Final Notes
So there you have it. Create two windows in your project, set one's super to "ResizableSheet" and make it a sheet window. Then just write the code which displays it as a sheet inside of the other window. Once you've done that, baddabing baddaboom. You're done.

As always, you can download the project for this tutorial.






Please support ResExcellence by Visiting our Sponsors. One click makes a difference.


Download REALbasic and create your own software!

#!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP #!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP