This commit is contained in:
parent
2858679cc4
commit
f8c678ac53
5 changed files with 78 additions and 12 deletions
|
|
@ -390,6 +390,13 @@ MWDECL void MWAPI MwFreeWidget(MwWidget handle);
|
||||||
*/
|
*/
|
||||||
MWDECL void MWAPI MwGetFrame(MwWidget handle, MwRect* rect);
|
MWDECL void MWAPI MwGetFrame(MwWidget handle, MwRect* rect);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Gets the clipping frame of the widget
|
||||||
|
* @param handle Widget
|
||||||
|
* @param rect Frame
|
||||||
|
*/
|
||||||
|
MWDECL void MWAPI MwGetClipFrame(MwWidget handle, MwRect* rect);
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
MWDECL void MwForceRender_Internal(MwWidget handle);
|
MWDECL void MwForceRender_Internal(MwWidget handle);
|
||||||
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);
|
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,13 @@ MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color,
|
||||||
*/
|
*/
|
||||||
MWDECL void MWAPI MwDrawCircle(MwWidget handle, MwRect* rect, MwLLColor color, MwLLColor background, int filled);
|
MWDECL void MWAPI MwDrawCircle(MwWidget handle, MwRect* rect, MwLLColor color, MwLLColor background, int filled);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Calculate intersect of 2 rectangles
|
||||||
|
* @param a 1st rectangle
|
||||||
|
* @param a 2nd rectangle
|
||||||
|
*/
|
||||||
|
MWDECL void MwIntersectRect(MwRect* a, const MwRect* b);
|
||||||
|
|
||||||
/* text.c */
|
/* text.c */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
27
src/core.c
27
src/core.c
|
|
@ -1241,4 +1241,31 @@ void MwGetFrame(MwWidget handle, MwRect* rect) {
|
||||||
rect->height = MwGetInteger(handle, MwNheight);
|
rect->height = MwGetInteger(handle, MwNheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MwGetClipFrame(MwWidget handle, MwRect* rect) {
|
||||||
|
MwWidget child = handle;
|
||||||
|
MwWidget p = handle->parent;
|
||||||
|
int o_x = 0, o_y = 0;
|
||||||
|
|
||||||
|
rect->x = 0;
|
||||||
|
rect->y = 0;
|
||||||
|
rect->width = MwGetInteger(handle, MwNwidth);
|
||||||
|
rect->height = MwGetInteger(handle, MwNheight);
|
||||||
|
while(p != NULL && p->widget_class != MwWindowClass) {
|
||||||
|
MwRect pclip;
|
||||||
|
|
||||||
|
o_x += MwGetInteger(child, MwNx);
|
||||||
|
o_y += MwGetInteger(child, MwNy);
|
||||||
|
|
||||||
|
pclip.x = -o_x;
|
||||||
|
pclip.y = -o_y;
|
||||||
|
pclip.width = MwGetInteger(p, MwNwidth);
|
||||||
|
pclip.height = MwGetInteger(p, MwNheight);
|
||||||
|
MwIntersectRect(rect, &pclip);
|
||||||
|
if(rect->width == 0 || rect->height == 0) break;
|
||||||
|
|
||||||
|
child = p;
|
||||||
|
p = p->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char* MwVersionString = MwVERSION;
|
const char* MwVersionString = MwVERSION;
|
||||||
|
|
|
||||||
32
src/draw.c
32
src/draw.c
|
|
@ -1125,3 +1125,35 @@ MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
|
||||||
|
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _min(int a, int b) {
|
||||||
|
return a < b ? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _max(int a, int b) {
|
||||||
|
return a > b ? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwIntersectRect(MwRect* a, const MwRect* b) {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int right;
|
||||||
|
int bottom;
|
||||||
|
|
||||||
|
x = _max(a->x, b->x);
|
||||||
|
y = _max(a->y, b->y);
|
||||||
|
right = _min(a->x + a->width, b->x + b->width);
|
||||||
|
bottom = _min(a->y + a->height, b->y + b->height);
|
||||||
|
|
||||||
|
a->x = x;
|
||||||
|
a->y = y;
|
||||||
|
|
||||||
|
if(right <= x || bottom <= x) {
|
||||||
|
a->width = 0;
|
||||||
|
a->height = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
a->width = right - x;
|
||||||
|
a->height = bottom - y;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,17 +59,9 @@ static void draw(MwWidget handle) {
|
||||||
MwFLFont font = NULL;
|
MwFLFont font = NULL;
|
||||||
MwPoint u_p, s_p, c_p;
|
MwPoint u_p, s_p, c_p;
|
||||||
int u = 0, s = 0, c = 0;
|
int u = 0, s = 0, c = 0;
|
||||||
int s_y = 0;
|
MwRect clip;
|
||||||
int s_h = MwGetInteger(handle, MwNheight);
|
|
||||||
MwWidget p = handle->parent;
|
|
||||||
|
|
||||||
s_y = MwGetInteger(handle, MwNy);
|
MwGetClipFrame(handle, &clip);
|
||||||
while(p != NULL && p->widget_class != MwWindowClass) {
|
|
||||||
s_y += MwGetInteger(p, MwNy);
|
|
||||||
|
|
||||||
p = p->parent;
|
|
||||||
}
|
|
||||||
s_y *= -1;
|
|
||||||
|
|
||||||
u_p.x = s_p.x = c_p.x = 0;
|
u_p.x = s_p.x = c_p.x = 0;
|
||||||
u_p.y = s_p.y = c_p.y = 0;
|
u_p.y = s_p.y = c_p.y = 0;
|
||||||
|
|
@ -87,11 +79,12 @@ static void draw(MwWidget handle) {
|
||||||
case MwDOCUMENT_TEXT:
|
case MwDOCUMENT_TEXT:
|
||||||
{
|
{
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
|
int th2;
|
||||||
|
|
||||||
p.x = l->x;
|
p.x = l->x;
|
||||||
p.y = l->y + MwTextHeight(handle, font, l->text) / 2;
|
p.y = l->y + (th2 = MwTextHeight(handle, font, l->text) / 2);
|
||||||
|
|
||||||
if(p.y <= s_y || p.y >= s_y + s_h) break;
|
if((p.y + th2) <= clip.y || (p.y - th2) >= clip.y + clip.height) break;
|
||||||
|
|
||||||
if(u || s || c) {
|
if(u || s || c) {
|
||||||
MwPoint line[2];
|
MwPoint line[2];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue