00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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