From: <mie...@us...> - 2009-01-20 22:27:01
|
Revision: 3978 http://oorexx.svn.sourceforge.net/oorexx/?rev=3978&view=rev Author: miesfeld Date: 2009-01-20 22:22:44 +0000 (Tue, 20 Jan 2009) Log Message: ----------- Use the ooTicket sample program to demonstrate how to use a button with an image list rather than use connectBitmapButton. Demonstrate how to let the user control the size and appearance of a dialog by picking the font the want it displayed in. Modified Paths: -------------- main/trunk/samples/windows/oodialog/ooticket.rex main/trunk/samples/windows/oodialog/rc/movies.rc main/trunk/samples/windows/oodialog/rc/ticket.rc Modified: main/trunk/samples/windows/oodialog/ooticket.rex =================================================================== --- main/trunk/samples/windows/oodialog/ooticket.rex 2009-01-20 22:04:08 UTC (rev 3977) +++ main/trunk/samples/windows/oodialog/ooticket.rex 2009-01-20 22:22:44 UTC (rev 3978) @@ -46,6 +46,9 @@ mydir = me~left(me~lastpos('\')-1) /* where is code */ mydir = directory(mydir) /* current is "my" */ + -- Let the user select a font for the program. + oldFont = setFont() + dlg = .TimedMessage~new("The upcoming dialog demonstrates the use of categorized pages", , "Categorized Dialog", 2000) dlg~execute @@ -65,6 +68,7 @@ call ErrorMessage "Selection error!"; dlg~deinstall ret = directory(curdir) + ret = restoreFont(oldFont) return end @@ -102,6 +106,7 @@ do dlg~deinstall ret = directory(curdir) + ret = restoreFont(oldFont) return end end @@ -114,6 +119,7 @@ dlg~execute("SHOWTOP") dlg~deinstall ret = directory(curdir) + ret = restoreFont(oldFont) return /*-------------------------------- requires -----------------------------------*/ @@ -170,8 +176,30 @@ ::method Ticket /* page 4 */ self~loaditems("rc\ticket.rc") self~connectList(41,"FilmClick") - self~connectBitmapButton(45, 'printTicket', "bmp\ticket.bmp",,,,"FRAME USEPAL STRETCH") + if .DlgUtil~comCtl32Version < 6 then do + self~addBitmapButton(45, 13, 87, 102, 40, "Get the Ticket", 'printTicket', - + "bmp\ticket.bmp",,,, "FRAME USEPAL STRETCH GROUP") + end + else do + self~addButton(45, 13, 87, 102, 40, "", 'printTicket', "GROUP") + end + +::method InitTicket + if .DlgUtil~comCtl32Version < 6 then return + + bmpButton = self~getButtonControl(45) + parse value bmpButton~getRect with x y x2 y2 + + size = .Size~new(x2 - x - 10, y2 - y - 10) + image = .Image~getImage('bmp\ticket.bmp', .Image~id(IMAGE_BITMAP), size) + imageList = .ImageList~create(size, .Image~id(ILC_COLOR8), 1, 0) + imageList~add(image) + + align = .Image~id(BUTTON_IMAGELIST_ALIGN_CENTER) + margin = .Rect~new(5) + bmpButton~setImageList(imageList, margin, align) + ::method SetFilmData expose sel. films films = .array~of("Vertigo","Taxi Driver","Superman","Larger than Life",, @@ -291,3 +319,57 @@ selectedFilm '-at-' selectedCinema~substr(2), 3000) +::routine setFont + + oldFont = .directory~new + oldFont~name = .PlainBaseDialog~getFontName + oldFont~size = .PlainBaseDialog~getFontSize + + dlg = .FontPicker~new("rc\movies.rc", IDD_FONT_PICKER, , , , 6) + if dlg~initCode == 0 then do + dlg~execute("SHOWTOP", IDI_DLG_OOREXX) + dlg~deinstall + end + + return oldFont + +::routine restoreFont + use strict arg oldFont + .PlainBaseDialog~setDefaultFont(oldFont~name, oldFont~size) + return oldFont + +::class 'FontPicker' subclass RcDialog inherit AdvancedControls MessageExtensions + +::method initAutoDetection + self~noAutoDetection + +::method initDialog + expose nameCB sizeCB + + nameCB = self~getComboBox(IDC_COMBO_NAME) + sizeCB = self~getComboBox(IDC_COMBO_SIZE) + + names = .array~of("Default", "Tahoma", "Courier", "MS Sans Serif") + sizes = .array~of("Default", '8 point', '10 point', '12 point', '16 point') + + do name over names + nameCB~add(name) + end + nameCB~select("Default") + + do size over sizes + sizeCB~add(size) + end + sizeCB~select("Default") + +::method ok + expose nameCB sizeCB + + fontName = nameCB~selected + if fontName == "Default" then fontName = .PlainBaseDialog~getFontName + + fontSize = sizeCB~selected~word(1) + if fontSize == "Default" then fontSize = .PlainBaseDialog~getFontSize + + .PlainBaseDialog~setDefaultFont(fontName, fontSize) + return self~ok:super Modified: main/trunk/samples/windows/oodialog/rc/movies.rc =================================================================== --- main/trunk/samples/windows/oodialog/rc/movies.rc 2009-01-20 22:04:08 UTC (rev 3977) +++ main/trunk/samples/windows/oodialog/rc/movies.rc 2009-01-20 22:22:44 UTC (rev 3978) @@ -38,6 +38,10 @@ /* OODialog\Samples\rc\movies.rc Let's go to the movies */ /*--------------------------------------------------------------------*/ +#define IDD_FONT_PICKER 101 +#define IDC_COMBO_SIZE 1004 +#define IDC_COMBO_NAME 1005 + 30 DIALOG 4, 12, 196, 143 STYLE WS_CHILD | WS_VISIBLE | WS_BORDER FONT 8, "System" @@ -47,9 +51,23 @@ CONTROL "Star", 33, "EDIT", WS_BORDER | WS_GROUP | WS_TABSTOP, 109, 53, 84, 12 CONTROL "Director", 34, "EDIT", WS_BORDER | WS_GROUP | WS_TABSTOP, 109, 83, 84, 12 CONTROL "with", 35, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_GROUP | WS_TABSTOP, 109, 113, 84, 33 - GROUPBOX "The movies comin'", -1, 3, 9, 99, 118, BS_GROUPBOX + GROUPBOX "The upcoming movies", -1, 3, 9, 99, 118, BS_GROUPBOX LTEXT "Produced by:", -1, 109, 10, 60, 8 LTEXT "Starring:", -1, 109, 40, 60, 8 LTEXT "Director:", -1, 109, 70, 83, 8 LTEXT "with:", -1, 109, 100, 60, 8 } + +IDD_FONT_PICKER DIALOG 0, 0, 208, 95 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU +CAPTION "Font Selection" +FONT 8, "Ms Shell Dlg 2" +BEGIN + GROUPBOX "Select a font for the upcoming example program", IDC_STATIC, 7, 7, 194, 62 + CTEXT "Font Name:", IDC_STATIC, 13, 20, 80, 8 + CTEXT "Font Size:", IDC_STATIC, 116, 20, 80, 8 + COMBOBOX IDC_COMBO_NAME, 13, 33, 80, 40, WS_TABSTOP | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_SORT + COMBOBOX IDC_COMBO_SIZE, 116, 33, 80, 40, WS_TABSTOP | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_HASSTRINGS + DEFPUSHBUTTON "OK", IDOK, 96, 74, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 151, 74, 50, 14 +END Modified: main/trunk/samples/windows/oodialog/rc/ticket.rc =================================================================== --- main/trunk/samples/windows/oodialog/rc/ticket.rc 2009-01-20 22:04:08 UTC (rev 3977) +++ main/trunk/samples/windows/oodialog/rc/ticket.rc 2009-01-20 22:22:44 UTC (rev 3978) @@ -47,7 +47,6 @@ AUTORADIOBUTTON "17:00", 47, 135, 84, 43, 12, BS_AUTORADIOBUTTON | WS_TABSTOP AUTORADIOBUTTON "20:00", 48, 135, 100, 46, 12, BS_AUTORADIOBUTTON | WS_TABSTOP AUTORADIOBUTTON "22:00", 49, 135, 116, 45, 12, BS_AUTORADIOBUTTON | WS_TABSTOP - AUTO3STATE "Get the Ticket", 45, 13, 87, 102, 40, BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP LTEXT "The movie of your choice:", -1, 55, 11, 85, 8 LTEXT "Day", 42, 13, 69, 76, 8, NOT WS_GROUP LTEXT "Time:", -1, 96, 69, 25, 8, NOT WS_GROUP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |