mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-10 10:35:46 +01:00
- removed configure.in. use only autoconf 2.5x fom now
- fixed a bug and memleak in WMBox code. - updated some translations - fixed some bug in the menu code about drawing disabled entries. - fixed Clip menu not to allow selecting of "Autoraise" if "Keep On Top" is active. - Added a "Browse" button to the menu editor in WPrefs where a program to run is specified (not finished).
This commit is contained in:
@@ -7,6 +7,9 @@ Changes since wmaker 0.80.0:
|
||||
- fixed labels not to display '\n' as a character if multiple '\n' are passed
|
||||
but just skip to the next line.
|
||||
- better warning when importing non-digit characters in PropList Data.
|
||||
- rewrote WMBox to use a WMArray for subviews. with this change fixed a bug
|
||||
about arranging subviews after removing one and a memleak occuring in the
|
||||
same case.
|
||||
|
||||
|
||||
Changes since wmaker 0.70.0:
|
||||
|
||||
@@ -138,19 +138,13 @@ testBox(WMScreen *scr)
|
||||
win = WMCreateWindow(scr, "testBox");
|
||||
WMSetWindowTitle(win, "Box");
|
||||
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||
|
||||
WMSetViewNotifySizeChanges(WMWidgetView(win), True);
|
||||
WMResizeWidget(win, 400, 300);
|
||||
|
||||
box = WMCreateBox(win);
|
||||
WMSetBoxBorderWidth(box, 5);
|
||||
|
||||
WMAddNotificationObserver(resizedWindow, box,
|
||||
WMViewSizeDidChangeNotification,
|
||||
WMWidgetView(win));
|
||||
WMResizeWidget(win, 400, 300);
|
||||
|
||||
WMSetViewExpandsToParent(WMWidgetView(box), 0, 0, 0, 0);
|
||||
|
||||
/* WMSetBoxHorizontal(box, True); */
|
||||
/*WMSetBoxHorizontal(box, True);*/
|
||||
for (i = 0; i < 4; i++) {
|
||||
btn = WMCreateCommandButton(box);
|
||||
WMSetButtonText(btn, "bla");
|
||||
@@ -1316,15 +1310,10 @@ main(int argc, char **argv)
|
||||
|
||||
testFrame(scr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
testSplitView(scr);
|
||||
|
||||
testGradientButtons(scr);
|
||||
|
||||
|
||||
testOpenFilePanel(scr);
|
||||
|
||||
testSlider(scr);
|
||||
|
||||
233
WINGs/wbox.c
233
WINGs/wbox.c
@@ -18,8 +18,7 @@ typedef struct W_Box {
|
||||
W_Class widgetClass;
|
||||
W_View *view;
|
||||
|
||||
SubviewItem *subviews;
|
||||
int subviewCount;
|
||||
WMArray *subviews;
|
||||
|
||||
short borderWidth;
|
||||
|
||||
@@ -40,10 +39,10 @@ static void didResize(struct W_ViewDelegate*, WMView*);
|
||||
|
||||
static W_ViewDelegate delegate = {
|
||||
NULL,
|
||||
NULL,
|
||||
didResize,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
didResize,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -53,7 +52,7 @@ WMBox*
|
||||
WMCreateBox(WMWidget *parent)
|
||||
{
|
||||
Box *bPtr;
|
||||
|
||||
|
||||
bPtr = wmalloc(sizeof(Box));
|
||||
memset(bPtr, 0, sizeof(Box));
|
||||
|
||||
@@ -65,87 +64,108 @@ WMCreateBox(WMWidget *parent)
|
||||
return NULL;
|
||||
}
|
||||
bPtr->view->self = bPtr;
|
||||
|
||||
|
||||
bPtr->view->delegate = &delegate;
|
||||
|
||||
|
||||
bPtr->subviews = WMCreateArrayWithDestructor(2, wfree);
|
||||
|
||||
WMCreateEventHandler(bPtr->view, StructureNotifyMask,
|
||||
handleEvents, bPtr);
|
||||
|
||||
WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
|
||||
bPtr->subviews = NULL;
|
||||
bPtr->subviewCount = 0;
|
||||
|
||||
|
||||
return bPtr;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
WMBox *box;
|
||||
int total;
|
||||
int expands;
|
||||
int x, y;
|
||||
int xe, ye;
|
||||
int w, h;
|
||||
} BoxData;
|
||||
|
||||
|
||||
static void
|
||||
computeExpansion(void *object, void *cdata)
|
||||
{
|
||||
SubviewItem *item = (SubviewItem*)object;
|
||||
BoxData *eData = (BoxData*)cdata;
|
||||
|
||||
eData->total -= item->minSize;
|
||||
eData->total -= item->space;
|
||||
if (item->expand) {
|
||||
eData->expands++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
doRearrange(void *object, void *cdata)
|
||||
{
|
||||
SubviewItem *item = (SubviewItem*)object;
|
||||
BoxData *eData = (BoxData*)cdata;
|
||||
|
||||
if (eData->box->horizontal) {
|
||||
eData->w = item->minSize;
|
||||
if (item->expand)
|
||||
eData->w += eData->total/eData->expands;
|
||||
} else {
|
||||
eData->h = item->minSize;
|
||||
if (item->expand)
|
||||
eData->h += eData->total/eData->expands;
|
||||
}
|
||||
if (!item->end) {
|
||||
W_MoveView(item->view, eData->x, eData->y);
|
||||
}
|
||||
W_ResizeView(item->view, eData->w, eData->h);
|
||||
if (eData->box->horizontal) {
|
||||
if (item->end)
|
||||
eData->xe -= eData->w + item->space;
|
||||
else
|
||||
eData->x += eData->w + item->space;
|
||||
} else {
|
||||
if (item->end)
|
||||
eData->ye -= eData->h + item->space;
|
||||
else
|
||||
eData->y += eData->h + item->space;
|
||||
}
|
||||
if (item->end) {
|
||||
W_MoveView(item->view, eData->xe, eData->ye);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
rearrange(WMBox *box)
|
||||
{
|
||||
int i;
|
||||
int x, y;
|
||||
int xe, ye;
|
||||
int w = 1, h = 1;
|
||||
int total;
|
||||
int expands = 0;
|
||||
|
||||
x = box->borderWidth;
|
||||
y = box->borderWidth;
|
||||
|
||||
BoxData eData;
|
||||
|
||||
eData.box = box;
|
||||
eData.x = eData.y = box->borderWidth;
|
||||
eData.w = eData.h = 1;
|
||||
eData.expands = 0;
|
||||
|
||||
if (box->horizontal) {
|
||||
ye = box->borderWidth;
|
||||
xe = WMWidgetWidth(box) - box->borderWidth;
|
||||
h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
eData.ye = box->borderWidth;
|
||||
eData.xe = WMWidgetWidth(box) - box->borderWidth;
|
||||
eData.h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
eData.total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
} else {
|
||||
xe = box->borderWidth;
|
||||
ye = WMWidgetHeight(box) - box->borderWidth;
|
||||
w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
eData.xe = box->borderWidth;
|
||||
eData.ye = WMWidgetHeight(box) - box->borderWidth;
|
||||
eData.w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
eData.total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
}
|
||||
|
||||
if (w <= 0 || h <= 0 || total <= 0) {
|
||||
if (eData.w <= 0 || eData.h <= 0 || eData.total <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < box->subviewCount; i++) {
|
||||
total -= box->subviews[i].minSize;
|
||||
total -= box->subviews[i].space;
|
||||
if (box->subviews[i].expand) {
|
||||
expands++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < box->subviewCount; i++) {
|
||||
if (box->horizontal) {
|
||||
w = box->subviews[i].minSize;
|
||||
if (box->subviews[i].expand)
|
||||
w += total/expands;
|
||||
} else {
|
||||
h = box->subviews[i].minSize;
|
||||
if (box->subviews[i].expand)
|
||||
h += total/expands;
|
||||
}
|
||||
if (!box->subviews[i].end) {
|
||||
W_MoveView(box->subviews[i].view, x, y);
|
||||
}
|
||||
W_ResizeView(box->subviews[i].view, w, h);
|
||||
if (box->horizontal) {
|
||||
if (box->subviews[i].end)
|
||||
xe -= w + box->subviews[i].space;
|
||||
else
|
||||
x += w + box->subviews[i].space;
|
||||
} else {
|
||||
if (box->subviews[i].end)
|
||||
ye -= h + box->subviews[i].space;
|
||||
else
|
||||
y += h + box->subviews[i].space;
|
||||
}
|
||||
if (box->subviews[i].end) {
|
||||
W_MoveView(box->subviews[i].view, xe, ye);
|
||||
}
|
||||
}
|
||||
WMMapArray(box->subviews, computeExpansion, &eData);
|
||||
WMMapArray(box->subviews, doRearrange, &eData);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,21 +183,18 @@ void
|
||||
WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
int minSize, int maxSize, int space)
|
||||
{
|
||||
int i = bPtr->subviewCount;
|
||||
|
||||
bPtr->subviewCount++;
|
||||
if (!bPtr->subviews)
|
||||
bPtr->subviews = wmalloc(sizeof(SubviewItem));
|
||||
else
|
||||
bPtr->subviews = wrealloc(bPtr->subviews,
|
||||
bPtr->subviewCount*sizeof(SubviewItem));
|
||||
bPtr->subviews[i].view = view;
|
||||
bPtr->subviews[i].minSize = minSize;
|
||||
bPtr->subviews[i].maxSize = maxSize;
|
||||
bPtr->subviews[i].expand = expand;
|
||||
bPtr->subviews[i].fill = fill;
|
||||
bPtr->subviews[i].space = space;
|
||||
bPtr->subviews[i].end = 0;
|
||||
SubviewItem *subView;
|
||||
|
||||
subView = wmalloc(sizeof(SubviewItem));
|
||||
subView->view = view;
|
||||
subView->minSize = minSize;
|
||||
subView->maxSize = maxSize;
|
||||
subView->expand = expand;
|
||||
subView->fill = fill;
|
||||
subView->space = space;
|
||||
subView->end = 0;
|
||||
|
||||
WMAddToArray(bPtr->subviews, subView);
|
||||
|
||||
rearrange(bPtr);
|
||||
}
|
||||
@@ -188,40 +205,36 @@ void
|
||||
WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
int minSize, int maxSize, int space)
|
||||
{
|
||||
int i = bPtr->subviewCount;
|
||||
|
||||
bPtr->subviewCount++;
|
||||
if (!bPtr->subviews)
|
||||
bPtr->subviews = wmalloc(sizeof(SubviewItem));
|
||||
else
|
||||
bPtr->subviews = wrealloc(bPtr->subviews,
|
||||
bPtr->subviewCount*sizeof(SubviewItem));
|
||||
bPtr->subviews[i].view = view;
|
||||
bPtr->subviews[i].minSize = minSize;
|
||||
bPtr->subviews[i].maxSize = maxSize;
|
||||
bPtr->subviews[i].expand = expand;
|
||||
bPtr->subviews[i].fill = fill;
|
||||
bPtr->subviews[i].space = space;
|
||||
bPtr->subviews[i].end = 1;
|
||||
SubviewItem *subView;
|
||||
|
||||
subView = wmalloc(sizeof(SubviewItem));
|
||||
subView->view = view;
|
||||
subView->minSize = minSize;
|
||||
subView->maxSize = maxSize;
|
||||
subView->expand = expand;
|
||||
subView->fill = fill;
|
||||
subView->space = space;
|
||||
subView->end = 1;
|
||||
|
||||
WMAddToArray(bPtr->subviews, subView);
|
||||
|
||||
rearrange(bPtr);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
matchView(void *item, void *cdata)
|
||||
{
|
||||
return (((SubviewItem*)item)->view == (WMView*)cdata);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMRemoveBoxSubview(WMBox *bPtr, WMView *view)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < bPtr->subviewCount; i++) {
|
||||
if (bPtr->subviews[i].view == view) {
|
||||
memmove(&bPtr->subviews[i], &bPtr->subviews[i+1],
|
||||
(bPtr->subviewCount - i - 1) * sizeof(void*));
|
||||
bPtr->subviewCount--;
|
||||
break;
|
||||
}
|
||||
if (WMRemoveFromArrayMatching(bPtr->subviews, matchView, view)) {
|
||||
rearrange(bPtr);
|
||||
}
|
||||
rearrange(bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -241,6 +254,7 @@ static void
|
||||
destroyBox(Box *bPtr)
|
||||
{
|
||||
WMRemoveNotificationObserver(bPtr);
|
||||
WMFreeArray(bPtr->subviews);
|
||||
wfree(bPtr);
|
||||
}
|
||||
|
||||
@@ -270,3 +284,4 @@ handleEvents(XEvent *event, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ destroyView(W_View *view)
|
||||
|
||||
WMRemoveNotificationObserver(view);
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
if (view->dragSourceProcs)
|
||||
wfree(view->dragSourceProcs);
|
||||
|
||||
@@ -733,9 +733,8 @@ WMGetViewScreenPosition(WMView *view)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void resizedParent(void *self, WMNotification *notif)
|
||||
static void
|
||||
resizedParent(void *self, WMNotification *notif)
|
||||
{
|
||||
WMSize size = WMGetViewSize((WMView*)WMGetNotificationObject(notif));
|
||||
WMView *view = (WMView*)self;
|
||||
@@ -745,7 +744,7 @@ static void resizedParent(void *self, WMNotification *notif)
|
||||
size.height - (view->topOffs + view->bottomOffs));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
WMSetViewExpandsToParent(WMView *view, int leftOffs, int topOffs,
|
||||
int rightOffs, int bottomOffs)
|
||||
@@ -766,3 +765,5 @@ WMSetViewExpandsToParent(WMView *view, int leftOffs, int topOffs,
|
||||
W_ResizeView(view, size.width - (leftOffs + rightOffs),
|
||||
size.height - (topOffs + bottomOffs));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user