1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2005-03-19 08:40:18 -08:00
|
|
|
* Copyright (C) 2000-2005 Carsten Haitzler, Geoff Harrison and various contributors
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
static EObj *coord_eo = NULL;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
void
|
2004-06-29 01:52:41 -07:00
|
|
|
CoordsShow(EWin * ewin)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-01-18 02:24:06 -08:00
|
|
|
TextClass *tc;
|
|
|
|
ImageClass *ic;
|
2005-04-17 06:58:09 -07:00
|
|
|
char s[256];
|
1999-08-17 15:56:46 -07:00
|
|
|
int md;
|
2004-01-18 02:24:06 -08:00
|
|
|
int x, y, w, h;
|
2005-04-12 09:43:39 -07:00
|
|
|
int cx, cy, cw, ch;
|
|
|
|
EObj *eo = coord_eo;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!Conf.movres.mode_info)
|
2000-04-24 15:21:29 -07:00
|
|
|
return;
|
2004-01-18 02:24:06 -08:00
|
|
|
if (ewin == NULL)
|
|
|
|
return;
|
2000-04-24 15:21:29 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
tc = TextclassFind("COORDS", 1);
|
|
|
|
ic = ImageclassFind("COORDS", 1);
|
1999-08-17 15:56:46 -07:00
|
|
|
if ((!ic) || (!tc))
|
|
|
|
return;
|
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
cx = cy = cw = ch = 0;
|
|
|
|
|
2004-05-18 16:31:07 -07:00
|
|
|
x = ewin->shape_x;
|
|
|
|
y = ewin->shape_y;
|
2004-01-18 02:24:06 -08:00
|
|
|
w = (ewin->client.w - ewin->client.base_w) / ewin->client.w_inc;
|
|
|
|
h = (ewin->client.h - ewin->client.base_h) / ewin->client.h_inc;
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
Esnprintf(s, sizeof(s), "%i x %i (%i, %i)", w, h, x, y);
|
|
|
|
TextSize(tc, 0, 0, 0, s, &cw, &ch, 17);
|
2005-04-12 09:43:39 -07:00
|
|
|
cw += ic->padding.left + ic->padding.right;
|
|
|
|
ch += ic->padding.top + ic->padding.bottom;
|
2004-06-29 01:52:41 -07:00
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
if (Mode.mode == MODE_MOVE)
|
|
|
|
md = Conf.movres.mode_move;
|
|
|
|
else
|
|
|
|
md = Conf.movres.mode_resize;
|
2004-06-29 01:52:41 -07:00
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
if ((md == 0) || ((cw < ewin->client.w) && (ch < ewin->client.h)))
|
|
|
|
{
|
|
|
|
if (Conf.movres.mode_info == 1)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2005-04-12 09:43:39 -07:00
|
|
|
switch (md)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2005-04-12 09:43:39 -07:00
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2005-05-07 02:27:16 -07:00
|
|
|
cx =
|
|
|
|
x + (ewin->shape_w + ewin->border->border.left +
|
|
|
|
ewin->border->border.right - cw) / 2 +
|
2005-04-12 09:43:39 -07:00
|
|
|
DeskGetX(EoGetDesk(ewin));
|
2005-05-07 02:27:16 -07:00
|
|
|
cy =
|
|
|
|
y + (ewin->shape_h + ewin->border->border.top +
|
|
|
|
ewin->border->border.bottom - ch) / 2 +
|
2005-04-12 09:43:39 -07:00
|
|
|
DeskGetY(EoGetDesk(ewin));
|
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-06-29 01:52:41 -07:00
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
if (!eo)
|
|
|
|
{
|
2005-04-17 06:58:09 -07:00
|
|
|
eo = EobjWindowCreate(EOBJ_TYPE_MISC, 0, 0, 1, 1, 2, "Coord");
|
2005-04-12 09:43:39 -07:00
|
|
|
if (!eo)
|
|
|
|
return;
|
|
|
|
coord_eo = eo;
|
|
|
|
}
|
2004-06-29 01:52:41 -07:00
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
EobjMoveResize(eo, cx, cy, cw, ch);
|
2004-06-29 01:52:41 -07:00
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
if (!eo->shown)
|
2005-04-23 00:31:18 -07:00
|
|
|
EobjMap(eo, 0);
|
2004-06-29 01:52:41 -07:00
|
|
|
|
2005-04-12 09:43:39 -07:00
|
|
|
ImageclassApply(ic, eo->win, cw, ch, 1, 0, STATE_NORMAL, 0, ST_UNKNWN);
|
|
|
|
TextclassApply(ic, eo->win, cw, ch, 0, 0, STATE_NORMAL, 0, tc, s);
|
|
|
|
|
2005-05-07 04:20:02 -07:00
|
|
|
EFlush();
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-06-29 01:52:41 -07:00
|
|
|
CoordsHide(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-04-12 09:43:39 -07:00
|
|
|
EObj *eo = coord_eo;
|
|
|
|
|
|
|
|
if (eo && eo->shown)
|
|
|
|
EobjUnmap(eo);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|