1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-04 04:44:16 +01:00

multiview and vertical splitview

some bug fixes
configurable default font size
etc
This commit is contained in:
kojima
1999-10-27 22:32:12 +00:00
parent 4e65111750
commit 94f4483dbd
34 changed files with 2756 additions and 1399 deletions

View File

@@ -6,10 +6,15 @@ changes since wmaker 0.61.1:
- rewrote WMPopUpButton to use WMMenuItem
- added WMGetPopUpButtonMenuItem(WMPopUpButton *bPtr, int index)
- WMSortListItemsWithComparer(WMList *lPtr, (int)(f)(const void*, const void*))
- WMSortBrowserColumnWithComparer()
- fixed bug with sorting list items.
- fixed bug in handling keyboard input associated with selection and
notification sending.
- filepanel puts dirs on top of list (Wolff <wolff@cybercable.fr>)
- added WMReplaceInBag (Wolff <wolff@cybercable.fr>)
- added vertical views and multiple views in WMSplitView (Wolff <wolff@cybercable.fr>)
- changed values of parameter values of WMSplitViewConstrainProc()
- configurable default fontsize patch (Igor P. Roboul <igor@mordor.myip.org>)
changes since wmaker 0.61.0:
............................

View File

@@ -107,14 +107,14 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WINGs/Resources/Makefile
cd $(top_srcdir) && $(AUTOMAKE) --gnu WINGs/Resources/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
@@ -146,6 +146,11 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = WINGs/Resources
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu WINGs/Resources/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \

View File

@@ -407,7 +407,7 @@ typedef void WMSplitViewResizeSubviewsProc(WMSplitView *sPtr,
*/
typedef void WMSplitViewConstrainProc(WMSplitView *sPtr, int dividerIndex,
int *minCoordinate, int *maxCoordinate);
int *minSize, int *maxSize);
typedef WMWidget *WMMatrixCreateCellProc(WMMatrix *mPtr);
@@ -1016,6 +1016,9 @@ WMListItem *WMInsertBrowserItem(WMBrowser *bPtr, int column, int row, char *text
void WMSortBrowserColumn(WMBrowser *bPtr, int column);
void WMSortBrowserColumnWithComparer(WMBrowser *bPtr, int column,
int (f)(const void*, const void*));
/* Don't free the returned string. */
char* WMSetBrowserPath(WMBrowser *bPtr, char *path);
@@ -1248,8 +1251,20 @@ void WMSetSliderImage(WMSlider *sPtr, WMPixmap *pixmap);
/* ....................................................................... */
/* only supports 2 subviews */
WMSplitView *WMCreateSplitView(WMWidget *parent);
Bool WMGetSplitViewVertical(WMSplitView *sPtr);
void WMSetSplitViewVertical(WMSplitView *sPtr, Bool flag);
int WMGetSplitViewSubViewsCount(WMSplitView *sPtr); /* ??? remove ??? */
WMView *WMGetSplitViewSubViewAt(WMSplitView *sPtr, int index);
/* remove the first subview == view */
void WMRemoveSplitViewSubview(WMSplitView *sPtr, WMView *view);
void WMRemoveSplitViewSubviewAt(WMSplitView *sPtr, int index);
void WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview);
@@ -1297,7 +1312,6 @@ void WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index);
void WMSetTabViewDelegate(WMTabView *tPtr, WMTabViewDelegate *delegate);
/* ....................................................................... */
WMTabViewItem *WMCreateTabViewItemWithIdentifier(int identifier);

View File

