/* Windows. Copyright (C) 2001 Johan Rydberg. All Rights Reserved. This file is part of Crust. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "priv.h" #include "SXWindow.h" #include "SXWindowTheme.h" /* RECT is the frame rect. */ SFWindowRef SFWindowCreate (GFRect frame_rect, SFWindowStyleMask style_mask, char *title, SFWindowLevel level) { SFLayerRef toplevel_layer; toplevel_layer = SFLayerGetToplevel (level); if (! toplevel_layer) return 0; return SXWindowCreate (toplevel_layer, frame_rect, title, style_mask, level); } void SFWindowShow (SFWindowRef window) { SFLayerMap (window->window_layer); } /* Move window to (X, Y). */ void SFWindowMove (SFWindowRef window, int x, int y) { SFLayerMove (window->window_layer, x, y); } /* Return a reference to content image for WINDOW. */ GFImageRef SFWindowContentImage (SFWindowRef window) { return window->pixbuf_content; } /* Gets the frame rectangle for content rectangle RECT in a window of type STYLE_MASK. */ GFRect SFWindowFrameRectForContentRect (GFRect rect, SFWindowStyleMask style_mask) { SXWindowThemeRef theme = SXWindowThemeCurrent (); GFRect content = rect; if (style_mask & kSFTitledWindowMask) { content.size.height += theme->titlebar.height; content.origin.y -= theme->titlebar.height; } if (style_mask & kSFResizableWindowMask) { content.size.height += 6; } return content; } /* Gets the content rectangle for frame rectangle RECT in a window of type STYLE_MASK. */ GFRect SFWindowContentRectForFrameRect (GFRect rect, SFWindowStyleMask style_mask) { SXWindowThemeRef theme = SXWindowThemeCurrent (); GFRect content = rect; if (style_mask & kSFTitledWindowMask) { content.size.height -= theme->titlebar.height; content.origin.y += theme->titlebar.height; } if (style_mask & kSFResizableWindowMask) { content.size.height -= 6; } return content; } /* Updates RECT in surface. */ void SFWindowUpdateRegion (SFWindowRef window, GFRect rect) { GFPoint diff; /* The difference between the frame rectangle and the content rectangle is the XY-offset to the window area. */ diff = GFPointSubtract (window->content_rect.origin, window->frame_rect.origin); /* ??? implement this using a function like GFPointSubtract. */ rect.origin.x += diff.x; rect.origin.y += diff.y; SFSurfaceUpdateRegion (window->window_surface, rect); } /* Returns the minimum frame width needed for TITLE in a window of type STYLE_MASK. */ float SFWindowMinFrameWidthWithTitle (char *title, SFWindowStyleMask style_mask) { return strlen (title) * 14.0; // implement } SFTrackingAreaRef SFWindowAddTrackingArea (SFWindowRef window, GFRect rect, unsigned int event_mask, void *user_data) { GFPoint diff; /* The difference between the frame rectangle and the content rectangle is the XY-offset to the window area. */ diff = GFPointSubtract (window->content_rect.origin, window->frame_rect.origin); /* ??? implement this using a function like GFPointSubtract. */ rect.origin.x += diff.x; rect.origin.y += diff.y; return SXTrackingAreaCreate (window->window_surface, rect, event_mask, user_data); }