1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

WINGs: Remove wprogressindicator and tree

Neither of them used (not by wdm either)

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
This commit is contained in:
Tamas TEVESZ
2010-09-29 00:29:11 +02:00
committed by Carlos R. Mafra
parent d8eea6a155
commit b4cb488241
5 changed files with 0 additions and 538 deletions

View File

@@ -50,7 +50,6 @@ libWINGs_la_SOURCES = \
wpanel.c \
wpixmap.c \
wpopupbutton.c \
wprogressindicator.c \
wscroller.c \
wscrollview.c \
wslider.c \
@@ -73,7 +72,6 @@ libWUtil_la_SOURCES = \
notification.c \
proplist.c \
string.c \
tree.c \
userdefaults.c \
usleep.c \
wapplication.c \

View File

@@ -1392,23 +1392,6 @@ void WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag);
Bool WMGetPopUpButtonEnabled(WMPopUpButton *bPtr);
/* ....................................................................... */
WMProgressIndicator* WMCreateProgressIndicator(WMWidget *parent);
void WMSetProgressIndicatorMinValue(WMProgressIndicator *progressindicator, int value);
void WMSetProgressIndicatorMaxValue(WMProgressIndicator *progressindicator, int value);
void WMSetProgressIndicatorValue(WMProgressIndicator *progressindicator, int value);
int WMGetProgressIndicatorMinValue(WMProgressIndicator *progressindicator);
int WMGetProgressIndicatorMaxValue(WMProgressIndicator *progressindicator);
int WMGetProgressIndicatorValue(WMProgressIndicator *progressindicator);
/* ....................................................................... */
WMColorPanel* WMGetColorPanel(WMScreen *scrPtr);

View File

@@ -599,49 +599,6 @@ unsigned WMGetDataFormat(WMData *aData);
/* Storing data */
/*--------------------------------------------------------------------------*/
/* Generic Tree and TreeNode */
WMTreeNode* WMCreateTreeNode(void *data);
WMTreeNode* WMCreateTreeNodeWithDestructor(void *data, WMFreeDataProc *destructor);
WMTreeNode* WMInsertItemInTree(WMTreeNode *parent, int index, void *item);
#define WMAddItemToTree(parent, item) WMInsertItemInTree(parent, -1, item)
WMTreeNode* WMInsertNodeInTree(WMTreeNode *parent, int index, WMTreeNode *aNode);
#define WMAddNodeToTree(parent, aNode) WMInsertNodeInTree(parent, -1, aNode)
void WMDestroyTreeNode(WMTreeNode *aNode);
void WMDeleteLeafForTreeNode(WMTreeNode *aNode, int index);
void WMRemoveLeafForTreeNode(WMTreeNode *aNode, void *leaf);
void* WMReplaceDataForTreeNode(WMTreeNode *aNode, void *newData);
void* WMGetDataForTreeNode(WMTreeNode *aNode);
int WMGetTreeNodeDepth(WMTreeNode *aNode);
WMTreeNode* WMGetParentForTreeNode(WMTreeNode *aNode);
/* Sort only the leaves of the passed node */
void WMSortLeavesForTreeNode(WMTreeNode *aNode, WMCompareDataProc *comparer);
/* Sort all tree recursively starting from the passed node */
void WMSortTree(WMTreeNode *aNode, WMCompareDataProc *comparer);
/* Returns the first node which matches node's data with cdata by 'match' */
WMTreeNode* WMFindInTree(WMTreeNode *aTree, WMMatchDataProc *match, void *cdata);
/* Returns first tree node that has data == cdata */
#define WMGetFirstInTree(aTree, cdata) WMFindInTree(aTree, NULL, cdata)
/*--------------------------------------------------------------------------*/

View File

