OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [demos/] [nanox/] [logfont.c] - Diff between revs 674 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 674 Rev 1765
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#if UNIX
#if UNIX
#include <time.h>
#include <time.h>
#endif
#endif
#define MWINCLUDECOLORS
#define MWINCLUDECOLORS
#include "nano-X.h"
#include "nano-X.h"
/*
/*
 * logical font demo for Nano-X
 * logical font demo for Nano-X
 */
 */
 
 
#define MAXW            630
#define MAXW            630
#define MAXH            470
#define MAXH            470
 
 
int main(int argc, char **argv)
int main(int argc, char **argv)
{
{
        GR_WINDOW_ID    window;
        GR_WINDOW_ID    window;
        GR_EVENT        event;
        GR_EVENT        event;
        GR_GC_ID        gc;
        GR_GC_ID        gc;
        GR_FONT_ID      fontid;
        GR_FONT_ID      fontid;
        int             x, y, rnd = 0;
        int             x, y, rnd = 0;
        MWLOGFONT       lf;
        MWLOGFONT       lf;
        char            description[128];
        char            description[128];
 
 
        srand(time(0));
        srand(time(0));
 
 
        GrOpen();
        GrOpen();
        window = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, MAXW, MAXH, 4, BLACK, BLUE);
        window = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, MAXW, MAXH, 4, BLACK, BLUE);
        GrMapWindow(window);
        GrMapWindow(window);
 
 
        gc = GrNewGC();
        gc = GrNewGC();
 
 
        GrSelectEvents(window,GR_EVENT_MASK_ALL);
        GrSelectEvents(window,GR_EVENT_MASK_ALL);
        GrSetGCUseBackground(gc,GR_FALSE);
        GrSetGCUseBackground(gc,GR_FALSE);
        GrSetGCBackground(gc, GR_RGB(0, 0, 0));
        GrSetGCBackground(gc, GR_RGB(0, 0, 0));
 
 
        y = 30;
        y = 30;
        x = 0;
        x = 0;
 
 
        while(1) {
        while(1) {
              GrCheckNextEvent(&event);
              GrCheckNextEvent(&event);
 
 
              if(event.type == GR_EVENT_TYPE_CLOSE_REQ) {
              if(event.type == GR_EVENT_TYPE_CLOSE_REQ) {
                        GrClose();
                        GrClose();
                        exit(0);
                        exit(0);
              }
              }
 
 
              /*sleep(1);*/
              /*sleep(1);*/
 
 
              MWLF_Clear(&lf);
              MWLF_Clear(&lf);
              description[0] = '\0';
              description[0] = '\0';
              /*lf.lfSerif = 1;*/
              /*lf.lfSerif = 1;*/
 
 
              if ( rnd & 1 ) {
              if ( rnd & 1 ) {
                      lf.lfWeight = MWLF_WEIGHT_BOLD;
                      lf.lfWeight = MWLF_WEIGHT_BOLD;
                      strcat(description,"Bold ");
                      strcat(description,"Bold ");
              }
              }
 
 
 
 
              if ( rnd & 2 ) {
              if ( rnd & 2 ) {
                      lf.lfItalic = 1;
                      lf.lfItalic = 1;
                      strcat(description,"Italics ");
                      strcat(description,"Italics ");
              }
              }
              if ( rnd & 4 ) {
              if ( rnd & 4 ) {
                      lf.lfOblique = 1;
                      lf.lfOblique = 1;
                      strcat(description,"Oblique ");
                      strcat(description,"Oblique ");
              }
              }
 
 
              if ( rnd & 8 ) {
              if ( rnd & 8 ) {
                      lf.lfMonospace = 1;
                      lf.lfMonospace = 1;
                      strcat(description,"Monospace ");
                      strcat(description,"Monospace ");
              } else {
              } else {
                      lf.lfProportional = 1;
                      lf.lfProportional = 1;
                      strcat(description,"Proportional ");
                      strcat(description,"Proportional ");
              }
              }
 
 
              if ( argc > 1 )
              if ( argc > 1 )
                      strcpy(lf.lfFaceName,argv[1]);
                      strcpy(lf.lfFaceName,argv[1]);
              else
              else
                      strcpy(lf.lfFaceName,"fantasy");
                      strcpy(lf.lfFaceName,"fantasy");
 
 
              fontid = GrCreateFont(0, 0, &lf);
              fontid = GrCreateFont(0, 0, &lf);
              /* GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0))); */
              /* GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0))); */
              GrSetFontSize(fontid,26);
              GrSetFontSize(fontid,26);
              GrSetFontRotation(fontid, 330);   /* 33 degrees*/
              GrSetFontRotation(fontid, 330);   /* 33 degrees*/
              GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
              GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
              GrSetGCFont(gc, fontid);
              GrSetGCFont(gc, fontid);
              /*GrSetGCBackground(gc, rand() & 0xffffff);*/
              /*GrSetGCBackground(gc, rand() & 0xffffff);*/
              GrSetGCForeground(gc, 0xffffff);
              GrSetGCForeground(gc, 0xffffff);
              /* x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
              /* x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
                 y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0)); */
                 y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0)); */
 
 
              GrText(window, gc,x,y, description, -1, GR_TFASCII);
              GrText(window, gc,x,y, description, -1, GR_TFASCII);
 
 
              GrDestroyFont(fontid);
              GrDestroyFont(fontid);
 
 
              rnd++;
              rnd++;
              y += 30;
              y += 30;
              if ( y > 460 )
              if ( y > 460 )
                      y = 0;
                      y = 0;
        }
        }
 
 
        GrClose();
        GrClose();
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.