#include <wx/wxprec.h>
#include <wx/wx.h>
#include "../include/wxdragon.h"
#include <wx/aui/auibook.h>
#include "wxd_utils.h"
extern "C" {
WXD_EXPORTED wxd_AuiNotebook_t*
wxd_AuiNotebook_Create(wxd_Window_t* parent, int id, wxd_Point pos, wxd_Size size, int64_t style)
{
wxWindow* parentPtr = (wxWindow*)parent;
wxPoint wxPos = wxPoint(pos.x, pos.y);
wxSize wxSizeInstance = wxSize(size.width, size.height);
wxAuiNotebook* notebook = new wxAuiNotebook(parentPtr, id, wxPos, wxSizeInstance, style);
return (wxd_AuiNotebook_t*)notebook;
}
WXD_EXPORTED bool
wxd_AuiNotebook_AddPage(wxd_AuiNotebook_t* self, wxd_Window_t* page, const char* caption,
bool select, int bitmap_id)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
wxWindow* pagePtr = (wxWindow*)page;
if (!notebook || !pagePtr) {
return false;
}
(void)bitmap_id;
wxString wxCaption = WXD_STR_TO_WX_STRING_UTF8_NULL_OK(caption);
return notebook->AddPage(pagePtr, wxCaption, select, bitmap_id);
}
WXD_EXPORTED size_t
wxd_AuiNotebook_GetPageCount(wxd_AuiNotebook_t* self)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) {
return 0; }
return notebook->GetPageCount();
}
WXD_EXPORTED size_t
wxd_AuiNotebook_SetSelection(wxd_AuiNotebook_t* self, size_t new_page)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) {
return new_page;
}
return notebook->SetSelection(new_page);
}
WXD_EXPORTED int
wxd_AuiNotebook_GetSelection(wxd_AuiNotebook_t* self)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return -1;
return notebook->GetSelection();
}
WXD_EXPORTED bool
wxd_AuiNotebook_InsertPage(wxd_AuiNotebook_t* self, size_t page_idx, wxd_Window_t* page,
const char* caption, bool select, int bitmap_id)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
wxWindow* pagePtr = (wxWindow*)page;
if (!notebook || !pagePtr) return false;
wxString wxCaption = WXD_STR_TO_WX_STRING_UTF8_NULL_OK(caption);
return notebook->InsertPage(page_idx, pagePtr, wxCaption, select, bitmap_id);
}
WXD_EXPORTED bool
wxd_AuiNotebook_DeletePage(wxd_AuiNotebook_t* self, size_t page)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return false;
return notebook->DeletePage(page);
}
WXD_EXPORTED bool
wxd_AuiNotebook_RemovePage(wxd_AuiNotebook_t* self, size_t page)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return false;
return notebook->RemovePage(page);
}
WXD_EXPORTED bool
wxd_AuiNotebook_DeleteAllPages(wxd_AuiNotebook_t* self)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return false;
return notebook->DeleteAllPages();
}
WXD_EXPORTED wxd_Window_t*
wxd_AuiNotebook_GetPage(wxd_AuiNotebook_t* self, size_t page_idx)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return nullptr;
return (wxd_Window_t*)notebook->GetPage(page_idx);
}
WXD_EXPORTED int
wxd_AuiNotebook_GetPageIndex(wxd_AuiNotebook_t* self, wxd_Window_t* page_wnd)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
wxWindow* page = (wxWindow*)page_wnd;
if (!notebook || !page) return -1;
return notebook->GetPageIndex(page);
}
WXD_EXPORTED int
wxd_AuiNotebook_GetPageText(wxd_AuiNotebook_t* self, size_t page_idx, char* buffer, size_t buffer_len)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return -1;
if (page_idx >= notebook->GetPageCount()) return -1;
wxString text = notebook->GetPageText(page_idx);
return (int)wxd_cpp_utils::copy_wxstring_to_buffer(text, buffer, buffer_len);
}
WXD_EXPORTED bool
wxd_AuiNotebook_SetPageText(wxd_AuiNotebook_t* self, size_t page_idx, const char* text)
{
wxAuiNotebook* notebook = (wxAuiNotebook*)self;
if (!notebook) return false;
if (page_idx >= notebook->GetPageCount()) return false;
wxString wxText = WXD_STR_TO_WX_STRING_UTF8_NULL_OK(text);
return notebook->SetPageText(page_idx, wxText);
}
}