1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
**
** popup.c
**
** Copyright (C) 1995, 1996, 1997 Johannes Plass
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** Author: Johannes Plass (plass@thep.physik.uni-mainz.de)
** Department of Physics
** Johannes Gutenberg-University
** Mainz, Germany
**
*/
/*
#define MESSAGES
*/
#include "message.h"
#include "config.h"
#include <stdio.h>
#include "paths.h"
#include INC_X11(Intrinsic.h)
#include INC_X11(StringDefs.h)
#include INC_X11(IntrinsicP.h)
#include INC_X11(ShellP.h)
#include "types.h"
#include "popup.h"
/*##################################################################*/
/* cb_popdownPopup Callback */
/*##################################################################*/
void
cb_popdownPopup(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
BEGINMESSAGE(cb_popdownPopup)
XtPopdown((Widget)client_data);
ENDMESSAGE(cb_popdownPopup)
}
/*##################################################################*/
/* cb_popupPopup Callback */
/* Popup a window. */
/*##################################################################*/
void
cb_popupPopup(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
BEGINMESSAGE(cb_popupPopup)
XtPopup((Widget)client_data,XtGrabNone);
XRaiseWindow(XtDisplay((Widget)client_data), XtWindow((Widget)client_data));
ENDMESSAGE(cb_popupPopup)
}
/*##################################################################*/
/* popup_positionPopup */
/*##################################################################*/
static int wmtdecor = 0;
static int wmbdecor = 0;
static int wmsdecor = 0;
void
popup_positionPopup(popup,ref_widget,mode,refx,refy)
Widget popup;
Widget ref_widget;
int mode;
int refx;
int refy;
{
Arg args[5];
Cardinal n;
Position posx,posy;
Position posrefx,posrefy;
Dimension width,height;
Dimension screenwidth, screenheight;
BEGINMESSAGE(popup_positionPopup)
if (((ShellWidget)popup)->shell.popped_up) {
INFMESSAGE(will not reposition popped up popup)
ENDMESSAGE(popup_positionPopup)
return;
}
posrefx = (Position)(refx);
posrefy = (Position)(refy);
IIMESSAGE(posrefx,posrefy)
screenwidth = XtScreen(ref_widget)->width;
screenheight = XtScreen(ref_widget)->height;
IIMESSAGE(screenwidth,screenheight);
width = popup->core.width;
height = popup->core.height;
IIMESSAGE(width,height);
XtTranslateCoords(ref_widget,0,0,&posx,&posy);
IIMESSAGE(posx,posy);
if (mode==POPUP_POSITION_POS) {
posx += posrefx + (Position)(wmsdecor);
posy += posrefy + (Position)(wmtdecor);
} else if (mode==POPUP_POSITION_CENTER) {
Dimension w,h;
w = ref_widget->core.width;
h = ref_widget->core.height;
posx += (Position)(w/2) - (Position)(width/2);
posy += (Position)(h/2) - (Position)(height/2);
} else if (mode==POPUP_POSITION_POS_CENTER) {
posx += posrefx - (Position)(width/2);
posy += posrefy - (Position)(height/2);
}
INFIIMESSAGE(after adding offsets,posx,posy)
if (posx + (Position)width >= (Position)screenwidth)
posx = ((Position)screenwidth) - ((Position)width) - ((Position)wmsdecor);
if (posx < 0) posx = 0;
if (posy + (Position)height >= (Position)screenheight)
posy = ((Position)screenheight) - ((Position)height) - ((Position)wmbdecor);
if (posy < 0) posy = 0;
INFIIMESSAGE(after adjustment,posx,posy)
n=0;
XtSetArg(args[n], XtNx, posx); n++;
XtSetArg(args[n], XtNy, posy); n++;
XtSetValues(popup, args, n);
ENDMESSAGE(popup_positionPopup)
}
|