mirror of
https://github.com/gryf/wmaker.git
synced 2026-03-20 09:43:32 +01:00
WINGs: refactor wlist
This patch refactors wlist to bring some improvements to not count the list of entries at each loop iteration.
This commit is contained in:
committed by
Carlos R. Mafra
parent
6d0953bc22
commit
3f5280987e
@@ -495,15 +495,16 @@ static void paintItem(List * lPtr, int index)
|
|||||||
static void paintList(List * lPtr)
|
static void paintList(List * lPtr)
|
||||||
{
|
{
|
||||||
W_Screen *scrPtr = lPtr->view->screen;
|
W_Screen *scrPtr = lPtr->view->screen;
|
||||||
int i, lim;
|
int i, lim, itemCount;
|
||||||
|
|
||||||
if (!lPtr->view->flags.mapped)
|
if (!lPtr->view->flags.mapped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (WMGetArrayItemCount(lPtr->items) > 0) {
|
itemCount = WMGetArrayItemCount(lPtr->items);
|
||||||
if (lPtr->topItem + lPtr->fullFitLines + lPtr->flags.dontFitAll > WMGetArrayItemCount(lPtr->items)) {
|
if (itemCount > 0) {
|
||||||
|
if (lPtr->topItem + lPtr->fullFitLines + lPtr->flags.dontFitAll > itemCount) {
|
||||||
|
|
||||||
lim = WMGetArrayItemCount(lPtr->items) - lPtr->topItem;
|
lim = itemCount - lPtr->topItem;
|
||||||
XClearArea(scrPtr->display, lPtr->view->window, 19,
|
XClearArea(scrPtr->display, lPtr->view->window, 19,
|
||||||
2 + lim * lPtr->itemHeight, lPtr->view->size.width - 21,
|
2 + lim * lPtr->itemHeight, lPtr->view->size.width - 21,
|
||||||
lPtr->view->size.height - lim * lPtr->itemHeight - 3, False);
|
lPtr->view->size.height - lim * lPtr->itemHeight - 3, False);
|
||||||
@@ -820,7 +821,7 @@ void WMSetListSelectionToRange(WMList * lPtr, WMRange range)
|
|||||||
|
|
||||||
void WMSelectAllListItems(WMList * lPtr)
|
void WMSelectAllListItems(WMList * lPtr)
|
||||||
{
|
{
|
||||||
int i;
|
int i, itemCount;
|
||||||
WMListItem *item;
|
WMListItem *item;
|
||||||
|
|
||||||
if (!lPtr->flags.allowMultipleSelection)
|
if (!lPtr->flags.allowMultipleSelection)
|
||||||
@@ -833,7 +834,8 @@ void WMSelectAllListItems(WMList * lPtr)
|
|||||||
WMFreeArray(lPtr->selectedItems);
|
WMFreeArray(lPtr->selectedItems);
|
||||||
lPtr->selectedItems = WMCreateArrayWithArray(lPtr->items);
|
lPtr->selectedItems = WMCreateArrayWithArray(lPtr->items);
|
||||||
|
|
||||||
for (i = 0; i < WMGetArrayItemCount(lPtr->items); i++) {
|
itemCount = WMGetArrayItemCount(lPtr->items);
|
||||||
|
for (i = 0; i < itemCount; i++) {
|
||||||
item = WMGetFromArray(lPtr->items, i);
|
item = WMGetFromArray(lPtr->items, i);
|
||||||
if (!item->selected) {
|
if (!item->selected) {
|
||||||
item->selected = 1;
|
item->selected = 1;
|
||||||
@@ -859,10 +861,11 @@ void WMSelectAllListItems(WMList * lPtr)
|
|||||||
*/
|
*/
|
||||||
static void unselectAllListItems(WMList * lPtr, WMListItem * exceptThis)
|
static void unselectAllListItems(WMList * lPtr, WMListItem * exceptThis)
|
||||||
{
|
{
|
||||||
int i;
|
int i, itemCount;
|
||||||
WMListItem *item;
|
WMListItem *item;
|
||||||
|
|
||||||
for (i = 0; i < WMGetArrayItemCount(lPtr->items); i++) {
|
itemCount = WMGetArrayItemCount(lPtr->items);
|
||||||
|
for (i = 0; i < itemCount; i++) {
|
||||||
item = WMGetFromArray(lPtr->items, i);
|
item = WMGetFromArray(lPtr->items, i);
|
||||||
if (item != exceptThis && item->selected) {
|
if (item != exceptThis && item->selected) {
|
||||||
item->selected = 0;
|
item->selected = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user