マイペースなプログラミング日記

DTMやプログラミングにお熱なd-kamiがマイペースに書くブログ

blink-dのC++ライブラリのコード

blink-dのC++側のコードです...GUIに関するgui.cppの部分だけ載せています。なぜここに__cxa_pure_virtual()があるのか?とか疑問に思わずに見ることを推奨します

#include "gui.h"

extern "C" int gui(int, int, int, int, int = 0, int = 0);
extern "C" int stdin(int, int, int, int, int = 0, int = 0);

void __cxa_pure_virtual(){
    
}

void HasUserData::setUserData(int data){
    stdin(0x7FFFFFFC, this->getWidgetId(), data, 0);
}

int HasUserData::getUserData(){
    return stdin(0x7FFFFFFD, this->getWidgetId(), 0, 0);
}

void HasText::setText(String text){
    gui(this->getWidgetType(), this->getWidgetId(), text.getId(), 0x10);
}

String HasText::getText(){
    String str(gui(this->getWidgetType(), this->getWidgetId(), 0, 0x11));
    
    return str;
}

Label::Label(){
    this->widgetType = 2;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
}

int Label::getWidgetId(){
    return this->widgetId;
}

int Label::getWidgetType(){
    return this->widgetType;
}

TextBox::TextBox(){
    this->widgetType = 9;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
}

TextBox::TextBox(int id){
    this->widgetId = id;
    this->widgetType = 9;
}

int TextBox::getWidgetId(){
    return this->widgetId;
}

int TextBox::getWidgetType(){
    return this->widgetType;
}

Button::Button(){
    this->widgetType = 6;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
}

Button::Button(int id){
    this->widgetType = 6;
    this->widgetId = id;
}

int Button::getWidgetId(){
    return this->widgetId;
}

int Button::getWidgetType(){
    return this->widgetType;
}

void Button::addClickEvent(void(*func)(int)){
    gui(this->widgetType, this->widgetId, (int)func, 0x100);
}

void Container::add(HasWidgetId& widget){
    gui(1, this->getWidgetId(), widget.getWidgetId(), 0x1000);
}

Window::Window(){
    this->widgetType = 0;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
    gui(this->widgetType, this->widgetId, 1, 1);
}

int Window::getWidgetId(){
    return this->widgetId;
}

int Window::getWidgetType(){
    return this->widgetType;
}

void Window::center(){
    gui(this->widgetType, this->widgetId, 0, 0x21);
}

VerticalPanel::VerticalPanel(){
    this->widgetType = 7;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
}

int VerticalPanel::getWidgetId(){
    return this->widgetId;
}

int VerticalPanel::getWidgetType(){
    return this->widgetType;
}

HorizontalPanel::HorizontalPanel(){
    this->widgetType = 8;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
}

int HorizontalPanel::getWidgetId(){
    return this->widgetId;
}

int HorizontalPanel::getWidgetType(){
    return this->widgetType;
}

Image::Image(String url){
    this->widgetType = 10;
    this->widgetId = gui(this->widgetType, url.getId(), 0, 0);
}

int Image::getWidgetId(){
    return this->widgetId;
}

int Image::getWidgetType(){
    return this->widgetType;
}

void Image::setSize(String width, String height){
    gui(this->widgetType, this->widgetId, 0, 0x40, width.getId(), height.getId());
}

GLCanvas::GLCanvas(int width, int height){
    this->widgetType = 5;
    this->widgetId = gui(this->widgetType, width, height, 0);
}

void GLCanvas::setVertexCount(int size){
    gui(this->widgetType, this->widgetId, size, 0x100001);
}

void GLCanvas::addVertex(int x, int y, int z){
    gui(this->widgetType, this->widgetId, x, 0x100002, y, z);
}

void GLCanvas::setColor(int color){
    gui(this->widgetType, this->widgetId, color, 0x100004);
}

void GLCanvas::draw(){
    gui(this->widgetType, this->widgetId, 0, 0x100003);
}

int GLCanvas::getWidgetId(){
    return this->widgetId;
}

int GLCanvas::getWidgetType(){
    return this->widgetType;
}

DragWidgetPanel::DragWidgetPanel(){
    this->widgetType = 12;
    this->widgetId = gui(this->widgetType, 0, 0, 0);
}

void DragWidgetPanel::addDragWidget(int x, int y, String text){
    int position = (y << 16) | x;
    gui(this->widgetType, this->widgetId, position, 0x1100, text.getId());
}

void DragWidgetPanel::setDragWidget(HasWidgetId& widget, int x, int y){
    int position = (y << 16) | x;
    gui(this->widgetType, this->widgetId, widget.getWidgetId(), 0x1101, position);
}

int DragWidgetPanel::getWidgetId(){
    return this->widgetId;
}

int DragWidgetPanel::getWidgetType(){
    return this->widgetType;
}