mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-11 11:53:29 +00:00
work on listbox
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@327 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
40
src/widget/listbox.c
Normal file
40
src/widget/listbox.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
int st;
|
||||
|
||||
if((st = MwViewportClass->create(handle)) != 0) return st;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void destroy(MwWidget handle) {
|
||||
MwViewportClass->destroy(handle);
|
||||
}
|
||||
|
||||
static void draw(MwWidget handle) {
|
||||
MwViewportClass->draw(handle);
|
||||
}
|
||||
|
||||
static void prop_change(MwWidget handle, const char* prop) {
|
||||
MwViewportClass->prop_change(handle, prop);
|
||||
}
|
||||
|
||||
MwClassRec MwListBoxClassRec = {
|
||||
create, /* create */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
prop_change, /* prop_change */
|
||||
NULL, /* mouse_move */
|
||||
NULL, /* mouse_up */
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
MwClass MwListBoxClass = &MwListBoxClassRec;
|
||||
@@ -1,19 +1,12 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
typedef struct viewport {
|
||||
MwWidget vscroll;
|
||||
MwWidget hscroll;
|
||||
MwWidget frame;
|
||||
MwWidget inframe;
|
||||
} viewport_t;
|
||||
|
||||
static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
viewport_t* vp = user;
|
||||
int v = MwGetInteger(handle, MwNvalue);
|
||||
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNheight);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
MwViewport vp = user;
|
||||
int v = MwGetInteger(handle, MwNvalue);
|
||||
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNheight);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
(void)call;
|
||||
if(v < 0) v = 0;
|
||||
MwVaApply(vp->inframe,
|
||||
@@ -22,11 +15,11 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
}
|
||||
|
||||
static void hscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
viewport_t* vp = user;
|
||||
int v = MwGetInteger(handle, MwNvalue);
|
||||
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNwidth);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
MwViewport vp = user;
|
||||
int v = MwGetInteger(handle, MwNvalue);
|
||||
int mv = MwGetInteger(handle, MwNmaxValue);
|
||||
int l = MwGetInteger(vp->frame, MwNwidth);
|
||||
v = (mv - l) * (double)v / mv;
|
||||
(void)call;
|
||||
if(v < 0) v = 0;
|
||||
MwVaApply(vp->inframe,
|
||||
@@ -35,11 +28,11 @@ static void hscroll_changed(MwWidget handle, void* user, void* call) {
|
||||
}
|
||||
|
||||
static void resize(MwWidget handle) {
|
||||
viewport_t* vp = handle->internal;
|
||||
int w = MwGetInteger(handle, MwNwidth);
|
||||
int h = MwGetInteger(handle, MwNheight);
|
||||
int iw;
|
||||
int ih;
|
||||
MwViewport vp = handle->internal;
|
||||
int w = MwGetInteger(handle, MwNwidth);
|
||||
int h = MwGetInteger(handle, MwNheight);
|
||||
int iw;
|
||||
int ih;
|
||||
if(vp->vscroll == NULL) {
|
||||
vp->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h - 16, NULL);
|
||||
MwAddUserHandler(vp->vscroll, MwNchangedHandler, vscroll_changed, vp);
|
||||
@@ -91,7 +84,7 @@ static void resize(MwWidget handle) {
|
||||
}
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
viewport_t* vp = malloc(sizeof(*vp));
|
||||
MwViewport vp = malloc(sizeof(*vp));
|
||||
memset(vp, 0, sizeof(*vp));
|
||||
|
||||
handle->internal = vp;
|
||||
@@ -103,6 +96,10 @@ static int create(MwWidget handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void destroy(MwWidget handle) {
|
||||
free(handle->internal);
|
||||
}
|
||||
|
||||
static void draw(MwWidget handle) {
|
||||
MwRect r;
|
||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||
@@ -123,7 +120,7 @@ static void prop_change(MwWidget handle, const char* prop) {
|
||||
|
||||
MwClassRec MwViewportClassRec = {
|
||||
create, /* create */
|
||||
NULL, /* destroy */
|
||||
destroy, /* destroy */
|
||||
draw, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
@@ -140,13 +137,13 @@ MwClassRec MwViewportClassRec = {
|
||||
MwClass MwViewportClass = &MwViewportClassRec;
|
||||
|
||||
MwWidget MwViewportGetViewport(MwWidget handle) {
|
||||
viewport_t* vp = handle->internal;
|
||||
MwViewport vp = handle->internal;
|
||||
|
||||
return vp->inframe;
|
||||
}
|
||||
|
||||
void MwViewportSetSize(MwWidget handle, int w, int h) {
|
||||
viewport_t* vp = handle->internal;
|
||||
MwViewport vp = handle->internal;
|
||||
|
||||
MwVaApply(vp->inframe,
|
||||
MwNwidth, w,
|
||||
|
||||
Reference in New Issue
Block a user