From: <mie...@us...> - 2011-06-22 21:47:42
|
Revision: 7010 http://oorexx.svn.sourceforge.net/oorexx/?rev=7010&view=rev Author: miesfeld Date: 2011-06-22 21:47:33 +0000 (Wed, 22 Jun 2011) Log Message: ----------- Begin a project that will consist of extra ooDialog examples that can be downloaded separately from SourceForge Modified Paths: -------------- incubator/samples/ooDialog/tutorial/001.intro/logon.rex incubator/samples/ooDialog/tutorial/001.intro/logon_a.rex incubator/samples/ooDialog/tutorial/002.topic/billingDlg.h incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rc incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rex Added Paths: ----------- incubator/samples/ooDialog/tutorial/001.intro/logon_a_uc.rex incubator/samples/ooDialog/tutorial/ReadMeFirst.txt incubator/samples/ooDialog.samples.package/ incubator/samples/ooDialog.samples.package/Controls/ incubator/samples/ooDialog.samples.package/Controls/Edit/ incubator/samples/ooDialog.samples.package/Controls/Edit/RestrictedInput.rex incubator/samples/ooDialog.samples.package/Controls/Edit/restrictedInput.h incubator/samples/ooDialog.samples.package/Controls/Edit/restrictedInput.rc incubator/samples/ooDialog.samples.package/Controls/Edit/restrictedInput32.dll incubator/samples/ooDialog.samples.package/Dialogs/ incubator/samples/ooDialog.samples.package/Menus/ incubator/samples/ooDialog.samples.package/install/ Removed Paths: ------------- incubator/samples/ooDialog/tutorial/ReadMe.First Modified: incubator/samples/ooDialog/tutorial/001.intro/logon.rex =================================================================== --- incubator/samples/ooDialog/tutorial/001.intro/logon.rex 2011-06-21 23:19:02 UTC (rev 7009) +++ incubator/samples/ooDialog/tutorial/001.intro/logon.rex 2011-06-22 21:47:33 UTC (rev 7010) @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------------*/ /* */ -/* Copyright (c) 2008 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2008-2011 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -36,10 +36,9 @@ /*----------------------------------------------------------------------------*/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ - File: logon.rex Author: Mark Miesfeld - Creation date: 05/20/2008 + File: logon.rex Creation date: 05/20/2008 - Project: ooDialog Tutorial Last update: 06/01/2008 + Project: ooDialog Tutorial Last update: 06/22/2011 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Category: @@ -50,10 +49,14 @@ Purpose: Show a very simple version of a dialog to demonstrate the very basics of - creating and executing a dialog. Show the default handling of the ok and + creating and executing a dialog. Shows the default handling of the ok and cancel methods and illustrate how ooDialog can take care of most of the details involved in putting up a dialog on the screen, interacting with the user and returning the user input. + + This program, the first in the series of tutorial programs, has very little + explanation. After reviewing this program, look to the logon_a.rex program + for comment explaining what is going on. \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ dlg = .LogonDialog~new @@ -71,13 +74,13 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ Directives, Classes, or Routines. \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ -::requires "oodialog.cls" +::requires "ooDialog.cls" ::class 'LogonDialog' public subclass UserDialog ::method defineDialog - self~addText(5, 5, 85, 10, "Do you want to log on?") - self~AddOkCancelRightBottom + self~createStaticText( , 5, 5, 85, 10, , "Do you want to log on?") + self~createOkCancelRightBottom /* - - - End Of File: logon.rex - - - - - - - - - - - - - - - - - - - - - - - */ Modified: incubator/samples/ooDialog/tutorial/001.intro/logon_a.rex =================================================================== --- incubator/samples/ooDialog/tutorial/001.intro/logon_a.rex 2011-06-21 23:19:02 UTC (rev 7009) +++ incubator/samples/ooDialog/tutorial/001.intro/logon_a.rex 2011-06-22 21:47:33 UTC (rev 7010) @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------------*/ /* */ -/* Copyright (c) 2008 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2008-2011 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -36,10 +36,9 @@ /*----------------------------------------------------------------------------*/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ - File: logon_a.rex Author: Mark Miesfeld - Creation date: 05/20/2008 + File: logon_a.rex Creation date: 05/20/2008 - Project: ooDialog Tutorial Last update: 06/01/2008 + Project: ooDialog Tutorial Last update: 06/22/2011 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Category: @@ -65,13 +64,13 @@ number of class objects that represent a dialog box and dialog box controls. In the graphical user interface of the Windows OS, everything is a window. - Most software applications consist of a main window or possibly several + Most software applications consist of a main window and possibly several document windows. In a main window the software application usually is responsible for drawing everything that takes place and handling every user generated event. A dialog box is a specialized type of window that is constructed using any - number of pre-defined control windows. Unlike with a main application + number of pre-defined control windows. Unlike an application with a main window, with a dialog box the programmer normally does none of the drawing and very little of the handling of user events. Instead the dialog box and dialog controls handle all the drawing and most of the user events @@ -83,37 +82,100 @@ apllications were written using only dialog boxes. ooDialog exposes the functionality of dialog boxes and dialog controls. It - does not expose the functionality of main windows. + does *not* expose the functionality of main windows. + All dialogs in the Windows operating system are created by supplying a + dialog template to the operating system (OS). The OS then creates the + dialog seen on the screen from the template. A dialog template defines the + size, position, and style of the dialog, along with the size, position, and + style of the dialog controls within the dialog. + + The ooDialog framework provides 3 basic ways for the programmer to provide + the dialog template to the OS in the form of 3 base dialog classes. The + programmer decides which method he wants to use to provide the dialog + template and then creates a dialog by subclassing one of the 3 base dialog + classes. + + The 3 base classes are: UseDialog, RcDialog, and ResDialog. + + With the UserDialog, the programmer defines the dialog template dynamically + using methods of the UserDialog class. + + With the RcDialog, the programmer provides the dialog template in the form + of a resource script file. Resource script files are usually created with + a resource editor. + + With the ResDialog, the programmer provides the dialog template in a + compiled binary form contained within a resource-only DLL. + + This introductory program uses a UserDialog subclass to provide the dialog + template. The dialog template is created by using methods supplied by the + UserDialog class. \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ + -- NOTE that all routines and methods not defined in this file are provided + -- by the ooDialog framework and are documented in the oodialog.pdf reference + -- book. + + -- Instantiate a new Rexx dialog object. The dialog presents a simple log on + -- screen to the user, with a field to enter the user name and a field to + -- enter the password. + dlg = .LogonDialog~new + -- The initCode attribute of the dialog object is used to signal any error in + -- the instantiation of the object. The init code is 0 if there were no + -- errors detected and not 0 if there were errors. It is very unlikely that + -- an error will occur, but it does no harm to check. + if dlg~initCode == 0 then do + + -- The create() and createCenter() methods start the definition of the + -- dialog template for a UserDialog subclass. One or the other must be + -- called first, before the creation of the dialog controls. The methods + -- defines the size and position of the dialog, the title of the dialog, + -- and the style of the dialog. + -- + -- The create() or createCenter() methods automatically invoke the + -- defineDialog(). Within the defineDialog() method, the programmer then + -- creates the dialog controls that populate the dialog. When the create() + -- or createCenter() method returns, the dialog template has been completely + -- finished. + dlg~createCenter(110, 55, "Logon", "VISIBLE NOMENU SYSTEMMODAL") + + -- Now that the dialog template is complete, we are ready to pass the + -- template on to the OS, show the dialog, and run the dialog. The + -- execute() method does just that. It passes the template to the OS, the + -- OS creates the undelying dialog, shows the dialog on the screen, and runs + -- the dialog. The dialog continues running until the user closes it. + -- + -- When the execute() method returns, the underlying Windows dialog has been + -- closed by the user. This could be seconds, minutes, or even days after + -- we invoke the execute() method. + dlg~execute + -- Now that the dialog has been closed, we get the results from the dialog. + accessLevel = dlg~access user = dlg~user -- After the logon attempt, the data would usually be passed on to the main -- program. Here it is just displayed to the console, using a convenience - -- function defined at the end of this program. + -- function, dislplay() defined at the end of this program. + accessData = display(accessLevel, user) end else do + -- This is the case that the initCode was not 0, we inform the user + j = infoDialog("System error. The logon dialog could" || '0d0a'x || - "not be created. Contact your system" || '0d0a'x || - "administrator.") accessData = .nil end - -- The deInstall method unregisters all the ooDialog external functions. - -- Normally that would only be done when the program is entirely finished. - -- Since this is just an example and it is now finished, the deInstall method - -- is invoked. This is not really needed. - dlg~deInstall - return accessData -- End of entry point. @@ -122,21 +184,61 @@ \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ ::requires "oodialog.cls" +-- This is the basis of our log on dialog. We subclass the UserDialog and then +-- code the methods that will define how the dialog behavies. ::class 'LogonDialog' public subclass UserDialog +/** defineDialog() + * + * The defineDialog() method is provided by the ooDialog framework, it is + * invoked at the proper time by the framework, that is, after the dialog + * template has been started and now needs the addition of the dialog controls. + * + * The default implementation of this method does nothing. The method is meant + * to be over-ridden by the programmer. Within the method, the programmer + * creates the dialog controls that will be present in the dialog. + */ ::method defineDialog - self~addText(5, 5, 35, 10, "User ID:") - self~addText(5, 20, 35, 10, "Password:") + -- Create 2 static controls. These controls are the labels for the edit + -- controls. - self~addEntryLine(101, , 43, 5, 62, 10, "AUTOSCROLLH") - self~addEntryLine(102, , 43, 20, 62, 10, "AUTOSCROLLH PASSWORD") + self~createStaticText( , 5, 5, 35, 10, , "User ID:") + self~createStaticText( , 5, 20, 35, 10, , "Password:") - self~addButton(2, 35, 35, 30, 15, "Cancel") - self~addButton(1, 75, 35, 30, 15, "Ok", , "DEFAULT") + -- Create 2 edit controls. These edit controls are where the user enters her + -- user ID and password. + self~createEdit(101, 43, 5, 62, 10, "AUTOSCROLLH") + self~createEdit(102, 43, 20, 62, 10, "AUTOSCROLLH PASSWORD") + + -- Create the Ok and Cancel push buttons. + + self~createPushButton(1, 35, 35, 30, 15, "DEFAULT", "Ok") + self~createPushButton(2, 75, 35, 30, 15, , "Cancel") + + -- setUp() is a private method of this dialog that we use to initialize + -- things. self~setUp +/** cancel() + * + * The cancel() method is provided by the ooDialog framework and is invoked + * by the framework automatically at the correct time. That is, when the user + * has canceled the dialog. + * + * The method is meant to be over-ridden by the programmer, if needed. + * + * The programmer can prevent the dialog from closing by simply not invoking the + * superclass cancel() method. + * + * To allow the dialog to close, invoke the superclass cancel() method. Always + * close a dialog by invoking either the superclass ok() or cancel() methods. + * This ensures that the dialog execution is processed correctly. + * + * We over-ride the method simply to ensure that the accessLevel and userID + * attributes are set to null values. + */ ::method cancel expose accessLevel userID @@ -145,11 +247,48 @@ self~cancel:super +/** okd() + * + * The okd() method is provided by the ooDialog framework and is invoked by the + * framework automatically at the correct time. That is, when the user has + * closed the dialog with okay. + * + * The method is meant to be over-ridden by the programmer, if needed. + * + * The programmer can prevent the dialog from closing by simply not invoking the + * superclass ok() method. + * + * To allow the dialog to close, continue by invoking the superclass ok() + * method. Always close a dialog by invoking either the superclass ok() or + * cancel() methods. This ensures that the dialog execution is processed + * correctly. + * + * Most often the ok() method is over-ridden to validate the user input. Here + * we over-ride the method to be sure the user entered a user ID and password, + * and then to check that the ID and password are correct. + */ ::method ok expose userID accessLevel - userID = self~getEntryLine(101)~strip - password = self~getEntryLine(102)~strip + -- We get the text in both edit controls. This is done by getting a new edit + -- control object and asking it for its text. + + userID = self~newEdit(101)~getText~strip + password = self~newEdit(102)~getText~strip + + /* + * The above is a short hand version of the method invocations. This is a + * clearer form that does the same thing: + * + * editControl = self~newEdit(101) + * text = editControl~getText + * userID = text~strip + */ + + -- The following is just standard programming to verify the user and password. + -- To prevent the dialog from closing, return 0. When everything checks out, + -- continue with the dialog closing by invoking the superclass ok() method. + if userID == "" | password == "" then do j = infoDialog("You must enter both a user ID and a password") return 0 Added: incubator/samples/ooDialog/tutorial/001.intro/logon_a_uc.rex =================================================================== --- incubator/samples/ooDialog/tutorial/001.intro/logon_a_uc.rex (rev 0) +++ incubator/samples/ooDialog/tutorial/001.intro/logon_a_uc.rex 2011-06-22 21:47:33 UTC (rev 7010) @@ -0,0 +1,210 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 2008-2011 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.oorexx.org/license.html */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ + File: logon_a_uc.rex Creation date: 06/22/2011 + + Project: ooDialog Tutorial Last update: 06/22/2011 + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Uncommented version of logon_a.rex +\* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ + + dlg = .LogonDialog~new + + if dlg~initCode == 0 then do + dlg~createCenter(110, 55, "Logon", "VISIBLE NOMENU SYSTEMMODAL") + dlg~execute + + accessLevel = dlg~access + user = dlg~user + accessData = display(accessLevel, user) + end + else do + j = infoDialog("System error. The logon dialog could" || '0d0a'x || - + "not be created. Contact your system" || '0d0a'x || - + "administrator.") + accessData = .nil + end + +return accessData +-- End of entry point. + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ + Directives, Classes, or Routines. +\* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ +::requires "oodialog.cls" + +::class 'LogonDialog' public subclass UserDialog + +::method defineDialog + + self~createStaticText( , 5, 5, 35, 10, , "User ID:") + self~createStaticText( , 5, 20, 35, 10, , "Password:") + + self~createEdit(101, 43, 5, 62, 10, "AUTOSCROLLH") + self~createEdit(102, 43, 20, 62, 10, "AUTOSCROLLH PASSWORD") + + self~createPushButton(1, 35, 35, 30, 15, "DEFAULT", "Ok") + self~createPushButton(2, 75, 35, 30, 15, , "Cancel") + + self~setUp + +::method cancel + expose accessLevel userID + + accessLevel = 0 + userID = "" + + self~cancel:super + +::method ok + expose userID accessLevel + + userID = self~newEdit(101)~getText~strip + password = self~newEdit(102)~getText~strip + + if userID == "" | password == "" then do + j = infoDialog("You must enter both a user ID and a password") + return 0 + end + + accessLevel = self~certify(userID, password) + + if accessLevel == 0 then do + j = infoDialog("The user ID or password is not recognized") + return 0 + end + + select + when accessLevel == -1 then do + j = infoDialog("Four failed log on attempts in a row." || '0d0a0d0a'x || - + "This session is terminated.") + end + + when accessLevel == -2 then do + j = infoDialog("Three failed log on attempts for" userID"." || - + '0d0a0d0a'x || - + "The" userID "account is locked.") + end + + otherwise + nop + end + -- End select + + self~ok:super + + +::method access + expose accessLevel + return accessLevel + +::method user + expose userID + return userID + +::method setUp private + expose userID accessLevel attempts + + userID = "" + accessLevel = 0 + attempts = 0 + + +::method certify private + expose users recorder attempts + use strict arg id, password + + attempts += 1 + id = id~upper + + if \ users~isA(.directory) then users = self~createUserDirectory + + if users[id] == password then return id~length + + if \ recorder~isA(.table) then recorder = .table~new + + if recorder~hasIndex(id) then do + recorder[id] += 1 + if recorder[id] > 2 then return -2 + end + else do + recorder[id] = 1 + end + + if attempts > 3 then return -1 + + return 0 + + +::method createUserDirectory private + d = .directory~new + + d~rick = 'java' + d~markh = 'tree' + d~david = 'ibm' + d~lee = 'safe' + d~miesfeld = 'ppclab' + d~jon = 'england' + + return d + +::routine display + use strict arg level, user + + select + when level == -2 then + say "Failed logon. The" user "account is now locked out." + + when level == -1 then + say "Failed logon. The session was forcibly terminated." + + when level == 0 & user == "" then + say "The user canceled the logon." + + when level == 0 then + say "The user" user "is not authorized to access this system." + + otherwise + say "The user" user "is granted access at level" level + end + -- End select + + return level user + +/* - - - End Of File: logon_a.rex - - - - - - - - - - - - - - - - - - - - - - */ Property changes on: incubator/samples/ooDialog/tutorial/001.intro/logon_a_uc.rex ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native Modified: incubator/samples/ooDialog/tutorial/002.topic/billingDlg.h =================================================================== --- incubator/samples/ooDialog/tutorial/002.topic/billingDlg.h 2011-06-21 23:19:02 UTC (rev 7009) +++ incubator/samples/ooDialog/tutorial/002.topic/billingDlg.h 2011-06-22 21:47:33 UTC (rev 7010) @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------------*/ /* */ -/* Copyright (c) 2008 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2008-2011 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -35,8 +35,13 @@ /* */ /*----------------------------------------------------------------------------*/ -#define IDI_DLG_ICON 15 -#define IDD_DLG_COMBOBOX 103 +#ifndef IDC_STATIC +#define IDC_STATIC (-1) +#endif + +#define IDD_COMBOBOX 103 +#define IDI_ICON 150 +#define IDD_ACCOUNTNAME 152 #define IDC_STATIC_TITLE 1001 #define IDC_STATIC_ACCOUNT 1002 #define IDC_STATIC_ADDRESS1 1007 @@ -54,3 +59,4 @@ #define IDC_STATIC_ZIP 1026 #define IDC_COMBO_STATE 1027 #define IDC_COMBO_ZIP 1028 +#define IDC_EDIT 1028 Modified: incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rc =================================================================== --- incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rc 2011-06-21 23:19:02 UTC (rev 7009) +++ incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rc 2011-06-22 21:47:33 UTC (rev 7010) @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------------*/ /* */ -/* Copyright (c) 2008 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2008-2011 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -34,38 +34,57 @@ /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*----------------------------------------------------------------------------*/ - +#include <windows.h> +#include <commctrl.h> +#include <winuser.h> #include "billingDlg.h" -#include "Windows.h" + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -IDI_DLG_ICON ICON "billingDlg.ico" +IDD_ACCOUNTNAME DIALOGEX 0, 0, 198, 125 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "New Account Name" +FONT 8, "Ms Shell Dlg", 400, 0, 1 +{ + GROUPBOX "Instructions", IDC_STATIC, 10, 10, 178, 54 + LTEXT "To facilitate using the Billing Address example program, enter a new account name. For example: Home Depot", IDC_STATIC, 25, 21, 148, 38, SS_LEFT + LTEXT "New account name:", IDC_STATIC, 14, 80, 67, 8, SS_LEFT + EDITTEXT IDC_EDIT, 83, 79, 105, 12, ES_AUTOHSCROLL + DEFPUSHBUTTON "OK", IDOK, 83, 101, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 138, 101, 50, 14 +} + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -IDD_DLG_COMBOBOX DIALOGEX 50, 50, 373, 143 -STYLE DS_SHELLFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU +IDD_COMBOBOX DIALOGEX 50, 50, 373, 143 +STYLE DS_SHELLFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU CAPTION "New Account - Billing Information" FONT 8, "MS Shell Dlg", 0, 0, 0 -BEGIN - CTEXT "Billing Address", IDC_STATIC_TITLE, 16, 13, 97, 14, NOT WS_GROUP | SS_CENTERIMAGE - GROUPBOX "Select County", IDC_GB_COUNTY, 17, 32, 100, 70 - AUTORADIOBUTTON "San Diego County", IDC_RB_SANDIEGO, 31, 49, 70, 10, WS_TABSTOP | BS_LEFT - AUTORADIOBUTTON "Orange County", IDC_RB_ORANGE, 31, 66, 70, 10 BS_LEFT - AUTORADIOBUTTON "Imperial County", IDC_RB_IMPERIAL, 31, 84, 70, 10, BS_LEFT - RTEXT "Account Name:", IDC_STATIC_ACCOUNT, 119, 13, 53, 14, NOT WS_GROUP | SS_CENTERIMAGE - LTEXT "Home Depot", IDC_STATIC_CUSTOMER, 177, 13, 139, 14, NOT WS_GROUP | SS_CENTERIMAGE - RTEXT "Address 1:", IDC_STATIC_ADDRESS1, 132, 34, 40, 14, NOT WS_GROUP | SS_CENTERIMAGE +{ + CTEXT "Billing Address", IDC_STATIC_TITLE, 16, 13, 97, 14, NOT WS_GROUP | SS_CENTER | SS_CENTERIMAGE + GROUPBOX "Select County", IDC_GB_COUNTY, 17, 32, 100, 70, WS_GROUP + AUTORADIOBUTTON "San Diego County", IDC_RB_SANDIEGO, 31, 49, 70, 10, WS_TABSTOP | BS_CENTER + AUTORADIOBUTTON "Orange County", IDC_RB_ORANGE, 31, 66, 70, 10, BS_CENTER + AUTORADIOBUTTON "Imperial County", IDC_RB_IMPERIAL, 31, 84, 70, 10, BS_CENTER + RTEXT "Account Name:", IDC_STATIC_ACCOUNT, 119, 13, 53, 14, NOT WS_GROUP | SS_RIGHT | SS_CENTERIMAGE + LTEXT "Home Depot", IDC_STATIC_CUSTOMER, 177, 13, 139, 14, NOT WS_GROUP | SS_LEFT | SS_CENTERIMAGE + RTEXT "Address 1:", IDC_STATIC_ADDRESS1, 132, 34, 40, 14, NOT WS_GROUP | SS_RIGHT | SS_CENTERIMAGE EDITTEXT IDC_EDIT_ADDR1, 177, 34, 186, 14, ES_AUTOHSCROLL - RTEXT "Address 2:", IDC_STATIC_ADDRESS2, 132, 56, 40, 14, NOT WS_GROUP | SS_CENTERIMAGE + RTEXT "Address 2:", IDC_STATIC_ADDRESS2, 132, 56, 40, 14, NOT WS_GROUP | SS_RIGHT | SS_CENTERIMAGE EDITTEXT IDC_EDIT_ADDR2, 177, 56, 186, 14, ES_AUTOHSCROLL - LTEXT "City:", IDC_STATIC_CITY, 177, 77, 25, 13, NOT WS_GROUP | SS_CENTERIMAGE + LTEXT "City:", IDC_STATIC_CITY, 177, 77, 25, 13, NOT WS_GROUP | SS_LEFT | SS_CENTERIMAGE COMBOBOX IDC_COMBO_CITY, 177, 91, 70, 13, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWN | CBS_SORT - LTEXT "State:", IDC_STATIC_STATE, 258, 77, 19, 13, NOT WS_GROUP | SS_CENTERIMAGE + LTEXT "State:", IDC_STATIC_STATE, 258, 77, 19, 13, NOT WS_GROUP | SS_LEFT | SS_CENTERIMAGE COMBOBOX IDC_COMBO_STATE, 258, 91, 54, 13, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWN | CBS_SORT - LTEXT "Zip Code:", IDC_STATIC_ZIP, 324, 77, 33, 13, NOT WS_GROUP | SS_CENTERIMAGE + LTEXT "Zip Code:", IDC_STATIC_ZIP, 324, 77, 33, 13, NOT WS_GROUP | SS_LEFT | SS_CENTERIMAGE COMBOBOX IDC_COMBO_ZIP, 324, 91, 39, 13, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWN | CBS_SORT - DEFPUSHBUTTON "Cancel", IDCANCEL, 231, 119, 60, 14, BS_CENTER | BS_VCENTER - DEFPUSHBUTTON "OK", IDOK, 303, 119, 60, 14, BS_CENTER | BS_VCENTER -END + DEFPUSHBUTTON "OK", IDOK, 231, 119, 60, 14, BS_CENTER | BS_VCENTER + PUSHBUTTON "Cancel", IDCANCEL, 303, 119, 60, 14, BS_CENTER | BS_VCENTER +} + + + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +IDI_ICON ICON "billingDlg.ico" Modified: incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rex =================================================================== --- incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rex 2011-06-21 23:19:02 UTC (rev 7009) +++ incubator/samples/ooDialog/tutorial/002.topic/billingDlg.rex 2011-06-22 21:47:33 UTC (rev 7010) @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------------*/ /* */ -/* Copyright (c) 2008 Rexx Language Association. All rights reserved. */ +/* Copyright (c) 2008-2011 Rexx Language Association. All rights reserved. */ /* */ /* This program and the accompanying materials are made available under */ /* the terms of the Common Public License v1.0 which accompanies this */ @@ -36,8 +36,7 @@ /*----------------------------------------------------------------------------*/ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ - File: billingDlg.rex Author: Mark Miesfeld - Creation date: 05/02/2008 + File: billingDlg.rex Creation date: 05/02/2008 Project: ooDialog Tutorial Last update: 05/19/2008 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -58,37 +57,130 @@ perhaps in a database, or maybe a flat file. A few things are done differently than they would be in a real program to - faciliate running this from a command prompt as a stand alone example. - Those places should be relatively easy to spot. + faciliate running this as a stand alone example. Those places should be + relatively easy to spot. \* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ -use arg accountName - -- In a real program, this would probably be called as a function and the - -- account name passed in as the argument. Here it is just faked by using a - -- command line argument. + -- In a real program, the setBillingAddres() routine would probably be called + -- directly and the account name passed in as the argument. Here we fake this + -- by using a simple dialog to query the account name from the user. - if arg(1, 'O') then do - say "You must supply an account name for this program" - say "Syntax:" - say " rexx billingDlg.rex <accountName>" - say - say "For example:" - say " rexx billingDlg.rex Home Depot" + -- Instantiate the dialog, check the init code, and return if some error + -- happened. + -- + -- The dialog is created from the template in the resource script, + -- billingDlg.rc. Symbolic IDs are used for the resource IDs throughout this + -- example. The IDs are defined in billingDlg.h. The symbolic ID, + -- IDD_ACCOUNTNAME is the ID of the dialog in the resource script. + + dlg = .AccountNameDialog~new("billingDlg.rc", IDD_ACCOUNTNAME, , "billingDlg.h") + if dlg~initCode <> 0 then do + msg = "Error starting account name dialog. initCode:" dlg~initCode + r = MessageDialog(msg, , "Dialog Initialization Error", "OK", "WARNING") return 99 end + -- The execute method is what actually creates the underlying Windows dialog + -- and runs it until the user closes the dialog. + -- + -- When the execute method returns, the underlying dialog has been closed. + -- The method will return 1 if the user pushes the Okay button, and 2 if the + -- user cancels the dialog. The account name data is only valid if the user + -- pushes Okay. + -- + -- Note that for this simple dialog we use a feature of ooDialog called + -- automatic data detection. To truly understand automatic data detection, + -- you should read the section on Data Attributes Methods. This section is in + -- the ooDialog reference, under the Dialog Object chapter. + -- + -- The essence here is that an attribute of the AccountNameDialog is auto- + -- matically created by the ooDialog framework. This attribute reflects the + -- 'data' of the edit control in the dialog. When the dialog is closed with + -- ok by the user, the data attribute is updated automatically with the text + -- of the edit control. The attribute is assigned the name of IDC_EDIT, which + -- in this case is the symbolic name of the resource ID of the edit control. + -- Therefore, when the user closes the dialog with okay, when can get the text + -- that the edit control contains by getting the value of the data attribute. + + ret = dlg~execute("SHOWTOP") + if ret == 1 then do + -- The value of the IDC_EDIT attribute is the text entered in the edit + -- control + + accountName = dlg~IDC_EDIT + + -- Call the setBillingAddress() routine with the account name. The routine + -- will return .nil if the user cancels, otherwise a table is returned with + -- the information the user entered. + + data = setBillingAddress(accountName) + + -- The setBillingAddress() routine returns 99 if some unrecoverable error + -- happend, .nil if the user cancelled, and a .table object if the user + -- entered the billing information and pressed okay. + -- + -- In a regular application the returned data would just be used directly. + -- For this example program we just display the results in a message box. + -- We set up a message based on the value of 'data' and then that message is + -- displayed before the program ends. + + select + when data == .nil then do + msg = "The user cancelled." + ret = 0 + end + when data~isA(.Table) then do + msg = "Account:" || '09'x || data['name'] || .endOfLine~copies(2) || - + "Address:" || .endOfLine~copies(2) || - + '09'x || data['address1'] || .endOfLine + + if data['address2'] \== .nil then do + msg ||= '09'x data['address2'] || .endOfLine + end + + msg ||= '09'x data['city'] data['state'] data['zip'] + ret = 0 + end + otherwise do + msg = "An unrecoverable error occurred." + ret = 99 + end + end + -- End select + end + else do + msg = "The user cancelled." + ret = 0 + end + + title = "New Account Billing Address Result" + r = MessageDialog(msg, , title, "OK", "INFORMATION", "SETFOREGROUND") + + return ret + +-- End of entry point. + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ + Directives, Classes, or Routines. +\* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ +::requires "ooDialog.cls" + +::routine setBillingAddress public + use strict arg accountName + -- Instantiate the dialog, check the init code, and return if some error -- happened. -- -- The dialog is created from the template in the resource script, -- billingDlg.rc. Symbolic IDs are used for the resource IDs throughout this -- example. The IDs are defined in billingDlg.h. The symbolic ID, - -- IDD_DLG_COMBOBOX is the ID of the dialog in the resource script. + -- IDD_COMBOBOX is the ID of the dialog in the resource script. - dlg = .BillingDialog~new("billingDlg.rc", IDD_DLG_COMBOBOX, , "billingDlg.h") + dlg = .BillingDialog~new("billingDlg.rc", IDD_COMBOBOX, , "billingDlg.h") if dlg~initCode <> 0 then do - say "Error starting dialog. initCode:" dlg~initCode - return dlg~initCode + msg = "Error starting billing address dialog. initCode:" dlg~initCode + r = MessageDialog(msg, , "Dialog Initialization Error", "OK", "WARNING") + return 99 end -- Pass the account name on to the dialog. @@ -103,7 +195,7 @@ -- The method will return 1 if the user pushes the Okay button, and 2 if the -- user cancels the dialog. The billing address data is only valid if -- the user pushes Okay. - ret = dlg~execute("NORMAL", IDI_DLG_ICON) + ret = dlg~execute("NORMAL", IDI_ICON) -- In a real program, the data object would be returned to the caller, maybe -- passing back .nil if the dialog was canceled. Here the results are just @@ -112,31 +204,15 @@ -- Get the billing address from the dialog. It is returned in the form of a -- table object. data = dlg~getBillingAddress - say data['name'] - say data['address1'] - if data['address2'] \== .nil then say data['address2'] - say data['city'] data['state'] data['zip'] end else do - say "The user canceled" + data = .nil end - -- The deInstall method unregisters all the ooDialog external functions. - -- Normally that would only be done when the program is entirely finished. - -- Since this is just an example and it is now finished, the deInstall method - -- is invoked. This is not really needed. - dlg~deInstall +return data -return 0 --- End of entry point. +::class 'BillingDialog' public subclass RcDialog -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*\ - Directives, Classes, or Routines. -\* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ -::requires "oodwin32.cls" - -::class 'BillingDialog' public subclass RcDialog inherit AdvancedControls MessageExtensions - /** init() * The initialization for this dialog. The superclass init method must be * called. Then the county / city / zip code data table is filled in. @@ -207,7 +283,7 @@ -- The account name does not change during the display of the dialog, so a -- static control is used for that information. Here that static control is -- set with the current account name. - self~getStaticControl(IDC_STATIC_CUSTOMER)~setTitle(accountName) + self~newStatic(IDC_STATIC_CUSTOMER)~setText(accountName) -- Start with the San Diego county radio button checked. For each county, the -- cities combo box is filled with the cities in that county. Each time a @@ -223,7 +299,7 @@ -- Diego county is fetched from the data table using the resource ID as the -- index. 3.) A private method is called that handles filling the combo -- boxes. - self~getRadioControl(IDC_RB_SANDIEGO)~check + self~newRadioButton(IDC_RB_SANDIEGO)~check zipData = countyData[self~constDir[IDC_RB_SANDIEGO]] self~setCities(zipData['cities']) @@ -231,7 +307,7 @@ -- in Southern California, so the state is unchanging. A combo box is used -- anyway, in case the business decides to expand to Arizona. Here, the combo -- box is filled with the single item, CA, and it is set as selected. - combo = self~getComboBox(IDC_COMBO_STATE) + combo = self~newComboBox(IDC_COMBO_STATE) combo~add("CA") combo~selectIndex(1) @@ -246,9 +322,9 @@ -- the program. -- -- In ooDialog, the programmer connects the events she is interested in with a - -- specific method in her dialog object. When the event occurrs, the method - -- in the dialog object is invoked. Events are tied to specific controls - -- using the resource ID of the control + -- specific method in her Rexx dialog object. When the event occurrs, the + -- method in the dialog object is invoked. Events are tied to specific + -- controls using the resource ID of the control -- -- This program has two main events that drive it. When the user selects a -- different county, the city and zip code combo boxes need to be filled with @@ -258,17 +334,19 @@ -- For the radio buttons, connect each button clicked event to the same -- method. When a radio button is clicked, it becomes the selected radio -- button in the group. - self~connectButton(IDC_RB_SANDIEGO, onClick) - self~connectButton(IDC_RB_ORANGE, onClick) - self~connectButton(IDC_RB_IMPERIAL, onClick) + self~connectButtonEvent(IDC_RB_SANDIEGO, "CLICKED", onClick) + self~connectButtonEvent(IDC_RB_ORANGE, "CLICKED", onClick) + self~connectButtonEvent(IDC_RB_IMPERIAL, "CLICKED", onClick) -- For combo boxes, there is an event generated each time the selected item in -- the combo box changes. Connect that event for the city combo box only. - self~connectComboBoxNotify(IDC_COMBO_CITY, "SELCHANGE", onCityChange) + self~connectComboBoxEvent(IDC_COMBO_CITY, "SELCHANGE", onCityChange) /** onClick() - * This method is invoked every time one of the county radio buttons is clicked. + * This is the event handler method for the radio button's CLICKED event. It is + * invoked every time one of the county radio buttons is clicked. + * * 2 arguments are sent to this method. The first will always be the resource * ID of the button clicked. The second will always be the window handle of the * button. @@ -278,7 +356,7 @@ * code combo boxes are populated. The window handle is not needed so that * argument is simply ignored. */ -::method onClick +::method onClick unguarded expose countyData zipData use arg buttonID @@ -291,14 +369,14 @@ /** onCityChange() - * This method is invoked every time the selected item in the cities combo box - * changes. The arguments sent to this method are not needed and are simply - * ignored. + * This is the event handler method for the combo box's selection changed event. + * it is invoked every time the selected item in the cities combo box changes. + * The arguments sent to this method are not needed and are simply ignored. * * The selected city is fetched from the combo box and the zip code combo box is * populated with the correct zip codes for that city. */ -::method onCityChange +::method onCityChange unguarded expose zipData -- Create an object that represents the underlying combo box. The method can @@ -309,7 +387,7 @@ -- created, or if the underlying control has been destroyed. Using symbolic -- IDs mostly eliminates the first error and the control can not generate a -- clicked event if it has not yet been created or has already been destroyed. - combo = self~getComboBox(IDC_COMBO_CITY) + combo = self~newComboBox(IDC_COMBO_CITY) if combo == .nil then return -- Combo boxes can have no items selected, which is why the check for the @@ -333,7 +411,7 @@ -- Create an object that represents the underlying combo box. See the notes -- in the onCityChange() method. - combo = self~getComboBox(IDC_COMBO_CITY) + combo = self~newComboBox(IDC_COMBO_CITY) if combo == .nil then return .false -- First, delete all the existing items in the combo box. @@ -371,7 +449,7 @@ -- Create an object that represents the underlying combo box. See the notes -- in the onCityChange() method. - combo = self~getComboBox(IDC_COMBO_ZIP) + combo = self~newComboBox(IDC_COMBO_ZIP) if combo == .Nil then return .false -- Remove all the existing items in the combo box. @@ -415,12 +493,14 @@ -- line 1 and fetch the text from the control. See the notes in -- onCityChange() concerning the possibility of getEditControl() returning -- .nil - text = self~getEditControl(IDC_EDIT_ADDR1)~getText~strip + text = self~newEdit(IDC_EDIT_ADDR1)~getText~strip -- Check that the user entered the address. If the edit control is blank, -- put up a message box telling the user what they need to do, and return 0. if text == "" then do - j = infoDialog("The address line 1 field must be filled in.") + title = "Date Entry Error" + msg = "The address line 1 field must be filled in." + r = MessageDialog(msg, self~hwnd, title, "OK", "WARNING") -- Returning 0 causes the dialog to keep executing. return 0 @@ -432,13 +512,13 @@ -- is left .nil. billingAddress['address1'] = text - text = self~GetEditControl(IDC_EDIT_ADDR2)~getText~strip + text = self~newEdit(IDC_EDIT_ADDR2)~getText~strip if text \== "" then billingAddress['address2'] = text - billingAddress['city'] = self~getComboBox(IDC_COMBO_CITY)~selected - billingAddress['state'] = self~getComboBox(IDC_COMBO_STATE)~selected - billingAddress['zip'] = self~getComboBox(IDC_COMBO_ZIP)~selected + billingAddress['city'] = self~newComboBox(IDC_COMBO_CITY)~selected + billingAddress['state'] = self~newComboBox(IDC_COMBO_STATE)~selected + billingAddress['zip'] = self~newComboBox(IDC_COMBO_ZIP)~selected -- Returning 1 closes the dialog. return 1 @@ -459,8 +539,7 @@ /* The methods below are used to construct a table of tables containing the * county, city, and zip code data used in this example. In a real world - * application, this data might be read from a file, or maybe gotten from a - * database. + * application, this data probably be gotten from a database. */ ::method fillCountyData private use arg tbl @@ -506,4 +585,27 @@ return t + +-- The account name dialog is used to query the user for a new account name. +-- The dialog is so simple that it does not need many methods. All we do is +-- over-ride the validate() method to be sure that when the user closes the +-- dialog with okay, there is some text to be used for the account name. +-- Everything else is handled automatically by the ooDialog framework. +::class 'AccountNameDialog' public subclass RcDialog + +::method validate + + if self~newEdit(IDC_EDIT)~getText~strip == "" then do + title = "Date Entry Error" + msg = "A new account name must be entered." + r = MessageDialog(msg, self~hwnd, title, "OK", "WARNING") + + -- Returning 0 causes the dialog to keep executing. + return 0 + end + + -- Returning 1 allows the dialog to close + return 1 + + /* - - - End Of File: billingDlg.rex- - - - - - - - - - - - - - - - - - - - - */ Deleted: incubator/samples/ooDialog/tutorial/ReadMe.First =================================================================== --- incubator/samples/ooDialog/tutorial/ReadMe.First 2011-06-21 23:19:02 UTC (rev 7009) +++ incubator/samples/ooDialog/tutorial/ReadMe.First 2011-06-22 21:47:33 UTC (rev 7010) @@ -1,59 +0,0 @@ - - - The ooDialog Tutorial - ===================== - -This directory and its subdirectories contain ooDialog programs that -comprise a tutorial for programming with ooDialog. The tutorial will use as -a framework a fictious business, the Acme Gizmos Company, and build up a -custom accounting program for this business. An attempt will be made to -contruct example programs that fit within this framework and demonstrate how -to do various things in ooDialog. - -Note: This project is just starting and much of what is said here may be -what is intended, not necessarily what is. - -The tutorial will start out with the basics and move on to increasingly more -complex topics. Things are divided up in subdirectories, starting with the -subdirectory: 001.intro, and moving on sequentially. The individual -programs are heavily commented and in general the code can be read from top -to bottom to grasp the context. - -One approach to using the tutorial, for a person new to ooDialog, would be -to start with 001.intro, read any "read me" text files, execute the example -program, and then read the example program code. Then move on through the -phases sequentially. For someone already familiar with ooDialog, another -approach would be to look for a directory containing example programs using -the control and / or concept that person is interested in and examine the -content of that directory. - -This file contains an index denoting which controls and concepts can be -found in which subdiretories. - -The text of this tutorial is contained in the files within this directory -tree, with most of the text in comments in the individual programs. At some -point the text of the tutorial may be extracted and incorporated into the -ooDialog documentation, a programmer's guide, and / or added to the ooRexx -Wiki. - -In ooDialog, as in most things, there are often several ways to accomplish -the same thing. Currently, this tutorial is written from the perspective of -one of the ooRexx developers and demonstrates how he would use ooDialog. -This approach to ooDialog is not necessarily the only approach and certainly -not the "correct" approach. - -Others are encouraged to add content to the tutorial, especially in areas -that are lightly touched upon by the original author, not as yet touched -upon at all, or that demonstrate an alternative method of doing something in -ooDialog. - - - Index - ===== - -001.intro - Simple user dialog, Ok / Cancel buttons, Ok / Cancel methods, -edit control, UserDialog - -002.topic - - -003.topic - Copied: incubator/samples/ooDialog/tutorial/ReadMeFirst.txt (from rev 7009, incubator/samples/ooDialog/tutorial/ReadMe.First) =================================================================== --- incubator/samples/ooDialog/tutorial/ReadMeFirst.txt (rev 0) +++ incubator/samples/ooDialog/tutorial/ReadMeFirst.txt 2011-06-22 21:47:33 UTC (rev 7010) @@ -0,0 +1,71 @@ + + + The ooDialog Tutorial + ===================== + +This directory and its subdirectories contain ooDialog programs that +comprise a tutorial for programming with ooDialog. The tutorial will use as +a framework a fictious business, the Acme Gizmos Company, and build up a +custom accounting program for this business. An attempt will be made to +contruct example programs that fit within this framework and demonstrate how +to do various things in ooDialog. + +Note: This project is just starting and much of what is said here may be +what is intended, not necessarily what is. + +The tutorial will start out with the basics and move on to increasingly more +complex topics. Things are divided up in subdirectories, starting with the +subdirectory: 001.intro, and moving on sequentially. The individual +programs are heavily commented and in general the code can be read from top +to bottom to grasp the context. + +One approach to using the tutorial, for a person new to ooDialog, would be +to start with 001.intro, read any "read me" text files, execute the example +program, and then read the example program code. Then move on through the +phases sequentially. For someone already familiar with ooDialog, another +approach would be to look for a directory containing example programs using +the control and / or concept that person is interested in and examine the +content of that directory. + +This file contains an index denoting which controls and concepts can be +found in which subdiretories. + +The text of this tutorial is contained in the program files within this +directory tree, with most of the text in comments in the individual +programs. At some point the text of the tutorial may be extracted and +incorporated into the ooDialog documentation, a programmer's guide, and / or +added to the ooRexx Wiki. + +Sometimes heavily commented programs prevent the programmer from being able +to easily follow the flow of the program. Because of that, many of the +programs in the tutorial will have an uncommented version of the program +contained in the same directory. The uncommented version will have "_uc" in +the program name. I.e., the program aaBcdeF_uc.rex is the uncommented +version of the aaBcdeF.rex program. + +In ooDialog, as in most things, there are often several ways to accomplish +the same thing. Currently, this tutorial is written from the perspective of +one of the ooRexx developers and demonstrates how he would use ooDialog. +This approach to ooDialog is not necessarily the only approach and certainly +not the "correct" approach. + +Others are encouraged to add content to the tutorial, especially in areas +that are lightly touched upon by the original author, not as yet touched +upon at all, or that demonstrate an alternative method of doing something in +ooDialog. + +NOTE that routines and methods not defined in a program file are routines or +methods provided by the ooDialog framework. To fully understand the +arguments to those routines or methods, please consult the ooDialog +Reference book. The PDF version of this book is oodialog.pdf and is +installed with your ooDialog installation. + + Index + ===== + +001.intro - Simple user dialog, Ok / Cancel buttons, Ok / Cancel methods, + edit control, UserDialog + +002.topic - + +003.topic - Added: incubator/samples/ooDialog.samples.package/Controls/Edit/RestrictedInput.rex =================================================================== --- incubator/samples/ooDialog.samples.package/Controls/Edit/RestrictedInput.rex (rev 0) +++ incubator/samples/ooDialog.samples.package/Controls/Edit/RestrictedInput.rex 2011-06-22 21:47:33 UTC (rev 7010) @@ -0,0 +1,471 @@ +/** + * Shows how prevent the user from entering invalid + * characters in an edit control. In this case the + * user is resctricted to entering a decimal number + * with no more than 2 decimal places. + */ + + -- Temp debugging + .local~debug = .true + + .Edit~inherit(.NumberOnlyEditEx, .EditControl) + + resourceDLL = "restrictedInput32.dll" + + if .OS~isWOW64 then nop + else if .OS~is64bit then resourceDLL = "restrictedInput64.dll" + + dlg = .MPGDlg~new(resourceDLL, IDD_MPG_DLG, , "restrictedInput.h") + if dlg~initCode <> 0 then do + say "Error initializing dialog. Aborting" + return 99 + end + + dlg~execute("SHOWTOP") + return 0 + +::requires ooDialog.cls +::requires winsystm.cls + + +::class 'MPGDlg' subclass ResDialog + +::method initDialog + expose editStartMiles editEndMiles editGas editCost stMPG stPM resultFont + + editStartMiles = self~newEdit(IDC_EDIT_START) + editStartMiles~initDecimalOnly(1, .true) -- temp to allow sign + editStartMiles~connectKeyEvent(onChar) + + editEndMiles = self~newEdit(IDC_EDIT_END) + editEndMiles~initDecimalOnly(0, .true) -- temp to allow sign, no deicmals + editEndMiles~connectKeyEvent(onChar) + + editGas = self~newEdit(IDC_EDIT_GAS) + editGas~initDecimalOnly(3) + editGas~connectKeyEvent(onChar) + + editCost = self~newEdit(IDC_EDIT_COST) + editCost~initDecimalOnly(2) + editCost~connectKeyEvent(onChar) + + stMPG = self~newStatic(IDC_ST_MPG) + stPM = self~newStatic(IDC_ST_PERMILE) + + resultFont = self~createFontEx("Verdana", 20) + + stMPG~setFont(resultFont) + stPM~setFont(resultFont) + + self~connectButtonEvent(IDC_PB_CALCULATE, "CLICKED", onCalc) + + +/** onChar() + * This is the handler for the key event. The args to the handler are: + * + * use arg char, isShift, isCtrl, isAlt, misc, control + * + * where 'control' is the dialog control that had the focus, and had the key + * event. We just forward to that control and let the control handle the event + * itself. + * + */ +::method onChar unguarded + forward to (arg(6)) + + +::method leaving + expose resultFont + self~deleteFont(resultFont) + + +::method onCalc unguarded + expose editStartMiles editEndMiles editGas editCost stMPG stPM + + sMiles = editStartMiles~getText + eMiles = editEndMiles~getText + gas = editGas~getText + cost = editCost~getText + + msg = "To calculate MPG, all fields must contain data." + + if sMiles == "" then return self~entryFieldErr(editStartMiles, msg) + if eMiles == "" then return self~entryFieldErr(editEndMiles, msg) + if gas == "" then return self~entryFieldErr(editGas, msg) + if cost == "" then return self~entryFieldErr(editCost, msg) + + msg = "The ending milage must be greater than the starting milage." + if sMiles >= eMiles then return self~entryFieldErr(editEndMiles, msg) + + msg = "The gasoline used can not be 0." + if gas == 0 then return self~entryFieldErr(editGas, msg) + + msg = "The cost of the gasoline can not be 0." + if cost = 0 then return self~entryFieldErr(editCost, msg) + + miles = eMiles - sMiles + mpg = miles / gas + cpm = (gas * cost) / miles + + mpg = mpg~format( , 3) || "mpg" + cpm = '$' || cpm~format( , 2) || "/mile" + + stMPG~setText(mpg) + stPM~setText(cpm) + +::method entryFieldErr private + use strict arg edit, msg + + title = "Data Entry Error" + ret = MessageDialog(msg, self~dlgHandle, title, "WARNING") + edit~assignFocus + return 0 + +::class 'NumberOnlyEditEx' public mixinclass object + +::method initDecimalOnly + expose decimalPlaces signOk initialized clipBoard + use strict arg decimalPlaces, plusMinus = .false + + if plusMinus~isA(.String), plusMinus~datatype('O') then signOk = plusMinus + else signOk = .false + + initialized = .... [truncated message content] |