1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-24 07:02:30 +01:00

fixed bugs of resized widgets

This commit is contained in:
kojima
2000-11-11 18:08:10 +00:00
parent 4d41658e1a
commit 52308a0abc
8 changed files with 116 additions and 17 deletions

View File

@@ -58,7 +58,7 @@ changes since wmaker 0.62.1:
the program name prepended to it. Similar to wwarning(), except that it
doesn't add "warning:" in the output message.
- added WMBox widget
- added W_SetViewCursor()
changes since wmaker 0.62.0:
............................

View File

@@ -115,12 +115,21 @@ testFrame(WMScreen *scr)
}
static void resizedWindow(void *self, WMNotification *notif)
{
WMView *view = (WMView*)WMGetNotificationObject(notif);
WMSize size = WMGetViewSize(view);
WMResizeWidget((WMWidget*)self, size.width, size.height);
}
void
testBox(WMScreen *scr)
{
WMWindow *win;
WMBox *box;
WMBox *box, *hbox;
WMButton *btn;
WMPopUpButton *pop;
int i;
windowCount++;
@@ -128,12 +137,19 @@ testBox(WMScreen *scr)
win = WMCreateWindow(scr, "testBox");
WMSetWindowTitle(win, "Box");
WMSetWindowCloseAction(win, closeAction, NULL);
WMResizeWidget(win, 400, 300);
WMSetViewNotifySizeChanges(WMWidgetView(win), True);
box = WMCreateBox(win);
WMMoveWidget(box, 50, 50);
WMResizeWidget(box, 300, 200);
// WMSetBoxHorizontal(box, True);
WMSetBoxBorderWidth(box, 5);
WMAddNotificationObserver(resizedWindow, box,
WMViewSizeDidChangeNotification,
WMWidgetView(win));
WMResizeWidget(win, 400, 300);
/* WMSetBoxHorizontal(box, True); */
for (i = 0; i < 4; i++) {
btn = WMCreateCommandButton(box);
WMSetButtonText(btn, "bla");
@@ -141,6 +157,25 @@ testBox(WMScreen *scr)
WMAddBoxSubview(box, WMWidgetView(btn), i&1, True, 20, 0, 5);
}
pop = WMCreatePopUpButton(box);
WMAddPopUpButtonItem(pop, "ewqeq");
WMAddPopUpButtonItem(pop, "ewqeqrewrw");
WMAddBoxSubview(box, WMWidgetView(pop), False, True, 20, 0, 5);
WMMapWidget(pop);
hbox = WMCreateBox(box);
WMSetBoxHorizontal(hbox, True);
WMAddBoxSubview(box, WMWidgetView(hbox), False, True, 24, 0, 0);
WMMapWidget(hbox);
for (i = 0; i < 4; i++) {
btn = WMCreateCommandButton(hbox);
WMSetButtonText(btn, "bla");
WMMapWidget(btn);
WMAddBoxSubview(hbox, WMWidgetView(btn), 1, True, 60, 0, i<3?5:0);
}
WMRealizeWidget(win);
WMMapSubwidgets(win);
WMMapWidget(win);
@@ -1239,7 +1274,9 @@ main(int argc, char **argv)
*/
testBox(scr);
#if 0
#if 0
testTabView(scr);
testList(scr);
testProgressIndicator(scr);
@@ -1259,7 +1296,6 @@ main(int argc, char **argv)
testFrame(scr);
testTabView(scr);

View File

@@ -337,6 +337,7 @@ typedef struct W_View {
WMColor *backColor;
Cursor cursor;
Atom *droppableTypes;
struct W_DragSourceProcs *dragSourceProcs;
@@ -461,6 +462,8 @@ void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
void W_SetViewBackgroundColor(W_View *view, WMColor *color);
void W_SetViewCursor(W_View *view, Cursor cursor);
void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
unsigned int height, WMReliefType relief);

View File

@@ -82,12 +82,12 @@ rearrange(WMBox *box)
{
int i;
int x, y;
int w, h;
int w = 1, h = 1;
int total;
int expands = 0;
x = box->borderWidth;
y = box->borderWidth;
y = box->borderWidth;
if (box->horizontal) {
h = WMWidgetHeight(box) - 2 * box->borderWidth;
total = WMWidgetWidth(box) - 2 * box->borderWidth;
@@ -95,16 +95,19 @@ rearrange(WMBox *box)
w = WMWidgetWidth(box) - 2 * box->borderWidth;
total = WMWidgetHeight(box) - 2 * box->borderWidth;
}
if (w <= 0 || h <= 0 || total <= 0) {
return;
}
for (i = 0; i < box->subviewCount; i++) {
total -= box->subviews[i].minSize;
total -= box->subviews[i].space;
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;
@@ -115,8 +118,8 @@ rearrange(WMBox *box)
if (box->subviews[i].expand)
h += total/expands;
}
W_ResizeView(box->subviews[i].view, w, h);
W_MoveView(box->subviews[i].view, x, y);
W_ResizeView(box->subviews[i].view, w, h);
if (box->horizontal) {
x += w + box->subviews[i].space;
} else {

View File

@@ -224,6 +224,7 @@ WMSetPopUpButtonSelectedItem(WMPopUpButton *bPtr, int index)
paintPopUpButton(bPtr);
}
int
WMGetPopUpButtonSelectedItem(WMPopUpButton *bPtr)
{

View File

@@ -73,6 +73,8 @@ WMCreateScrollView(WMWidget *parent)
sPtr->view->delegate = &_ScrollViewViewDelegate;
W_SetViewBackgroundColor(sPtr->viewport,
WMBlackColor(WMWidgetScreen(parent)));
sPtr->viewport->flags.mapWhenRealized = 1;
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
@@ -163,7 +165,7 @@ reorganizeInterior(WMScrollView *sPtr)
W_ResizeView(sPtr->viewport, cw, ch);
W_MoveView(sPtr->viewport, cx, cy);
if (sPtr->flags.hasHScroller) {
WMResizeWidget(sPtr->hScroller, hw, 20);
WMMoveWidget(sPtr->hScroller, hx, hy);

View File

@@ -37,6 +37,9 @@ typedef struct W_TabView {
#define DEFAULT_WIDTH 40
#define DEFAULT_HEIGHT 40
@@ -61,6 +64,19 @@ static WMView *W_TabViewItemView(WMTabViewItem *item);
static void recalcTabWidth(TabView *tPtr);
static void didResize(struct W_ViewDelegate*, WMView*);
static W_ViewDelegate delegate = {
NULL,
NULL,
didResize,
NULL,
NULL
};
static void
handleEvents(XEvent *event, void *data)
{
@@ -131,6 +147,7 @@ WMCreateTabView(WMWidget *parent)
return NULL;
}
tPtr->view->self = tPtr;
tPtr->view->delegate = &delegate;
tPtr->lightGray = WMCreateRGBColor(scr, 0xd9d9, 0xd9d9, 0xd9d9, False);
tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, False);
@@ -640,6 +657,32 @@ paintTabView(TabView *tPtr)
}
static void
rearrange(TabView *tPtr)
{
int i;
int width, height;
recalcTabWidth(tPtr);
width = tPtr->view->size.width - 3;
height = tPtr->view->size.height - tPtr->tabHeight - 3;
for (i = 0; i < tPtr->itemCount; i++) {
W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height);
}
if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view))
paintTabView(tPtr);
}
static void
didResize(struct W_ViewDelegate *deleg, WMView *view)
{
rearrange(view->self);
}
static void
destroyTabView(TabView *tPtr)
{

View File

@@ -561,6 +561,18 @@ W_SetViewBackgroundColor(W_View *view, WMColor *color)
}
void
W_SetViewCursor(W_View *view, Cursor cursor)
{
view->cursor = cursor;
if (W_VIEW_REALIZED(view)) {
XDefineCursor(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view), cursor);
} else {
view->attribFlags |= CWCursor;
view->attribs.cursor = cursor;
}
}
W_View*
W_FocusedViewOfToplevel(W_View *view)
@@ -714,4 +726,3 @@ WMGetViewScreenPosition(WMView *view)
}