mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-28 09:22:27 +01:00
fixed various bugs
This commit is contained in:
@@ -611,16 +611,14 @@ static WMRange columnsInRect(WMTableView *table, WMRect rect)
|
|||||||
j = 1;
|
j = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
range.count++;
|
||||||
if (width > rect.pos.x + rect.size.width) {
|
if (width > rect.pos.x + rect.size.width) {
|
||||||
range.count = i - range.position;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
width += column->width;
|
width += column->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
range.count = WMAX(1, WMIN(range.count, totalColumns - range.position));
|
range.count = WMAX(1, WMIN(range.count, totalColumns - range.position));
|
||||||
|
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,7 +679,6 @@ static void setRowSelected(WMTableView *table, unsigned row, Bool flag)
|
|||||||
{
|
{
|
||||||
int repaint = 0;
|
int repaint = 0;
|
||||||
|
|
||||||
|
|
||||||
if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) {
|
if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) {
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
WMRemoveFromArray(table->selectedRows, (void*)row);
|
WMRemoveFromArray(table->selectedRows, (void*)row);
|
||||||
@@ -693,8 +690,7 @@ static void setRowSelected(WMTableView *table, unsigned row, Bool flag)
|
|||||||
repaint = 1;
|
repaint = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (repaint && row < table->rows) {
|
||||||
if (repaint) {
|
|
||||||
drawFullRow(table, row);
|
drawFullRow(table, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -725,7 +721,7 @@ static void repaintTable(WMTableView *table, int x, int y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rows = rowsInRect(table, rect);
|
rows = rowsInRect(table, rect);
|
||||||
for (i = rows.position;
|
for (i = rows.position;
|
||||||
i < WMIN(rows.position+rows.count + 1, table->rows);
|
i < WMIN(rows.position+rows.count + 1, table->rows);
|
||||||
i++) {
|
i++) {
|
||||||
drawRow(table, i, rect);
|
drawRow(table, i, rect);
|
||||||
@@ -773,16 +769,17 @@ void WMSelectTableViewRow(WMTableView *table, int row)
|
|||||||
if (table->clickedRow >= 0)
|
if (table->clickedRow >= 0)
|
||||||
setRowSelected(table, table->clickedRow, False);
|
setRowSelected(table, table->clickedRow, False);
|
||||||
|
|
||||||
if (row <= table->rows)
|
if (row >= table->rows) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setRowSelected(table, row, True);
|
setRowSelected(table, row, True);
|
||||||
table->clickedRow = row;
|
table->clickedRow = row;
|
||||||
|
|
||||||
if (table->action)
|
if (table->action)
|
||||||
(*table->action)(table, table->clientData);
|
(*table->action)(table, table->clientData);
|
||||||
WMPostNotificationName(WMTableViewSelectionDidChangeNotification,
|
WMPostNotificationName(WMTableViewSelectionDidChangeNotification,
|
||||||
table, NULL);
|
table, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -790,10 +787,22 @@ void WMReloadTableView(WMTableView *table)
|
|||||||
{
|
{
|
||||||
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
|
||||||
|
/* when this is called, nothing in the table can be assumed to be
|
||||||
|
* like the last time we accessed it (ie, rows might have disappeared) */
|
||||||
|
|
||||||
|
WMEmptyArray(table->selectedRows);
|
||||||
|
|
||||||
|
if (table->clickedRow >= 0) {
|
||||||
|
table->clickedRow = -1;
|
||||||
|
|
||||||
|
if (table->action)
|
||||||
|
(*table->action)(table, table->clientData);
|
||||||
|
WMPostNotificationName(WMTableViewSelectionDidChangeNotification,
|
||||||
|
table, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
repaintTable(table, 0, 0,
|
repaintTable(table, 0, 0,
|
||||||
W_VIEW_WIDTH(table->tableView), rect.size.height);
|
W_VIEW_WIDTH(table->tableView), rect.size.height);
|
||||||
|
|
||||||
table->clickedRow = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -863,7 +872,7 @@ static void handleEvents(XEvent *event, void *data)
|
|||||||
|
|
||||||
if (event->xexpose.serial == 0) {
|
if (event->xexpose.serial == 0) {
|
||||||
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
|
||||||
repaintTable(table, rect.pos.x, rect.pos.y,
|
repaintTable(table, rect.pos.x, rect.pos.y,
|
||||||
rect.size.width, rect.size.height);
|
rect.size.width, rect.size.height);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1617,6 +1617,8 @@ WMTabView *WMCreateTabView(WMWidget *parent);
|
|||||||
|
|
||||||
void WMSetTabViewType(WMTabView *tPtr, WMTabViewType type);
|
void WMSetTabViewType(WMTabView *tPtr, WMTabViewType type);
|
||||||
|
|
||||||
|
void WMSetTabViewEnabled(WMTabView *tPtr, Bool flag);
|
||||||
|
|
||||||
void WMSetTabViewFont(WMTabView *tPtr, WMFont *font);
|
void WMSetTabViewFont(WMTabView *tPtr, WMFont *font);
|
||||||
|
|
||||||
void WMAddItemInTabView(WMTabView *tPtr, WMTabViewItem *item);
|
void WMAddItemInTabView(WMTabView *tPtr, WMTabViewItem *item);
|
||||||
|
|||||||
@@ -230,6 +230,8 @@ WMSetBoxExpandsToParent(WMBox *box)
|
|||||||
WMViewSizeDidChangeNotification,
|
WMViewSizeDidChangeNotification,
|
||||||
W_VIEW(box)->parent);
|
W_VIEW(box)->parent);
|
||||||
WMSetViewNotifySizeChanges(W_VIEW(box)->parent, True);
|
WMSetViewNotifySizeChanges(W_VIEW(box)->parent, True);
|
||||||
|
WMResizeWidget(box, W_VIEW(box)->parent->size.width,
|
||||||
|
W_VIEW(box)->parent->size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
char *alternateButton, char *otherButton)
|
char *alternateButton, char *otherButton)
|
||||||
{
|
{
|
||||||
WMAlertPanel *panel;
|
WMAlertPanel *panel;
|
||||||
int x, dw=0, aw=0, ow=0, w;
|
int dw=0, aw=0, ow=0, w;
|
||||||
WMBox *hbox;
|
WMBox *hbox;
|
||||||
|
|
||||||
|
|
||||||
@@ -130,6 +130,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
WMMapWidget(panel->vbox);
|
WMMapWidget(panel->vbox);
|
||||||
|
|
||||||
hbox = WMCreateBox(panel->vbox);
|
hbox = WMCreateBox(panel->vbox);
|
||||||
|
WMSetBoxBorderWidth(hbox, 10);
|
||||||
WMSetBoxHorizontal(hbox, True);
|
WMSetBoxHorizontal(hbox, True);
|
||||||
WMMapWidget(hbox);
|
WMMapWidget(hbox);
|
||||||
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 80, 0, 5);
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 80, 0, 5);
|
||||||
@@ -139,7 +140,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
WMMapWidget(panel->iLbl);
|
WMMapWidget(panel->iLbl);
|
||||||
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 10);
|
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 10);
|
||||||
|
|
||||||
if (scrPtr->applicationIcon) {
|
if (scrPtr->applicationIcon) {
|
||||||
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +179,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hbox = WMCreateBox(panel->vbox);
|
hbox = WMCreateBox(panel->vbox);
|
||||||
|
WMSetBoxBorderWidth(hbox, 10);
|
||||||
WMSetBoxHorizontal(hbox, True);
|
WMSetBoxHorizontal(hbox, True);
|
||||||
WMMapWidget(hbox);
|
WMMapWidget(hbox);
|
||||||
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 24, 0, 0);
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 24, 0, 0);
|
||||||
@@ -215,37 +217,29 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
dw += t/3;
|
dw += t/3;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = 400;
|
|
||||||
|
|
||||||
if (defaultButton) {
|
if (defaultButton) {
|
||||||
x -= dw + 10;
|
panel->defBtn = WMCreateCommandButton(hbox);
|
||||||
|
|
||||||
panel->defBtn = WMCreateCommandButton(panel->win);
|
|
||||||
WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel);
|
||||||
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn),
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn),
|
||||||
False, True, dw, 0, 5);
|
False, True, dw, 0, 0);
|
||||||
WMSetButtonText(panel->defBtn, defaultButton);
|
WMSetButtonText(panel->defBtn, defaultButton);
|
||||||
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow);
|
||||||
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow);
|
||||||
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
WMSetButtonImagePosition(panel->defBtn, WIPRight);
|
||||||
}
|
}
|
||||||
if (alternateButton) {
|
if (alternateButton) {
|
||||||
x -= aw + 10;
|
panel->altBtn = WMCreateCommandButton(hbox);
|
||||||
|
|
||||||
panel->altBtn = WMCreateCommandButton(panel->win);
|
|
||||||
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->altBtn),
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->altBtn),
|
||||||
False, True, aw, 0, 5);
|
False, True, aw, 0, 5);
|
||||||
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel);
|
||||||
WMSetButtonText(panel->altBtn, alternateButton);
|
WMSetButtonText(panel->altBtn, alternateButton);
|
||||||
}
|
}
|
||||||
if (otherButton) {
|
if (otherButton) {
|
||||||
x -= ow + 10;
|
panel->othBtn = WMCreateCommandButton(hbox);
|
||||||
|
|
||||||
panel->othBtn = WMCreateCommandButton(panel->win);
|
|
||||||
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
|
WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel);
|
||||||
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->othBtn),
|
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->othBtn),
|
||||||
False, True, ow, 0, 5);
|
False, True, ow, 0, 5);
|
||||||
WMSetButtonText(panel->othBtn, otherButton);
|
WMSetButtonText(panel->othBtn, otherButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
WMMapSubwidgets(hbox);
|
WMMapSubwidgets(hbox);
|
||||||
|
|||||||
@@ -588,7 +588,10 @@ handleEvents(XEvent *event, void *data)
|
|||||||
case Expose:
|
case Expose:
|
||||||
if (event->xexpose.count!=0)
|
if (event->xexpose.count!=0)
|
||||||
break;
|
break;
|
||||||
paintScrollView(sPtr);
|
if (event->xexpose.serial == 0) /* means it's artificial */
|
||||||
|
W_RedisplayView(sPtr->contentView);
|
||||||
|
else
|
||||||
|
paintScrollView(sPtr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
@@ -601,9 +604,7 @@ handleEvents(XEvent *event, void *data)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
destroyScrollView(ScrollView *sPtr)
|
destroyScrollView(ScrollView *sPtr)
|
||||||
{
|
{
|
||||||
puts("destroyScrollView not implemented");
|
|
||||||
|
|
||||||
wfree(sPtr);
|
wfree(sPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ typedef struct W_TabView {
|
|||||||
WMTitlePosition titlePosition:4;
|
WMTitlePosition titlePosition:4;
|
||||||
WMTabViewType type:2;
|
WMTabViewType type:2;
|
||||||
|
|
||||||
|
unsigned enabled:1;
|
||||||
unsigned tabbed:1;
|
unsigned tabbed:1;
|
||||||
unsigned dontFitAll:1;
|
unsigned dontFitAll:1;
|
||||||
unsigned bordered:1;
|
unsigned bordered:1;
|
||||||
@@ -54,7 +55,8 @@ static void paintTabView(TabView *tPtr);
|
|||||||
|
|
||||||
static void W_SetTabViewItemParent(WMTabViewItem *item, WMTabView *parent);
|
static void W_SetTabViewItemParent(WMTabViewItem *item, WMTabView *parent);
|
||||||
|
|
||||||
static void W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect);
|
static void W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect,
|
||||||
|
Bool enabled);
|
||||||
|
|
||||||
static void W_UnmapTabViewItem(WMTabViewItem *item);
|
static void W_UnmapTabViewItem(WMTabViewItem *item);
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ handleEvents(XEvent *event, void *data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
{
|
if (tPtr->flags.enabled) {
|
||||||
WMTabViewItem *item = WMTabViewItemAtPoint(tPtr,
|
WMTabViewItem *item = WMTabViewItemAtPoint(tPtr,
|
||||||
event->xbutton.x,
|
event->xbutton.x,
|
||||||
event->xbutton.y);
|
event->xbutton.y);
|
||||||
@@ -209,6 +211,7 @@ WMCreateTabView(WMWidget *parent)
|
|||||||
tPtr->flags.type = WTTopTabsBevelBorder;
|
tPtr->flags.type = WTTopTabsBevelBorder;
|
||||||
tPtr->flags.bordered = 1;
|
tPtr->flags.bordered = 1;
|
||||||
tPtr->flags.uniformTabs = 0;
|
tPtr->flags.uniformTabs = 0;
|
||||||
|
tPtr->flags.enabled = 1;
|
||||||
|
|
||||||
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|
||||||
|ButtonPressMask, handleEvents, tPtr);
|
|ButtonPressMask, handleEvents, tPtr);
|
||||||
@@ -250,6 +253,15 @@ WMAddItemInTabView(WMTabView *tPtr, WMTabViewItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMSetTabViewEnabled(WMTabView *tPtr, Bool flag)
|
||||||
|
{
|
||||||
|
tPtr->flags.enabled = flag;
|
||||||
|
if (W_VIEW_REALIZED(tPtr->view))
|
||||||
|
paintTabView(tPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
||||||
{
|
{
|
||||||
@@ -737,7 +749,8 @@ paintTabView(TabView *tPtr)
|
|||||||
rect.pos.y = ty;
|
rect.pos.y = ty;
|
||||||
rect.size.width = W_TabViewItemTabWidth(tPtr->items[first+i]);
|
rect.size.width = W_TabViewItemTabWidth(tPtr->items[first+i]);
|
||||||
rect.size.height = theight;
|
rect.size.height = theight;
|
||||||
W_DrawLabel(tPtr->items[first+i], buffer, rect);
|
W_DrawLabel(tPtr->items[first+i], buffer, rect,
|
||||||
|
tPtr->flags.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moreAtLeft) {
|
if (moreAtLeft) {
|
||||||
@@ -858,15 +871,16 @@ W_SetTabViewItemParent(WMTabViewItem *item, WMTabView *parent)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect)
|
W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect, Bool enabled)
|
||||||
{
|
{
|
||||||
WMScreen *scr = W_VIEW(item->tabView)->screen;
|
WMScreen *scr = W_VIEW(item->tabView)->screen;
|
||||||
|
|
||||||
if (!item->label)
|
if (!item->label)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WMDrawString(scr, d, WMColorGC(scr->black), item->tabView->font,
|
WMDrawString(scr, d, WMColorGC(enabled ? scr->black : scr->darkGray),
|
||||||
rect.pos.x, rect.pos.y, item->label, strlen(item->label));
|
item->tabView->font, rect.pos.x, rect.pos.y,
|
||||||
|
item->label, strlen(item->label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user