/* * coords.h * * Miscellaneous handling of window-related geometries * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Steel library. * * Steel 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, or (at your option) * any later version. * * Steel 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 Steel. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __coords_h #define __coords_h #ifndef __wimp #include "wimp.h" #endif /* --- Passing window information to coords --- */ typedef struct { wimp_box box; int scx; int scy; } coords_cvtstr; /* --- Passing individual points --- * * * This is actually slightly silly, but we do it this way for compatibility * with RISC_OSLib */ typedef struct { int x; int y; } coords_pointstr; /* * int coords_x_toscreen(int x,coords_cvtstr *c) * int coords_y_toscreen(int y,coords_cvtstr *c) * int coords_x_toworkarea(int x,coords_cvtstr *c) * int coords_y_toworkarea(int y,coords_cvtstr *c) * * Use * Convert x- or y-coordinates from window to screen coordinates or vice- * versa. * * Parameters * int x or int y == the coordinate to convert * coords_cvtstr *c == pointer to window information (e.g. cast from a * wimp_wstate or a wimp_redrawstr) * * Returns * The appropriate screen- or window-relative coordinate */ int coords_x_toscreen(int x,coords_cvtstr *c); int coords_y_toscreen(int y,coords_cvtstr *c); int coords_x_toworkarea(int x,coords_cvtstr *c); int coords_y_toworkarea(int y,coords_cvtstr *c); /* * void coords_box_toscreen(wimp_box *b,coords_cvtstr *c) * void coords_box_toworkarea(wimp_box *b,coords_cvtstr *c) * * Use * Converts a whole rectangle from window to screen coordinates or vice- * versa. * * Parameters * wimp_box *b == pointer to the rectangle to convert * coords_cvtstr *c == pointer to the window information to use */ void coords_box_toscreen(wimp_box *b,coords_cvtstr *c); void coords_box_toworkarea(wimp_box *b,coords_cvtstr *c); /* * void coords_point_toscreen(coords_pointstr *p,coords_cvtstr *c) * void coords_point_toworkarea(coords_pointstr *p,coords_cvtstr *c) * * Use * Converts a single point from window to screen coordinates or vice-versa. * * Parameters * coords_pointstr *p == pointer to the rectangle to convert * coords_cvtstr *c == pointer to the window information to use */ void coords_point_toscreen(coords_pointstr *p,coords_cvtstr *c); void coords_point_toworkarea(wimp_box *b,coords_cvtstr *c); /* * BOOL coords_withinbox(coords_pointstr *p,wimp_box *b) * * Use * Returns whether the given point lies within (or on the edge of) the * specified box * * Parameters * coords_pointstr *p == pointer to the point * wimp_box *b == pointer to the box * * Returns * TRUE if the point is indeed within the box, and FALSE otherwise */ BOOL coords_withinbox(coords_pointstr *p,wimp_box *b); /* * void coords_offsetbox(wimp_box *source,int ox,int oy,wimp_box *dest) * * Use * Nudges the given rectangle by adding the given offsets to the x and y * coordinates. * * Parameters * wimp_box *source == pointer to the rectangle to nudge * int ox == amount to nudge the x-coordinates of the box * int oy == amount to nudge the y-coordinates of the box * wimp_box *dest == pointer to where to put the nudged rectangle (may be * the same as source) */ void coords_offsetbox(wimp_box *source,int ox,int oy,wimp_box *dest); /* * BOOL coords_intersects(wimp_box *line,wimp_box *box,int width) * * Use * Returns FALSE only if the line specified does not intersect the specified * box. The line is considered to have a thickness of width. The method * used is very approximate, and false positives may occur. * * Parameters * wimp_box *line == pointer to the coordinates of the line * wimp_box *box == pointer to the coordinates of the box * * Returns * FALSE if the line does not intersect the box */ BOOL coords_intersects(wimp_box *line,wimp_box *box,int width); /* * BOOL coords_boxesoverlap(wimp_box *a,wimp_box *b) * * Use * Determines whether two boxes overlap at all (useful for checking whether * to redraw something). * * Parameters * wimp_box *a == pointer to one of the rectangles to test * wimp_box *b == pointer to the other rectangle * * Returns * TRUE if the boxes overlap, or FALSE if they don't */ BOOL coords_boxesoverlap(wimp_box *a,wimp_box *b); #endif