/* Simple rendering test. 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 #include #include #include #include #include #include #include #include #include #include #define IMAGE_WIDTH 800 #define IMAGE_HEIGHT 250 #define IMAGE_PITCH (IMAGE_WIDTH * 4) #define kWindowStyle (kSFTitledWindowMask | kSFClosableWindowMask) void SFSurfaceSetOpacity (SFSurfaceRef, float opacity); const char *tst_str = "Hello World!\nWassup?\n1\n2\n3!"; int main (int argc, char *argv) { #if 1 SFTrackingAreaRef tracking_area; SFEvent event; GFImageRef picture, screen; SFSurfaceRef surface; SFLayerRef layer, apa; SFWindowRef window; GFRect frame_rect; GFSize size; float z; SFApplicationInitShared ("Testsuite Application", &argc, &argv); layer = SFLayerGetToplevel (5); if (! layer) error (1, 0, "No toplevel layer"); size = SFLayerSize (layer); surface = SFSurfaceCreate (size, 1.0); if (! surface) error (1, 0, "No surface"); SFLayerInsertSurface (layer, surface, GFPointZero); SFSurfaceMap (surface); screen = SFSurfaceCreateImageReference (surface); picture = read_tif_into_image ("/gnu/src/crust/crust/libs/ServicesFoundation/testsuite/background.tif"); if (picture) GFImageComposite (screen, picture, 0, 0, size.width, size.height); SFSurfaceMap (surface); /* Create FAT window. */ frame_rect = SFWindowFrameRectForContentRect (GFRectMake (200, 200, 500, 50), kWindowStyle); window = SFWindowCreate (frame_rect, kWindowStyle, "Crust", kSFNormalWindowLevel); if (! window) return 1; /* 35, 100. */ #if 0 GXContextRenderTextAtPoint (window->pixbuf_content, 0, 100, "Crust Display System", strlen ("Crust Display System"), 0, 30); #endif #if 0 tracking_area = SFWindowAddTrackingArea (window, GFRectMake (0, 0, 100, 100), kSFEventMouseEnteredMask | kSFEventMouseExitedMask | kSFEventMouseDownMask, 0); assert (tracking_area); #endif if (1) { GFImageRef content = SFWindowContentImage (window); char rnd_str [64], *s; int i, x, y; float color [] = { 0, 0, 0, 1.0 }; int fh; x = 0; y = 12; fh = GXFontGetHandle ("Lucida Sans Typewriter", "Regular"); if (fh < 0) { fh = 0; printf ("no font\n"); } for (s = tst_str; *s;) { i = 0; while (*s != '\n' && *s) rnd_str [i++] = *s++; rnd_str [i] = 0; if (*s == '\n') s++; GFImageRenderTextAtPoint (content, x, y, rnd_str, strlen (rnd_str), fh, 12.0, color); y += 12; } } SFWindowShow (window); z = 0; for (;;) { if (SFEventNext (&event, 0)) { printf ("Got event %d\n", event.event_code); if (event.event_code == 666) return 0; } #if 0 SFWindowMove (window, 300 + cos (z) * 50, 300 + sin (z) * 50); z += M_PI/60; #endif } return 0; #else SFApplicationInitShared ("Testsuite Application", &argc, &argv); #endif }