@@ -1,231 +0,0 @@
#include <string.h>
#include "WUtil.h"
typedef struct W_TreeNode {
void *data;
/*unsigned int uflags:16; */
WMArray *leaves;
int depth;
struct W_TreeNode *parent;
WMFreeDataProc *destructor;
} W_TreeNode;
void destroyNode(void *data)
{
WMTreeNode *aNode = (WMTreeNode *) data;
if (aNode->destructor) {
(*aNode->destructor) (aNode->data);
}
if (aNode->leaves) {
WMFreeArray(aNode->leaves);
}
wfree(aNode);
}
WMTreeNode *WMCreateTreeNode(void *data)
{
return WMCreateTreeNodeWithDestructor(data, NULL);
}
WMTreeNode *WMCreateTreeNodeWithDestructor(void *data, WMFreeDataProc * destructor)
{
WMTreeNode *aNode;
aNode = (WMTreeNode *) wmalloc(sizeof(W_TreeNode));
aNode->destructor = destructor;
aNode->data = data;
aNode->parent = NULL;
aNode->depth = 0;
aNode->leaves = NULL;
/*aNode->leaves = WMCreateArrayWithDestructor(1, destroyNode); */
return aNode;
}
WMTreeNode *WMInsertItemInTree(WMTreeNode * parent, int index, void *item)
{
WMTreeNode *aNode;
wassertrv(parent != NULL, NULL);
aNode = WMCreateTreeNodeWithDestructor(item, parent->destructor);
aNode->parent = parent;
aNode->depth = parent->depth + 1;
if (!parent->leaves) {
parent->leaves = WMCreateArrayWithDestructor(1, destroyNode);
}
if (index < 0) {
WMAddToArray(parent->leaves, aNode);
} else {
WMInsertInArray(parent->leaves, index, aNode);
}
return aNode;
}
static void updateNodeDepth(WMTreeNode * aNode, int depth)
{
int i;
aNode->depth = depth;
if (aNode->leaves) {
for (i = 0; i < WMGetArrayItemCount(aNode->leaves); i++) {
updateNodeDepth(WMGetFromArray(aNode->leaves, i), depth + 1);
}
}
}
WMTreeNode *WMInsertNodeInTree(WMTreeNode * parent, int index, WMTreeNode * aNode)
{
wassertrv(parent != NULL, NULL);
wassertrv(aNode != NULL, NULL);
aNode->parent = parent;
updateNodeDepth(aNode, parent->depth + 1);
if (!parent->leaves) {
parent->leaves = WMCreateArrayWithDestructor(1, destroyNode);
}
if (index < 0) {
WMAddToArray(parent->leaves, aNode);
} else {
WMInsertInArray(parent->leaves, index, aNode);
}
return aNode;
}
void WMDestroyTreeNode(WMTreeNode * aNode)
{
wassertr(aNode != NULL);
if (aNode->parent && aNode->parent->leaves) {
WMRemoveFromArray(aNode->parent->leaves, aNode);
} else {
destroyNode(aNode);
}
}
void WMDeleteLeafForTreeNode(WMTreeNode * aNode, int index)
{
wassertr(aNode != NULL);
wassertr(aNode->leaves != NULL);
WMDeleteFromArray(aNode->leaves, index);
}
static int sameData(const void *item, const void *data)
{
return (((WMTreeNode *) item)->data == data);
}
void WMRemoveLeafForTreeNode(WMTreeNode * aNode, void *leaf)
{
int index;
wassertr(aNode != NULL);
wassertr(aNode->leaves != NULL);
index = WMFindInArray(aNode->leaves, sameData, leaf);
if (index != WANotFound) {
WMDeleteFromArray(aNode->leaves, index);
}
}
void *WMReplaceDataForTreeNode(WMTreeNode * aNode, void *newData)
{
void *old;
wassertrv(aNode != NULL, NULL);
old = aNode->data;
aNode->data = newData;
return old;
}
void *WMGetDataForTreeNode(WMTreeNode * aNode)
{
return aNode->data;
}
int WMGetTreeNodeDepth(WMTreeNode * aNode)
{
return aNode->depth;
}
WMTreeNode *WMGetParentForTreeNode(WMTreeNode * aNode)
{
return aNode->parent;
}
void WMSortLeavesForTreeNode(WMTreeNode * aNode, WMCompareDataProc * comparer)
{
wassertr(aNode != NULL);
if (aNode->leaves) {
WMSortArray(aNode->leaves, comparer);
}
}
static void sortLeavesForNode(WMTreeNode * aNode, WMCompareDataProc * comparer)
{
int i;
if (!aNode->leaves)
return;
WMSortArray(aNode->leaves, comparer);
for (i = 0; i < WMGetArrayItemCount(aNode->leaves); i++) {
sortLeavesForNode(WMGetFromArray(aNode->leaves, i), comparer);
}
}
void WMSortTree(WMTreeNode * aNode, WMCompareDataProc * comparer)
{
wassertr(aNode != NULL);
sortLeavesForNode(aNode, comparer);
}
static WMTreeNode *findNodeInTree(WMTreeNode * aNode, WMMatchDataProc * match, void *cdata)
{
if (match == NULL) {
if (aNode->data == cdata) {
return aNode;
}
} else {
if ((*match) (aNode->data, cdata)) {
return aNode;
}
}
if (aNode->leaves) {
WMTreeNode *leaf;
int i;
for (i = 0; i < WMGetArrayItemCount(aNode->leaves); i++) {
leaf = findNodeInTree(WMGetFromArray(aNode->leaves, i), match, cdata);
if (leaf) {
return leaf;
}
}
}
return NULL;
}
WMTreeNode *WMFindInTree(WMTreeNode * aTree, WMMatchDataProc * match, void *cdata)
{
wassertrv(aTree != NULL, NULL);
return findNodeInTree(aTree, match, cdata);
}

