Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

bmcdwin.cpp

Go to the documentation of this file.
00001 // $Id$
00002 
00003 //**********************************************************************
00004 //                                                                     *
00005 //    Description:   'Bell Master' TurboVision window to select a bell *
00006 //                   code from a list.                                 *
00007 //                                                                     *
00008 //    Author:        Chris White (whitecf@bcs.org.uk)                  *
00009 //                                                                     *
00010 //    Copyright (C) 2003  Monitor Computing Services Ltd.              *
00011 //                                                                     *
00012 //    This program is free software; you can redistribute it and/or    *
00013 //    modify it under the terms of the GNU General Public License      *
00014 //    as published by the Free Software Foundation; either version 2   *
00015 //    of the License, or any later version.                            *
00016 //                                                                     *
00017 //    This program is distributed in the hope that it will be useful,  *
00018 //    but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00019 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00020 //    GNU General Public License for more details.                     *
00021 //                                                                     *
00022 //    You should have received a copy of the GNU General Public        *
00023 //    License (http://www.gnu.org/copyleft/gpl.html) along with this   *
00024 //    program; if not, write to:                                       *
00025 //       The Free Software Foundation Inc.,                            *
00026 //       59 Temple Place - Suite 330,                                  *
00027 //       Boston, MA  02111-1307,                                       *
00028 //       USA.                                                          *
00029 //                                                                     *
00030 //**********************************************************************
00031 //                                                                     *
00032 //    Notes:                                                           *
00033 //                                                                     *
00034 //**********************************************************************
00035 
00036 #define Uses_TButton
00037 #define Uses_TEvent
00038 #define Uses_TRect
00039 #define Uses_TScrollBar
00040 
00041 #include "bellcode.h"
00042 #include "bclist.h"
00043 #include "bmcdlvw.h"
00044 #include "mytrace.h"
00045 
00046 #include "bmcdwin.h"
00047 
00048 
00049 using namespace Monitor::BellMaster;
00050 
00051 
00052 
00053 CodeWindow::CodeWindow(const BellCodeList&    newBellCodes,
00054                        TRect&                 bounds) :
00055     TDialog(bounds, "Select Bell Code"),
00056     TWindowInit(&CodeWindow::initFrame),
00057     listView(0)
00058 {
00059     _USEMYTRACE_("CodeWindow::CodeWindow")
00060 
00061     bounds = getExtent();
00062 
00063     TRect    scrollBarBounds(bounds.b.x - 1,
00064                              bounds.a.y + 1,
00065                              bounds.b.x,
00066                              bounds.b.y - 4);
00067 
00068     TScrollBar    *vScrollBar = new TScrollBar(scrollBarBounds);
00069 
00070     if (vScrollBar == 0)
00071     {
00072         cerr << "vScrollBar init error" << endl;
00073         exit(1);
00074     }
00075 
00076     vScrollBar->options |= ofPostProcess;
00077     insert(vScrollBar);
00078 
00079     TRect    listViewBounds(bounds.a.x + 1,
00080                             bounds.a.y + 1,
00081                             bounds.b.x - 1,
00082                             bounds.b.y - 4);
00083 
00084     listView = new CodeListView(newBellCodes, listViewBounds, vScrollBar);
00085 
00086     insert(listView);
00087 
00088     int    midX         = (bounds.b.x - bounds.a.x) / 2;
00089     int    buttonBottom = bounds.b.y - 1;
00090     int    buttonTop    = buttonBottom - 2;
00091 
00092     insert(new TButton(TRect(midX - 15, buttonTop, midX - 5, buttonBottom),
00093                        "~S~elect",
00094                        cmOK,
00095                        bfDefault));
00096 
00097     insert(new TButton(TRect(midX + 5, buttonTop, midX + 15, buttonBottom),
00098                        "~C~ancel",
00099                        cmCancel,
00100                        bfNormal));
00101 }
00102 
00103 
00104 
00105 void
00106 CodeWindow::handleEvent(TEvent&    event)
00107 {
00108     if ((event.what == evBroadcast) &&
00109         (event.message.command == cmListItemSelected))
00110     {
00111         event.what            = evCommand;
00112         event.message.command = cmOK;
00113     }
00114 
00115     TDialog::handleEvent(event);
00116 }
00117 
00118 
00119 
00120 BellCode*
00121 CodeWindow::getSelectedBellCode()
00122 {
00123     BellCode    *selectedBellCode = 0;
00124 
00125     if (listView)
00126     {
00127         selectedBellCode = listView->getSelectedBellCode();
00128     }
00129 
00130     return selectedBellCode;
00131 }
00132 

Generated on Wed Oct 29 20:55:43 2003 for Bellmaster BC Turbo Vision by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002