Dobbs Software

Paul Dobbs

 

Home
Programming
Fun
Model Railroading
Maybe Even Useful

A lot of these classes are very simple, but they keep me from having to write the same stuff over and over again. Instead, I just drop one of these into the project.

I've zipped these, since Stuffit handles zip files with no problem, but Windows users usually can't handle .sit files.

If you modify any of the classes or modules, I'd appreciate a copy of the modified version and permission to distrubute it.

Classes

Bar A canvas subclass that works a lot like a progress bar, but is customizable with regard to color of the bar, color of the background, and whether or not there is an outline. Vertical or Horizontal depending on whether it is wide or tall. I used it for a very simple animated bar graph.
BaseNumEdit A subclass of EditField. Allows entry of numbers in any base from 2 to 36. Methods exist to set the integer value and the base. Decimal points and negative numbers are not allowed.
ChangeChecker A class which I use to track whether or not a file is changed. It automates the addition of an asterisk to the file name or the modified dot in the window close button. It also handles the check before closing to see if you need to save a file, and if so, displays a change/don't change/cancel dialog.
ColorEdit A subclass of Editfield. Allows the entry of a color as six hexadecimal degits (rrggbb) . Colors the characters as in the sample shown. I haven't thought of a use for it yet, though.
FileEnumerator An abstract class. When you subclass it, you must replace a couple of methods. Moves through a file tree doing something to all the files. You get to decide what the something is. Potentially very useful.
FormattedList A subclass of ListBox. Allows the user to set the background color, text color and text format (bold, italic, underline) of cells or entire rows. Contains methods to set the width of columns according to the width of the contained text and to print the listbox. (If all you need is the last two methods, see ListBoxExtensions in the modules list.)
GraphicsSettings Creating a new GraphicsSettings object saves the settings of a Graphics object (Bold, ForeColor, Italic, PenHeight, TextFont, TextSize, and Underline). The settings are restored when the object is destroyed (when you exit the creation context). There is also a Restore Method, in case you need to do it before you exit.
LED A Canvas subclass. Simulates an LED. The color can be set in the properties dialog, and it can be turned on and off. The off color is half of each of the RGB values.
Rational A rational number class. Represents numbers as an integer numerator and denominator. Contains most math operations, plus comparisons and conversions. Not useful, but fun.
ScrollCanvas A Canvas subclass. Displays a text string. If the text is shorter than the width of the canvas, it will be centered horizontally. If it is longer, it will scroll. I use it in iTrack.
Splitter Another canvas subclass. Implements an invisible splitter. It is a horizontal splitter (moves horizontally) if it is tall and narrow, and a vertical splitter (moves up and down) if it is wide and short. You set the controls to the sides (or top and bottom) and a limit on how small a section can be. You could add graphics to it if you need a splitter you can see.

Modules

CharDefs Contains definitions for all of the control characters. For example, with this module in your program, you can refer to the tab character as chHT. Also contains definitions for a number of useful keys, such as the enter key.
DateExtensions Contains three routines: Add, Diff and ParseLongDate. Add adds some number of time units (days, hours, minutes ... -- you select it) to a date. Diff returns the number of time units (selectable) between two dates. ParseLongDate attempts to convert a long text date into a Date.
ErrorReporting A module which does two things: displays error dialogs to the user and optionally logs the error to a file. I use it to get a consistent style of error reporting.
GraphicsExtensions Contains a number of routines to draw and fill basic shapes in a single operation. Also contains a couple of routines to save graphics settings: PopSettings and PushSettings.
IntegerExtensions Contains routines which mimic some of the C assignment operators, but take longer to type. Instead of X++, you have X.inc. A real waste of time, but it was fun to prove that I could extend the Integer class.
ListBoxExtensions Routines to set the width of columns according to the contents, add or insert a whole row at the same time using a tab-delimited string (instead of just the first cell), and print the listbox.
Object2DExtensions Three routines. MovePoint moves an X, Y pair by distance and angle. RegPoly creates a FigureShape with N sides and a specified radius. Translate moves an Object2D by distance and angle.
PopupMenuExtensions Contains two methods: AddSorted, which adds an item to the menu in sorted order; and SetByText, which sets the listindex of the popupmenu according to the text you pass in, setting -1 if the text is not found. Yes, these are simple routines, but I hate writing them each time I write a program.
Prefs A module to handle preferences, using a dictionary. Contains routines to get and set a preference, and to read and write a text preferences file.
Radians Constants for pi, two pi, pi divided by 2, pi divided by four, and conversion factors for degrees to radians (D2R) and radians to degrees (R2D).
StandardColors Constants for Black, Blue, Cyan, Dark Gray, Gray, Green, Light Gray, Magenta, Red, White and Yellow.
StringMethods A whole catalog of string methods: Delete, DeleteImmediate, FindNoneOf, FindOneOf, Insert, InsertImmediate, IsAlpha, IsAlphaNumeric, IsBasedDigit, IsBinaryDigit, IsControl, IsDigit, IsHexDigit, IsLower, IsOctalDigit, Is Punct, IsSpace, IsUpper, Repeat, ReplaceAllImmediate, ReplaceImmediate, Reverse, ReverseImmediate, RInStr. Most methods return the result, but ...Immediate methods act directly on the input parameter.
XWindowsColors A catalog of the named colors from the XWindows system.

Tools

FileDumper This program opens any file and displays its contents in hexadecimal and ASCII. Selecting a location in the file displays the byte(s) at that location as character, byte, short, long, single, double, c string and p string values. A viewer only, not an editor. This one's a .sitx file, since it is Mac only.