@@ -351,6 +351,7 @@ typedef struct W_EventHandler {
typedef struct _WINGsConfiguration {
char *systemFont;
char *boldSystemFont;
int defaultFontSize;
Bool useMultiByte;
unsigned doubleClickDelay;
} _WINGsConfiguration;

View File

@@ -253,6 +253,7 @@ void *WMGetFromBag(WMBag *bag, int index);
int WMCountInBag(WMBag *bag, void *item);
void *WMReplaceInBag(WMBag *bag, int index, void *item);
/* comparer must return:
* < 0 if a < b

View File

@@ -130,8 +130,7 @@ WMRemoveFromBag(WMBag *bag, void *item)
void
WMDeleteFromBag(WMBag *bag, int index)
{
if (index < 0 || index >= bag->count)
return;
wassertr(index >= 0 && index < bag->count);
if (index < bag->count-1) {
memmove(&bag->items[index], &bag->items[index + 1],
@@ -144,9 +143,7 @@ WMDeleteFromBag(WMBag *bag, int index)
void*
WMGetFromBag(WMBag *bag, int index)
{
if (index < 0 || index >= bag->count) {
return NULL;
}
wassertrv(index >= 0 && index < bag->count, NULL);
return bag->items[index];
}
@@ -203,3 +200,17 @@ WMMapBag(WMBag *bag, void *(*function)(void *))
return new;
}
void*
WMReplaceInBag(WMBag *bag, int index, void *item)
{
void *old;
wassertrv(index >= 0 && index < bag->count, NULL);
old = bag->items[index];
bag->items[index] = item;
return old;
}

View File

@@ -38,7 +38,11 @@ W_ReadConfigurations(void)
WINGsConfiguration.doubleClickDelay =
WMGetUDIntegerForKey(defaults, "DoubleClickTime");
WINGsConfiguration.defaultFontSize =
WMGetUDIntegerForKey(defaults, "DefaultFontSize");
}
if (!WINGsConfiguration.systemFont) {
WINGsConfiguration.systemFont = SYSTEM_FONT;
@@ -49,5 +53,9 @@ W_ReadConfigurations(void)
if (WINGsConfiguration.doubleClickDelay == 0) {
WINGsConfiguration.doubleClickDelay = 250;
}
if (WINGsConfiguration.defaultFontSize == 0) {
WINGsConfiguration.defaultFontSize = 12;
}
}

View File

@@ -440,6 +440,14 @@ WMSortBrowserColumn(WMBrowser *bPtr, int column)
}
void
WMSortBrowserColumnWithComparer(WMBrowser *bPtr, int column,
int (f)(const void*, const void*))
{
WMSortListItemsWithComparer(bPtr->columns[column], f);
}
WMListItem*
WMInsertBrowserItem(WMBrowser *bPtr, int column, int row, char *text,

View File

@@ -532,6 +532,19 @@ filterFileName(WMFilePanel *panel, char *file, Bool isDirectory)
}
#define CAST(item) (*((WMListItem**)item))
static int
comparer(const void *a, const void *b)
{
if (CAST(a)->isBranch == CAST(b)->isBranch)
return (strcmp(CAST(a)->text, CAST(b)->text));
if (CAST(a)->isBranch)
return (-1);
return (1);
}
#undef CAST
static void
listDirectoryOnColumn(WMFilePanel *panel, int column, char *path)
{
@@ -581,7 +594,7 @@ listDirectoryOnColumn(WMFilePanel *panel, int column, char *path)
WMInsertBrowserItem(bPtr, column, -1, dentry->d_name, isDirectory);
}
}
WMSortBrowserColumn(bPtr, column);
WMSortBrowserColumnWithComparer(bPtr, column, comparer);
closedir(dir);
}

View File

@@ -82,13 +82,15 @@ static void sizeClick(WMWidget *, void *);
static void listFamilies(WMScreen *scr, WMFontPanel *panel);
static void
splitViewConstrainCallback(WMSplitView *sPtr, int divIndex, int *min, int *max)
{
*min = MIN_UPPER_HEIGHT;
*max = WMWidgetHeight(sPtr)-BUTTON_SPACE_HEIGHT-MIN_LOWER_HEIGHT;
}
static void
splitViewConstrainCallback(WMSplitView *sPtr, int indView, int *min, int *max)
{
if (indView == 0)
*min = MIN_UPPER_HEIGHT;
else
*min = MIN_LOWER_HEIGHT;
}
static void
notificationObserver(void *self, WMNotification *notif)

View File

@@ -635,9 +635,11 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
WINGsConfiguration.defaultFontSize);
scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr,
WINGsConfiguration.defaultFontSize);
if (!scrPtr->boldFont)
scrPtr->boldFont = scrPtr->normalFont;

View File

@@ -130,15 +130,7 @@ WMCreateList(WMWidget *parent)
static int
comparator(const void *a, const void *b)
{
WMListItem *item1 = *(WMListItem**)a;
WMListItem *item2 = *(WMListItem**)b;
if (strcmp(item1->text, item2->text) < 0)
return -1;
else if (strcmp(item1->text, item2->text) > 0)
return 1;
else
return 0;
return (strcmp((*(WMListItem**)a)->text, (*(WMListItem**)b)->text));
}

File diff suppressed because it is too large Load Diff

View File

@@ -393,7 +393,6 @@ testPullDown(WMScreen *scr)
}
void
testTabView(WMScreen *scr)
{
@@ -461,6 +460,172 @@ testTabView(WMScreen *scr)
}
void
splitViewConstrainProc(WMSplitView *sPtr, int indView,
int *minSize, int *maxSize)
{
switch (indView) {
case 0:
*minSize = 20;
break;
case 1:
*minSize = 40;
*maxSize = 80;
break;
case 2:
*maxSize = 60;
break;
default:
break;
}
}
static void
resizeSplitView(XEvent *event, void *data)
{
WMSplitView *sPtr = (WMSplitView*)data;
if (event->type == ConfigureNotify) {
int width = event->xconfigure.width - 10;
if (width < WMGetSplitViewDividerThickness(sPtr))
width = WMGetSplitViewDividerThickness(sPtr);
if (width != WMWidgetWidth(sPtr) ||
event->xconfigure.height != WMWidgetHeight(sPtr))
WMResizeWidget(sPtr, width, event->xconfigure.height - 55);
}
}
void
appendSubviewButtonAction(WMWidget *self, void *data)
{
WMSplitView *sPtr = (WMSplitView*)data;
char buf[64];
WMLabel *label = WMCreateLabel(sPtr);
sprintf(buf, "Subview %d", WMGetSplitViewSubViewsCount(sPtr) + 1);
WMSetLabelText(label, buf);
WMSetLabelRelief(label, WRSunken);
WMAddSplitViewSubview(sPtr, WMWidgetView(label));
WMRealizeWidget(label);
WMMapWidget(label);
}
void
removeSubviewButtonAction(WMWidget *self, void *data)
{
WMSplitView *sPtr = (WMSplitView*)data;
int count = WMGetSplitViewSubViewsCount(sPtr);
if (count > 2) {
WMView *view = WMGetSplitViewSubViewAt(sPtr, count-1);
WMDestroyWidget(WMWidgetOfView(view));
WMRemoveSplitViewSubviewAt(sPtr, count-1);
}
}
void
orientationButtonAction(WMWidget *self, void *data)
{
WMSplitView *sPtr = (WMSplitView*)data;
WMSetSplitViewVertical(sPtr, !WMGetSplitViewVertical(sPtr));
}
void
adjustSubviewsButtonAction(WMWidget *self, void *data)
{
WMAdjustSplitViewSubViews((WMSplitView*)data);
}
void
testSplitView(WMScreen *scr)
{
WMWindow *win;
WMSplitView *splitv1, *splitv2;
WMFrame *frame;
WMLabel *label;
WMButton *button;
windowCount++;
win = WMCreateWindow(scr, "testTabs");
WMResizeWidget(win, 300, 400);
WMSetWindowCloseAction(win, closeAction, NULL);
frame = WMCreateFrame(win);
WMSetFrameRelief(frame, WRSunken);
WMMoveWidget(frame, 5, 5);
WMResizeWidget(frame, 290, 40);
splitv1 = WMCreateSplitView(win);
WMMoveWidget(splitv1, 5, 50);
WMResizeWidget(splitv1, 290, 345);
WMSetSplitViewConstrainProc(splitv1, splitViewConstrainProc);
WMCreateEventHandler(WMWidgetView(win), StructureNotifyMask,
resizeSplitView, splitv1);
button = WMCreateCommandButton(frame);
WMSetButtonText(button, "+");
WMSetButtonAction(button, appendSubviewButtonAction, splitv1);
WMMoveWidget(button, 10, 8);
WMMapWidget(button);
button = WMCreateCommandButton(frame);
WMSetButtonText(button, "-");
WMSetButtonAction(button, removeSubviewButtonAction, splitv1);
WMMoveWidget(button, 80, 8);
WMMapWidget(button);
button = WMCreateCommandButton(frame);
WMSetButtonText(button, "=");
WMMoveWidget(button, 150, 8);
WMSetButtonAction(button, adjustSubviewsButtonAction, splitv1);
WMMapWidget(button);
button = WMCreateCommandButton(frame);
WMSetButtonText(button, "#");
WMMoveWidget(button, 220, 8);
WMSetButtonAction(button, orientationButtonAction, splitv1);
WMMapWidget(button);
label = WMCreateLabel(splitv1);
WMSetLabelText(label, "Subview 1");
WMSetLabelRelief(label, WRSunken);
WMMapWidget(label);
WMAddSplitViewSubview(splitv1, WMWidgetView(label));
splitv2 = WMCreateSplitView(splitv1);
WMResizeWidget(splitv2, 150, 150);
WMSetSplitViewVertical(splitv2, True);
label = WMCreateLabel(splitv2);
WMSetLabelText(label, "Subview 2.1");
WMSetLabelRelief(label, WRSunken);
WMMapWidget(label);
WMAddSplitViewSubview(splitv2, WMWidgetView(label));
label = WMCreateLabel(splitv2);
WMSetLabelText(label, "Subview 2.2");
WMSetLabelRelief(label, WRSunken);
WMMapWidget(label);
WMAddSplitViewSubview(splitv2, WMWidgetView(label));
label = WMCreateLabel(splitv2);
WMSetLabelText(label, "Subview 2.3");
WMSetLabelRelief(label, WRSunken);
WMMapWidget(label);
WMAddSplitViewSubview(splitv2, WMWidgetView(label));
WMMapWidget(splitv2);
WMAddSplitViewSubview(splitv1, WMWidgetView(splitv2));
WMRealizeWidget(win);
WMMapSubwidgets(win);
WMMapWidget(win);
}
#include "WUtil.h"
@@ -513,8 +678,7 @@ int main(int argc, char **argv)
*/
testPullDown(scr);
testSplitView(scr);
testFontPanel(scr);
#if 0
@@ -527,11 +691,11 @@ int main(int argc, char **argv)
testOpenFilePanel(scr);
testList(scr);
testGradientButtons(scr);
testScrollView(scr);
testSlider(scr);
testPullDown(scr);
#endif
/*
* The main event loop.