View File

@@ -1,245 +0,0 @@
/*
* Original idea and implementation by Frederik Schueler <fr.schueler@netsurf.de>
* Rewritten by Pascal Hofstee <daeron@windowmaker.info>
* - Added options to set min/max values
* - centralized drawing into one pain function
*/
#include "WINGsP.h"
typedef struct W_ProgressIndicator {
W_Class widgetClass;
W_View *view;
int value;
int minValue;
int maxValue;
void *clientData;
} ProgressIndicator;
#define DEFAULT_PROGRESS_INDICATOR_WIDTH 276
#define DEFAULT_PROGRESS_INDICATOR_HEIGHT 16
/* define if only the ticks within the progress region should be displayed */
#undef SHOW_PROGRESS_TICKS_ONLY
static void didResizeProgressIndicator();
W_ViewDelegate _ProgressIndicatorDelegate = {
NULL,
NULL,
didResizeProgressIndicator,
NULL,
NULL
};
static void destroyProgressIndicator(ProgressIndicator * pPtr);
static void paintProgressIndicator(ProgressIndicator * pPtr);
static void handleEvents(XEvent * event, void *data);
WMProgressIndicator *WMCreateProgressIndicator(WMWidget * parent)
{
ProgressIndicator *pPtr;
pPtr = wmalloc(sizeof(ProgressIndicator));
pPtr->widgetClass = WC_ProgressIndicator;
pPtr->view = W_CreateView(W_VIEW(parent));
if (!pPtr->view) {
wfree(pPtr);
return NULL;
}
pPtr->view->self = pPtr;
pPtr->view->delegate = &_ProgressIndicatorDelegate;
WMCreateEventHandler(pPtr->view, ExposureMask | StructureNotifyMask, handleEvents, pPtr);
W_ResizeView(pPtr->view, DEFAULT_PROGRESS_INDICATOR_WIDTH, DEFAULT_PROGRESS_INDICATOR_HEIGHT);
/* Initialize ProgressIndicator Values */
pPtr->value = 0;
pPtr->minValue = 0;
pPtr->maxValue = 100;
return pPtr;
}
void WMSetProgressIndicatorMinValue(WMProgressIndicator * progressindicator, int value)
{
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
progressindicator->minValue = value;
if (progressindicator->value < value) {
progressindicator->value = value;
if (progressindicator->view->flags.mapped) {
paintProgressIndicator(progressindicator);
}
}
}
void WMSetProgressIndicatorMaxValue(WMProgressIndicator * progressindicator, int value)
{
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
progressindicator->maxValue = value;
if (progressindicator->value > value) {
progressindicator->value = value;
if (progressindicator->view->flags.mapped) {
paintProgressIndicator(progressindicator);
}
}
}
void WMSetProgressIndicatorValue(WMProgressIndicator * progressindicator, int value)
{
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
progressindicator->value = value;
/* Check if value is within min/max-range */
if (progressindicator->minValue > value)
progressindicator->value = progressindicator->minValue;
if (progressindicator->maxValue < value)
progressindicator->value = progressindicator->maxValue;
if (progressindicator->view->flags.mapped) {
paintProgressIndicator(progressindicator);
}
}
int WMGetProgressIndicatorMinValue(WMProgressIndicator * progressindicator)
{
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
return progressindicator->minValue;
}
int WMGetProgressIndicatorMaxValue(WMProgressIndicator * progressindicator)
{
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
return progressindicator->maxValue;
}
int WMGetProgressIndicatorValue(WMProgressIndicator * progressindicator)
{
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
return progressindicator->value;
}
static void didResizeProgressIndicator(W_ViewDelegate * self, WMView * view)
{
WMProgressIndicator *pPtr = (WMProgressIndicator *) view->self;
int width = pPtr->view->size.width;
int height = pPtr->view->size.height;
assert(width > 0);
assert(height > 0);
}
static void paintProgressIndicator(ProgressIndicator * pPtr)
{
W_Screen *scr = pPtr->view->screen;
GC bgc;
GC wgc;
GC lgc;
GC dgc;
WMSize size = pPtr->view->size;
int perc, w, h;
double unit, i;
Pixmap buffer;
bgc = WMColorGC(scr->black);
wgc = WMColorGC(scr->white);
lgc = WMColorGC(scr->gray);
dgc = WMColorGC(scr->darkGray);
unit = (double)(size.width - 3.0) / 100;
buffer = XCreatePixmap(scr->display, pPtr->view->window, size.width, size.height, scr->depth);
XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width, size.height);
/* Calculate size of Progress to draw and paint ticks */
perc = (pPtr->value - pPtr->minValue) * 100 / (pPtr->maxValue - pPtr->minValue);
w = (int)((double)(perc * unit));
h = size.height - 2;
if (w > (size.width - 3))
w = size.width - 3;
if (w > 0) {
XFillRectangle(scr->display, buffer, lgc, 2, 1, w, h);
XFillRectangle(scr->display, buffer, scr->stippleGC, 2, 1, w, h);
W_DrawRelief(scr, buffer, 2, 1, w, h, WRFlat);
/* Draw Progress Marks */
i = (5.0 * unit);
#ifdef SHOW_PROGRESS_TICKS_ONLY
while ((int)i < w + 5) {
#else
while ((int)i < (size.width - 3)) {
#endif
XDrawLine(scr->display, buffer, dgc, (int)i + 2, h - 1, i + 2, h - 3);
i += (5.0 * unit);
#ifdef SHOW_PROGRESS_TICKS_ONLY
if ((int)i >= w)
break;
#endif
XDrawLine(scr->display, buffer, dgc, (int)i + 2, h - 1, i + 2, h - 6);
i += (5.0 * unit);
}
}
XDrawLine(scr->display, buffer, bgc, w + 2, 1, w + 2, h + 1);
XDrawLine(scr->display, buffer, lgc, 2, h, w + 2, h);
XDrawLine(scr->display, buffer, dgc, 0, 0, 0, size.height - 1);
XDrawLine(scr->display, buffer, dgc, 0, 0, size.width, 0);
XDrawLine(scr->display, buffer, bgc, 1, 1, 1, size.height - 1);
XDrawLine(scr->display, buffer, bgc, 1, 1, size.width - 1, 1);
XDrawLine(scr->display, buffer, wgc, size.width - 1, 0, size.width - 1, size.height - 1);
XDrawLine(scr->display, buffer, wgc, 0, size.height - 1, size.width - 1, size.height - 1);
XCopyArea(scr->display, buffer, pPtr->view->window, scr->copyGC, 0, 0, size.width, size.height, 0, 0);
XFreePixmap(scr->display, buffer);
}
static void handleEvents(XEvent * event, void *data)
{
ProgressIndicator *pPtr = (ProgressIndicator *) data;
CHECK_CLASS(data, WC_ProgressIndicator);
switch (event->type) {
case Expose:
if (event->xexpose.count != 0)
break;
paintProgressIndicator(pPtr);
break;
case DestroyNotify:
destroyProgressIndicator(pPtr);
break;
}
}
static void destroyProgressIndicator(ProgressIndicator * pPtr)
{
WMRemoveNotificationObserver(pPtr);
wfree(pPtr);
}