git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@209 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-08 08:46:56 +00:00
parent 951dcc054a
commit fc3450ae03
19 changed files with 192 additions and 80 deletions

View File

@@ -28,7 +28,7 @@ L_LIBS = $(LIBS)
L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o
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/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 src/widget/checkbox.o
L_OBJS += src/cursor/default.o src/cursor/cross.o
OOL_CFLAGS = $(DEPINC) $(CFLAGS) -std=c++98 -fPIC -D_MILSKO

View File

@@ -22,6 +22,7 @@
#include <Mw/Widget/Menu.h>
#include <Mw/Widget/SubMenu.h>
#include <Mw/Widget/Button.h>
#include <Mw/Widget/CheckBox.h>
#include <Mw/Widget/Frame.h>
#include <Mw/Widget/Image.h>
#include <Mw/Widget/ScrollBar.h>

View File

@@ -15,6 +15,7 @@
#define MwNmaxValue "ImaxValue"
#define MwNvalue "Ivalue"
#define MwNareaShown "IareaShown"
#define MwNchecked "Ichecked"
#define MwNtitle "Stitle"
#define MwNtext "Stext"
@@ -30,5 +31,6 @@
#define MwNmenuHandler "Cmenu"
#define MwNmouseDownHandler "CmouseDownHandler"
#define MwNmouseUpHandler "CmouseUpHandler"
#define MwNchangedHandler "CchangedHandler"
#endif

View File

