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