Developers tool for object-oriented programming5710926Abstract A software developer's tool to help write application programs for an object-oriented operating system includes a storage device holding code. The code includes a clipboard copying utility and a first code section permitting the identification of dialog boxes and event tables associated with dialog boxes, the event tables signifying events capable of taking place during running of the application program to be written. A second code section permits the copying of dialog boxes and their associated event tables by actuation of the clipboard copying utility, and creates a new object identical to the parent object, providing a unique object name for the new object, and generating an event table name for the event table associated with the new object derived from the name of the parent object such that the event table includes controls having names derived from the name of the event table. A third code section permits editing of the child event table without altering the parent event table. Sequential use of the first, second and third code sections creates a parent object and a child object having associated parent and child event tables, the child object having an event table derived from the parent event table and having the capability of running independently of the parent object. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
______________________________________
command
An operation a software program carries out.
object A group of one or more data items.
dialog box
A visible window on screen. A specific type of object.
Dialog boxes usually contain smaller objects called
controls. The children of a dialog box are the controls.
The user can give a program information via a dialog box
with child controls for use by a command.
control
An object which is a child of a dialog box. The parent of
a control may be a control. Traversing up a tree of
controls leads to the dialog box or other object.
statement
A set of symbols valid for the syntax of a programming
language.
function
A group of statements.
method A function which can only be executed by certain types
of objects.
event A computer generated occurrence or user generated
occurrence. For example, a key stroke, mouse movement,
mouse button press, or a timer tick.
event A function that is called as the result of an event.
handler
event table
A group of event handlers for a specific object such as a
control or dialog box.
property
A data item which is contained by an object. For
example, a dialog box has a title, a window size
(x,y,height,width), and window color. An input field
control has a window size and text. The text property
contains what the user has typed into the input field.
dialog A program which is used to create or modify dialog boxes
editor with controls and allows a programmer to modify the
properties and event handlers.
pointer
A pointer in the C programming sense means a specific
memory location which is the start of some data or code.
In a more general sense, it is a mechanism that specifies
a location which is the start of some data or code. For
example, source code for a program is stored in several
files (or maybe just one file); Each source file typically
has more than one function. One method for keeping
track of where a function is would be to store the source
file name and the offset (line number) into the file where
the function starts.
offset Relative pointer. A pointer refers to the start of code or
data. An offset specifies a number of bytes, lines, or
some other measurement from the start of some code or
data. For the example above, offset was a line number
relative to the start of a source file.
class A group of methods and properties for a specific object
such as a control or dialog box.
______________________________________
Important elements to my implementation are as follows: 1. When a user creates a new empty dialog box, make sure the name given to the dialog box is different from all existing dialog boxes the user has already created. Maintain an event table name with the dialog box which is based on the dialog box name. In my implementation I name the event table the same as the dialog box. An event table is used to group event handling code for an object, such as a dialog box. 2. When the user creates a new child control (object) on the dialog box, maintain a control name which is different from other controls on the dialog box. Also maintain an event table name with the control which is based on the control name and the dialog box name. For example, if the dialog box has the name "box1", possible event table names for two child control objects could be "box1.control1" and "box1.control2". Referring now to FIG. 1, there is depicted in schematic form a dialog box which may be displayed on a video display screen, such as the video display 10 under the control of CPU and memory 12 of FIG. 7. Also shown in FIG. 1 are the names of the various objects of the dialog box. The parenthesis pairs represent the name of the object to the left of the comma and its associated event table name on the right. For example assume that "control1" represents an input field in which the user types, and "control2" represents a button (OK button) which is pushed when the user has finished typing into the input field. The pushing of the OK button is done by directing a pointer controlled by mouse 16 (seen in FIG. 7) to the portion of the screen associated with the "OK" legend and pressing a button on the mouse, in conventional fashion. The above dialog box might be used as a simple way for a user to enter a file name. Assume also that the programmer chooses not to allow percent (`%`) or dollar sign (`$`) characters to be typed into the input field. In Slick-C language in which the statement "defeventtab" means to define an event table, the code for processing the dialog box for box1 is as follows:
______________________________________
defeventtab box1.control1
control1.`%`( )
// Define an event handler for when the. user types `%`
.sub.-- beep( );
// Beep at the user to indicate an invalid character
}
control1.`$`( )
// Define an event handler for when the user types `$`
{
.sub.-- beep( );
// Beep at the user to indicate an invalid character
}
defeventtab box1.control2
control2.lbutton.sub.-- up( )
// Define event handler for pushing button with
// mouse
{
// Close the dialog box window and return the result
p.sub.-- active.sub.-- form..sub.-- delete.sub.-- window(control1.p.sub.--
text)
}
______________________________________
(Note: Words to the right of the double slash "//" are not part of the computer commands but are descriptions helpful to programmers and those reading the programmers' code.) The invention thus permits the copying of box1 while maintaining code pointers to the original code. In a graphical environment, this is typically done with the clipboard. However, copying a dialog box can also be done with a "duplicate" command or a "copy to new location" command. The programmer can visually select box1 on the screen by encircling it using the mouse and then invoke a command to copy/duplicate the object to a new location on the screen. To use the clipboard, the user copies the dialog box to the clipboard (a temporary storage location) and pastes the object at a new location on the screen. The new object appears as seen in FIG. 2. The new dialog box must be given a name which is different than "box1". FIG. 2 illustrates that the new dialog box has been given the name "box2". All child controls for box2 keep the same name as before. All event table names for the dialog box "box2" remain the same. This allows the new dialog box to execute (inherit) the same code as the original dialog box. Code may be added to the new dialog box without affecting the code for the original dialog box. Assume, for example that the reason for copying the "open file" dialog box is to create a similar dialog box which is used to find a string a user will specify in some file he or she is editing. In addition, for some reason the user does not want this input field to allow a percent (`%`) or a dollar sign (`$`) either. However, let's say that the programmer desires that when the user presses Ctrl-W in the input field, the word at the cursor in the file being edited is to be inserted into the input field to permit searching for other occurrences. The programmer uses the dialog editor to change the caption of the dialog box "box2" from "Open File" to "Find". Then the programmer selects the input field control (control1) and uses the dialog editor to write an event handler for the selected object. This is done by double clicking the mouse 16 on control1. As is conventional with some dialog editors like VisualBasic, the code for the object will appear on the screen and can be edited from the keyboard 14. Select `Ctrl-W` (i.e. a user's simultaneously pressing the "control" key and the `W` Key of the keyboard) as the event you wish to modify. The dialog editor detects the need for inheritance by noticing that the existing event table attached to the input field control1 does not belong to this control because the name of the event table is "box1.control1". Notice that "box1", the name to the left of the `.` is not the name of the dialog box ("box2"). Therefore, the dialog editor inserts the following code into a new source file for dialog box "box2":
______________________________________
// box2 source
defeventtab box2.control1 .sub.-- inherit box1.control1
control1.c.sub.-- w( )
}
______________________________________
Now code and comments can be added to the event handler to achieve the following:
______________________________________
// box2 source
defeventtab box2.control1 .sub.-- inherit box1.control1
control1.c.sub.-- w( ) // Define event handler for user pressing Ctrl-W
in input
{ //field
keyin(get.sub.-- cur.sub.-- word( ))
______________________________________
The defeventtab statement above inherits the original event table. Alternatively, the defeventtab line may be typed in manually. This statement creates a linked list of event tables (inheritance chain) that can be scanned for event handlers for the control. If the user makes a copy of dialog box "box2" and adds another event handler to the input field control, the dialog editor links an event table called "box3.control1" to "box2.control1". Once an event handler is found, the event handler is executed and, in a preferred embodiment this halts the searching for the event handlers that follow. FIG. 3 is a graphical representation of the chain of code pointers. The parenthesis pairs represent the name of the event followed by the module (file) name, followed by the offset to the event handling code. The resulting source code may be compiled to object code and then run in a suitable computer. In running the object code, the linked lists of event tables are scanned, so that the object code for the original commands is sought out and executed. C++ Language Implementation In a C++ language implementation, the key elements are the same. A class is used to group the code instead of an event table and each event handler is defined as a method in the class. 1. When a user creates a new, empty dialog box, the name given to the dialog box is different from all existing dialog boxes the user has already created. A class name is maintained with the dialog box which is based on the dialog box name. In my implementation I name the class the same as the dialog box but prefix it with an underscore (` `). 2. When the user creates a new child control (object) on the dialog box, maintain a control name which is different from other controls on the dialog box. Also maintain a class name with the control which is based on the control name and the dialog box name. If the dialog box has the name "box1", possible class names for two child control objects could be" box1 control1" and " box1 control2". Referring to FIG. 4, a copying method for C++ similar to that described above will be shown. The parenthesis pairs represent the name of the object to the left of the comma and the class name on the right. Assume that control1represents an input field in which the user types and control2represents a button (OK button) which is pushed when the user has finished typing into the input field. The above dialog box might be used as a simple way for a user to enter a file name. As an example, assume the program is being written not to allow percent (`%`) or dollar sign (`$`) characters to be typed into the input field. In C++, the code for processing the dialog box for box1is as follows:
______________________________________
// Define the classes that require methods
class.sub.-- box1.sub.-- control1:control {
// Must inherit control class
public: // which defines default methods
void percent( ); // and properties.
void dollar( ):
};
class.sub.-- box1.sub.-- control2:control { // Must inherit control
class
public: // which defines default methods
void ibutton.sub.-- up( );
};
// Methods for control1
void.sub.-- box1.sub.-- control1::percent( )
.sub.-- beep( );
}
void.sub.-- box1.sub.-- control1::dollar( )
{
.sub.-- beep( );
}
// Method for control2
void.sub.-- box1.sub.-- control2::Ibutton.sub.-- up( )
{
// Close the dialog box window and return the result
p.sub.-- active.sub.-- form->.sub.-- delete.sub.-- window(find.sub.--
control("control1")->p.sub.-- text);
}
______________________________________
The invention enables the making of a copy of box1 while maintaining code pointers to the original code. The new object will look like FIG. 5. The new dialog box must be given a name which is different than "box1". FIG. 5 illustrates that the new dialog box has been given the name "box2". All child controls keep the same name as before. ALL class names for the dialog box "box2" remain the same. This allows the new dialog box to execute (inherit) the same code as the original dialog box. In this embodiment code may be added to the new dialog box without affecting the code for the original dialog box. Assume for example that the reason for copying the open file dialog box is to create a similar dialog box which is used to find a user-specified string in a file he or she is editing. In addition, for some reason the programmer does not want this input field to allow a percent (`%`) or a dollar sign (`$`) either. However, let's say when the user presses Ctrl-W in the input field, the program being written is to insert the word at the cursor in the file being edited into the input field to permit searching for other occurrences. The programmer uses the dialog editor to change the caption of dialog box "box2" from "Open File" to "Find". Then the programmer selects the input field control and tells the dialog editor of his desire to write an event handler for the selected object. In the example, the programmer selects `Ctrl-W` as the event to modify. The dialog editor detects the need for inheritance by noticing that the existing class attached to the input field control1does not belong to this control because the name of the class is " box1 control1". Notice that "box1", the name to the left of the second underscore, is not the name of the dialog box ("box2") with an underscore inserted at the front. Therefore, the dialog editor inserts the following code into a new source file for dialog box "box2":
______________________________________
// box2 source
class.sub.-- box2.sub.-- control1:.sub.-- box1.sub.-- control1{//
Inherit.sub.-- box1.sub.-- control1 class
public:
void c.sub.-- w( );
};
void.sub.-- box2.sub.-- control1::c.sub.-- w( )
}
______________________________________
Now the programmer can fill in the code for the method as follows:
______________________________________
class.sub.-- box2.sub.-- control1:.sub.-- box1.sub.-- control1 {
public:
void c.sub.-- w( );
};
void.sub.-- box2.sub.-- control1::c.sub.-- w( )
keyin(get.sub.-- cur.sub.-- word( ));
}
______________________________________
Notice that the class statement above inherits the original class. This creates a linked list of classes (inheritance chain) that can be scanned for methods for the control. If the programmer were to make a copy of dialog box "box2" and add another event handler to the input field control, the dialog editor would link a class called " box3 control1" and link it to " box2 control1". For C++, the compiler performs this scanning and writes a copy of the found code in the object code for the daughter box, so that no scanning is required when the program is executed. FIG. 6 depicts the class tree of code pointers. The parenthesis pairs represent the name of the method followed by the module (file) name, followed by the offset to the method handling code. The examples above show how to copy an entire dialog box and preserve the code pointers. Sub-trees of controls may be copied as well. To copy control1 and control2, onto an existing dialog box, select both controls using the dialog editor. Copy the controls to the new dialog box and preserve the event table names in the new controls. When copying controls from one dialog box to an existing dialog box which already has control(s) with the same name, the invention renames the new controls and leaves the existing control names unchanged. The programmer may then delete existing controls before copying the same controls twice. Alternatively, the program according to the invention may prompt the user to replace a control whose name conflicts. Changing the names of controls does not affect the code pointers. However, there are cases when groups of controls communicate with each other by referencing the control name. Control names are referenced relative to the active dialog box. Typically, the programmer will choose better names than "control1" and "control2" so that the names of controls do not conflict often when they are copied to another dialog box. In addition to implementation in SlickC, SlickEdit and C++ languages, the invention may be implemented in any object-oriented language, including object-oriented Pascal. Those of ordinary skill in the art will appreciate that various modifications can be made to the apparatus as specifically described and still fall within the scope of the invention.
|
Same subclass Same class Consider this |
||||||||||
