mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-26 19:13:05 +00:00
kinda
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@166 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -16,4 +16,12 @@ enum MwDIRECTION {
|
|||||||
MwWEST
|
MwWEST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* %brief Orientation
|
||||||
|
*/
|
||||||
|
enum MwORIENTATION {
|
||||||
|
MwVERTICAL = 0,
|
||||||
|
MwHORIZONTAL
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#define MwNy "Iy"
|
#define MwNy "Iy"
|
||||||
#define MwNwidth "Iwidth"
|
#define MwNwidth "Iwidth"
|
||||||
#define MwNheight "Iheight"
|
#define MwNheight "Iheight"
|
||||||
|
#define MwNorientation "Iorientation"
|
||||||
|
|
||||||
#define MwNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MwNtext "Stext"
|
#define MwNtext "Stext"
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
|
|||||||
|
|
||||||
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
||||||
MwPoint p1[4], p2[4], p3[4], p4[3];
|
MwPoint p1[4], p2[4], p3[4], p4[3];
|
||||||
const int border = BorderWidth * 2;
|
const int border = BorderWidth;
|
||||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
||||||
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,85 @@
|
|||||||
/* $Id $*/
|
/* $Id $*/
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
typedef struct scrollbar {
|
||||||
|
MwPoint point;
|
||||||
|
int point_set;
|
||||||
|
} scrollbar_t;
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int create(MwWidget handle) {
|
||||||
|
scrollbar_t* scr = malloc(sizeof(*scr));
|
||||||
|
|
||||||
|
scr->point_set = 0;
|
||||||
|
|
||||||
|
handle->internal = scr;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroy(MwWidget handle) {
|
||||||
|
free(handle->internal);
|
||||||
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwRect r, rt;
|
MwRect r, rt;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
|
||||||
|
scrollbar_t* scr = handle->internal;
|
||||||
|
int or ;
|
||||||
|
int uy, dy, ux, dx;
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = MwGetInteger(handle, MwNwidth);
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
uy = r.width;
|
||||||
|
dy = r.height - r.width;
|
||||||
|
|
||||||
|
ux = r.height;
|
||||||
|
dx = r.width - r.height;
|
||||||
|
|
||||||
MwDrawFrame(handle, &r, dark, 1);
|
MwDrawFrame(handle, &r, dark, 1);
|
||||||
MwDrawRect(handle, &r, dark);
|
MwDrawRect(handle, &r, dark);
|
||||||
|
|
||||||
rt = r;
|
if(handle->pressed && !scr->point_set) {
|
||||||
rt.height = rt.width;
|
scr->point = handle->mouse_point;
|
||||||
MwDrawTriangle(handle, &rt, base, 0, MwNORTH);
|
scr->point_set = 1;
|
||||||
rt.y = r.y + r.height - rt.height;
|
} else if(!handle->pressed && scr->point_set) {
|
||||||
MwDrawTriangle(handle, &rt, base, 0, MwSOUTH);
|
scr->point_set = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt = r;
|
||||||
|
|
||||||
|
if((or = MwGetInteger(handle, MwNorientation)) == -1 || or == MwVERTICAL) {
|
||||||
|
rt.height = rt.width;
|
||||||
|
|
||||||
|
rt.y = r.y;
|
||||||
|
MwDrawTriangle(handle, &rt, base, (handle->pressed && scr->point.y <= uy) ? 1 : 0, MwNORTH);
|
||||||
|
|
||||||
|
rt.y = r.y + r.height - rt.height;
|
||||||
|
MwDrawTriangle(handle, &rt, base, (handle->pressed && scr->point.y >= dy) ? 1 : 0, MwSOUTH);
|
||||||
|
} else if((or = MwGetInteger(handle, MwNorientation)) == -1 || or == MwHORIZONTAL) {
|
||||||
|
rt.width = rt.height;
|
||||||
|
|
||||||
|
rt.x = r.x;
|
||||||
|
MwDrawTriangle(handle, &rt, base, (handle->pressed && scr->point.x <= ux) ? 1 : 0, MwWEST);
|
||||||
|
|
||||||
|
rt.x = r.x + r.width - rt.width;
|
||||||
|
MwDrawTriangle(handle, &rt, base, (handle->pressed && scr->point.x >= dx) ? 1 : 0, MwEAST);
|
||||||
|
}
|
||||||
|
|
||||||
MwLLFreeColor(dark);
|
MwLLFreeColor(dark);
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwScrollBarClassRec = {
|
MwClassRec MwScrollBarClassRec = {
|
||||||
create, /* create */
|
create, /* create */
|
||||||
NULL, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL /* parent_resize */
|
NULL /* parent_resize */
|
||||||
};
|
};
|
||||||
MwClass MwScrollBarClass = &MwScrollBarClassRec;
|
MwClass MwScrollBarClass = &MwScrollBarClassRec;
|
||||||
|
|||||||
Reference in New Issue
Block a user