2 * Copyright 2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, <axeld@pinc-software.de>
10 #include "IPAddressControl.h"
12 #include <NetworkAddress.h>
15 static const uint32 kMsgModified
= 'txmd';
18 IPAddressControl::IPAddressControl(int family
, const char* label
,
21 BTextControl(name
, label
, "", NULL
),
25 SetModificationMessage(new BMessage(kMsgModified
));
29 IPAddressControl::~IPAddressControl()
35 IPAddressControl::AllowEmpty() const
42 IPAddressControl::SetAllowEmpty(bool empty
)
49 IPAddressControl::AttachedToWindow()
51 BTextControl::AttachedToWindow();
58 IPAddressControl::MessageReceived(BMessage
* message
)
60 switch (message
->what
) {
66 BTextControl::MessageReceived(message
);
73 IPAddressControl::_UpdateMark()
75 if (TextLength() == 0) {
76 MarkAsInvalid(!fAllowEmpty
);
80 BNetworkAddress address
;
81 bool success
= address
.SetTo(fFamily
, Text(), (char*)NULL
,
82 B_NO_ADDRESS_RESOLUTION
) == B_OK
;
84 MarkAsInvalid(!success
);