mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
replaced linked lists with WMBag, added progress indicator
This commit is contained in:
@@ -3,6 +3,8 @@ changes since wmaker 0.60.0:
|
|||||||
|
|
||||||
- added WMScreenWidth() and WMScreenHeight() functions.
|
- added WMScreenWidth() and WMScreenHeight() functions.
|
||||||
- fixed some problems when compiling with non gcc compilers.
|
- fixed some problems when compiling with non gcc compilers.
|
||||||
|
- added WMSetButtonImageDefault() (craig nellist <crn@ozemail.com.au>)
|
||||||
|
- added WMBag (array/list)
|
||||||
- added libWUtil, a library that is a subset of libWINGs. It contains utils
|
- added libWUtil, a library that is a subset of libWINGs. It contains utils
|
||||||
that can be used in writing non-GUI programs. They include: hashes,
|
that can be used in writing non-GUI programs. They include: hashes,
|
||||||
notifications, input/idle/timer handlers, user defaults database handling,
|
notifications, input/idle/timer handlers, user defaults database handling,
|
||||||
@@ -47,6 +49,7 @@ changes since wmaker 0.60.0:
|
|||||||
WMAddInputHandler(int fd, int condition, WMInputProc *proc,
|
WMAddInputHandler(int fd, int condition, WMInputProc *proc,
|
||||||
void *clientData);
|
void *clientData);
|
||||||
WMDeleteInputHandler(WMHandlerID handlerID);
|
WMDeleteInputHandler(WMHandlerID handlerID);
|
||||||
|
- added progress indicator widget
|
||||||
|
|
||||||
|
|
||||||
changes since wmaker 0.53.0:
|
changes since wmaker 0.53.0:
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ libWINGs_a_SOURCES = \
|
|||||||
WINGs.h \
|
WINGs.h \
|
||||||
WINGsP.h \
|
WINGsP.h \
|
||||||
configuration.c \
|
configuration.c \
|
||||||
llist.h \
|
|
||||||
llist.c \
|
|
||||||
international.c \
|
international.c \
|
||||||
notification.c \
|
notification.c \
|
||||||
selection.c \
|
selection.c \
|
||||||
@@ -86,6 +84,7 @@ libWINGs_a_SOURCES = \
|
|||||||
wpanel.c \
|
wpanel.c \
|
||||||
wpixmap.c \
|
wpixmap.c \
|
||||||
wpopupbutton.c \
|
wpopupbutton.c \
|
||||||
|
wprogressindicator.c \
|
||||||
wscroller.c \
|
wscroller.c \
|
||||||
wscrollview.c \
|
wscrollview.c \
|
||||||
wslider.c \
|
wslider.c \
|
||||||
@@ -96,6 +95,7 @@ libWINGs_a_SOURCES = \
|
|||||||
wview.c \
|
wview.c \
|
||||||
error.c \
|
error.c \
|
||||||
findfile.c \
|
findfile.c \
|
||||||
|
bag.c \
|
||||||
hashtable.c \
|
hashtable.c \
|
||||||
memory.c \
|
memory.c \
|
||||||
usleep.c
|
usleep.c
|
||||||
@@ -104,8 +104,7 @@ libWINGs_a_SOURCES = \
|
|||||||
libWUtil_a_SOURCES = \
|
libWUtil_a_SOURCES = \
|
||||||
WINGs.h \
|
WINGs.h \
|
||||||
WINGsP.h \
|
WINGsP.h \
|
||||||
llist.h \
|
bag.c \
|
||||||
llist.c \
|
|
||||||
international.c \
|
international.c \
|
||||||
notification.c \
|
notification.c \
|
||||||
userdefaults.c \
|
userdefaults.c \
|
||||||
|
|||||||
@@ -59,12 +59,10 @@ PRE_UNINSTALL = :
|
|||||||
POST_UNINSTALL = :
|
POST_UNINSTALL = :
|
||||||
host_alias = @host_alias@
|
host_alias = @host_alias@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
AS = @AS@
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CPP_PATH = @CPP_PATH@
|
CPP_PATH = @CPP_PATH@
|
||||||
DFLAGS = @DFLAGS@
|
DFLAGS = @DFLAGS@
|
||||||
DLLIBS = @DLLIBS@
|
DLLIBS = @DLLIBS@
|
||||||
DLLTOOL = @DLLTOOL@
|
|
||||||
GFXLIBS = @GFXLIBS@
|
GFXLIBS = @GFXLIBS@
|
||||||
HEADER_SEARCH_PATH = @HEADER_SEARCH_PATH@
|
HEADER_SEARCH_PATH = @HEADER_SEARCH_PATH@
|
||||||
ICONEXT = @ICONEXT@
|
ICONEXT = @ICONEXT@
|
||||||
@@ -79,7 +77,6 @@ MAKEINFO = @MAKEINFO@
|
|||||||
MOFILES = @MOFILES@
|
MOFILES = @MOFILES@
|
||||||
NLSDIR = @NLSDIR@
|
NLSDIR = @NLSDIR@
|
||||||
NM = @NM@
|
NM = @NM@
|
||||||
OBJDUMP = @OBJDUMP@
|
|
||||||
PACKAGE = @PACKAGE@
|
PACKAGE = @PACKAGE@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
VERSION = @VERSION@
|
VERSION = @VERSION@
|
||||||
@@ -143,10 +140,10 @@ wmquery_LDADD = libWINGs.a $(LIBLIST)
|
|||||||
EXTRA_DIST = logo.xpm BUGS
|
EXTRA_DIST = logo.xpm BUGS
|
||||||
|
|
||||||
# wbutton.c
|
# wbutton.c
|
||||||
libWINGs_a_SOURCES = WINGs.h WINGsP.h configuration.c llist.h llist.c international.c notification.c selection.c userdefaults.c wapplication.c wappresource.c wballoon.c wbrowser.c wbutton.c wcolor.c wcolorpanel.c wcolorwell.c wevent.c wfilepanel.c wframe.c wfont.c wfontpanel.c widgets.c wlabel.c wlist.c wmisc.c wpanel.c wpixmap.c wpopupbutton.c wscroller.c wscrollview.c wslider.c wsplitview.c wtabview.c wtextfield.c wwindow.c wview.c error.c findfile.c hashtable.c memory.c usleep.c
|
libWINGs_a_SOURCES = WINGs.h WINGsP.h configuration.c international.c notification.c selection.c userdefaults.c wapplication.c wappresource.c wballoon.c wbrowser.c wbutton.c wcolor.c wcolorpanel.c wcolorwell.c wevent.c wfilepanel.c wframe.c wfont.c wfontpanel.c widgets.c wlabel.c wlist.c wmisc.c wpanel.c wpixmap.c wpopupbutton.c wprogressindicator.c wscroller.c wscrollview.c wslider.c wsplitview.c wtabview.c wtextfield.c wwindow.c wview.c error.c findfile.c bag.c hashtable.c memory.c usleep.c
|
||||||
|
|
||||||
|
|
||||||
libWUtil_a_SOURCES = WINGs.h WINGsP.h llist.h llist.c international.c notification.c userdefaults.c wapplication.c wutil.c error.c findfile.c hashtable.c memory.c usleep.c
|
libWUtil_a_SOURCES = WINGs.h WINGsP.h bag.c international.c notification.c userdefaults.c wapplication.c wutil.c error.c findfile.c hashtable.c memory.c usleep.c
|
||||||
|
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/wrlib -I$(top_srcdir)/src -DRESOURCE_PATH=\"$(datadir)/WINGs\" @HEADER_SEARCH_PATH@ -DDEBUG
|
INCLUDES = -I$(top_srcdir)/wrlib -I$(top_srcdir)/src -DRESOURCE_PATH=\"$(datadir)/WINGs\" @HEADER_SEARCH_PATH@ -DDEBUG
|
||||||
@@ -165,15 +162,16 @@ X_CFLAGS = @X_CFLAGS@
|
|||||||
X_LIBS = @X_LIBS@
|
X_LIBS = @X_LIBS@
|
||||||
X_PRE_LIBS = @X_PRE_LIBS@
|
X_PRE_LIBS = @X_PRE_LIBS@
|
||||||
libWINGs_a_LIBADD =
|
libWINGs_a_LIBADD =
|
||||||
libWINGs_a_OBJECTS = configuration.o llist.o international.o \
|
libWINGs_a_OBJECTS = configuration.o international.o notification.o \
|
||||||
notification.o selection.o userdefaults.o wapplication.o wappresource.o \
|
selection.o userdefaults.o wapplication.o wappresource.o wballoon.o \
|
||||||
wballoon.o wbrowser.o wbutton.o wcolor.o wcolorpanel.o wcolorwell.o \
|
wbrowser.o wbutton.o wcolor.o wcolorpanel.o wcolorwell.o wevent.o \
|
||||||
wevent.o wfilepanel.o wframe.o wfont.o wfontpanel.o widgets.o wlabel.o \
|
wfilepanel.o wframe.o wfont.o wfontpanel.o widgets.o wlabel.o wlist.o \
|
||||||
wlist.o wmisc.o wpanel.o wpixmap.o wpopupbutton.o wscroller.o \
|
wmisc.o wpanel.o wpixmap.o wpopupbutton.o wprogressindicator.o \
|
||||||
wscrollview.o wslider.o wsplitview.o wtabview.o wtextfield.o wwindow.o \
|
wscroller.o wscrollview.o wslider.o wsplitview.o wtabview.o \
|
||||||
wview.o error.o findfile.o hashtable.o memory.o usleep.o
|
wtextfield.o wwindow.o wview.o error.o findfile.o bag.o hashtable.o \
|
||||||
|
memory.o usleep.o
|
||||||
libWUtil_a_LIBADD =
|
libWUtil_a_LIBADD =
|
||||||
libWUtil_a_OBJECTS = llist.o international.o notification.o \
|
libWUtil_a_OBJECTS = bag.o international.o notification.o \
|
||||||
userdefaults.o wapplication.o wutil.o error.o findfile.o hashtable.o \
|
userdefaults.o wapplication.o wutil.o error.o findfile.o hashtable.o \
|
||||||
memory.o usleep.o
|
memory.o usleep.o
|
||||||
AR = ar
|
AR = ar
|
||||||
@@ -213,7 +211,7 @@ DIST_COMMON = README ChangeLog Makefile.am Makefile.in TODO
|
|||||||
|
|
||||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
|
|
||||||
TAR = tar
|
TAR = gtar
|
||||||
GZIP_ENV = --best
|
GZIP_ENV = --best
|
||||||
SOURCES = $(libWINGs_a_SOURCES) $(libWUtil_a_SOURCES) $(wtest_SOURCES) $(wmquery_SOURCES) $(wmfile_SOURCES) $(fontl_SOURCES) $(testmywidget_SOURCES) $(testcolorpanel_SOURCES) $(testnot_SOURCES)
|
SOURCES = $(libWINGs_a_SOURCES) $(libWUtil_a_SOURCES) $(wtest_SOURCES) $(wmquery_SOURCES) $(wmfile_SOURCES) $(fontl_SOURCES) $(testmywidget_SOURCES) $(testcolorpanel_SOURCES) $(testnot_SOURCES)
|
||||||
OBJECTS = $(libWINGs_a_OBJECTS) $(libWUtil_a_OBJECTS) $(wtest_OBJECTS) $(wmquery_OBJECTS) $(wmfile_OBJECTS) $(fontl_OBJECTS) $(testmywidget_OBJECTS) $(testcolorpanel_OBJECTS) $(testnot_OBJECTS)
|
OBJECTS = $(libWINGs_a_OBJECTS) $(libWUtil_a_OBJECTS) $(wtest_OBJECTS) $(wmquery_OBJECTS) $(wmfile_OBJECTS) $(fontl_OBJECTS) $(testmywidget_OBJECTS) $(testcolorpanel_OBJECTS) $(testnot_OBJECTS)
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ Widgets provided by WINGs:
|
|||||||
- color well
|
- color well
|
||||||
- split view (only 2 subviews)
|
- split view (only 2 subviews)
|
||||||
- tabbed view
|
- tabbed view
|
||||||
|
- progress indicator
|
||||||
|
|
||||||
- input box
|
- input box
|
||||||
- file panel
|
- file panel
|
||||||
|
|||||||
@@ -59,12 +59,10 @@ PRE_UNINSTALL = :
|
|||||||
POST_UNINSTALL = :
|
POST_UNINSTALL = :
|
||||||
host_alias = @host_alias@
|
host_alias = @host_alias@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
AS = @AS@
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CPP_PATH = @CPP_PATH@
|
CPP_PATH = @CPP_PATH@
|
||||||
DFLAGS = @DFLAGS@
|
DFLAGS = @DFLAGS@
|
||||||
DLLIBS = @DLLIBS@
|
DLLIBS = @DLLIBS@
|
||||||
DLLTOOL = @DLLTOOL@
|
|
||||||
GFXLIBS = @GFXLIBS@
|
GFXLIBS = @GFXLIBS@
|
||||||
HEADER_SEARCH_PATH = @HEADER_SEARCH_PATH@
|
HEADER_SEARCH_PATH = @HEADER_SEARCH_PATH@
|
||||||
ICONEXT = @ICONEXT@
|
ICONEXT = @ICONEXT@
|
||||||
@@ -79,7 +77,6 @@ MAKEINFO = @MAKEINFO@
|
|||||||
MOFILES = @MOFILES@
|
MOFILES = @MOFILES@
|
||||||
NLSDIR = @NLSDIR@
|
NLSDIR = @NLSDIR@
|
||||||
NM = @NM@
|
NM = @NM@
|
||||||
OBJDUMP = @OBJDUMP@
|
|
||||||
PACKAGE = @PACKAGE@
|
PACKAGE = @PACKAGE@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
VERSION = @VERSION@
|
VERSION = @VERSION@
|
||||||
@@ -107,7 +104,7 @@ DIST_COMMON = Makefile.am Makefile.in
|
|||||||
|
|
||||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
|
|
||||||
TAR = tar
|
TAR = gtar
|
||||||
GZIP_ENV = --best
|
GZIP_ENV = --best
|
||||||
all: all-redirect
|
all: all-redirect
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|||||||
@@ -263,7 +263,8 @@ enum {
|
|||||||
WC_Slider = 11,
|
WC_Slider = 11,
|
||||||
WC_Matrix = 12, /* not ready */
|
WC_Matrix = 12, /* not ready */
|
||||||
WC_SplitView = 13,
|
WC_SplitView = 13,
|
||||||
WC_TabView = 14
|
WC_TabView = 14,
|
||||||
|
WC_ProgressIndicator = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All widgets must start with the following structure
|
/* All widgets must start with the following structure
|
||||||
@@ -301,6 +302,7 @@ typedef struct W_ScrollView WMScrollView;
|
|||||||
typedef struct W_List WMList;
|
typedef struct W_List WMList;
|
||||||
typedef struct W_Browser WMBrowser;
|
typedef struct W_Browser WMBrowser;
|
||||||
typedef struct W_PopUpButton WMPopUpButton;
|
typedef struct W_PopUpButton WMPopUpButton;
|
||||||
|
typedef struct W_ProgressIndicator WMProgressIndicator;
|
||||||
typedef struct W_ColorWell WMColorWell;
|
typedef struct W_ColorWell WMColorWell;
|
||||||
typedef struct W_Slider WMSlider;
|
typedef struct W_Slider WMSlider;
|
||||||
typedef struct W_Matrix WMMatrix; /* not ready */
|
typedef struct W_Matrix WMMatrix; /* not ready */
|
||||||
@@ -385,6 +387,7 @@ typedef void WMAction(WMWidget *self, void *clientData);
|
|||||||
/* same as WMAction, but for stuff that arent widgets */
|
/* same as WMAction, but for stuff that arent widgets */
|
||||||
typedef void WMAction2(void *self, void *clientData);
|
typedef void WMAction2(void *self, void *clientData);
|
||||||
|
|
||||||
|
|
||||||
typedef void WMCallback(void *data);
|
typedef void WMCallback(void *data);
|
||||||
|
|
||||||
|
|
||||||
@@ -796,6 +799,8 @@ WMButton *WMCreateButton(WMWidget *parent, WMButtonType type);
|
|||||||
|
|
||||||
WMButton *WMCreateCustomButton(WMWidget *parent, int behaviourMask);
|
WMButton *WMCreateCustomButton(WMWidget *parent, int behaviourMask);
|
||||||
|
|
||||||
|
void WMSetButtonImageDefault(WMButton *bPtr);
|
||||||
|
|
||||||
void WMSetButtonImage(WMButton *bPtr, WMPixmap *image);
|
void WMSetButtonImage(WMButton *bPtr, WMPixmap *image);
|
||||||
|
|
||||||
void WMSetButtonAltImage(WMButton *bPtr, WMPixmap *image);
|
void WMSetButtonAltImage(WMButton *bPtr, WMPixmap *image);
|
||||||
@@ -1051,6 +1056,23 @@ void WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag);
|
|||||||
|
|
||||||
Bool WMGetPopUpButtonEnabled(WMPopUpButton *bPtr);
|
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);
|
WMColorPanel *WMGetColorPanel(WMScreen *scrPtr);
|
||||||
|
|||||||
@@ -92,13 +92,14 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct W_Bag WMBag; /* equivalent to a linked list or array */
|
||||||
typedef struct W_HashTable WMHashTable;
|
typedef struct W_HashTable WMHashTable;
|
||||||
typedef struct W_UserDefaults WMUserDefaults;
|
typedef struct W_UserDefaults WMUserDefaults;
|
||||||
typedef struct W_Notification WMNotification;
|
typedef struct W_Notification WMNotification;
|
||||||
typedef struct W_NotificationQueue WMNotificationQueue;
|
typedef struct W_NotificationQueue WMNotificationQueue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
|
/* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *table;
|
void *table;
|
||||||
@@ -119,6 +120,7 @@ typedef struct {
|
|||||||
} WMHashTableCallbacks;
|
} WMHashTableCallbacks;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char character; /* the escape character */
|
char character; /* the escape character */
|
||||||
@@ -127,6 +129,7 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef void WMNotificationObserverAction(void *observerData,
|
typedef void WMNotificationObserverAction(void *observerData,
|
||||||
WMNotification *notification);
|
WMNotification *notification);
|
||||||
|
|
||||||
@@ -223,6 +226,46 @@ extern const WMHashTableCallbacks WMStringHashCallbacks;
|
|||||||
extern const WMHashTableCallbacks WMStringPointerHashCallbacks;
|
extern const WMHashTableCallbacks WMStringPointerHashCallbacks;
|
||||||
/* keys are strings, bug they are not copied */
|
/* keys are strings, bug they are not copied */
|
||||||
|
|
||||||
|
|
||||||
|
/*......................................................................*/
|
||||||
|
|
||||||
|
|
||||||
|
WMBag *WMCreateBag(int size);
|
||||||
|
|
||||||
|
int WMGetBagItemCount(WMBag *bag);
|
||||||
|
|
||||||
|
void WMAppendBag(WMBag *bag, WMBag *appendedBag);
|
||||||
|
|
||||||
|
void WMPutInBag(WMBag *bag, void *item);
|
||||||
|
|
||||||
|
void WMInsertInBag(WMBag *bag, int index, void *item);
|
||||||
|
|
||||||
|
int WMGetFirstInBag(WMBag *bag, void *item);
|
||||||
|
|
||||||
|
int WMGetLastInBag(WMBag *bag, void *item);
|
||||||
|
|
||||||
|
void WMRemoveFromBag(WMBag *bag, void *item);
|
||||||
|
|
||||||
|
void WMDeleteFromBag(WMBag *bag, int index);
|
||||||
|
|
||||||
|
void *WMGetFromBag(WMBag *bag, int index);
|
||||||
|
|
||||||
|
int WMCountInBag(WMBag *bag, void *item);
|
||||||
|
|
||||||
|
|
||||||
|
/* comparer must return:
|
||||||
|
* < 0 if a < b
|
||||||
|
* > 0 if a > b
|
||||||
|
* = 0 if a = b
|
||||||
|
*/
|
||||||
|
void WMSortBag(WMBag *bag, int (*comparer)(void*,void*));
|
||||||
|
|
||||||
|
void WMEmptyBag(WMBag *bag);
|
||||||
|
|
||||||
|
void WMFreeBag(WMBag *bag);
|
||||||
|
|
||||||
|
WMBag *WMMapBag(WMBag *bag, void* (*function)(void*));
|
||||||
|
|
||||||
/*......................................................................*/
|
/*......................................................................*/
|
||||||
|
|
||||||
WMNotification *WMCreateNotification(char *name, void *object, void *clientData);
|
WMNotification *WMCreateNotification(char *name, void *object, void *clientData);
|
||||||
|
|||||||
195
WINGs/bag.c
Normal file
195
WINGs/bag.c
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "WUtil.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct W_Bag {
|
||||||
|
int size;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
void **items;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WMBag*
|
||||||
|
WMCreateBag(int size)
|
||||||
|
{
|
||||||
|
WMBag *bag;
|
||||||
|
|
||||||
|
wassertrv(size > 0, NULL);
|
||||||
|
|
||||||
|
bag = wmalloc(sizeof(WMBag));
|
||||||
|
|
||||||
|
bag->items = wmalloc(sizeof(void*) * size);
|
||||||
|
bag->size = size;
|
||||||
|
bag->count = 0;
|
||||||
|
|
||||||
|
return bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
WMGetBagItemCount(WMBag *bag)
|
||||||
|
{
|
||||||
|
return bag->count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMAppendBag(WMBag *bag, WMBag *appendedBag)
|
||||||
|
{
|
||||||
|
bag->items = wrealloc(bag->items,
|
||||||
|
sizeof(void*) * (bag->size+appendedBag->count));
|
||||||
|
|
||||||
|
memcpy(bag->items + bag->count, appendedBag->items, appendedBag->count);
|
||||||
|
|
||||||
|
bag->count += appendedBag->count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMPutInBag(WMBag *bag, void *item)
|
||||||
|
{
|
||||||
|
WMInsertInBag(bag, bag->count, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMInsertInBag(WMBag *bag, int index, void *item)
|
||||||
|
{
|
||||||
|
if (bag->count == bag->size) {
|
||||||
|
bag->size += 16;
|
||||||
|
bag->items = wrealloc(bag->items, sizeof(void*) * bag->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bag->items[bag->count++] = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
WMGetFirstInBag(WMBag *bag, void *item)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < bag->count; i++) {
|
||||||
|
if (bag->items[i] == item) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
WMGetLastInBag(WMBag *bag, void *item)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = bag->count-1; i>= 0; i--) {
|
||||||
|
if (bag->items[i] == item) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMRemoveFromBag(WMBag *bag, void *item)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = WMGetFirstInBag(bag, item);
|
||||||
|
if (i >= 0) {
|
||||||
|
WMDeleteFromBag(bag, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMDeleteFromBag(WMBag *bag, int index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= bag->count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (index < bag->count-1) {
|
||||||
|
memmove(&bag->items[index], &bag->items[index + 1],
|
||||||
|
(bag->count - index - 1) * sizeof(void*));
|
||||||
|
}
|
||||||
|
bag->count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void*
|
||||||
|
WMGetFromBag(WMBag *bag, int index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= bag->count) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bag->items[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
WMCountInBag(WMBag *bag, void *item)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (j = 0, i = 0; j < bag->count; j++) {
|
||||||
|
if (bag->items[j] == item)
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMSortBag(WMBag *bag, int (*comparer)(void*, void*))
|
||||||
|
{
|
||||||
|
qsort(bag->items, bag->count, sizeof(void*), comparer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMFreeBag(WMBag *bag)
|
||||||
|
{
|
||||||
|
free(bag->items);
|
||||||
|
free(bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMEmptyBag(WMBag *bag)
|
||||||
|
{
|
||||||
|
bag->count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WMBag*
|
||||||
|
WMMapBag(WMBag *bag, void *(*function)(void *))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
WMBag *new = WMCreateBag(bag->size);
|
||||||
|
|
||||||
|
for (i = 0; i < bag->count; i++) {
|
||||||
|
WMPutInBag(new, (*function)(bag->items[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,9 +9,10 @@ _WINGsConfiguration WINGsConfiguration;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SYSTEM_FONT "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*"
|
#define SYSTEM_FONT "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-*-*-%d-*-*-*-*-*-*-*"
|
||||||
|
|
||||||
|
#define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-*-*-%d-*-*-*-*-*-*-*"
|
||||||
|
|
||||||
#define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
126
WINGs/llist.c
126
WINGs/llist.c
@@ -1,126 +0,0 @@
|
|||||||
|
|
||||||
#include "WUtil.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "llist.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE void*
|
|
||||||
lhead(list_t *list)
|
|
||||||
{
|
|
||||||
if (!list)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return list->head;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t*
|
|
||||||
ltail(list_t *list)
|
|
||||||
{
|
|
||||||
if (!list)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return list->tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t*
|
|
||||||
lcons(void *newHead, list_t *list)
|
|
||||||
{
|
|
||||||
list_t *newNode;
|
|
||||||
|
|
||||||
newNode = wmalloc(sizeof(list_t));
|
|
||||||
newNode->head = newHead;
|
|
||||||
newNode->tail = list;
|
|
||||||
|
|
||||||
return newNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t*
|
|
||||||
lappend(list_t *list, list_t *tail)
|
|
||||||
{
|
|
||||||
list_t *ptr;
|
|
||||||
|
|
||||||
if (!list)
|
|
||||||
return tail;
|
|
||||||
|
|
||||||
for (ptr = list; ptr->tail == NULL; ptr = ptr->tail);
|
|
||||||
|
|
||||||
ptr->tail = tail;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE void
|
|
||||||
lfree(list_t *list)
|
|
||||||
{
|
|
||||||
if (list) {
|
|
||||||
lfree(list->tail);
|
|
||||||
free(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE void*
|
|
||||||
lfind(void *objeto, list_t *list, int (*compare)(void*, void*))
|
|
||||||
{
|
|
||||||
while (list) {
|
|
||||||
if ((*compare)(list->head, objeto)==0) {
|
|
||||||
return list->head;
|
|
||||||
}
|
|
||||||
list = list->tail;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE int
|
|
||||||
llength(list_t *list)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
while (list) {
|
|
||||||
list = list->tail;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t*
|
|
||||||
lremove(list_t *list, void *object)
|
|
||||||
{
|
|
||||||
if (!list)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (list->head == object) {
|
|
||||||
list_t *tmp = list->tail;
|
|
||||||
|
|
||||||
free(list);
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
list->tail = lremove(list->tail, object);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t*
|
|
||||||
lremovehead(list_t *list)
|
|
||||||
{
|
|
||||||
list_t *tmp = NULL;
|
|
||||||
|
|
||||||
if (list) {
|
|
||||||
tmp = list->tail;
|
|
||||||
free(list);
|
|
||||||
}
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
|
||||||
# define WINLINE inline
|
|
||||||
#else
|
|
||||||
# define WINLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct list_t {
|
|
||||||
void *head;
|
|
||||||
struct list_t *tail;
|
|
||||||
} list_t;
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE void *lhead(list_t *list);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t *ltail(list_t *list);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t *lcons(void *newHead, list_t *list);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t *lappend(list_t *list, list_t *tail);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE void lfree(list_t *list);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE void *lfind(void *object, list_t *list, int (*compare)(void*, void*));
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE int llength(list_t *list);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t *lremove(list_t *list, void *object);
|
|
||||||
|
|
||||||
|
|
||||||
WINLINE list_t *lremovehead(list_t *list);
|
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ static void
|
|||||||
defaultHandler(int bla)
|
defaultHandler(int bla)
|
||||||
{
|
{
|
||||||
if (bla)
|
if (bla)
|
||||||
raise(SIGABRT);
|
kill(getpid(), SIGABRT);
|
||||||
else
|
else
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "WUtil.h"
|
#include "WUtil.h"
|
||||||
|
|
||||||
#include "llist.h"
|
|
||||||
|
|
||||||
typedef struct W_Notification {
|
typedef struct W_Notification {
|
||||||
char *name;
|
char *name;
|
||||||
@@ -379,8 +378,8 @@ WMPostNotificationName(char *name, void *object, void *clientData)
|
|||||||
|
|
||||||
|
|
||||||
typedef struct W_NotificationQueue {
|
typedef struct W_NotificationQueue {
|
||||||
list_t *asapQueue;
|
WMBag *asapQueue;
|
||||||
list_t *idleQueue;
|
WMBag *idleQueue;
|
||||||
|
|
||||||
struct W_NotificationQueue *next;
|
struct W_NotificationQueue *next;
|
||||||
} NotificationQueue;
|
} NotificationQueue;
|
||||||
@@ -409,8 +408,8 @@ WMCreateNotificationQueue(void)
|
|||||||
|
|
||||||
queue = wmalloc(sizeof(NotificationQueue));
|
queue = wmalloc(sizeof(NotificationQueue));
|
||||||
|
|
||||||
queue->asapQueue = NULL;
|
queue->asapQueue = WMCreateBag(8);
|
||||||
queue->idleQueue = NULL;
|
queue->idleQueue = WMCreateBag(8);
|
||||||
queue->next = notificationQueueList;
|
queue->next = notificationQueueList;
|
||||||
|
|
||||||
notificationQueueList = queue;
|
notificationQueueList = queue;
|
||||||
@@ -429,50 +428,52 @@ WMEnqueueNotification(WMNotificationQueue *queue, WMNotification *notification,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
matchName(void *a, void *b)
|
|
||||||
{
|
|
||||||
WMNotification *n1 = (WMNotification*)a;
|
|
||||||
WMNotification *n2 = (WMNotification*)b;
|
|
||||||
|
|
||||||
return strcmp(n1->name, n2->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
matchSender(void *a, void *b)
|
|
||||||
{
|
|
||||||
WMNotification *n1 = (WMNotification*)a;
|
|
||||||
WMNotification *n2 = (WMNotification*)b;
|
|
||||||
|
|
||||||
return (n1->object == n2->object);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
||||||
WMNotification *notification, unsigned mask)
|
WMNotification *notification, unsigned mask)
|
||||||
{
|
{
|
||||||
void *n;
|
int i;
|
||||||
|
WMNotification *tmp;
|
||||||
|
|
||||||
if (mask & WNCOnName) {
|
if (mask & WNCOnName) {
|
||||||
while ((n = lfind(notification->name, queue->asapQueue, matchName))) {
|
for (i = 0; i < WMGetBagItemCount(queue->asapQueue); i++) {
|
||||||
queue->asapQueue = lremove(queue->asapQueue, n);
|
tmp = WMGetFromBag(queue->asapQueue, i);
|
||||||
WMReleaseNotification((WMNotification*)n);
|
|
||||||
|
if (strcmp(notification->name, tmp) == 0) {
|
||||||
|
WMRemoveFromBag(queue->asapQueue, tmp);
|
||||||
|
WMReleaseNotification(tmp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < WMGetBagItemCount(queue->idleQueue); i++) {
|
||||||
|
tmp = WMGetFromBag(queue->idleQueue, i);
|
||||||
|
|
||||||
|
if (strcmp(notification->name, tmp) == 0) {
|
||||||
|
WMRemoveFromBag(queue->idleQueue, tmp);
|
||||||
|
WMReleaseNotification(tmp);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while ((n = lfind(notification->name, queue->idleQueue, matchName))) {
|
|
||||||
queue->idleQueue = lremove(queue->idleQueue, n);
|
|
||||||
WMReleaseNotification((WMNotification*)n);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mask & WNCOnSender) {
|
if (mask & WNCOnSender) {
|
||||||
while ((n = lfind(notification->name, queue->asapQueue, matchSender))) {
|
for (i = 0; i < WMGetBagItemCount(queue->asapQueue); i++) {
|
||||||
queue->asapQueue = lremove(queue->asapQueue, n);
|
tmp = WMGetFromBag(queue->asapQueue, i);
|
||||||
WMReleaseNotification((WMNotification*)n);
|
|
||||||
|
if (notification->object == tmp->object) {
|
||||||
|
WMRemoveFromBag(queue->asapQueue, tmp);
|
||||||
|
WMReleaseNotification(tmp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < WMGetBagItemCount(queue->idleQueue); i++) {
|
||||||
|
tmp = WMGetFromBag(queue->idleQueue, i);
|
||||||
|
|
||||||
|
if (notification->object == tmp->object) {
|
||||||
|
WMRemoveFromBag(queue->idleQueue, tmp);
|
||||||
|
WMReleaseNotification(tmp);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while ((n = lfind(notification->name, queue->idleQueue, matchSender))) {
|
|
||||||
queue->idleQueue = lremove(queue->idleQueue, n);
|
|
||||||
WMReleaseNotification((WMNotification*)n);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -493,13 +494,11 @@ WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WMPostASAP:
|
case WMPostASAP:
|
||||||
queue->asapQueue = lappend(queue->asapQueue,
|
WMPutInBag(queue->asapQueue, notification);
|
||||||
lcons(notification, NULL));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WMPostWhenIdle:
|
case WMPostWhenIdle:
|
||||||
queue->idleQueue = lappend(queue->idleQueue,
|
WMPutInBag(queue->idleQueue, notification);
|
||||||
lcons(notification, NULL));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -511,10 +510,14 @@ W_FlushASAPNotificationQueue()
|
|||||||
WMNotificationQueue *queue = notificationQueueList;
|
WMNotificationQueue *queue = notificationQueueList;
|
||||||
|
|
||||||
while (queue) {
|
while (queue) {
|
||||||
while (queue->asapQueue) {
|
while (WMGetBagItemCount(queue->asapQueue)) {
|
||||||
WMPostNotification((WMNotification*)lhead(queue->asapQueue));
|
WMNotification *tmp = WMGetFromBag(queue->asapQueue, 0);
|
||||||
queue->asapQueue = lremovehead(queue->asapQueue);
|
|
||||||
|
WMPostNotification(tmp);
|
||||||
|
WMDeleteFromBag(queue->asapQueue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queue = queue->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,10 +528,14 @@ W_FlushIdleNotificationQueue()
|
|||||||
WMNotificationQueue *queue = notificationQueueList;
|
WMNotificationQueue *queue = notificationQueueList;
|
||||||
|
|
||||||
while (queue) {
|
while (queue) {
|
||||||
while (queue->idleQueue) {
|
while (WMGetBagItemCount(queue->idleQueue)) {
|
||||||
WMPostNotification((WMNotification*)lhead(queue->idleQueue));
|
WMNotification *tmp = WMGetFromBag(queue->idleQueue, 0);
|
||||||
queue->idleQueue = lremovehead(queue->idleQueue);
|
|
||||||
|
WMPostNotification(tmp);
|
||||||
|
WMDeleteFromBag(queue->idleQueue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queue = queue->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,6 +263,12 @@ updateDisabledMask(WMButton *bPtr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WMSetButtonImageDefault(WMButton *bPtr)
|
||||||
|
{
|
||||||
|
WMSetButtonImage (bPtr, WMWidgetScreen(bPtr)->buttonArrow);
|
||||||
|
WMSetButtonAltImage (bPtr, WMWidgetScreen(bPtr)->pushedButtonArrow);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WMSetButtonImage(WMButton *bPtr, WMPixmap *image)
|
WMSetButtonImage(WMButton *bPtr, WMPixmap *image)
|
||||||
|
|||||||
@@ -694,7 +694,7 @@ createDir(WMButton *bPre, WMFilePanel *panel)
|
|||||||
if ((s = strrchr(directory_name, '/')) && !s[1]) s[0] = 0;
|
if ((s = strrchr(directory_name, '/')) && !s[1]) s[0] = 0;
|
||||||
|
|
||||||
file = wmalloc(strlen(directory_name)+strlen(directory)+1);
|
file = wmalloc(strlen(directory_name)+strlen(directory)+1);
|
||||||
sprintf(file, "%s/%s\0", directory, directory_name);
|
sprintf(file, "%s/%s", directory, directory_name);
|
||||||
while (s = strstr(file,"//")) {
|
while (s = strstr(file,"//")) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 2;s[i] == '/';i++);
|
for (i = 2;s[i] == '/';i++);
|
||||||
@@ -762,10 +762,10 @@ deleteFile(WMButton *bPre, WMFilePanel *panel)
|
|||||||
return;
|
return;
|
||||||
} else if (S_ISDIR(filestat.st_mode)) {
|
} else if (S_ISDIR(filestat.st_mode)) {
|
||||||
buffer = wmalloc(strlen(file)+20);
|
buffer = wmalloc(strlen(file)+20);
|
||||||
sprintf(buffer,"Delete directory %s ?\0",file);
|
sprintf(buffer,"Delete directory %s ?",file);
|
||||||
} else {
|
} else {
|
||||||
buffer = wmalloc(strlen(file)+15);
|
buffer = wmalloc(strlen(file)+15);
|
||||||
sprintf(buffer,"Delete file %s ?\0",file);
|
sprintf(buffer,"Delete file %s ?",file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
|
if (!WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
|
||||||
|
|||||||
@@ -70,9 +70,8 @@ static char *scalableFontSizes[] = {
|
|||||||
|
|
||||||
static void arrangeLowerFrame(FontPanel *panel);
|
static void arrangeLowerFrame(FontPanel *panel);
|
||||||
|
|
||||||
static proplist_t createFontDatabase(WMScreen *scr);
|
|
||||||
|
|
||||||
static void listFamilies(proplist_t fdb, WMList *list);
|
static void listFamilies(WMScreen *scr, WMFontPanel *panel);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
splitViewConstrainCallback(WMSplitView *sPtr, int divIndex, int *min, int *max)
|
splitViewConstrainCallback(WMSplitView *sPtr, int divIndex, int *min, int *max)
|
||||||
@@ -279,8 +278,9 @@ WMGetFontPanel(WMScreen *scr)
|
|||||||
WMViewSizeDidChangeNotification,
|
WMViewSizeDidChangeNotification,
|
||||||
WMWidgetView(panel->lowerF));
|
WMWidgetView(panel->lowerF));
|
||||||
|
|
||||||
panel->fdb = createFontDatabase(scr);
|
|
||||||
listFamilies(panel->fdb, panel->famLs);
|
listFamilies(scr, panel);
|
||||||
|
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
@@ -404,8 +404,10 @@ arrangeLowerFrame(FontPanel *panel)
|
|||||||
#define NUM_FIELDS 14
|
#define NUM_FIELDS 14
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
parseFont(char *font, char **values)
|
parseFont(char *font, char values[NUM_FIELDS][256])
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int part;
|
int part;
|
||||||
@@ -418,7 +420,7 @@ parseFont(char *font, char **values)
|
|||||||
while (*ptr) {
|
while (*ptr) {
|
||||||
if (*ptr == '-') {
|
if (*ptr == '-') {
|
||||||
*bptr = 0;
|
*bptr = 0;
|
||||||
values[part]=wstrdup(buffer);
|
strcpy(values[part], buffer);
|
||||||
bptr = buffer;
|
bptr = buffer;
|
||||||
part++;
|
part++;
|
||||||
} else {
|
} else {
|
||||||
@@ -427,7 +429,7 @@ parseFont(char *font, char **values)
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
*bptr = 0;
|
*bptr = 0;
|
||||||
values[part]=wstrdup(buffer);
|
strcpy(values[part], buffer);
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
@@ -452,203 +454,203 @@ isXLFD(char *font, int *length_ret)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static proplist_t foundryKey = NULL;
|
typedef struct {
|
||||||
static proplist_t typeKey = NULL;
|
char *weight;
|
||||||
static proplist_t sizeKey, encKey, xlfdKey;
|
char *slant;
|
||||||
|
|
||||||
|
char *setWidth;
|
||||||
|
char *addStyle;
|
||||||
|
|
||||||
|
char showWeight; /* not Medium */
|
||||||
|
char showSlant; /* not R */
|
||||||
|
char showSetWidth; /* when duplicated */
|
||||||
|
char showAddStyle; /* when duplicated */
|
||||||
|
} Typeface;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
char *foundry;
|
||||||
|
char *registry, *encoding;
|
||||||
|
|
||||||
|
char showFoundry; /* when duplicated */
|
||||||
|
char showRegistry; /* when duplicated */
|
||||||
|
|
||||||
|
WMBag *typefaces;
|
||||||
|
} Family;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
addSizeToEnc(proplist_t enc, char **fields)
|
addTypefaceToFamily(Family *family, char fontFields[NUM_FIELDS][256])
|
||||||
{
|
{
|
||||||
proplist_t sizel;
|
|
||||||
|
|
||||||
sizel = PLGetDictionaryEntry(enc, sizeKey);
|
|
||||||
if (!sizel) {
|
|
||||||
sizel = PLMakeArrayFromElements(PLMakeString(fields[PIXEL_SIZE]),NULL);
|
|
||||||
PLInsertDictionaryEntry(enc, sizeKey, sizel);
|
|
||||||
} else {
|
|
||||||
PLAppendArrayElement(sizel, PLMakeString(fields[PIXEL_SIZE]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static proplist_t
|
|
||||||
addTypefaceToFont(proplist_t font, char **fields)
|
|
||||||
{
|
|
||||||
proplist_t face, encod, facedic, encodic;
|
|
||||||
char buffer[256];
|
|
||||||
|
|
||||||
strcpy(buffer, fields[WEIGHT]);
|
/*
|
||||||
|
* families (same family name) (Hashtable of family -> bag)
|
||||||
if (strcasecmp(fields[SLANT], "R")==0)
|
* registries (same family but different registries)
|
||||||
strcat(buffer, " Roman ");
|
*
|
||||||
else if (strcasecmp(fields[SLANT], "I")==0)
|
|
||||||
strcat(buffer, " Italic ");
|
|
||||||
else if (strcasecmp(fields[SLANT], "O")==0)
|
|
||||||
strcat(buffer, " Oblique ");
|
|
||||||
else if (strcasecmp(fields[SLANT], "RI")==0)
|
|
||||||
strcat(buffer, " Reverse Italic ");
|
|
||||||
else if (strcasecmp(fields[SLANT], "RO")==0)
|
|
||||||
strcat(buffer, " Reverse Oblique ");
|
|
||||||
else if (strcasecmp(fields[SLANT], "OT")==0)
|
|
||||||
strcat(buffer, " ? ");
|
|
||||||
/* else
|
|
||||||
* polymorphic fonts
|
|
||||||
*/
|
*/
|
||||||
strcat(buffer, fields[SETWIDTH]);
|
|
||||||
strcat(buffer, " ");
|
|
||||||
strcat(buffer, fields[ADD_STYLE]);
|
|
||||||
|
|
||||||
face = PLMakeString(buffer);
|
static void
|
||||||
|
addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
|
||||||
facedic = PLGetDictionaryEntry(font, face);
|
|
||||||
if (!facedic) {
|
|
||||||
facedic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
|
||||||
PLInsertDictionaryEntry(font, face, facedic);
|
|
||||||
PLRelease(facedic);
|
|
||||||
}
|
|
||||||
PLRelease(face);
|
|
||||||
|
|
||||||
strcpy(buffer, fields[REGISTRY]);
|
|
||||||
strcat(buffer, "-");
|
|
||||||
strcat(buffer, fields[ENCODING]);
|
|
||||||
encod = PLMakeString(buffer);
|
|
||||||
|
|
||||||
encodic = PLGetDictionaryEntry(facedic, encod);
|
|
||||||
if (!encodic) {
|
|
||||||
proplist_t tmp;
|
|
||||||
sprintf(buffer, "-%s-%s-%s-%s-%s-%s-%%d-0-%s-%s-%s-%s-%s-%s",
|
|
||||||
fields[FOUNDRY], fields[FAMILY], fields[WEIGHT],
|
|
||||||
fields[SLANT], fields[SETWIDTH], fields[ADD_STYLE],
|
|
||||||
fields[RES_X], fields[RES_Y], fields[SPACING],
|
|
||||||
fields[AV_WIDTH], fields[REGISTRY], fields[ENCODING]);
|
|
||||||
tmp = PLMakeString(buffer);
|
|
||||||
|
|
||||||
encodic = PLMakeDictionaryFromEntries(xlfdKey, tmp, NULL);
|
|
||||||
PLRelease(tmp);
|
|
||||||
PLInsertDictionaryEntry(facedic, encod, encodic);
|
|
||||||
PLRelease(encodic);
|
|
||||||
}
|
|
||||||
addSizeToEnc(encodic, fields);
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static proplist_t
|
|
||||||
makeFontEntry(char **fields)
|
|
||||||
{
|
{
|
||||||
proplist_t font;
|
int i;
|
||||||
proplist_t value;
|
Family *fam;
|
||||||
proplist_t tmp;
|
WMBag *family;
|
||||||
value = PLMakeString(fields[FOUNDRY]);
|
|
||||||
|
|
||||||
tmp = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
family = WMHashGet(families, fontFields[FAMILY]);
|
||||||
|
|
||||||
font = PLMakeDictionaryFromEntries(foundryKey, value,
|
if (family) {
|
||||||
typeKey, tmp,
|
/* look for same encoding/registry and foundry */
|
||||||
NULL);
|
for (i = 0; i < WMGetBagItemCount(family); i++) {
|
||||||
PLRelease(value);
|
int enc, reg, found;
|
||||||
PLRelease(tmp);
|
|
||||||
|
|
||||||
addTypefaceToFont(font, fields);
|
fam = WMGetFromBag(family, i);
|
||||||
|
|
||||||
return font;
|
enc = (strcmp(fam->encoding, fontFields[ENCODING]) == 0);
|
||||||
|
reg = (strcmp(fam->registry, fontFields[REGISTRY]) == 0);
|
||||||
|
found = (strcmp(fam->foundry, fontFields[FOUNDRY]) == 0);
|
||||||
|
|
||||||
|
if (enc && reg && found) {
|
||||||
|
addTypefaceToFamily(fam, fontFields);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* look for same encoding/registry */
|
||||||
|
for (i = 0; i < WMGetBagItemCount(family); i++) {
|
||||||
|
int enc, reg;
|
||||||
|
|
||||||
|
fam = WMGetFromBag(family, i);
|
||||||
|
|
||||||
|
enc = (strcmp(fam->encoding, fontFields[ENCODING]) == 0);
|
||||||
|
reg = (strcmp(fam->registry, fontFields[REGISTRY]) == 0);
|
||||||
|
|
||||||
|
if (enc && reg) {
|
||||||
|
/* has the same encoding, but the foundry is different */
|
||||||
|
fam->showRegistry = 1;
|
||||||
|
|
||||||
|
fam = wmalloc(sizeof(Family));
|
||||||
|
memset(fam, 0, sizeof(Family));
|
||||||
|
|
||||||
|
fam->name = wstrdup(fontFields[FAMILY]);
|
||||||
|
fam->foundry = wstrdup(fontFields[FOUNDRY]);
|
||||||
|
fam->registry = wstrdup(fontFields[REGISTRY]);
|
||||||
|
fam->encoding = wstrdup(fontFields[ENCODING]);
|
||||||
|
fam->showRegistry = 1;
|
||||||
|
|
||||||
|
addTypefaceToFamily(fam, fontFields);
|
||||||
|
|
||||||
|
WMPutInBag(family, fam);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* look for same foundry */
|
||||||
|
for (i = 0; i < WMGetBagItemCount(family); i++) {
|
||||||
|
int found;
|
||||||
|
|
||||||
|
fam = WMGetFromBag(family, i);
|
||||||
|
|
||||||
|
found = (strcmp(fam->foundry, fontFields[FOUNDRY]) == 0);
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
/* has the same foundry, but encoding is different */
|
||||||
|
fam->showFoundry = 1;
|
||||||
|
|
||||||
|
fam = wmalloc(sizeof(Family));
|
||||||
|
memset(fam, 0, sizeof(Family));
|
||||||
|
|
||||||
|
fam->name = wstrdup(fontFields[FAMILY]);
|
||||||
|
fam->foundry = wstrdup(fontFields[FOUNDRY]);
|
||||||
|
fam->registry = wstrdup(fontFields[REGISTRY]);
|
||||||
|
fam->encoding = wstrdup(fontFields[ENCODING]);
|
||||||
|
fam->showFoundry = 1;
|
||||||
|
|
||||||
|
addTypefaceToFamily(fam, fontFields);
|
||||||
|
|
||||||
|
WMPutInBag(family, fam);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* foundry and encoding do not match anything known */
|
||||||
|
fam = wmalloc(sizeof(Family));
|
||||||
|
memset(fam, 0, sizeof(Family));
|
||||||
|
|
||||||
|
fam->name = wstrdup(fontFields[FAMILY]);
|
||||||
|
fam->foundry = wstrdup(fontFields[FOUNDRY]);
|
||||||
|
fam->registry = wstrdup(fontFields[REGISTRY]);
|
||||||
|
fam->encoding = wstrdup(fontFields[ENCODING]);
|
||||||
|
|
||||||
|
addTypefaceToFamily(fam, fontFields);
|
||||||
|
|
||||||
|
WMPutInBag(family, fam);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
family = WMCreateBag(8);
|
||||||
|
|
||||||
|
fam = wmalloc(sizeof(Family));
|
||||||
|
memset(fam, 0, sizeof(Family));
|
||||||
|
|
||||||
|
fam->name = wstrdup(fontFields[FAMILY]);
|
||||||
|
fam->foundry = wstrdup(fontFields[FOUNDRY]);
|
||||||
|
fam->registry = wstrdup(fontFields[REGISTRY]);
|
||||||
|
fam->encoding = wstrdup(fontFields[ENCODING]);
|
||||||
|
|
||||||
|
addTypefaceToFamily(fam, fontFields);
|
||||||
|
|
||||||
|
WMPutInBag(family, fam);
|
||||||
|
|
||||||
|
WMHashInsert(families, fam->name, family);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static proplist_t
|
|
||||||
createFontDatabase(WMScreen *scr)
|
static void
|
||||||
|
listFamilies(WMScreen *scr, WMFontPanel *panel)
|
||||||
{
|
{
|
||||||
char **fontList;
|
char **fontList;
|
||||||
int count;
|
int count;
|
||||||
char *fields[NUM_FIELDS];
|
|
||||||
int font_name_length;
|
|
||||||
char buffer[256];
|
|
||||||
int i;
|
int i;
|
||||||
proplist_t fdb;
|
WMHashTable *families = WMCreateHashTable(WMStringHashCallbacks);
|
||||||
proplist_t font;
|
char fields[NUM_FIELDS][256];
|
||||||
proplist_t family;
|
|
||||||
proplist_t foundry;
|
|
||||||
proplist_t tmp;
|
|
||||||
|
|
||||||
if (!foundryKey) {
|
|
||||||
foundryKey = PLMakeString("Foundry");
|
|
||||||
typeKey = PLMakeString("Typeface");
|
|
||||||
encKey = PLMakeString("Encoding");
|
|
||||||
sizeKey = PLMakeString("Sizes");
|
|
||||||
xlfdKey = PLMakeString("XLFD");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* retrieve a complete listing of the available fonts */
|
|
||||||
fontList = XListFonts(scr->display, ALL_FONTS_MASK, MAX_FONTS_TO_RETRIEVE,
|
fontList = XListFonts(scr->display, ALL_FONTS_MASK, MAX_FONTS_TO_RETRIEVE,
|
||||||
&count);
|
&count);
|
||||||
if (!fontList) {
|
if (!fontList) {
|
||||||
wwarning("could not retrieve font list");
|
WMRunAlertPanel(scr, panel->win, "Error",
|
||||||
return NULL;
|
"Could not retrieve font list", "OK", NULL, NULL);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdb = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
for (i = 0; i < count; i++) {
|
||||||
|
int fname_len;
|
||||||
|
|
||||||
for (i=0; i<count; i++) {
|
if (!isXLFD(fontList[i], &fname_len)) {
|
||||||
if (!isXLFD(fontList[i], &font_name_length)) {
|
*fontList[i] = '\0';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* the XLFD specs limit the size of a font description in 255 chars */
|
if (fname_len > 255) {
|
||||||
assert(font_name_length < 256);
|
wwarning("font name %s is longer than 256, which is invalid.",
|
||||||
|
fontList[i]);
|
||||||
if (parseFont(fontList[i], fields)) {
|
*fontList[i] = '\0';
|
||||||
family = PLMakeString(fields[FAMILY]);
|
continue;
|
||||||
font = PLGetDictionaryEntry(fdb, family);
|
|
||||||
if (font) {
|
|
||||||
foundry = PLGetDictionaryEntry(font, foundryKey);
|
|
||||||
if (strcmp(PLGetString(foundry), fields[FOUNDRY])==0) {
|
|
||||||
/* already a font with the same family */
|
|
||||||
addTypefaceToFont(font, fields);
|
|
||||||
} else {
|
|
||||||
/* same font family by different foundries */
|
|
||||||
sprintf(buffer, "%s (%s)", fields[FAMILY],
|
|
||||||
fields[FOUNDRY]);
|
|
||||||
PLRelease(family);
|
|
||||||
family = PLMakeString(buffer);
|
|
||||||
|
|
||||||
font = PLGetDictionaryEntry(fdb, family);
|
|
||||||
if (font) {
|
|
||||||
/* already a font with the same family */
|
|
||||||
addTypefaceToFont(font, fields);
|
|
||||||
} else {
|
|
||||||
tmp = makeFontEntry(fields);
|
|
||||||
PLInsertDictionaryEntry(fdb, family, tmp);
|
|
||||||
PLRelease(tmp);
|
|
||||||
}
|
}
|
||||||
|
if (!parseFont(fontList[i], fields)) {
|
||||||
|
*fontList[i] = '\0';
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
addFontToFamily(families, (char**)fields);
|
||||||
tmp = makeFontEntry(fields);
|
|
||||||
PLInsertDictionaryEntry(fdb, family, tmp);
|
|
||||||
PLRelease(tmp);
|
|
||||||
}
|
|
||||||
PLRelease(family);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XFreeFontNames(fontList);
|
|
||||||
|
|
||||||
return fdb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
listFamilies(proplist_t fdb, WMList *list)
|
|
||||||
{
|
|
||||||
proplist_t arr;
|
|
||||||
proplist_t fam;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
arr = PLGetAllDictionaryKeys(fdb);
|
|
||||||
for (i = 0; i<PLGetNumberOfElements(arr); i++) {
|
|
||||||
fam = PLGetArrayElement(arr, i);
|
|
||||||
WMAddSortedListItem(list, PLGetString(fam));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
299
WINGs/wprogressindicator.c
Normal file
299
WINGs/wprogressindicator.c
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
/*
|
||||||
|
* Original idea and implementation by Frederik Schueler <fr.schueler@netsurf.de>
|
||||||
|
* Rewritten by Pascal Hofstee <daeron@windowmaker.org>
|
||||||
|
* - 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 */
|
||||||
|
#define 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 realizeProgressIndicator(ProgressIndicator *pPtr);
|
||||||
|
static void handleEvents(XEvent *event, void *data);
|
||||||
|
|
||||||
|
static void realizeObserver(void *self, WMNotification *not) {
|
||||||
|
|
||||||
|
realizeProgressIndicator(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WMProgressIndicator*
|
||||||
|
WMCreateProgressIndicator(WMWidget *parent)
|
||||||
|
{
|
||||||
|
ProgressIndicator *pPtr;
|
||||||
|
W_Screen *scrPtr = W_VIEW(parent)->screen;
|
||||||
|
|
||||||
|
pPtr = wmalloc(sizeof(ProgressIndicator));
|
||||||
|
memset(pPtr, 0, sizeof(ProgressIndicator));
|
||||||
|
|
||||||
|
pPtr->widgetClass = WC_ProgressIndicator;
|
||||||
|
|
||||||
|
pPtr->view = W_CreateView(W_VIEW(parent));
|
||||||
|
if (!pPtr->view) {
|
||||||
|
free(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;
|
||||||
|
|
||||||
|
WMAddNotificationObserver(realizeObserver, pPtr,
|
||||||
|
WMViewRealizedNotification, pPtr->view);
|
||||||
|
|
||||||
|
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
|
||||||
|
realizeProgressIndicator(ProgressIndicator *pPtr)
|
||||||
|
{
|
||||||
|
W_RealizeView(pPtr->view);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
free(pPtr);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -330,6 +330,30 @@ testTextField(WMScreen *scr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
testProgressIndicator(WMScreen *scr)
|
||||||
|
{
|
||||||
|
WMWindow *win;
|
||||||
|
WMProgressIndicator *pPtr;
|
||||||
|
|
||||||
|
windowCount++;
|
||||||
|
|
||||||
|
win = WMCreateWindow(scr, "testProgressIndicator");
|
||||||
|
WMResizeWidget(win, 292, 32);
|
||||||
|
|
||||||
|
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||||
|
|
||||||
|
pPtr = WMCreateProgressIndicator(win);
|
||||||
|
WMMoveWidget(pPtr, 8, 8);
|
||||||
|
WMSetProgressIndicatorValue(pPtr, 75);
|
||||||
|
|
||||||
|
WMRealizeWidget(win);
|
||||||
|
WMMapSubwidgets(win);
|
||||||
|
WMMapWidget(win);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
testPullDown(WMScreen *scr)
|
testPullDown(WMScreen *scr)
|
||||||
{
|
{
|
||||||
@@ -437,14 +461,16 @@ testTabView(WMScreen *scr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "WUtil.h"
|
#include "WUtil.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
WMScreen *scr;
|
WMScreen *scr;
|
||||||
WMPixmap *pixmap;
|
WMPixmap *pixmap;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the application */
|
/* Initialize the application */
|
||||||
WMInitializeApplication("Test", &argc, argv);
|
WMInitializeApplication("Test", &argc, argv);
|
||||||
|
|
||||||
@@ -486,17 +512,19 @@ int main(int argc, char **argv)
|
|||||||
* Put the testSomething() function you want to test here.
|
* Put the testSomething() function you want to test here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
testGradientButtons(scr);
|
|
||||||
|
|
||||||
|
|
||||||
|
testFontPanel(scr);
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
|
testProgressIndicator(scr);
|
||||||
|
testGradientButtons(scr);
|
||||||
testColorWell(scr);
|
testColorWell(scr);
|
||||||
|
|
||||||
testTabView(scr);
|
testTabView(scr);
|
||||||
testTextField(scr);
|
testTextField(scr);
|
||||||
|
|
||||||
testOpenFilePanel(scr);
|
testOpenFilePanel(scr);
|
||||||
testFontPanel(scr);
|
|
||||||
testList(scr);
|
testList(scr);
|
||||||
testGradientButtons(scr);
|
testGradientButtons(scr);
|
||||||
testScrollView(scr);
|
testScrollView(scr);
|
||||||
|
|||||||
@@ -983,7 +983,9 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
|||||||
if (!control_pressed) {
|
if (!control_pressed) {
|
||||||
goto normal_key;
|
goto normal_key;
|
||||||
}
|
}
|
||||||
|
#ifdef XK_KP_Left
|
||||||
case XK_KP_Left:
|
case XK_KP_Left:
|
||||||
|
#endif
|
||||||
case XK_Left:
|
case XK_Left:
|
||||||
if (tPtr->cursorPosition > 0) {
|
if (tPtr->cursorPosition > 0) {
|
||||||
paintCursor(tPtr);
|
paintCursor(tPtr);
|
||||||
@@ -1010,7 +1012,9 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
|||||||
if (!control_pressed) {
|
if (!control_pressed) {
|
||||||
goto normal_key;
|
goto normal_key;
|
||||||
}
|
}
|
||||||
|
#ifdef XK_KP_Right
|
||||||
case XK_KP_Right:
|
case XK_KP_Right:
|
||||||
|
#endif
|
||||||
case XK_Right:
|
case XK_Right:
|
||||||
if (tPtr->cursorPosition < tPtr->textLen) {
|
if (tPtr->cursorPosition < tPtr->textLen) {
|
||||||
paintCursor(tPtr);
|
paintCursor(tPtr);
|
||||||
@@ -1040,7 +1044,9 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
|||||||
if (!control_pressed) {
|
if (!control_pressed) {
|
||||||
goto normal_key;
|
goto normal_key;
|
||||||
}
|
}
|
||||||
|
#ifdef XK_KP_Home
|
||||||
case XK_KP_Home:
|
case XK_KP_Home:
|
||||||
|
#endif
|
||||||
case XK_Home:
|
case XK_Home:
|
||||||
if (tPtr->cursorPosition > 0) {
|
if (tPtr->cursorPosition > 0) {
|
||||||
paintCursor(tPtr);
|
paintCursor(tPtr);
|
||||||
@@ -1058,7 +1064,9 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
|||||||
if (!control_pressed) {
|
if (!control_pressed) {
|
||||||
goto normal_key;
|
goto normal_key;
|
||||||
}
|
}
|
||||||
|
#ifdef XK_KP_End
|
||||||
case XK_KP_End:
|
case XK_KP_End:
|
||||||
|
#endif
|
||||||
case XK_End:
|
case XK_End:
|
||||||
if (tPtr->cursorPosition < tPtr->textLen) {
|
if (tPtr->cursorPosition < tPtr->textLen) {
|
||||||
paintCursor(tPtr);
|
paintCursor(tPtr);
|
||||||
@@ -1104,7 +1112,9 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
|||||||
if (!control_pressed) {
|
if (!control_pressed) {
|
||||||
goto normal_key;
|
goto normal_key;
|
||||||
}
|
}
|
||||||
|
#ifdef XK_KP_Delete
|
||||||
case XK_KP_Delete:
|
case XK_KP_Delete:
|
||||||
|
#endif
|
||||||
case XK_Delete:
|
case XK_Delete:
|
||||||
if (tPtr->cursorPosition < tPtr->textLen || tPtr->prevselection.count) {
|
if (tPtr->cursorPosition < tPtr->textLen || tPtr->prevselection.count) {
|
||||||
WMRange range;
|
WMRange range;
|
||||||
|
|||||||
Reference in New Issue
Block a user