mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
- added WMGetLabelText()
- added WMReparentWidget() - added WMCreateTabViewItem() - added W_CreateUnmanagedTopView() - fixed deletion from tree bag
This commit is contained in:
@@ -4,6 +4,12 @@ changes since wmaker 0.62.1:
|
||||
- added WText widget (rtf multiline text widget)
|
||||
Nwanua Elumeze <nwanua@colorado.edu>
|
||||
- added a new AUTO option for the UseMultiByte option
|
||||
- added WMRaiseWidget()/WMLowerWidget()
|
||||
- added missing EscapeTextMovement to textfield delegate/notification
|
||||
- added WMGetLabelText()
|
||||
- added WMReparentWidget()
|
||||
- added WMCreateTabViewItem()
|
||||
- added W_CreateUnmanagedTopView()
|
||||
|
||||
changes since wmaker 0.62.0:
|
||||
............................
|
||||
|
||||
@@ -805,6 +805,10 @@ void WMUnmapWidget(WMWidget *w);
|
||||
|
||||
void WMMapWidget(WMWidget *w);
|
||||
|
||||
void WMRaiseWidget(WMWidget *w);
|
||||
|
||||
void WMLowerWidget(WMWidget *w);
|
||||
|
||||
void WMMoveWidget(WMWidget *w, int x, int y);
|
||||
|
||||
void WMResizeWidget(WMWidget *w, unsigned int width, unsigned int height);
|
||||
@@ -976,6 +980,8 @@ void WMSetLabelImage(WMLabel *lPtr, WMPixmap *image);
|
||||
|
||||
WMPixmap *WMGetLabelImage(WMLabel *lPtr);
|
||||
|
||||
char *WMGetLabelText(WMLabel *lPtr);
|
||||
|
||||
void WMSetLabelImagePosition(WMLabel *lPtr, WMImagePosition position);
|
||||
|
||||
void WMSetLabelTextAlignment(WMLabel *lPtr, WMAlignment alignment);
|
||||
@@ -1404,7 +1410,7 @@ WMRuler *WMCreateRuler (WMWidget *parent);
|
||||
|
||||
void WMShowRulerTabs(WMRuler *rPtr, Bool Show);
|
||||
|
||||
WMRulerMargins WMGetRulerMargins(WMRuler *rPtr);
|
||||
int WMGetRulerMargin(WMRuler *rPtr, int which);
|
||||
|
||||
void WMSetRulerMargins(WMRuler *rPtr, WMRulerMargins margins);
|
||||
|
||||
@@ -1522,6 +1528,8 @@ void WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index);
|
||||
void WMSetTabViewDelegate(WMTabView *tPtr, WMTabViewDelegate *delegate);
|
||||
|
||||
|
||||
WMTabViewItem *WMCreateTabViewItem(int identifier, char *label);
|
||||
|
||||
WMTabViewItem *WMCreateTabViewItemWithIdentifier(int identifier);
|
||||
|
||||
int WMGetTabViewItemIdentifier(WMTabViewItem *item);
|
||||
|
||||
@@ -327,7 +327,7 @@ typedef struct W_View {
|
||||
|
||||
struct W_View *nextSister; /* next on parent's children list */
|
||||
|
||||
struct W_EventHandler *handlerList;/* list of event handlers for this window */
|
||||
WMBag *eventHandlers; /* event handlers for this window */
|
||||
|
||||
unsigned long attribFlags;
|
||||
XSetWindowAttributes attribs;
|
||||
@@ -377,8 +377,6 @@ typedef struct W_EventHandler {
|
||||
WMEventProc *proc;
|
||||
|
||||
void *clientData;
|
||||
|
||||
struct W_EventHandler *nextHandler;
|
||||
} W_EventHandler;
|
||||
|
||||
|
||||
@@ -407,7 +405,8 @@ extern _WINGsConfiguration WINGsConfiguration;
|
||||
|
||||
#define W_VIEW_REALIZED(view) (view)->flags.realized
|
||||
#define W_VIEW_MAPPED(view) (view)->flags.mapped
|
||||
|
||||
|
||||
#define W_VIEW_DISPLAY(view) (view)->screen->display
|
||||
#define W_VIEW_SCREEN(view) (view)->screen
|
||||
#define W_VIEW_DRAWABLE(view) (view)->window
|
||||
|
||||
@@ -429,6 +428,8 @@ W_View *W_CreateView(W_View *parent);
|
||||
|
||||
W_View *W_CreateTopView(W_Screen *screen);
|
||||
|
||||
W_View *W_CreateUnmanagedTopView(W_Screen *screen);
|
||||
|
||||
|
||||
W_View *W_CreateRootView(W_Screen *screen);
|
||||
|
||||
@@ -438,6 +439,11 @@ void W_RealizeView(W_View *view);
|
||||
|
||||
void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
|
||||
|
||||
void W_RaiseView(W_View *view);
|
||||
|
||||
void W_LowerView(W_View *view);
|
||||
|
||||
|
||||
void W_MapView(W_View *view);
|
||||
|
||||
void W_MapSubviews(W_View *view);
|
||||
|
||||
@@ -217,7 +217,7 @@ static void rbTreeInsert(W_TreeBag *tree, W_Node *node)
|
||||
static void rbDeleteFixup(W_TreeBag *tree, W_Node *node)
|
||||
{
|
||||
W_Node *w;
|
||||
|
||||
|
||||
while (node != tree->root && node->color == 'B') {
|
||||
if (IS_LEFT(node)) {
|
||||
w = node->parent->right;
|
||||
@@ -248,7 +248,7 @@ static void rbDeleteFixup(W_TreeBag *tree, W_Node *node)
|
||||
if (w->color == 'R') {
|
||||
w->color = 'B';
|
||||
node->parent->color = 'R';
|
||||
leftRotate(tree, node->parent);
|
||||
rightRotate(tree, node->parent);
|
||||
w = node->parent->left;
|
||||
}
|
||||
if (w->left->color == 'B' && w->right->color == 'B') {
|
||||
@@ -258,18 +258,19 @@ static void rbDeleteFixup(W_TreeBag *tree, W_Node *node)
|
||||
if (w->left->color == 'B') {
|
||||
w->right->color = 'B';
|
||||
w->color = 'R';
|
||||
rightRotate(tree, w);
|
||||
leftRotate(tree, w);
|
||||
w = node->parent->left;
|
||||
}
|
||||
w->color = node->parent->color;
|
||||
node->parent->color = 'B';
|
||||
w->left->color = 'B';
|
||||
leftRotate(tree, node->parent);
|
||||
rightRotate(tree, node->parent);
|
||||
node = tree->root;
|
||||
}
|
||||
}
|
||||
}
|
||||
node->color = 'B';
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -481,11 +482,13 @@ static int appendBag(WMBag *self, WMBag *bag)
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern WMBag *bla;
|
||||
|
||||
static int putInBag(WMBag *self, void *item)
|
||||
{
|
||||
W_Node *ptr;
|
||||
|
||||
|
||||
ptr = wmalloc(sizeof(W_Node));
|
||||
|
||||
ptr->data = item;
|
||||
@@ -505,7 +508,7 @@ static int putInBag(WMBag *self, void *item)
|
||||
static int insertInBag(WMBag *self, int index, void *item)
|
||||
{
|
||||
W_Node *ptr;
|
||||
|
||||
|
||||
ptr = wmalloc(sizeof(W_Node));
|
||||
|
||||
ptr->data = item;
|
||||
@@ -569,6 +572,8 @@ static int eraseFromBag(WMBag *self, int index)
|
||||
self->destructor(ptr->data);
|
||||
free(ptr);
|
||||
|
||||
wassertrv(SELF->count == 0||SELF->root->index >= 0, 1);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -579,23 +584,25 @@ static int eraseFromBag(WMBag *self, int index)
|
||||
static int deleteFromBag(WMBag *self, int index)
|
||||
{
|
||||
W_Node *ptr = treeSearch(SELF->root, SELF->nil, index);
|
||||
|
||||
|
||||
if (ptr != SELF->nil) {
|
||||
W_Node *tmp;
|
||||
|
||||
SELF->count--;
|
||||
|
||||
|
||||
tmp = treeSuccessor(ptr, SELF->nil);
|
||||
while (tmp != SELF->nil) {
|
||||
tmp->index--;
|
||||
tmp = treeSuccessor(tmp, SELF->nil);
|
||||
}
|
||||
|
||||
|
||||
ptr = rbTreeDelete(SELF, ptr);
|
||||
if (self->destructor)
|
||||
self->destructor(ptr->data);
|
||||
free(ptr);
|
||||
|
||||
wassertrv(SELF->count == 0||SELF->root->index >= 0, 1);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
@@ -713,7 +713,7 @@ WMDragImageFromView(WMView *view, WMPixmap *image, char *dataTypes[],
|
||||
/* start pointer grab */
|
||||
XGrabPointer(dpy, scr->rootWin, False,
|
||||
ButtonPressMask|ButtonReleaseMask|ButtonMotionMask,
|
||||
GrabModeSync, GrabModeAsync, None, scr->defaultCursor,
|
||||
GrabModeAsync, GrabModeAsync, None, scr->defaultCursor,
|
||||
CurrentTime);
|
||||
|
||||
XFlush(dpy);
|
||||
@@ -739,7 +739,6 @@ WMDragImageFromView(WMView *view, WMPixmap *image, char *dataTypes[],
|
||||
state = 1;
|
||||
|
||||
while (state != 6 && state != 0 && !_XErrorOccured) {
|
||||
XAllowEvents(dpy, SyncPointer, CurrentTime);
|
||||
WMNextEvent(dpy, &ev);
|
||||
|
||||
switch (ev.type) {
|
||||
|
||||
@@ -61,16 +61,13 @@ W_CreateBalloon(WMScreen *scr)
|
||||
bPtr = wmalloc(sizeof(Balloon));
|
||||
memset(bPtr, 0, sizeof(Balloon));
|
||||
|
||||
bPtr->view = W_CreateTopView(scr);
|
||||
bPtr->view = W_CreateUnmanagedTopView(scr);
|
||||
if (!bPtr->view) {
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
}
|
||||
bPtr->view->self = bPtr;
|
||||
|
||||
bPtr->view->attribFlags |= CWOverrideRedirect;
|
||||
bPtr->view->attribs.override_redirect = True;
|
||||
|
||||
bPtr->textColor = WMRetainColor(bPtr->view->screen->black);
|
||||
|
||||
WMCreateEventHandler(bPtr->view, StructureNotifyMask, handleEvents, bPtr);
|
||||
|
||||
103
WINGs/wevent.c
103
WINGs/wevent.c
@@ -403,38 +403,27 @@ void
|
||||
WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
|
||||
void *clientData)
|
||||
{
|
||||
W_EventHandler *handler;
|
||||
W_EventHandler *ptr = view->handlerList;
|
||||
W_EventHandler *handler, *ptr;
|
||||
unsigned long eventMask;
|
||||
|
||||
if (ptr==NULL) {
|
||||
WMBagIterator iter;
|
||||
|
||||
|
||||
handler = NULL;
|
||||
eventMask = mask;
|
||||
|
||||
WM_ITERATE_BAG(view->eventHandlers, ptr, iter) {
|
||||
if (ptr->clientData == clientData && ptr->proc == eventProc) {
|
||||
handler = ptr;
|
||||
eventMask |= ptr->eventMask;
|
||||
}
|
||||
}
|
||||
if (!handler) {
|
||||
handler = wmalloc(sizeof(W_EventHandler));
|
||||
|
||||
handler->nextHandler = NULL;
|
||||
|
||||
view->handlerList = handler;
|
||||
|
||||
eventMask = mask;
|
||||
} else {
|
||||
handler = NULL;
|
||||
eventMask = mask;
|
||||
while (ptr != NULL) {
|
||||
if (ptr->clientData == clientData && ptr->proc == eventProc) {
|
||||
handler = ptr;
|
||||
}
|
||||
eventMask |= ptr->eventMask;
|
||||
|
||||
ptr = ptr->nextHandler;
|
||||
}
|
||||
if (!handler) {
|
||||
handler = wmalloc(sizeof(W_EventHandler));
|
||||
handler->nextHandler = view->handlerList;
|
||||
view->handlerList = handler;
|
||||
}
|
||||
WMPutInBag(view->eventHandlers, handler);
|
||||
}
|
||||
|
||||
/* select events for window */
|
||||
handler->eventMask = mask;
|
||||
handler->eventMask = eventMask;
|
||||
handler->proc = eventProc;
|
||||
handler->clientData = clientData;
|
||||
}
|
||||
@@ -450,31 +439,24 @@ void
|
||||
WMDeleteEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
|
||||
void *clientData)
|
||||
{
|
||||
W_EventHandler *handler, *ptr, *pptr;
|
||||
|
||||
ptr = view->handlerList;
|
||||
|
||||
W_EventHandler *handler, *ptr;
|
||||
WMBagIterator iter;
|
||||
|
||||
handler = NULL;
|
||||
pptr = NULL;
|
||||
|
||||
while (ptr!=NULL) {
|
||||
WM_ITERATE_BAG(view->eventHandlers, ptr, iter) {
|
||||
if (ptr->eventMask == mask && ptr->proc == eventProc
|
||||
&& ptr->clientData == clientData) {
|
||||
handler = ptr;
|
||||
break;
|
||||
}
|
||||
pptr = ptr;
|
||||
ptr = ptr->nextHandler;
|
||||
}
|
||||
|
||||
if (!handler)
|
||||
return;
|
||||
|
||||
if (!pptr) {
|
||||
view->handlerList = handler->nextHandler;
|
||||
} else {
|
||||
pptr->nextHandler = handler->nextHandler;
|
||||
}
|
||||
WMRemoveFromBag(view->eventHandlers, handler);
|
||||
|
||||
wfree(handler);
|
||||
}
|
||||
|
||||
@@ -483,14 +465,11 @@ WMDeleteEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
|
||||
void
|
||||
W_CleanUpEvents(WMView *view)
|
||||
{
|
||||
W_EventHandler *ptr, *nptr;
|
||||
W_EventHandler *ptr;
|
||||
WMBagIterator iter;
|
||||
|
||||
ptr = view->handlerList;
|
||||
|
||||
while (ptr!=NULL) {
|
||||
nptr = ptr->nextHandler;
|
||||
WM_ITERATE_BAG(view->eventHandlers, ptr, iter) {
|
||||
wfree(ptr);
|
||||
ptr = nptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,18 +508,17 @@ void
|
||||
W_CallDestroyHandlers(W_View *view)
|
||||
{
|
||||
XEvent event;
|
||||
WMBagIterator iter;
|
||||
W_EventHandler *hPtr;
|
||||
|
||||
event.type = DestroyNotify;
|
||||
event.xdestroywindow.window = view->window;
|
||||
event.xdestroywindow.event = view->window;
|
||||
hPtr = view->handlerList;
|
||||
while (hPtr!=NULL) {
|
||||
|
||||
WM_ITERATE_BAG(view->eventHandlers, hPtr, iter) {
|
||||
if (hPtr->eventMask & StructureNotifyMask) {
|
||||
(*hPtr->proc)(&event, hPtr->clientData);
|
||||
}
|
||||
|
||||
hPtr = hPtr->nextHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,6 +530,7 @@ WMHandleEvent(XEvent *event)
|
||||
W_View *view, *vPtr, *toplevel;
|
||||
unsigned long mask;
|
||||
Window window;
|
||||
WMBagIterator iter;
|
||||
|
||||
if (event->type == MappingNotify) {
|
||||
XRefreshKeyboardMapping(&event->xmapping);
|
||||
@@ -570,6 +549,7 @@ WMHandleEvent(XEvent *event)
|
||||
}
|
||||
}
|
||||
view = W_GetViewForXWindow(event->xany.display, window);
|
||||
|
||||
if (!view) {
|
||||
if (extraEventHandler)
|
||||
(extraEventHandler)(event);
|
||||
@@ -642,34 +622,23 @@ WMHandleEvent(XEvent *event)
|
||||
* might destroy the widget. */
|
||||
W_RetainView(toplevel);
|
||||
|
||||
hPtr = view->handlerList;
|
||||
|
||||
while (hPtr!=NULL) {
|
||||
W_EventHandler *tmp;
|
||||
|
||||
tmp = hPtr->nextHandler;
|
||||
|
||||
WM_ITERATE_BAG(view->eventHandlers, hPtr, iter) {
|
||||
if ((hPtr->eventMask & mask)) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
|
||||
hPtr = tmp;
|
||||
}
|
||||
|
||||
|
||||
/* pass the event to the top level window of the widget */
|
||||
/* TODO: change this to a responder chain */
|
||||
if (view->parent != NULL) {
|
||||
vPtr = view;
|
||||
while (vPtr->parent != NULL)
|
||||
vPtr = vPtr->parent;
|
||||
|
||||
hPtr = vPtr->handlerList;
|
||||
|
||||
while (hPtr != NULL) {
|
||||
|
||||
WM_ITERATE_BAG(vPtr->eventHandlers, hPtr, iter) {
|
||||
if (hPtr->eventMask & mask) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
hPtr = hPtr->nextHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,9 +651,9 @@ WMHandleEvent(XEvent *event)
|
||||
view->screen->lastClickTime = event->xbutton.time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
W_ReleaseView(toplevel);
|
||||
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
@@ -880,6 +880,13 @@ WMMapWidget(WMWidget *w)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMReparentWidget(WMWidget *w, WMWidget *newParent, int x, int y)
|
||||
{
|
||||
W_ReparentView(W_VIEW(w), newParent, x, y);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
makeChildrenAutomap(W_View *view, int flag)
|
||||
{
|
||||
@@ -930,6 +937,22 @@ void
|
||||
WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
|
||||
{
|
||||
W_SetViewBackgroundColor(W_VIEW(w), color);
|
||||
if (W_VIEW(w)->flags.mapped)
|
||||
WMRedisplayWidget(w);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMRaiseWidget(WMWidget *w)
|
||||
{
|
||||
W_RaiseView(W_VIEW(w));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMLowerWidget(WMWidget *w)
|
||||
{
|
||||
W_LowerView(W_VIEW(w));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,6 +98,13 @@ WMGetLabelImage(WMLabel *lPtr)
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
WMGetLabelText(WMLabel *lPtr)
|
||||
{
|
||||
return lPtr->caption;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetLabelImagePosition(WMLabel *lPtr, WMImagePosition position)
|
||||
{
|
||||
|
||||
@@ -95,9 +95,7 @@ WMCreatePopUpButton(WMWidget *parent)
|
||||
|
||||
bPtr->selectedItemIndex = -1;
|
||||
|
||||
bPtr->menuView = W_CreateTopView(scr);
|
||||
bPtr->menuView->attribs.override_redirect = True;
|
||||
bPtr->menuView->attribFlags |= CWOverrideRedirect;
|
||||
bPtr->menuView = W_CreateUnmanagedTopView(scr);
|
||||
|
||||
W_ResizeView(bPtr->menuView, bPtr->view->size.width, 1);
|
||||
|
||||
|
||||
522
WINGs/wruler.c
522
WINGs/wruler.c
@@ -8,27 +8,27 @@
|
||||
|
||||
typedef struct W_Ruler {
|
||||
W_Class widgetClass;
|
||||
W_View *view;
|
||||
W_View *pview; /* the parent's view (for drawing the line) */
|
||||
W_View *view;
|
||||
W_View *pview; /* the parent's view (for drawing the line) */
|
||||
|
||||
WMAction *moveAction; /* what to when while moving */
|
||||
WMAction *releaseAction; /* what to do when released */
|
||||
WMAction *releaseAction; /* what to do when released */
|
||||
void *clientData;
|
||||
|
||||
GC fg, bg;
|
||||
WMFont *font;
|
||||
WMRulerMargins margins;
|
||||
int offset;
|
||||
int motion; /* the position of the _moving_ marker(s) */
|
||||
int end; /* the last tick on the baseline (restrict markers to it) */
|
||||
int motion; /* the position of the _moving_ marker(s) */
|
||||
int end; /* the last tick on the baseline (restrict markers to it) */
|
||||
|
||||
Pixmap drawBuffer;
|
||||
|
||||
struct {
|
||||
unsigned int buttonPressed:1;
|
||||
/* 0, 1, 2, 3, 4, 5, 6 */
|
||||
unsigned int whichMarker:3; /* none, left, right, first, body, tabstop, both */
|
||||
unsigned int RESERVED:28;
|
||||
unsigned int buttonPressed:1;
|
||||
/* 0, 1, 2, 3, 4, 5, 6 */
|
||||
unsigned int whichMarker:3; /* none, left, right, first, body, tabstop, both */
|
||||
unsigned int RESERVED:28;
|
||||
} flags;
|
||||
} Ruler;
|
||||
|
||||
@@ -36,158 +36,155 @@ typedef struct W_Ruler {
|
||||
|
||||
/* Marker for left margin
|
||||
|
||||
|\
|
||||
| \
|
||||
|__\
|
||||
|
|
||||
|
|
||||
|\
|
||||
| \
|
||||
|__\
|
||||
|
|
||||
|
|
||||
|
||||
*/
|
||||
static void
|
||||
drawLeftMarker(Ruler *rPtr)
|
||||
*/
|
||||
static void drawLeftMarker(Ruler * rPtr)
|
||||
{
|
||||
XPoint points[4];
|
||||
int xpos = (rPtr->flags.whichMarker==1?
|
||||
rPtr->motion:rPtr->margins.left);
|
||||
XPoint points[4];
|
||||
int xpos = (rPtr->flags.whichMarker == 1 ?
|
||||
rPtr->motion : rPtr->margins.left);
|
||||
|
||||
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, xpos, 8, xpos, 22);
|
||||
rPtr->fg, xpos, 8, xpos, 22);
|
||||
points[0].x = xpos;
|
||||
points[0].y = 1;
|
||||
points[1].x = points[0].x+6;
|
||||
points[1].x = points[0].x + 6;
|
||||
points[1].y = 8;
|
||||
points[2].x = points[0].x+6;
|
||||
points[2].x = points[0].x + 6;
|
||||
points[2].y = 9;
|
||||
points[3].x = points[0].x;
|
||||
points[3].y = 9;
|
||||
XFillPolygon (rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, points, 4, Convex, CoordModeOrigin);
|
||||
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, points, 4, Convex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
|
||||
/* Marker for right margin
|
||||
|
||||
/|
|
||||
/ |
|
||||
/__|
|
||||
|
|
||||
|
|
||||
/|
|
||||
/ |
|
||||
/__|
|
||||
|
|
||||
|
|
||||
|
||||
*/
|
||||
static void
|
||||
drawRightMarker(Ruler *rPtr)
|
||||
*/
|
||||
static void drawRightMarker(Ruler * rPtr)
|
||||
{
|
||||
XPoint points[4];
|
||||
int xpos = (rPtr->flags.whichMarker==2?
|
||||
rPtr->motion:rPtr->margins.right);
|
||||
XPoint points[4];
|
||||
int xpos = (rPtr->flags.whichMarker == 2 ?
|
||||
rPtr->motion : rPtr->margins.right);
|
||||
|
||||
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, xpos, 8, xpos, 22);
|
||||
points[0].x = xpos+1;
|
||||
rPtr->fg, xpos, 8, xpos, 22);
|
||||
points[0].x = xpos + 1;
|
||||
points[0].y = 0;
|
||||
points[1].x = points[0].x-6;
|
||||
points[1].x = points[0].x - 6;
|
||||
points[1].y = 7;
|
||||
points[2].x = points[0].x-6;
|
||||
points[2].x = points[0].x - 6;
|
||||
points[2].y = 9;
|
||||
points[3].x = points[0].x;
|
||||
points[3].y = 9;
|
||||
XFillPolygon (rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, points, 4, Convex, CoordModeOrigin);
|
||||
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, points, 4, Convex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
|
||||
/* Marker for first line only
|
||||
_____
|
||||
|___|
|
||||
|
|
||||
_____
|
||||
|___|
|
||||
|
|
||||
|
||||
*/
|
||||
static void
|
||||
drawFirstMarker(Ruler *rPtr)
|
||||
static void drawFirstMarker(Ruler * rPtr)
|
||||
{
|
||||
int xpos = ((rPtr->flags.whichMarker==3 || rPtr->flags.whichMarker==6)?
|
||||
rPtr->motion:rPtr->margins.first);
|
||||
int xpos = ((rPtr->flags.whichMarker == 3 || rPtr->flags.whichMarker == 6) ?
|
||||
rPtr->motion : rPtr->margins.first);
|
||||
|
||||
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, xpos-5, 10, 11, 5);
|
||||
rPtr->fg, xpos - 5, 10, 11, 5);
|
||||
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, xpos, 12, xpos, 22);
|
||||
rPtr->fg, xpos, 12, xpos, 22);
|
||||
}
|
||||
|
||||
/* Marker for rest of body
|
||||
_____
|
||||
\ /
|
||||
\./
|
||||
*/
|
||||
static void
|
||||
drawBodyMarker(Ruler *rPtr)
|
||||
_____
|
||||
\ /
|
||||
\./
|
||||
*/
|
||||
static void drawBodyMarker(Ruler * rPtr)
|
||||
{
|
||||
XPoint points[4];
|
||||
int xpos = ((rPtr->flags.whichMarker==4 || rPtr->flags.whichMarker==6)?
|
||||
rPtr->motion:rPtr->margins.body);
|
||||
points[0].x = xpos-5;
|
||||
XPoint points[4];
|
||||
int xpos = ((rPtr->flags.whichMarker == 4 || rPtr->flags.whichMarker == 6) ?
|
||||
rPtr->motion : rPtr->margins.body);
|
||||
|
||||
points[0].x = xpos - 5;
|
||||
points[0].y = 16;
|
||||
points[1].x = points[0].x+11;
|
||||
points[1].x = points[0].x + 11;
|
||||
points[1].y = 16;
|
||||
points[2].x = points[0].x+5;
|
||||
points[2].x = points[0].x + 5;
|
||||
points[2].y = 22;
|
||||
XFillPolygon (rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, points, 3, Convex, CoordModeOrigin);
|
||||
XFillPolygon(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, points, 3, Convex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
createDrawBuffer(Ruler *rPtr)
|
||||
static void createDrawBuffer(Ruler * rPtr)
|
||||
{
|
||||
if(rPtr->drawBuffer)
|
||||
XFreePixmap(rPtr->view->screen->display, rPtr->drawBuffer);
|
||||
if (rPtr->drawBuffer)
|
||||
XFreePixmap(rPtr->view->screen->display, rPtr->drawBuffer);
|
||||
rPtr->drawBuffer = XCreatePixmap(rPtr->view->screen->display,
|
||||
rPtr->view->window, rPtr->view->size.width, 40,
|
||||
rPtr->view->screen->depth);
|
||||
rPtr->view->window, rPtr->view->size.width, 40,
|
||||
rPtr->view->screen->depth);
|
||||
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->bg, 0, 0, rPtr->view->size.width, 40);
|
||||
rPtr->bg, 0, 0, rPtr->view->size.width, 40);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
drawRulerOnPixmap(Ruler *rPtr)
|
||||
static void drawRulerOnPixmap(Ruler * rPtr)
|
||||
{
|
||||
int i, j, w, m;
|
||||
char c[3];
|
||||
int marks[9] = {11, 3, 5, 3, 7, 3, 5, 3};
|
||||
int marks[9] =
|
||||
{11, 3, 5, 3, 7, 3, 5, 3};
|
||||
|
||||
if(!rPtr->drawBuffer)
|
||||
createDrawBuffer(rPtr);
|
||||
if (!rPtr->drawBuffer)
|
||||
createDrawBuffer(rPtr);
|
||||
|
||||
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->bg, 0, 0, rPtr->view->size.width, 40);
|
||||
rPtr->bg, 0, 0, rPtr->view->size.width, 40);
|
||||
|
||||
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
|
||||
rPtr->font, rPtr->margins.left+2, 26, "0 inches", 10);
|
||||
rPtr->font, rPtr->margins.left + 2, 26, "0 inches", 10);
|
||||
|
||||
/* marker ticks */
|
||||
i=j=m=0;
|
||||
i = j = m = 0;
|
||||
w = rPtr->view->size.width - rPtr->margins.left;
|
||||
while(m < w) {
|
||||
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, rPtr->margins.left+m, 23,
|
||||
rPtr->margins.left+m, marks[i%8]+23);
|
||||
if(i!=0 && i%8==0) {
|
||||
if(j<10)
|
||||
snprintf(c,3,"%d",++j);
|
||||
else
|
||||
snprintf(c,3,"%2d",++j);
|
||||
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
|
||||
rPtr->font, rPtr->margins.left+2+m, 26, c, 2);
|
||||
}
|
||||
m = (++i)*10;
|
||||
while (m < w) {
|
||||
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->fg, rPtr->margins.left + m, 23,
|
||||
rPtr->margins.left + m, marks[i % 8] + 23);
|
||||
if (i != 0 && i % 8 == 0) {
|
||||
if (j < 10)
|
||||
snprintf(c, 3, "%d", ++j);
|
||||
else
|
||||
snprintf(c, 3, "%2d", ++j);
|
||||
WMDrawString(rPtr->view->screen, rPtr->drawBuffer, rPtr->fg,
|
||||
rPtr->font, rPtr->margins.left + 2 + m, 26, c, 2);
|
||||
}
|
||||
m = (++i) * 10;
|
||||
}
|
||||
|
||||
rPtr->end = rPtr->margins.left+m-10;
|
||||
if(rPtr->margins.right > rPtr->end)
|
||||
rPtr->margins.right = rPtr->end;
|
||||
rPtr->end = rPtr->margins.left + m - 10;
|
||||
if (rPtr->margins.right > rPtr->end)
|
||||
rPtr->margins.right = rPtr->end;
|
||||
/* base line */
|
||||
XDrawLine(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->fg,
|
||||
rPtr->margins.left, 22, rPtr->margins.left+m-10, 22);
|
||||
rPtr->margins.left, 22, rPtr->margins.left + m - 10, 22);
|
||||
|
||||
drawLeftMarker(rPtr);
|
||||
drawRightMarker(rPtr);
|
||||
@@ -196,59 +193,58 @@ drawRulerOnPixmap(Ruler *rPtr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
paintRuler(Ruler *rPtr)
|
||||
static void paintRuler(Ruler * rPtr)
|
||||
{
|
||||
WMScreen *screen = rPtr->view->screen;
|
||||
if(1||!rPtr->drawBuffer) {
|
||||
drawRulerOnPixmap(rPtr);
|
||||
}
|
||||
|
||||
if (1 || !rPtr->drawBuffer) {
|
||||
drawRulerOnPixmap(rPtr);
|
||||
}
|
||||
XCopyArea(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->view->window, rPtr->bg, 0, 0, rPtr->view->size.width, 40,
|
||||
0, 0);
|
||||
rPtr->view->window, rPtr->bg, 0, 0, rPtr->view->size.width, 40,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
verifyMarkerMove(Ruler *rPtr, int x)
|
||||
verifyMarkerMove(Ruler * rPtr, int x)
|
||||
{
|
||||
if(rPtr->flags.whichMarker<1 || rPtr->flags.whichMarker>6)
|
||||
return False;
|
||||
if (rPtr->flags.whichMarker < 1 || rPtr->flags.whichMarker > 6)
|
||||
return False;
|
||||
|
||||
switch(rPtr->flags.whichMarker) {
|
||||
case 1:
|
||||
if(x > rPtr->margins.right - 10 || x < rPtr->offset ||
|
||||
rPtr->margins.body + x > rPtr->margins.right-MIN_DOC_WIDTH ||
|
||||
rPtr->margins.first + x > rPtr->margins.right-MIN_DOC_WIDTH)
|
||||
return False;
|
||||
break;
|
||||
switch (rPtr->flags.whichMarker) {
|
||||
case 1:
|
||||
if (x > rPtr->margins.right - 10 || x < rPtr->offset ||
|
||||
rPtr->margins.body + x > rPtr->margins.right - MIN_DOC_WIDTH ||
|
||||
rPtr->margins.first + x > rPtr->margins.right - MIN_DOC_WIDTH)
|
||||
return False;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if(x < rPtr->margins.first+MIN_DOC_WIDTH ||
|
||||
x < rPtr->margins.body+MIN_DOC_WIDTH ||
|
||||
x < rPtr->margins.left+MIN_DOC_WIDTH ||
|
||||
x > rPtr->end) /*rPtr->view->size.width)*/
|
||||
return False;
|
||||
break;
|
||||
case 2:
|
||||
if (x < rPtr->margins.first + MIN_DOC_WIDTH ||
|
||||
x < rPtr->margins.body + MIN_DOC_WIDTH ||
|
||||
x < rPtr->margins.left + MIN_DOC_WIDTH ||
|
||||
x > rPtr->end) /*rPtr->view->size.width) */
|
||||
return False;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if(x >= rPtr->margins.right-MIN_DOC_WIDTH || x < rPtr->margins.left)
|
||||
return False;
|
||||
break;
|
||||
case 3:
|
||||
if (x >= rPtr->margins.right - MIN_DOC_WIDTH || x < rPtr->margins.left)
|
||||
return False;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if(x >= rPtr->margins.right-MIN_DOC_WIDTH || x < rPtr->margins.left)
|
||||
return False;
|
||||
break;
|
||||
case 4:
|
||||
if (x >= rPtr->margins.right - MIN_DOC_WIDTH || x < rPtr->margins.left)
|
||||
return False;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if(x >= rPtr->margins.right-MIN_DOC_WIDTH || x < rPtr->margins.left)
|
||||
return False;
|
||||
break;
|
||||
case 6:
|
||||
if (x >= rPtr->margins.right - MIN_DOC_WIDTH || x < rPtr->margins.left)
|
||||
return False;
|
||||
break;
|
||||
|
||||
default:
|
||||
return False;
|
||||
default:
|
||||
return False;
|
||||
}
|
||||
|
||||
rPtr->motion = x;
|
||||
@@ -256,120 +252,123 @@ verifyMarkerMove(Ruler *rPtr, int x)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
whichMarker(Ruler *rPtr, int x, int y)
|
||||
static int whichMarker(Ruler * rPtr, int x, int y)
|
||||
{
|
||||
if(x<rPtr->offset || y>22)
|
||||
return 0;
|
||||
if (x < rPtr->offset || y > 22)
|
||||
return 0;
|
||||
|
||||
if( rPtr->margins.left-x >= -6 && y <= 9
|
||||
&& (rPtr->margins.left-x <=0) && y>=4) {
|
||||
rPtr->motion = rPtr->margins.left;
|
||||
return 1;
|
||||
if (rPtr->margins.left - x >= -6 && y <= 9
|
||||
&& (rPtr->margins.left - x <= 0) && y >= 4) {
|
||||
rPtr->motion = rPtr->margins.left;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(rPtr->margins.right-x >= -1 && y <= 11
|
||||
&& rPtr->margins.right-x <=5 && y>=4) {
|
||||
rPtr->motion = rPtr->margins.right;
|
||||
return 2;
|
||||
if (rPtr->margins.right - x >= -1 && y <= 11
|
||||
&& rPtr->margins.right - x <= 5 && y >= 4) {
|
||||
rPtr->motion = rPtr->margins.right;
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* both first and body? */
|
||||
if( rPtr->margins.first-x <= 4 && rPtr->margins.first-x >= -5
|
||||
&& rPtr->margins.body-x <= 4 && rPtr->margins.body-x >= -5
|
||||
&& y>=15 && y<=17) {
|
||||
rPtr->motion = rPtr->margins.first;
|
||||
return 6;
|
||||
if (rPtr->margins.first - x <= 4 && rPtr->margins.first - x >= -5
|
||||
&& rPtr->margins.body - x <= 4 && rPtr->margins.body - x >= -5
|
||||
&& y >= 15 && y <= 17) {
|
||||
rPtr->motion = rPtr->margins.first;
|
||||
return 6;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(rPtr->margins.first-x <= 4 && y<=15
|
||||
&& rPtr->margins.first-x >= -5 && y>=10) {
|
||||
rPtr->motion = rPtr->margins.first;
|
||||
return 3;
|
||||
if (rPtr->margins.first - x <= 4 && y <= 15
|
||||
&& rPtr->margins.first - x >= -5 && y >= 10) {
|
||||
rPtr->motion = rPtr->margins.first;
|
||||
return 3;
|
||||
}
|
||||
|
||||
if( rPtr->margins.body-x <= 4 && y<=21 &&
|
||||
rPtr->margins.body-x >= -5 && y>=17) {
|
||||
rPtr->motion = rPtr->margins.body;
|
||||
return 4;
|
||||
if (rPtr->margins.body - x <= 4 && y <= 21 &&
|
||||
rPtr->margins.body - x >= -5 && y >= 17) {
|
||||
rPtr->motion = rPtr->margins.body;
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
/* do tabs (5)*/
|
||||
/* do tabs (5) */
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
handleEvents(XEvent *event, void *data)
|
||||
static void handleEvents(XEvent * event, void *data)
|
||||
{
|
||||
Ruler *rPtr = (Ruler*)data;
|
||||
Ruler *rPtr = (Ruler *) data;
|
||||
Display *dpy = event->xany.display;
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
paintRuler(rPtr);
|
||||
break;
|
||||
case Expose:
|
||||
paintRuler(rPtr);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if(rPtr->flags.buttonPressed
|
||||
&& (event->xmotion.state & Button1Mask)) {
|
||||
if(verifyMarkerMove(rPtr, event->xmotion.x)){
|
||||
GC gc = WMColorGC(WMDarkGrayColor(rPtr->view->screen));
|
||||
paintRuler(rPtr);
|
||||
if(rPtr->moveAction)
|
||||
(rPtr->moveAction)(rPtr, rPtr->clientData);
|
||||
XSetLineAttributes(rPtr->view->screen->display, gc, 1,
|
||||
LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawLine(rPtr->pview->screen->display,
|
||||
rPtr->pview->window,
|
||||
gc, rPtr->motion+1, 40,
|
||||
rPtr->motion+1, rPtr->pview->size.height-5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
if (rPtr->flags.buttonPressed
|
||||
&& (event->xmotion.state & Button1Mask)) {
|
||||
if (verifyMarkerMove(rPtr, event->xmotion.x)) {
|
||||
GC gc = WMColorGC(WMDarkGrayColor(rPtr->view->screen));
|
||||
|
||||
case ButtonPress:
|
||||
if(event->xbutton.button != Button1)
|
||||
return;
|
||||
rPtr->flags.buttonPressed = True;
|
||||
rPtr->flags.whichMarker =
|
||||
whichMarker(rPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
break;
|
||||
paintRuler(rPtr);
|
||||
if (rPtr->moveAction)
|
||||
(rPtr->moveAction) (rPtr, rPtr->clientData);
|
||||
XSetLineAttributes(rPtr->view->screen->display, gc, 1,
|
||||
LineSolid, CapNotLast, JoinMiter);
|
||||
XDrawLine(rPtr->pview->screen->display,
|
||||
rPtr->pview->window,
|
||||
gc, rPtr->motion + 1, 40,
|
||||
rPtr->motion + 1, rPtr->pview->size.height - 5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if(event->xbutton.button != Button1)
|
||||
return;
|
||||
rPtr->flags.buttonPressed = False;
|
||||
switch(rPtr->flags.whichMarker) {
|
||||
case 1: {
|
||||
int change = rPtr->margins.left-rPtr->motion;
|
||||
rPtr->margins.first -=change;
|
||||
rPtr->margins.body -= change;
|
||||
rPtr->margins.left = rPtr->motion;
|
||||
paintRuler(rPtr); break;
|
||||
}
|
||||
case 2: rPtr->margins.right = rPtr->motion; break;
|
||||
case 3: rPtr->margins.first = rPtr->motion; break;
|
||||
case 4: rPtr->margins.body = rPtr->motion; break;
|
||||
case 6: rPtr->margins.first = rPtr->margins.body
|
||||
= rPtr->motion; break;
|
||||
}
|
||||
if(rPtr->releaseAction)
|
||||
(rPtr->releaseAction)(rPtr, rPtr->clientData);
|
||||
break;
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button != Button1)
|
||||
return;
|
||||
rPtr->flags.buttonPressed = True;
|
||||
rPtr->flags.whichMarker =
|
||||
whichMarker(rPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event->xbutton.button != Button1)
|
||||
return;
|
||||
rPtr->flags.buttonPressed = False;
|
||||
switch (rPtr->flags.whichMarker) {
|
||||
case 1:{
|
||||
int change = rPtr->margins.left - rPtr->motion;
|
||||
|
||||
rPtr->margins.first -= change;
|
||||
rPtr->margins.body -= change;
|
||||
rPtr->margins.left = rPtr->motion;
|
||||
paintRuler(rPtr);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
rPtr->margins.right = rPtr->motion;
|
||||
break;
|
||||
case 3:
|
||||
rPtr->margins.first = rPtr->motion;
|
||||
break;
|
||||
case 4:
|
||||
rPtr->margins.body = rPtr->motion;
|
||||
break;
|
||||
case 6:
|
||||
rPtr->margins.first = rPtr->margins.body
|
||||
= rPtr->motion;
|
||||
break;
|
||||
}
|
||||
if (rPtr->releaseAction)
|
||||
(rPtr->releaseAction) (rPtr, rPtr->clientData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rulerDidResize(W_ViewDelegate *self, WMView *view)
|
||||
static void rulerDidResize(W_ViewDelegate * self, WMView * view)
|
||||
{
|
||||
Ruler *rPtr = (Ruler *)view->self;
|
||||
Ruler *rPtr = (Ruler *) view->self;
|
||||
|
||||
createDrawBuffer(rPtr);
|
||||
paintRuler(rPtr);
|
||||
@@ -388,7 +387,7 @@ W_ViewDelegate _RulerViewDelegate =
|
||||
|
||||
|
||||
WMRuler *
|
||||
WMCreateRuler(WMWidget *parent)
|
||||
WMCreateRuler(WMWidget * parent)
|
||||
{
|
||||
Ruler *rPtr = wmalloc(sizeof(Ruler));
|
||||
unsigned int w = WMWidgetWidth(parent);
|
||||
@@ -399,8 +398,8 @@ WMCreateRuler(WMWidget *parent)
|
||||
|
||||
rPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!rPtr->view) {
|
||||
free(rPtr);
|
||||
return NULL;
|
||||
free(rPtr);
|
||||
return NULL;
|
||||
}
|
||||
rPtr->view->self = rPtr;
|
||||
|
||||
@@ -408,10 +407,10 @@ WMCreateRuler(WMWidget *parent)
|
||||
|
||||
W_ResizeView(rPtr->view, w, 40);
|
||||
|
||||
WMCreateEventHandler(rPtr->view, ExposureMask|StructureNotifyMask
|
||||
|EnterWindowMask|LeaveWindowMask|FocusChangeMask
|
||||
|ButtonReleaseMask|ButtonPressMask|KeyReleaseMask
|
||||
|KeyPressMask|Button1MotionMask, handleEvents, rPtr);
|
||||
WMCreateEventHandler(rPtr->view, ExposureMask | StructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask | FocusChangeMask
|
||||
| ButtonReleaseMask | ButtonPressMask | KeyReleaseMask
|
||||
| KeyPressMask | Button1MotionMask, handleEvents, rPtr);
|
||||
|
||||
rPtr->view->delegate = &_RulerViewDelegate;
|
||||
|
||||
@@ -423,9 +422,9 @@ WMCreateRuler(WMWidget *parent)
|
||||
rPtr->margins.left = 22;
|
||||
rPtr->margins.body = 22;
|
||||
rPtr->margins.first = 42;
|
||||
rPtr->margins.right = (w<502?w:502);
|
||||
rPtr->margins.right = (w < 502 ? w : 502);
|
||||
|
||||
rPtr->flags.whichMarker = 0; /* none */
|
||||
rPtr->flags.whichMarker = 0; /* none */
|
||||
rPtr->flags.buttonPressed = False;
|
||||
|
||||
rPtr->moveAction = NULL;
|
||||
@@ -437,75 +436,70 @@ WMCreateRuler(WMWidget *parent)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetRulerMargins(WMRuler *rPtr, WMRulerMargins margins)
|
||||
void WMSetRulerMargins(WMRuler * rPtr, WMRulerMargins margins)
|
||||
{
|
||||
if(!rPtr)
|
||||
return;
|
||||
if (!rPtr)
|
||||
return;
|
||||
rPtr->margins.left = margins.left + rPtr->offset;
|
||||
rPtr->margins.right = margins.right + rPtr->offset;
|
||||
rPtr->margins.first = margins.first + rPtr->offset;
|
||||
rPtr->margins.body = margins.body + rPtr->offset;
|
||||
rPtr->margins.tabs = margins.tabs; /*for loop*/
|
||||
rPtr->margins.tabs = margins.tabs; /*for loop */
|
||||
paintRuler(rPtr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
WMRulerMargins
|
||||
WMGetRulerMargins(WMRuler *rPtr)
|
||||
WMGetRulerMargins(WMRuler * rPtr)
|
||||
{
|
||||
WMRulerMargins margins;
|
||||
|
||||
if(!rPtr)
|
||||
return margins;
|
||||
if (!rPtr)
|
||||
return margins;
|
||||
|
||||
margins.left = rPtr->margins.left - rPtr->offset;
|
||||
margins.right = rPtr->margins.right - rPtr->offset;
|
||||
margins.first = rPtr->margins.first - rPtr->offset;
|
||||
margins.body = rPtr->margins.body - rPtr->offset;
|
||||
/*for*/
|
||||
/*for */
|
||||
margins.tabs = rPtr->margins.tabs;
|
||||
|
||||
return rPtr->margins;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetRulerOffset(WMRuler *rPtr, int pixels)
|
||||
void WMSetRulerOffset(WMRuler * rPtr, int pixels)
|
||||
{
|
||||
if(!rPtr || pixels<0 || pixels+MIN_DOC_WIDTH>=rPtr->view->size.width)
|
||||
return;
|
||||
if (!rPtr || pixels < 0 || pixels + MIN_DOC_WIDTH >= rPtr->view->size.width)
|
||||
return;
|
||||
rPtr->offset = pixels;
|
||||
/*rulerDidResize(rPtr, rPtr->view);*/
|
||||
/*rulerDidResize(rPtr, rPtr->view); */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
WMGetRulerOffset(WMRuler *rPtr)
|
||||
int WMGetRulerOffset(WMRuler * rPtr)
|
||||
{
|
||||
if(!rPtr)
|
||||
return;
|
||||
if (!rPtr)
|
||||
return;
|
||||
return rPtr->offset;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetRulerReleaseAction(WMRuler *rPtr, WMAction *action, void *clientData)
|
||||
void WMSetRulerReleaseAction(WMRuler * rPtr, WMAction * action, void *clientData)
|
||||
{
|
||||
if(!rPtr)
|
||||
return;
|
||||
if (!rPtr)
|
||||
return;
|
||||
|
||||
rPtr->releaseAction = action;
|
||||
rPtr->clientData = clientData;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetRulerMoveAction(WMRuler *rPtr, WMAction *action, void *clientData)
|
||||
void WMSetRulerMoveAction(WMRuler * rPtr, WMAction * action, void *clientData)
|
||||
{
|
||||
if(!rPtr)
|
||||
return;
|
||||
if (!rPtr)
|
||||
return;
|
||||
|
||||
rPtr->moveAction = action;
|
||||
rPtr->clientData = clientData;
|
||||
@@ -513,22 +507,18 @@ WMSetRulerMoveAction(WMRuler *rPtr, WMAction *action, void *clientData)
|
||||
|
||||
|
||||
/* _which_ one was released */
|
||||
int
|
||||
WMGetReleasedRulerMargin(WMRuler *rPtr)
|
||||
int WMGetReleasedRulerMargin(WMRuler * rPtr)
|
||||
{
|
||||
if(!rPtr)
|
||||
return 0;
|
||||
if (!rPtr)
|
||||
return 0;
|
||||
return rPtr->flags.whichMarker;
|
||||
}
|
||||
|
||||
|
||||
/* _which_ one is being grabbed */
|
||||
int
|
||||
WMGetGrabbedRulerMargin(WMRuler *rPtr)
|
||||
int WMGetGrabbedRulerMargin(WMRuler * rPtr)
|
||||
{
|
||||
if(!rPtr)
|
||||
return 0;
|
||||
if (!rPtr)
|
||||
return 0;
|
||||
return rPtr->flags.whichMarker;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -424,6 +424,8 @@ WMSetScrollViewRelief(WMScrollView *sPtr, WMReliefType type)
|
||||
{
|
||||
sPtr->flags.relief = type;
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
|
||||
if (sPtr->view->flags.mapped)
|
||||
paintScrollView(sPtr);
|
||||
|
||||
|
||||
@@ -724,6 +724,22 @@ WMCreateTabViewItemWithIdentifier(int identifier)
|
||||
}
|
||||
|
||||
|
||||
WMTabViewItem*
|
||||
WMCreateTabViewItem(int identifier, char *label)
|
||||
{
|
||||
WMTabViewItem *item;
|
||||
|
||||
item = wmalloc(sizeof(WMTabViewItem));
|
||||
memset(item, 0, sizeof(WMTabViewItem));
|
||||
|
||||
item->identifier = identifier;
|
||||
WMSetTabViewItemLabel(item, label);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
WMGetTabViewItemIdentifier(WMTabViewItem *item)
|
||||
{
|
||||
|
||||
@@ -140,6 +140,44 @@ testList(WMScreen *scr)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
testButton(WMScreen *scr)
|
||||
{
|
||||
WMWindow *win;
|
||||
int i;
|
||||
char *types[] = {
|
||||
"MomentaryPush",
|
||||
"PushOnPushOff",
|
||||
"Toggle",
|
||||
"Switch",
|
||||
"Radio",
|
||||
"MomentaryChange",
|
||||
"OnOff",
|
||||
"MomentaryLigh"
|
||||
};
|
||||
|
||||
windowCount++;
|
||||
|
||||
win = WMCreateWindow(scr, "testButton");
|
||||
WMResizeWidget(win, 300, 300);
|
||||
WMSetWindowTitle(win, "Buttons");
|
||||
|
||||
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||
|
||||
for (i = 1; i < 9; i++) {
|
||||
WMButton *b;
|
||||
b = WMCreateButton(win, i);
|
||||
WMResizeWidget(b, 150, 24);
|
||||
WMMoveWidget(b, 20, i*30);
|
||||
WMSetButtonText(b, types[i-1]);
|
||||
}
|
||||
|
||||
WMRealizeWidget(win);
|
||||
WMMapSubwidgets(win);
|
||||
WMMapWidget(win);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
testGradientButtons(WMScreen *scr)
|
||||
{
|
||||
@@ -1042,6 +1080,10 @@ int main(int argc, char **argv)
|
||||
testDragAndDrop(scr);
|
||||
testDragAndDrop(scr);
|
||||
|
||||
testScrollView(scr);
|
||||
|
||||
testButton(scr);
|
||||
|
||||
#if 0
|
||||
testFrame(scr);
|
||||
|
||||
@@ -1061,7 +1103,6 @@ int main(int argc, char **argv)
|
||||
|
||||
testOpenFilePanel(scr);
|
||||
testList(scr);
|
||||
testScrollView(scr);
|
||||
|
||||
|
||||
testSlider(scr);
|
||||
|
||||
3703
WINGs/wtext.c
3703
WINGs/wtext.c
File diff suppressed because it is too large
Load Diff
@@ -298,6 +298,7 @@ _notification(void *observerData, WMNotification *notification)
|
||||
if (to != tw) lostHandler(to->view, XA_PRIMARY, NULL);
|
||||
}
|
||||
|
||||
|
||||
WMTextField*
|
||||
WMCreateTextField(WMWidget *parent)
|
||||
{
|
||||
@@ -1028,6 +1029,11 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
||||
textEvent = WMTextDidEndEditingNotification;
|
||||
break;
|
||||
|
||||
case XK_Escape:
|
||||
data = (void*)WMEscapeTextMovement;
|
||||
textEvent = WMTextDidEndEditingNotification;
|
||||
break;
|
||||
|
||||
case XK_Return:
|
||||
data = (void*)WMReturnTextMovement;
|
||||
textEvent = WMTextDidEndEditingNotification;
|
||||
@@ -1229,9 +1235,11 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
||||
if (textEvent==WMTextDidBeginEditingNotification &&
|
||||
tPtr->delegate->didBeginEditing)
|
||||
(*tPtr->delegate->didBeginEditing)(tPtr->delegate, notif);
|
||||
|
||||
else if (textEvent==WMTextDidEndEditingNotification &&
|
||||
tPtr->delegate->didEndEditing)
|
||||
(*tPtr->delegate->didEndEditing)(tPtr->delegate, notif);
|
||||
|
||||
else if (textEvent==WMTextDidChangeNotification &&
|
||||
tPtr->delegate->didChange)
|
||||
(*tPtr->delegate->didChange)(tPtr->delegate, notif);
|
||||
|
||||
@@ -112,9 +112,7 @@ createView(W_Screen *screen, W_View *parent)
|
||||
|
||||
view = wmalloc(sizeof(W_View));
|
||||
memset(view, 0, sizeof(W_View));
|
||||
|
||||
view->refCount = 1;
|
||||
|
||||
|
||||
view->screen = screen;
|
||||
|
||||
if (parent!=NULL) {
|
||||
@@ -131,6 +129,8 @@ createView(W_Screen *screen, W_View *parent)
|
||||
|
||||
adoptChildView(parent, view);
|
||||
}
|
||||
|
||||
view->eventHandlers = WMCreateBag(4);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -182,6 +182,24 @@ W_CreateTopView(W_Screen *screen)
|
||||
}
|
||||
|
||||
|
||||
W_View*
|
||||
W_CreateUnmanagedTopView(W_Screen *screen)
|
||||
{
|
||||
W_View *view;
|
||||
|
||||
view = createView(screen, screen->rootView);
|
||||
if (!view)
|
||||
return NULL;
|
||||
|
||||
view->flags.topLevel = 1;
|
||||
view->attribs.event_mask |= StructureNotifyMask;
|
||||
|
||||
view->attribFlags |= CWOverrideRedirect;
|
||||
view->attribs.override_redirect = True;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
W_RealizeView(W_View *view)
|
||||
@@ -253,6 +271,23 @@ W_ReparentView(W_View *view, W_View *newParent, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
W_RaiseView(W_View *view)
|
||||
{
|
||||
if (W_VIEW_REALIZED(view))
|
||||
XRaiseWindow(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
W_LowerView(W_View *view)
|
||||
{
|
||||
if (W_VIEW_REALIZED(view))
|
||||
XLowerWindow(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
W_MapView(W_View *view)
|
||||
@@ -324,7 +359,9 @@ W_TopLevelOfView(W_View *view)
|
||||
{
|
||||
W_View *toplevel;
|
||||
|
||||
for (toplevel=view; !toplevel->flags.topLevel; toplevel=toplevel->parent);
|
||||
for (toplevel=view;
|
||||
toplevel && !toplevel->flags.topLevel;
|
||||
toplevel=toplevel->parent);
|
||||
|
||||
return toplevel;
|
||||
}
|
||||
@@ -374,7 +411,7 @@ destroyView(W_View *view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* destroy children recursively */
|
||||
while (view->childrenList!=NULL) {
|
||||
ptr = view->childrenList;
|
||||
@@ -391,7 +428,8 @@ destroyView(W_View *view)
|
||||
W_CallDestroyHandlers(view);
|
||||
|
||||
if (view->flags.realized) {
|
||||
XDeleteContext(view->screen->display, view->window, ViewContext);
|
||||
XDeleteContext(view->screen->display,
|
||||
view->window, ViewContext);
|
||||
|
||||
/* if parent is being destroyed, it will die naturaly */
|
||||
if (!view->flags.parentDying || view->flags.topLevel)
|
||||
@@ -403,6 +441,9 @@ destroyView(W_View *view)
|
||||
|
||||
W_CleanUpEvents(view);
|
||||
|
||||
WMFreeBag(view->eventHandlers);
|
||||
view->eventHandlers = NULL;
|
||||
|
||||
WMUnregisterViewDraggedTypes(view);
|
||||
|
||||
#if 0
|
||||
@@ -424,7 +465,8 @@ destroyView(W_View *view)
|
||||
void
|
||||
W_DestroyView(W_View *view)
|
||||
{
|
||||
W_ReleaseView(view);
|
||||
if (view->refCount == 0)
|
||||
destroyView(view);
|
||||
}
|
||||
|
||||
|
||||
@@ -607,6 +649,7 @@ WMView*
|
||||
W_RetainView(WMView *view)
|
||||
{
|
||||
view->refCount++;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -616,7 +659,8 @@ void
|
||||
W_ReleaseView(WMView *view)
|
||||
{
|
||||
view->refCount--;
|
||||
if (view->refCount < 1) {
|
||||
|
||||
if (view->refCount < 0) {
|
||||
destroyView(view);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user