xref: /haiku/src/apps/resedit/NumberEditors.cpp (revision cda5b8808fd0262f0fac472f6cfa809f846a83cf)
1 #include "InternalEditors.h"
2 #include "ResourceData.h"
3 #include <Messenger.h>
4 #include <Message.h>
5 #include <String.h>
6 #include <stdlib.h>
7 
8 DoubleEditor::DoubleEditor(const BRect &frame, ResourceData *data,
9 							BHandler *owner)
10   :	Editor(frame, data, owner)
11 {
12 	if (data->GetName())
13 		SetTitle(data->GetName());
14 
15 	fView = new StringEditView(Bounds());
16 	AddChild(fView);
17 
18 	fView->SetID(data->GetIDString());
19 	fView->SetName(data->GetName());
20 	fView->SetValue(data->GetData());
21 }
22 
23 
24 void
25 DoubleEditor::MessageReceived(BMessage *msg)
26 {
27 	if (msg->what == M_UPDATE_RESOURCE) {
28 		// We have to have an ID, so if the squirrely developer didn't give us
29 		// one, don't do anything
30 		if (fView->GetID()) {
31 			int32 newid = atol(fView->GetID());
32 			GetData()->SetID(newid);
33 		}
34 
35 		GetData()->SetName(fView->GetName());
36 		GetData()->SetData(fView->GetValue(),strlen(fView->GetValue()));
37 
38 		BMessage updatemsg(M_UPDATE_RESOURCE);
39 		updatemsg.AddPointer("item",GetData());
40 		BMessenger msgr(GetOwner());
41 		msgr.SendMessage(&updatemsg);
42 		PostMessage(B_QUIT_REQUESTED);
43 
44 	} else {
45 		Editor::MessageReceived(msg);
46 	}
47 }
48 
49