mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
oo binding
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@202 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
17
GNUmakefile
17
GNUmakefile
@@ -31,11 +31,12 @@ L_OBJS += src/external/ds.o src/external/image.o
|
||||
L_OBJS += src/widget/window.o src/widget/button.o src/widget/frame.o src/widget/menu.o src/widget/submenu.o src/widget/image.o src/widget/scrollbar.o
|
||||
L_OBJS += src/cursor/default.o src/cursor/cross.o
|
||||
|
||||
OOL_CFLAGS = $(CFLAGS) -fPIC
|
||||
OOL_LDFLAGS = $(LDFLAGS)
|
||||
OOL_LIBS = $(LIBS)
|
||||
OOL_CFLAGS = $(DEPINC) $(CFLAGS) -std=c++98 -fPIC -D_MILSKO
|
||||
OOL_LDFLAGS = $(LDFLAGS) -L src
|
||||
OOL_LIBS = $(LIBS) -lMw
|
||||
|
||||
OOL_OBJS = src/core.o
|
||||
OOL_OBJS = oosrc/base.o
|
||||
include oosrc/deps.mk
|
||||
|
||||
E_CFLAGS = $(CFLAGS)
|
||||
E_LDFLAGS = $(LDFLAGS) -Lsrc
|
||||
@@ -136,11 +137,13 @@ EXAMPLES = examples/example$(EXEC) examples/rotate$(EXEC) examples/image$(EXEC)
|
||||
|
||||
ifeq ($(OPENGL),1)
|
||||
L_OBJS += src/widget/opengl.o
|
||||
OOL_OBJS += oosrc/widget/opengl.o
|
||||
EXAMPLES += examples/gltriangle$(EXEC) examples/glgears$(EXEC) examples/glboing$(EXEC) examples/glcube$(EXEC)
|
||||
endif
|
||||
|
||||
ifeq ($(VULKAN),1)
|
||||
L_OBJS += src/widget/vulkan.o
|
||||
OOL_OBJS += oosrc/widget/vulkan.o
|
||||
EXAMPLES += examples/vulkan$(EXEC)
|
||||
endif
|
||||
|
||||
@@ -152,14 +155,14 @@ oolib: src/$(LIB)MwOO$(SO)
|
||||
examples: $(EXAMPLES)
|
||||
|
||||
format:
|
||||
clang-format --verbose -i `find src include examples tools "(" -name "*.c" -or -name "*.h" ")" -and -not -name "stb_*.h"`
|
||||
clang-format --verbose -i `find oosrc src include examples tools "(" -name "*.c" -or -name "*.h" ")" -and -not -name "stb_*.h"`
|
||||
perltidy -b -bext='/' --paren-tightness=2 `find tools -name "*.pl"`
|
||||
|
||||
src/$(LIB)Mw$(SO): $(L_OBJS)
|
||||
$(CC) $(L_LDFLAGS) $(SHARED) -o $@ $^ $(L_LIBS)
|
||||
|
||||
src/$(LIB)MwOO$(SO): $(OOL_OBJS) src/$(LIB)Mw$(SO)
|
||||
$(CC) $(OOL_LDFLAGS) $(SHARED) -o $@ $^ $(OOL_LIBS)
|
||||
src/$(LIB)MwOO$(SO): $(OOL_OBJS) lib
|
||||
$(CC) $(OOL_LDFLAGS) $(SHARED) -o $@ $(OOL_OBJS) $(OOL_LIBS)
|
||||
|
||||
examples/gl%$(EXEC): examples/gl%.o src/$(LIB)Mw$(SO)
|
||||
$(CC) $(E_LDFLAGS) -o $@ $< $(E_LIBS) $(GL)
|
||||
|
||||
17
include/MwOO/Base.h
Normal file
17
include/MwOO/Base.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_BASE_H__
|
||||
#define __MWOO_BASE_H__
|
||||
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
class MwOOWidget {
|
||||
protected:
|
||||
MwClass widget_class = NULL;
|
||||
MwWidget widget;
|
||||
|
||||
public:
|
||||
MwOOWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
~MwOOWidget(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/Button.h
Normal file
12
include/MwOO/Widget/Button.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_BUTTON_H__
|
||||
#define __MWOO_WIDGET_BUTTON_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOButtonWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOButtonWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/Frame.h
Normal file
12
include/MwOO/Widget/Frame.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_FRAME_H__
|
||||
#define __MWOO_WIDGET_FRAME_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOFrameWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOFrameWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/Image.h
Normal file
12
include/MwOO/Widget/Image.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_IMAGE_H__
|
||||
#define __MWOO_WIDGET_IMAGE_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOImageWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOImageWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/Menu.h
Normal file
12
include/MwOO/Widget/Menu.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_MENU_H__
|
||||
#define __MWOO_WIDGET_MENU_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOMenuWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOMenuWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/OpenGL.h
Normal file
12
include/MwOO/Widget/OpenGL.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_OPENGL_H__
|
||||
#define __MWOO_WIDGET_OPENGL_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOOpenGLWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOOpenGLWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/ScrollBar.h
Normal file
12
include/MwOO/Widget/ScrollBar.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_SCROLLBAR_H__
|
||||
#define __MWOO_WIDGET_SCROLLBAR_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOScrollBarWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOScrollBarWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/SubMenu.h
Normal file
12
include/MwOO/Widget/SubMenu.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_SUBMENU_H__
|
||||
#define __MWOO_WIDGET_SUBMENU_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOSubMenuWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOSubMenuWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/Vulkan.h
Normal file
12
include/MwOO/Widget/Vulkan.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_VULKAN_H__
|
||||
#define __MWOO_WIDGET_VULKAN_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOVulkanWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOVulkanWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
include/MwOO/Widget/Window.h
Normal file
12
include/MwOO/Widget/Window.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $Id$ */
|
||||
#ifndef __MWOO_WIDGET_WINDOW_H__
|
||||
#define __MWOO_WIDGET_WINDOW_H__
|
||||
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
class MwOOWindowWidget : public MwOOWidget {
|
||||
public:
|
||||
MwOOWindowWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
#endif
|
||||
10
oosrc/base.cc
Normal file
10
oosrc/base.cc
Normal file
@@ -0,0 +1,10 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Base.h>
|
||||
|
||||
MwOOWidget::MwOOWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h){
|
||||
this->widget = MwCreateWidget(this->widget_class, name, parent->widget, x, y, w, h);
|
||||
}
|
||||
|
||||
MwOOWidget::~MwOOWidget(void){
|
||||
MwDestroyWidget(this->widget);
|
||||
}
|
||||
2
oosrc/deps.mk
Normal file
2
oosrc/deps.mk
Normal file
@@ -0,0 +1,2 @@
|
||||
# $Id$
|
||||
OOL_OBJS += oosrc/widget/button.o oosrc/widget/frame.o oosrc/widget/image.o oosrc/widget/menu.o oosrc/widget/scrollbar.o oosrc/widget/submenu.o oosrc/widget/window.o
|
||||
7
oosrc/widget/button.cc
Normal file
7
oosrc/widget/button.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/Button.h>
|
||||
#include <Mw/Widget/Button.h>
|
||||
|
||||
MwOOButtonWidget::MwOOButtonWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwButtonClass;
|
||||
}
|
||||
7
oosrc/widget/frame.cc
Normal file
7
oosrc/widget/frame.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/Frame.h>
|
||||
#include <Mw/Widget/Frame.h>
|
||||
|
||||
MwOOFrameWidget::MwOOFrameWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwFrameClass;
|
||||
}
|
||||
7
oosrc/widget/image.cc
Normal file
7
oosrc/widget/image.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/Image.h>
|
||||
#include <Mw/Widget/Image.h>
|
||||
|
||||
MwOOImageWidget::MwOOImageWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwImageClass;
|
||||
}
|
||||
7
oosrc/widget/menu.cc
Normal file
7
oosrc/widget/menu.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/Menu.h>
|
||||
#include <Mw/Widget/Menu.h>
|
||||
|
||||
MwOOMenuWidget::MwOOMenuWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwMenuClass;
|
||||
}
|
||||
7
oosrc/widget/opengl.cc
Normal file
7
oosrc/widget/opengl.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/OpenGL.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
MwOOOpenGLWidget::MwOOOpenGLWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwOpenGLClass;
|
||||
}
|
||||
7
oosrc/widget/scrollbar.cc
Normal file
7
oosrc/widget/scrollbar.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/ScrollBar.h>
|
||||
#include <Mw/Widget/ScrollBar.h>
|
||||
|
||||
MwOOScrollBarWidget::MwOOScrollBarWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwScrollBarClass;
|
||||
}
|
||||
7
oosrc/widget/submenu.cc
Normal file
7
oosrc/widget/submenu.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/SubMenu.h>
|
||||
#include <Mw/Widget/SubMenu.h>
|
||||
|
||||
MwOOSubMenuWidget::MwOOSubMenuWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwSubMenuClass;
|
||||
}
|
||||
7
oosrc/widget/vulkan.cc
Normal file
7
oosrc/widget/vulkan.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/Vulkan.h>
|
||||
#include <Mw/Widget/Vulkan.h>
|
||||
|
||||
MwOOVulkanWidget::MwOOVulkanWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwVulkanClass;
|
||||
}
|
||||
7
oosrc/widget/window.cc
Normal file
7
oosrc/widget/window.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $Id$ */
|
||||
#include <MwOO/Widget/Window.h>
|
||||
#include <Mw/Widget/Window.h>
|
||||
|
||||
MwOOWindowWidget::MwOOWindowWidget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){
|
||||
this->widget_class = MwWindowClass;
|
||||
}
|
||||
@@ -142,9 +142,9 @@ static void mouse_move(MwWidget handle) {
|
||||
int max = MwGetInteger(handle, MwNmaxValue);
|
||||
|
||||
if(or == MwVERTICAL) {
|
||||
l = handle->mouse_point.y + scr->pos;
|
||||
l = handle->mouse_point.y + scr->pos;
|
||||
} else if(or == MwHORIZONTAL) {
|
||||
l = handle->mouse_point.x + scr->pos;
|
||||
l = handle->mouse_point.x + scr->pos;
|
||||
}
|
||||
|
||||
len = l / len;
|
||||
|
||||
@@ -89,7 +89,7 @@ sub scan_dir {
|
||||
print(STDERR "Scanning $path\n");
|
||||
my @paths = sort(readdir($dh));
|
||||
foreach my $p (@paths) {
|
||||
if ($p eq '.' || $p eq '..') {
|
||||
if ($p eq '.' || $p eq '..' || $p eq 'MwOO') {
|
||||
next;
|
||||
}
|
||||
scan_dir($first, $path . "/" . $p);
|
||||
|
||||
55
tools/genoo.pl
Executable file
55
tools/genoo.pl
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env perl
|
||||
# $Id$
|
||||
|
||||
my $objs = "";
|
||||
|
||||
opendir(DIR, "include/Mw/Widget");
|
||||
my @files = readdir(DIR);
|
||||
foreach my $f (@files) {
|
||||
if ($f eq '.' || $f eq '..') {
|
||||
next;
|
||||
}
|
||||
|
||||
$f =~ /^(.+)\.h$/;
|
||||
|
||||
my $name = $1;
|
||||
|
||||
open(OUT, ">", "include/MwOO/Widget/$f");
|
||||
print(OUT "/* \$Id\$ */\n");
|
||||
print(OUT "#ifndef __MWOO_WIDGET_" . uc($name) . "_H__\n");
|
||||
print(OUT "#define __MWOO_WIDGET_" . uc($name) . "_H__\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "#include <MwOO/Base.h>\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "class MwOO${name}Widget : public MwOOWidget {\n");
|
||||
print(OUT "public:\n");
|
||||
print(OUT
|
||||
" MwOO${name}Widget(const char* name, MwOOWidget* parent, int x, int y, int w, int h);\n"
|
||||
);
|
||||
print(OUT "};\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "#endif\n");
|
||||
close(OUT);
|
||||
|
||||
open(OUT, ">", "oosrc/widget/" . lc($name) . ".cc");
|
||||
print(OUT "/* \$Id\$ */\n");
|
||||
print(OUT "#include <MwOO/Widget/$name.h>\n");
|
||||
print(OUT "#include <Mw/Widget/$name.h>\n");
|
||||
print(OUT "\n");
|
||||
print(OUT
|
||||
"MwOO${name}Widget::MwOO${name}Widget(const char* name, MwOOWidget* parent, int x, int y, int w, int h) : MwOOWidget(name, parent, x, y, w, h){\n"
|
||||
);
|
||||
print(OUT " this->widget_class = Mw${name}Class;\n");
|
||||
print(OUT "}\n");
|
||||
close(OUT);
|
||||
|
||||
if (!($name eq 'Vulkan' || $name eq 'OpenGL')) {
|
||||
$objs = $objs . " oosrc/widget/" . lc($name) . ".o";
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
|
||||
open(OUT, ">", "oosrc/deps.mk");
|
||||
print(OUT "# \$Id\$\n");
|
||||
print(OUT "OOL_OBJS +=$objs\n");
|
||||
close(OUT);
|
||||
Reference in New Issue
Block a user