This commit is contained in:
parent
56d4d0377c
commit
eb8b945995
3 changed files with 21 additions and 5 deletions
|
|
@ -341,7 +341,7 @@ int main() {
|
||||||
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
|
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
|
||||||
|
|
||||||
f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass,
|
f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass,
|
||||||
MwNcolumnSpan, 2,
|
MwNcolumnSpan, 3,
|
||||||
NULL);
|
NULL);
|
||||||
w = child(f);
|
w = child(f);
|
||||||
MwViewportSetSize(w, 512, 512);
|
MwViewportSetSize(w, 512, 512);
|
||||||
|
|
@ -352,7 +352,9 @@ int main() {
|
||||||
MwNtitle, "Sub window 2",
|
MwNtitle, "Sub window 2",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
f = frame("Tab", -PaddingContent, -PaddingContent, MwTabClass, NULL);
|
f = frame("Tab", -PaddingContent, -PaddingContent, MwTabClass,
|
||||||
|
MwNcolumnSpan, 2,
|
||||||
|
NULL);
|
||||||
w = child(f);
|
w = child(f);
|
||||||
MwSetString(MwTabAdd(w, "ABC"), MwNbackground, "#f00");
|
MwSetString(MwTabAdd(w, "ABC"), MwNbackground, "#f00");
|
||||||
MwSetString(MwTabAdd(w, "DEF"), MwNbackground, "#0f0");
|
MwSetString(MwTabAdd(w, "DEF"), MwNbackground, "#0f0");
|
||||||
|
|
@ -364,7 +366,14 @@ int main() {
|
||||||
v = MwTreeViewAdd(w, v, NULL, "def");
|
v = MwTreeViewAdd(w, v, NULL, "def");
|
||||||
v = MwTreeViewAdd(w, v, NULL, "ghi");
|
v = MwTreeViewAdd(w, v, NULL, "ghi");
|
||||||
|
|
||||||
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass, NULL);
|
f = frame("Text", -PaddingContent, -PaddingContent, MwViewportClass,
|
||||||
|
MwNcolumnSpan, 2,
|
||||||
|
NULL);
|
||||||
|
w = child(f);
|
||||||
|
|
||||||
|
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass,
|
||||||
|
MwNcolumnSpan, 2,
|
||||||
|
NULL);
|
||||||
w = child(f);
|
w = child(f);
|
||||||
MwViewportSetSize(w, 256, 256);
|
MwViewportSetSize(w, 256, 256);
|
||||||
MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128,
|
MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128,
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,8 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name,
|
||||||
h->lowlevel = NULL;
|
h->lowlevel = NULL;
|
||||||
}
|
}
|
||||||
h->widget_class = widget_class;
|
h->widget_class = widget_class;
|
||||||
|
h->mouse_point.x = 0;
|
||||||
|
h->mouse_point.y = 0;
|
||||||
h->pressed = 0;
|
h->pressed = 0;
|
||||||
h->close = 0;
|
h->close = 0;
|
||||||
h->destroy_queue = NULL;
|
h->destroy_queue = NULL;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ static int calc_length(MwWidget handle) {
|
||||||
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
|
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
|
||||||
int area = MwGetInteger(handle, MwNareaShown);
|
int area = MwGetInteger(handle, MwNareaShown);
|
||||||
if(area > len) area = len;
|
if(area > len) area = len;
|
||||||
|
if(len == 0) return max;
|
||||||
|
|
||||||
return (int)(max * (double)area / len);
|
return (int)(max * (double)area / len);
|
||||||
}
|
}
|
||||||
|
|
@ -35,6 +36,7 @@ static int calc_position(MwWidget handle) {
|
||||||
int max = MwScrollBarGetVisibleLength(handle);
|
int max = MwScrollBarGetVisibleLength(handle);
|
||||||
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
|
int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue);
|
||||||
int val = MwGetInteger(handle, MwNvalue);
|
int val = MwGetInteger(handle, MwNvalue);
|
||||||
|
if(len == 0) return 0;
|
||||||
|
|
||||||
return (int)((max - calc_length(handle)) * (double)val / len);
|
return (int)((max - calc_length(handle)) * (double)val / len);
|
||||||
}
|
}
|
||||||
|
|
@ -49,8 +51,10 @@ static void add_value(MwWidget handle, int mul) {
|
||||||
if(val < min) val = min;
|
if(val < min) val = min;
|
||||||
if(val > max) val = max;
|
if(val > max) val = max;
|
||||||
|
|
||||||
MwSetInteger(handle, MwNvalue, val);
|
if(MwGetInteger(handle, MwNvalue) != val) {
|
||||||
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
|
MwSetInteger(handle, MwNvalue, val);
|
||||||
|
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
|
|
@ -223,6 +227,7 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
static void prop_change(MwWidget handle, const char* key) {
|
static void prop_change(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MwNminValue) == 0 || strcmp(key, MwNvalue) == 0 || strcmp(key, MwNmaxValue) == 0) {
|
if(strcmp(key, MwNminValue) == 0 || strcmp(key, MwNvalue) == 0 || strcmp(key, MwNmaxValue) == 0) {
|
||||||
if(MwGetInteger(handle, MwNvalue) > MwGetInteger(handle, MwNmaxValue)) MwSetInteger(handle, MwNvalue, MwGetInteger(handle, MwNmaxValue));
|
if(MwGetInteger(handle, MwNvalue) > MwGetInteger(handle, MwNmaxValue)) MwSetInteger(handle, MwNvalue, MwGetInteger(handle, MwNmaxValue));
|
||||||
|
if(MwGetInteger(handle, MwNvalue) < MwGetInteger(handle, MwNminValue)) MwSetInteger(handle, MwNvalue, MwGetInteger(handle, MwNminValue));
|
||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
if(strcmp(key, MwNshowArrows) == 0 || strcmp(key, MwNareaShown) == 0) {
|
if(strcmp(key, MwNshowArrows) == 0 || strcmp(key, MwNareaShown) == 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue