mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-28 09:22:27 +01:00
fixed bugs of resized widgets
This commit is contained in:
@@ -58,7 +58,7 @@ changes since wmaker 0.62.1:
|
|||||||
the program name prepended to it. Similar to wwarning(), except that it
|
the program name prepended to it. Similar to wwarning(), except that it
|
||||||
doesn't add "warning:" in the output message.
|
doesn't add "warning:" in the output message.
|
||||||
- added WMBox widget
|
- added WMBox widget
|
||||||
|
- added W_SetViewCursor()
|
||||||
|
|
||||||
changes since wmaker 0.62.0:
|
changes since wmaker 0.62.0:
|
||||||
............................
|
............................
|
||||||
|
|||||||
@@ -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
|
void
|
||||||
testBox(WMScreen *scr)
|
testBox(WMScreen *scr)
|
||||||
{
|
{
|
||||||
WMWindow *win;
|
WMWindow *win;
|
||||||
WMBox *box;
|
WMBox *box, *hbox;
|
||||||
WMButton *btn;
|
WMButton *btn;
|
||||||
|
WMPopUpButton *pop;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
windowCount++;
|
windowCount++;
|
||||||
@@ -128,12 +137,19 @@ testBox(WMScreen *scr)
|
|||||||
win = WMCreateWindow(scr, "testBox");
|
win = WMCreateWindow(scr, "testBox");
|
||||||
WMSetWindowTitle(win, "Box");
|
WMSetWindowTitle(win, "Box");
|
||||||
WMSetWindowCloseAction(win, closeAction, NULL);
|
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||||
WMResizeWidget(win, 400, 300);
|
|
||||||
|
WMSetViewNotifySizeChanges(WMWidgetView(win), True);
|
||||||
|
|
||||||
box = WMCreateBox(win);
|
box = WMCreateBox(win);
|
||||||
WMMoveWidget(box, 50, 50);
|
WMSetBoxBorderWidth(box, 5);
|
||||||
WMResizeWidget(box, 300, 200);
|
|
||||||
// WMSetBoxHorizontal(box, True);
|
WMAddNotificationObserver(resizedWindow, box,
|
||||||
|
WMViewSizeDidChangeNotification,
|
||||||
|
WMWidgetView(win));
|
||||||
|
WMResizeWidget(win, 400, 300);
|
||||||
|
|
||||||
|
|
||||||
|
/* WMSetBoxHorizontal(box, True); */
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
btn = WMCreateCommandButton(box);
|
btn = WMCreateCommandButton(box);
|
||||||
WMSetButtonText(btn, "bla");
|
WMSetButtonText(btn, "bla");
|
||||||
@@ -141,6 +157,25 @@ testBox(WMScreen *scr)
|
|||||||
WMAddBoxSubview(box, WMWidgetView(btn), i&1, True, 20, 0, 5);
|
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);
|
WMRealizeWidget(win);
|
||||||
WMMapSubwidgets(win);
|
WMMapSubwidgets(win);
|
||||||
WMMapWidget(win);
|
WMMapWidget(win);
|
||||||
@@ -1239,7 +1274,9 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
testBox(scr);
|
testBox(scr);
|
||||||
#if 0
|
|
||||||
|
#if 0
|
||||||
|
testTabView(scr);
|
||||||
testList(scr);
|
testList(scr);
|
||||||
|
|
||||||
testProgressIndicator(scr);
|
testProgressIndicator(scr);
|
||||||
@@ -1259,7 +1296,6 @@ main(int argc, char **argv)
|
|||||||
testFrame(scr);
|
testFrame(scr);
|
||||||
|
|
||||||
|
|
||||||
testTabView(scr);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ typedef struct W_View {
|
|||||||
|
|
||||||
WMColor *backColor;
|
WMColor *backColor;
|
||||||
|
|
||||||
|
Cursor cursor;
|
||||||
|
|
||||||
Atom *droppableTypes;
|
Atom *droppableTypes;
|
||||||
struct W_DragSourceProcs *dragSourceProcs;
|
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_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,
|
void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||||
unsigned int height, WMReliefType relief);
|
unsigned int height, WMReliefType relief);
|
||||||
|
|
||||||
|
|||||||
17
WINGs/wbox.c
17
WINGs/wbox.c
@@ -82,12 +82,12 @@ rearrange(WMBox *box)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int x, y;
|
int x, y;
|
||||||
int w, h;
|
int w = 1, h = 1;
|
||||||
int total;
|
int total;
|
||||||
int expands = 0;
|
int expands = 0;
|
||||||
|
|
||||||
x = box->borderWidth;
|
x = box->borderWidth;
|
||||||
y = box->borderWidth;
|
y = box->borderWidth;
|
||||||
if (box->horizontal) {
|
if (box->horizontal) {
|
||||||
h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||||
total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||||
@@ -95,16 +95,19 @@ rearrange(WMBox *box)
|
|||||||
w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||||
total = WMWidgetHeight(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++) {
|
for (i = 0; i < box->subviewCount; i++) {
|
||||||
total -= box->subviews[i].minSize;
|
total -= box->subviews[i].minSize;
|
||||||
total -= box->subviews[i].space;
|
total -= box->subviews[i].space;
|
||||||
if (box->subviews[i].expand) {
|
if (box->subviews[i].expand) {
|
||||||
expands++;
|
expands++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < box->subviewCount; i++) {
|
for (i = 0; i < box->subviewCount; i++) {
|
||||||
if (box->horizontal) {
|
if (box->horizontal) {
|
||||||
w = box->subviews[i].minSize;
|
w = box->subviews[i].minSize;
|
||||||
@@ -115,8 +118,8 @@ rearrange(WMBox *box)
|
|||||||
if (box->subviews[i].expand)
|
if (box->subviews[i].expand)
|
||||||
h += total/expands;
|
h += total/expands;
|
||||||
}
|
}
|
||||||
W_ResizeView(box->subviews[i].view, w, h);
|
|
||||||
W_MoveView(box->subviews[i].view, x, y);
|
W_MoveView(box->subviews[i].view, x, y);
|
||||||
|
W_ResizeView(box->subviews[i].view, w, h);
|
||||||
if (box->horizontal) {
|
if (box->horizontal) {
|
||||||
x += w + box->subviews[i].space;
|
x += w + box->subviews[i].space;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ WMSetPopUpButtonSelectedItem(WMPopUpButton *bPtr, int index)
|
|||||||
paintPopUpButton(bPtr);
|
paintPopUpButton(bPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
WMGetPopUpButtonSelectedItem(WMPopUpButton *bPtr)
|
WMGetPopUpButtonSelectedItem(WMPopUpButton *bPtr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ WMCreateScrollView(WMWidget *parent)
|
|||||||
|
|
||||||
sPtr->view->delegate = &_ScrollViewViewDelegate;
|
sPtr->view->delegate = &_ScrollViewViewDelegate;
|
||||||
|
|
||||||
|
W_SetViewBackgroundColor(sPtr->viewport,
|
||||||
|
WMBlackColor(WMWidgetScreen(parent)));
|
||||||
sPtr->viewport->flags.mapWhenRealized = 1;
|
sPtr->viewport->flags.mapWhenRealized = 1;
|
||||||
|
|
||||||
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
|
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
|
||||||
@@ -163,7 +165,7 @@ reorganizeInterior(WMScrollView *sPtr)
|
|||||||
|
|
||||||
W_ResizeView(sPtr->viewport, cw, ch);
|
W_ResizeView(sPtr->viewport, cw, ch);
|
||||||
W_MoveView(sPtr->viewport, cx, cy);
|
W_MoveView(sPtr->viewport, cx, cy);
|
||||||
|
|
||||||
if (sPtr->flags.hasHScroller) {
|
if (sPtr->flags.hasHScroller) {
|
||||||
WMResizeWidget(sPtr->hScroller, hw, 20);
|
WMResizeWidget(sPtr->hScroller, hw, 20);
|
||||||
WMMoveWidget(sPtr->hScroller, hx, hy);
|
WMMoveWidget(sPtr->hScroller, hx, hy);
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ typedef struct W_TabView {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_WIDTH 40
|
#define DEFAULT_WIDTH 40
|
||||||
#define DEFAULT_HEIGHT 40
|
#define DEFAULT_HEIGHT 40
|
||||||
|
|
||||||
@@ -61,6 +64,19 @@ static WMView *W_TabViewItemView(WMTabViewItem *item);
|
|||||||
static void recalcTabWidth(TabView *tPtr);
|
static void recalcTabWidth(TabView *tPtr);
|
||||||
|
|
||||||
|
|
||||||
|
static void didResize(struct W_ViewDelegate*, WMView*);
|
||||||
|
|
||||||
|
static W_ViewDelegate delegate = {
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
didResize,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handleEvents(XEvent *event, void *data)
|
handleEvents(XEvent *event, void *data)
|
||||||
{
|
{
|
||||||
@@ -131,6 +147,7 @@ WMCreateTabView(WMWidget *parent)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tPtr->view->self = tPtr;
|
tPtr->view->self = tPtr;
|
||||||
|
tPtr->view->delegate = &delegate;
|
||||||
|
|
||||||
tPtr->lightGray = WMCreateRGBColor(scr, 0xd9d9, 0xd9d9, 0xd9d9, False);
|
tPtr->lightGray = WMCreateRGBColor(scr, 0xd9d9, 0xd9d9, 0xd9d9, False);
|
||||||
tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, 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
|
static void
|
||||||
destroyTabView(TabView *tPtr)
|
destroyTabView(TabView *tPtr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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_View*
|
||||||
W_FocusedViewOfToplevel(W_View *view)
|
W_FocusedViewOfToplevel(W_View *view)
|
||||||
@@ -714,4 +726,3 @@ WMGetViewScreenPosition(WMView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user