/wxIpAddressCtrl

C++ Custom IpAddressCtrl demonstrated in a Code::Blocks sample project

Primary LanguageC++GNU General Public License v3.0GPL-3.0

wxIpAddressCtrl (C++ / wxWidgets)

C++ Custom IpAddressCtrl for wxWidgets demonstrated inside a Code::Blocks sample project

Introduction
The wxIpAddressCtrl widget is derived from wxTextCtrl and testet on
• a Raspberry pi with Raspberry OS
• a Odroid N2 with Ubuntu 20.04 (arm64-CPU)
• Debian Linux 64 bit

Using the code
• Copy the files “wxIpAddressCtrl.h” and “wxIpAddressCtrl.cpp” into your project directory.
• Include “wxIpAddressCtrl.h” into the header file of your dialog or frame window.
• Make a declaration for the pointer to the control class in the header file of your dialog or frame window,
   i.e: wxIpAddressCtrl* IpAddressInput;
• Create the control with an initialization string:
   IpAddressInput = new wxIpAddressCtrl(this, _("10.12.0.1"), wxPoint(120,32), wxSize(128,24));

The “Show”-Button demonstrates how to use some native functions from parent class.

What happens in wxIpAddrCtrl.h
• Declaration of the class “wxIpAddressCtrl” derived from the wxWidgets native class “wxTextCtrl”.
• Declaration of a wxKeyEvent function:
   void keyReleased(wxKeyEvent& event);
• Declaration of some functions and variables

What happens in wxIpAddrCtrl.cpp
• Activate the event EVT_KEY_UP which call the “keyReleased” function.
• Initalization of the wxIpAdressCtrl class in the constructor.
• Write the formatted output to the control.
• Check the input chars and handle them.