@@ -0,0 +1,26 @@
/* $Id: CheckBox.h 206 2025-10-07 15:10:46Z nishi $ */
/*!
* %file Mw/Widget/CheckBox.h
* %brief CheckBox widget
* %prop MwNpixmap
*/
#ifndef __MW_WIDGET_CHECKBOX_H__
#define __MW_WIDGET_CHECKBOX_H__
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
/*!
* %brief CheckBox widget class
*/
MWDECL MwClass MwCheckBoxClass;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -26,15 +26,16 @@ class Base {
int GetY(void);
int GetWidth(void);
int GetHeight(void);
/* BEGIN AUTOGENERATE */
virtual void OnActivate(void*) {};
virtual void OnResize(void*) {};
virtual void OnTick(void*) {};
virtual void OnMenu(void*) {};
virtual void OnMouseDownHandler(void*) {};
virtual void OnMouseUpHandler(void*) {};
/* BEGIN AUTOGENERATE */
virtual void OnActivate(void*){};
virtual void OnResize(void*){};
virtual void OnTick(void*){};
virtual void OnMenu(void*){};
virtual void OnMouseDownHandler(void*){};
virtual void OnMouseUpHandler(void*){};
virtual void OnChangedHandler(void*){};
/* END AUTOGENERATE */
/* END AUTOGENERATE */
Base(MwClass widget_class, const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
~Base(void);

View File

@@ -5,12 +5,12 @@
#include <MwOO/Base.h>
namespace MwOO {
class Button : public MwOO::Base {
public:
Button(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void SetPixmap(void* value);
void* GetPixmap(void);
};
} // namespace MwOO
class Button : public MwOO::Base {
public:
Button(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void SetPixmap(void* value);
void* GetPixmap(void);
};
}
#endif

View File

@@ -0,0 +1,16 @@
/* $Id$ */
#ifndef __MWOO_WIDGET_CHECKBOX_H__
#define __MWOO_WIDGET_CHECKBOX_H__
#include <MwOO/Base.h>
namespace MwOO {
class CheckBox : public MwOO::Base {
public:
CheckBox(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void SetPixmap(void* value);
void* GetPixmap(void);
};
}
#endif

View File

@@ -5,10 +5,10 @@
#include <MwOO/Base.h>
namespace MwOO {
class Frame : public MwOO::Base {
public:
Frame(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
};
} // namespace MwOO
class Frame : public MwOO::Base {
public:
Frame(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
};
}
#endif

View File

@@ -5,12 +5,12 @@
#include <MwOO/Base.h>
namespace MwOO {
class Image : public MwOO::Base {
public:
Image(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void SetPixmap(void* value);
void* GetPixmap(void);
};
} // namespace MwOO
class Image : public MwOO::Base {
public:
Image(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void SetPixmap(void* value);
void* GetPixmap(void);
};
}
#endif

View File

@@ -5,11 +5,11 @@
#include <MwOO/Base.h>
namespace MwOO {
class Menu : public MwOO::Base {
public:
Menu(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
MwMenu Add(MwMenu menu, const char* name);
};
} // namespace MwOO
class Menu : public MwOO::Base {
public:
Menu(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
MwMenu Add(MwMenu menu, const char* name);
};
}
#endif

View File

@@ -5,13 +5,13 @@
#include <MwOO/Base.h>
namespace MwOO {
class OpenGL : public MwOO::Base {
public:
OpenGL(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void MakeCurrent(void);
void* GetProcAddress(const char* name);
void SwapBuffer(void);
};
} // namespace MwOO
class OpenGL : public MwOO::Base {
public:
OpenGL(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void MakeCurrent(void);
void* GetProcAddress(const char* name);
void SwapBuffer(void);
};
}
#endif

View File

@@ -5,21 +5,21 @@
#include <MwOO/Base.h>
namespace MwOO {
class ScrollBar : public MwOO::Base {
public:
ScrollBar(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
int GetVisibleLength(void);
void SetAreaShown(int value);
int GetAreaShown(void);
void SetValue(int value);
int GetValue(void);
void SetMinValue(int value);
int GetMinValue(void);
void SetMaxValue(int value);
int GetMaxValue(void);
void SetOrientation(int value);
int GetOrientation(void);
};
} // namespace MwOO
class ScrollBar : public MwOO::Base {
public:
ScrollBar(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
int GetVisibleLength(void);
void SetAreaShown(int value);
int GetAreaShown(void);
void SetValue(int value);
int GetValue(void);
void SetMinValue(int value);
int GetMinValue(void);
void SetMaxValue(int value);
int GetMaxValue(void);
void SetOrientation(int value);
int GetOrientation(void);
};
}
#endif

View File

@@ -5,11 +5,11 @@
#include <MwOO/Base.h>
namespace MwOO {
class SubMenu : public MwOO::Base {
public:
SubMenu(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void Appear(MwMenu menu, MwPoint* point);
};
} // namespace MwOO
class SubMenu : public MwOO::Base {
public:
SubMenu(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void Appear(MwMenu menu, MwPoint* point);
};
}
#endif

View File

@@ -5,15 +5,15 @@
#include <MwOO/Base.h>
namespace MwOO {
class Vulkan : public MwOO::Base {
public:
Vulkan(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void EnableExtension(void);
void EnableLayer(void);
void Configure(void);
void* GetField(MwVulkanField field, MwErrorEnum* out);
VkBool32 Supported(void);
};
} // namespace MwOO
class Vulkan : public MwOO::Base {
public:
Vulkan(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void EnableExtension(void);
void EnableLayer(void);
void Configure(void);
void* GetField(MwVulkanField field, MwErrorEnum* out);
VkBool32 Supported(void);
};
}
#endif

View File

@@ -5,10 +5,10 @@
#include <MwOO/Base.h>
namespace MwOO {
class Window : public MwOO::Base {
public:
Window(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
};
} // namespace MwOO
class Window : public MwOO::Base {
public:
Window(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
};
}
#endif

View File

@@ -73,6 +73,10 @@ static void __OnMouseUpHandler(MwWidget widget, void* user, void* call){
MwOO::Base* c = (MwOO::Base*)user;
c->OnMouseUpHandler(call);
}
static void __OnChangedHandler(MwWidget widget, void* user, void* call){
MwOO::Base* c = (MwOO::Base*)user;
c->OnChangedHandler(call);
}
void MwOO::Base::SetHandler(void){
MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, this);
@@ -81,5 +85,6 @@ void MwOO::Base::SetHandler(void){
MwAddUserHandler(this->widget, MwNmenuHandler, __OnMenu, this);
MwAddUserHandler(this->widget, MwNmouseDownHandler, __OnMouseDownHandler, this);
MwAddUserHandler(this->widget, MwNmouseUpHandler, __OnMouseUpHandler, this);
MwAddUserHandler(this->widget, MwNchangedHandler, __OnChangedHandler, this);
}
/* END AUTOGENERATE */

View File

@@ -1,2 +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
OOL_OBJS += oosrc/widget/button.o oosrc/widget/menu.o oosrc/widget/window.o oosrc/widget/image.o oosrc/widget/submenu.o oosrc/widget/frame.o oosrc/widget/scrollbar.o oosrc/widget/checkbox.o

15
oosrc/widget/checkbox.cc Normal file
View File

@@ -0,0 +1,15 @@
/* $Id$ */
#include <MwOO/Widget/CheckBox.h>
#include <Mw/Widget/CheckBox.h>
MwOO::CheckBox::CheckBox(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwCheckBoxClass, widget_name, parent, x, y, w, h){
}
void MwOO::CheckBox::SetPixmap(void* value){
MwSetVoid(this->widget, MwNpixmap, value);
}
void* MwOO::CheckBox::GetPixmap(void){
return MwGetVoid(this->widget, MwNpixmap);
}

46
src/widget/checkbox.c Normal file
View File

@@ -0,0 +1,46 @@
/* $Id: button.c 168 2025-10-04 19:30:58Z nishi $ */
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNchecked, 0);
return 0;
}
static void draw(MwWidget handle) {
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
r.x = 0;
r.y = 0;
r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
MwDrawRect(handle, &r, base);
if(handle->pressed || MwGetInteger(handle, MwNchecked)){
/* TODO: write check mark */
}
MwLLFreeColor(base);
}
static void click(MwWidget handle) {
MwSetInteger(handle, MwNchecked, MwGetInteger(handle, MwNchecked) ? 0 : 1);
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
}
MwClassRec MwCheckBoxClassRec = {
create, /* create */
NULL, /* destroy */
draw, /* draw */
click, /* click */
NULL, /* parent_resize */
NULL, /* mouse_move */
MwForceRender, /* mouse_up */
MwForceRender /* mouse_down */
};
MwClass MwCheckBoxClass = &MwCheckBoxClassRec;