-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetWatchWin.cpp
More file actions
71 lines (65 loc) · 2.21 KB
/
NetWatchWin.cpp
File metadata and controls
71 lines (65 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*****************************************************************
* Copyright (c) 2005 Simon Taylor, Tim de Jong *
* *
* All rights reserved. *
* Distributed under the terms of the MIT License. *
*****************************************************************/
#include <be/app/Application.h>
#include <be/interface/View.h>
#include <be/interface/ScrollView.h>
#include <cstdio>
#include <iostream>
#include "NetWatchWin.h"
#include "NetListItem.h"
#include "NetListView.h"
NetWatchWin::NetWatchWin(BRect frame, const char *title)
: BWindow(frame, title, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE)
{
float minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
minWidth = 200;
minHeight = 100;
//SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
BRect r = Bounds();
r.right -= 15;
m_listView = new NetListView(r, "trafficlog", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS);
m_listView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(new BScrollView("log_scroller", m_listView, B_FOLLOW_ALL_SIDES, B_FULL_UPDATE_ON_RESIZE, false, true, B_NO_BORDER));
BFont viewFont;
m_listView->GetFont(&viewFont);
m_listView->AddItem(new NetListItem(INFO_EVENT, "BNetEndpoint Created", &viewFont));
}
void NetWatchWin::MessageReceived(BMessage *message)
{
switch(message->what)
{
case 'ADMS':
{
const char* string = "";
message->FindString("Text", &string);
int8 type = 0;
message->FindInt8("Type", &type);
BFont viewFont;
m_listView->GetFont(&viewFont);
switch(type)
{
case INFO_EVENT:
m_listView->AddItem(new NetListItem(INFO_EVENT, string, &viewFont));
break;
case DATA_RECEIVED_EVENT:
m_listView->AddItem(new NetListItem(DATA_RECEIVED_EVENT, string, &viewFont));
break;
case DATA_SENT_EVENT:
m_listView->AddItem(new NetListItem(DATA_SENT_EVENT, string, &viewFont));
break;
}
//scroll to last item in list
m_listView->Select(m_listView->CountItems() - 1);
m_listView->ScrollToSelection();
}
break;
default:
BWindow::MessageReceived(message);
break;
}
}