#include <wx/wxprec.h>
#include <wx/wx.h>
#include "../include/wxdragon.h"
#include "wxd_utils.h"
#include <wx/stattext.h>
#include <string>
extern "C" {
WXD_EXPORTED wxd_StaticText_t*
wxd_StaticText_Create(wxd_Window_t* parent, wxd_Id id, const char* label, wxd_Point pos,
wxd_Size size, wxd_Style_t style)
{
if (!parent) {
return nullptr;
}
wxWindow* wx_parent = reinterpret_cast<wxWindow*>(parent);
wxString wx_label = wxString::FromUTF8(label ? label : "");
wxStaticText* stext = new wxStaticText(wx_parent, id, wx_label, wxd_cpp_utils::to_wx(pos),
wxd_cpp_utils::to_wx(size), style);
return reinterpret_cast<wxd_StaticText_t*>(stext);
}
WXD_EXPORTED void
wxd_StaticText_Destroy(wxd_StaticText_t* stext)
{
if (!stext)
return;
wxStaticText* wx_stext = reinterpret_cast<wxStaticText*>(stext);
wx_stext->Destroy();
}
WXD_EXPORTED void
wxd_StaticText_SetLabel(wxd_StaticText_t* stext, const char* label)
{
if (!stext)
return;
wxStaticText* wx_stext = reinterpret_cast<wxStaticText*>(stext);
wxString wx_label = wxString::FromUTF8(label ? label : "");
wx_stext->SetLabel(wx_label);
}
WXD_EXPORTED int
wxd_StaticText_GetLabel(const wxd_StaticText_t* stext, char* buffer, size_t buffer_len)
{
if (!stext)
return -1;
const wxStaticText* wx_stext = reinterpret_cast<const wxStaticText*>(stext);
wxString label = wx_stext->GetLabel();
return (int)wxd_cpp_utils::copy_wxstring_to_buffer(label, buffer, buffer_len);
}
WXD_EXPORTED void
wxd_StaticText_Wrap(wxd_StaticText_t* stext, int width)
{
if (!stext)
return;
wxStaticText* wx_stext = reinterpret_cast<wxStaticText*>(stext);
wx_stext->Wrap(width);
}
}