#include <wx/wxprec.h>
#include <wx/wx.h>
#include "wxdragon.h"
#include <wx/notebook.h>
WXD_EXPORTED wxd_Notebook_t*
wxd_Notebook_Create(wxd_Window_t* parent, wxd_Id id, wxd_Point pos, wxd_Size size,
wxd_Style_t style)
{
wxWindow* parentWin = reinterpret_cast<wxWindow*>(parent);
wxNotebook* notebook = new wxNotebook(parentWin, id, wxPoint(pos.x, pos.y),
wxSize(size.width, size.height), style);
return reinterpret_cast<wxd_Notebook_t*>(notebook);
}
WXD_EXPORTED bool
wxd_Notebook_AddPage(wxd_Notebook_t* self, wxd_Window_t* page, const char* text, bool select)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
wxWindow* pageWin = reinterpret_cast<wxWindow*>(page);
if (!notebook || !pageWin)
return false;
return notebook->AddPage(pageWin, wxString::FromUTF8(text ? text : ""), select);
}
WXD_EXPORTED int
wxd_Notebook_GetSelection(wxd_Notebook_t* self)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return wxNOT_FOUND; return notebook->GetSelection();
}
WXD_EXPORTED int
wxd_Notebook_SetSelection(wxd_Notebook_t* self, int page)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return wxNOT_FOUND;
return notebook->SetSelection(static_cast<size_t>(page));
}
WXD_EXPORTED int
wxd_NotebookEvent_GetSelection(wxd_Event_t* event)
{
if (!event)
return wxNOT_FOUND;
wxEvent* baseEvent = reinterpret_cast<wxEvent*>(event);
wxBookCtrlEvent* notebookEvent = dynamic_cast<wxBookCtrlEvent*>(baseEvent);
if (!notebookEvent)
return wxNOT_FOUND;
return notebookEvent->GetSelection();
}
WXD_EXPORTED int
wxd_NotebookEvent_GetOldSelection(wxd_Event_t* event)
{
if (!event)
return wxNOT_FOUND;
wxEvent* baseEvent = reinterpret_cast<wxEvent*>(event);
wxBookCtrlEvent* notebookEvent = dynamic_cast<wxBookCtrlEvent*>(baseEvent);
if (!notebookEvent)
return wxNOT_FOUND;
return notebookEvent->GetOldSelection();
}
WXD_EXPORTED void
wxd_Notebook_SetPadding(wxd_Notebook_t* self, wxd_Size padding)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (notebook) {
notebook->SetPadding(wxSize(padding.width, padding.height));
}
}
WXD_EXPORTED int
wxd_Notebook_ChangeSelection(wxd_Notebook_t* self, size_t page)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return wxNOT_FOUND;
return notebook->ChangeSelection(page);
}
WXD_EXPORTED void
wxd_Notebook_AdvanceSelection(wxd_Notebook_t* self, bool forward)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (notebook) {
notebook->AdvanceSelection(forward);
}
}
WXD_EXPORTED void
wxd_Notebook_SetImageList(wxd_Notebook_t* self, wxd_ImageList_t* imageList)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
wxImageList* wx_imageList = reinterpret_cast<wxImageList*>(imageList);
if (notebook) {
notebook->SetImageList(wx_imageList); }
}
WXD_EXPORTED wxd_ImageList_t*
wxd_Notebook_GetImageList(wxd_Notebook_t* self)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return nullptr;
return reinterpret_cast<wxd_ImageList_t*>(notebook->GetImageList());
}
WXD_EXPORTED bool
wxd_Notebook_AddPageWithImageId(wxd_Notebook_t* self, wxd_Window_t* page, const char* text,
bool select, int imageId)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
wxWindow* pageWin = reinterpret_cast<wxWindow*>(page);
if (!notebook || !pageWin)
return false;
return notebook->AddPage(pageWin, wxString::FromUTF8(text ? text : ""), select, imageId);
}
WXD_EXPORTED bool
wxd_Notebook_InsertPage(wxd_Notebook_t* self, size_t index, wxd_Window_t* page, const char* text,
bool select)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
wxWindow* pageWin = reinterpret_cast<wxWindow*>(page);
if (!notebook || !pageWin)
return false;
return notebook->InsertPage(index, pageWin, wxString::FromUTF8(text ? text : ""), select);
}
WXD_EXPORTED bool
wxd_Notebook_InsertPageWithImageId(wxd_Notebook_t* self, size_t index, wxd_Window_t* page,
const char* text, bool select, int imageId)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
wxWindow* pageWin = reinterpret_cast<wxWindow*>(page);
if (!notebook || !pageWin)
return false;
return notebook->InsertPage(index, pageWin, wxString::FromUTF8(text ? text : ""), select,
imageId);
}
WXD_EXPORTED size_t
wxd_Notebook_GetPageCount(wxd_Notebook_t* self)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return 0;
return notebook->GetPageCount();
}
WXD_EXPORTED wxd_Window_t*
wxd_Notebook_GetPage(wxd_Notebook_t* self, size_t n)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return nullptr;
wxWindow* page = notebook->GetPage(n);
return reinterpret_cast<wxd_Window_t*>(page);
}
WXD_EXPORTED bool
wxd_Notebook_RemovePage(wxd_Notebook_t* self, size_t n)
{
wxNotebook* notebook = reinterpret_cast<wxNotebook*>(self);
if (!notebook)
return false;
return notebook->RemovePage(n);
}