-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreplitxtWindow.cpp
More file actions
76 lines (61 loc) · 1.6 KB
/
replitxtWindow.cpp
File metadata and controls
76 lines (61 loc) · 1.6 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
72
73
74
75
76
// replitxtWindow.cpp
#ifndef __replitxtWINDOW_H__
#include "replitxtWindow.h"
#endif
#ifndef __replicantWINDOW_H__
#include "replicantWindow.h"
#endif
#ifndef __replitxtREPLICANT_H__
#include "replitxtReplicant.h"
#endif
#define M_CREATE_REPLICANT 'crea'
replitxtWindow::replitxtWindow()
: BWindow(BRect(70, 70, 240, 180), "replitxt",
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
InitGUI();
}
void
replitxtWindow::InitGUI()
{
BRect rect(Bounds());
BView *background = new BView(Bounds(), "background", B_FOLLOW_ALL, 0);
background->SetViewColor(216, 216, 216, 0);
AddChild(background);
rect.InsetBy(10,10);
BBox *box = new BBox(rect);
background->AddChild(box);
box->SetLabel("Type text here ...");
rect.InsetBy(10,10);
rect.OffsetBy(-10, 0);
textView = new BTextControl(rect, "text_view", "", "", new BMessage(M_CREATE_REPLICANT));
textView->SetDivider(0.0);
box->AddChild(textView);
textView->MakeFocus(true);
// resize the box
box->ResizeTo(box->Bounds().right, 10+textView->Bounds().bottom + 20);
rect.Set(10, 25+box->Bounds().bottom, 40, 46);
rect.InsetBy(10,0);
BButton *button = new BButton(rect, "create", "Create replicant...", new BMessage(M_CREATE_REPLICANT));
button->ResizeToPreferred();
background->AddChild(button);
}
void
replitxtWindow::MessageReceived(BMessage *msg)
{
replicantWindow *repWin;
switch (msg->what) {
case M_CREATE_REPLICANT:
repWin = new replicantWindow(textView->Text());
repWin->Show();
break;
default:
BWindow::MessageReceived(msg);
}
}
bool
replitxtWindow::QuitRequested()
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}