nanogui: No BLACK with True Types?


Previous by date: 29 Jan 2002 17:00:58 -0000 Re: Newbie question--passing events between programs, Alex Holden
Next by date: 29 Jan 2002 17:00:58 -0000 Re: No BLACK with True Types?, Greg Haerr
Previous in thread:
Next in thread: 29 Jan 2002 17:00:58 -0000 Re: No BLACK with True Types?, Greg Haerr

Subject: No BLACK with True Types?
From: Olaf Winne ####@####.####
Date: 29 Jan 2002 17:00:58 -0000
Message-Id: <02012917573600.12417@o6v9n4>

Hi all,

now we are using the nano-X app... Almost everything works fine!!! Thanks to 
the developers.

One problem: I'm using True Types, but I can't use the defined color BLACK 
(with GrSetForeground) to write. With all other colors it works. BLACK also 
works fine with the nano-X system fonts.

I use the framebuffer device (Linux 2.4.3.) 8bpp.

regards
Olaf 



Am Dienstag, 29. Januar 2002 17:32 schrieb Alex Holden:
> Henry Chea wrote:
> > Maybe point me to examples, docs, or perhaps edit my source code below to
> > show how to solve the problem?
>
> One way is to use a pipe to send events to the slave.
>
> Something along these lines (completely untested):
>
> //control.c
> #include <unistd.h>
> #include <stdio.h>
> #define MWINCLUDECOLORS
> #include "microwin/nano-X.h"
>
> GR_WINDOW_ID control_wid;
> GR_GC_ID gc;
>
> int control_fd;
> int pipefds[2];
>
> void event_handler (GR_EVENT *event);
>
> int main (void)
> {
>          pid_t pid;
>
>          if(pipe(pipefds) < 0) {
>            fprintf(stderr, "pipe() failed\n");
>            exit(1);
>          }
>
>          if((pid = fork()) < 0) {
>            fprintf(stderr, "fork() failed\n");
> 	  exit(1);
>          } else if(pid > 0) {
>            close(pipefds[0]); /* parent closes the output side */
>          } else {
>            close(pipefds[1]); /* child closes the input side */
>            /* Set stdin to the output of the pipe: */
>            if(dup2(pipefds[0], STDIN_FILENO) != STDIN_FILENO) {
> 	    fprintf(stderr, "dup2() failed\n");
>              exit(1);
>            }
>            close(pipefds[0]);
>            if(execl("/usr/local/bin/SLAVE", "SLAVE", NULL) < 0) {
>              fprintf(stderr, "execl() failed\n");
>              exit(1);
>            }
>          }
>
>          if ((control_fd = GrOpen()) < 0)
>          {
>                  fprintf (stderr, "GrOpen failed");
>                  exit (1);
>          }
>
>
>          gc = GrNewGC();
>          GrSetGCUseBackground (gc, GR_FALSE);
>          GrSetGCForeground (gc, BLUE);
>
>          control_wid = GrNewWindowEx (GR_WM_PROPS_NOMOVE |
>                          GR_WM_PROPS_BORDER |
>                          GR_WM_PROPS_NOAUTOMOVE |
>                          GR_WM_PROPS_NOAUTORESIZE,
>                          "Control Window",
>                          GR_ROOT_WINDOW_ID,
>                          0, 0, 150, 478, YELLOW);
>
>          GrSelectEvents (control_wid, GR_EVENT_MASK_EXPOSURE |
>                          GR_EVENT_MASK_BUTTON_DOWN);
>
>          GrMapWindow (control_wid);
>          GrMainLoop (event_handler);
> }
>
> void event_handler (GR_EVENT *event)
> {
>          switch (event->type)
>          {
>          case GR_EVENT_TYPE_EXPOSURE:
>                  GrText (control_wid, gc, 20, 20,
>                          "Click me", -1, GR_TFASCII);
>                  break;
>
>          case GR_EVENT_TYPE_BUTTON_DOWN:
>                  GrClearWindow (control_wid , GR_TRUE);
>                  if(write(pipe_fds[1], "1", 1) != 1) {
>                    fprintf(stderr, "Couldn't write message to child\n");
>                    exit(1);
>                  }
>                  break;
>          }
> }
>
> ******************************
> //SLAVE.C
> #include <stdio.h>
> #define MWINCLUDECOLORS
> #include "microwin/nano-X.h"
>
> GR_WINDOW_ID slave_wid;
> GR_GC_ID gc;
>
> void event_handler (GR_EVENT *event);
>
> int slave_fd;
>
> int main (void)
> {
>          if ((slave_fd = GrOpen()) < 0)
>          {
>                  fprintf (stderr, "GrOpen failed");
>                  exit (1);
>          }
>
>          gc = GrNewGC();
>          GrSetGCUseBackground (gc, GR_FALSE);
>          GrSetGCForeground (gc, RED);
>
>
>   slave_wid = GrNewWindowEx (GR_WM_PROPS_APPFRAME |
>                          GR_WM_PROPS_CAPTION |
>                          GR_WM_PROPS_CLOSEBOX,
>                          "slave Window",
>                          GR_ROOT_WINDOW_ID,
>                          150, 150, 200, 100, WHITE);
>
>          GrRegisterInput(STDIN_FILENO);
>
>
>          GrSelectEvents (slave_wid, GR_EVENT_MASK_CLOSE_REQ|
>                          GR_EVENT_TYPE_FDINPUT);
>
>          GrMapWindow (slave_wid);
>          GrMainLoop (event_handler);
> }
>
> void event_handler (GR_EVENT *event)
> {
>          char in;
>
>          switch (event->type)
>          {
>          case GR_EVENT_TYPE_CLOSE_REQ:
>                  GrClose();
>                  exit (0);
>
>          case GR_EVENT_TYPE_FDINPUT:
>                  if(read(STDIN_FILENO, &in, 1) != 1) {
>                    fprintf(stderr, "couldn't read event from parent\n");
>                    exit(1);
>                  }
>                  if(in == '1') {
>                    GrText (slave_wid, gc, 50, 50,
>                          "Button 1 pressed", -1, GR_TFASCII);
>                  } else if(in == '2') {
>                    GrText (slave_wid, gc, 50, 50,
>                          "Button 2 pressed", -1, GR_TFASCII);
>                  } else {
>                    GrText (slave_wid, gc, 50, 50,
>                          "Unknown button pressed", -1, GR_TFASCII);
>                  }
>                  break;
>          }
> }

Previous by date: 29 Jan 2002 17:00:58 -0000 Re: Newbie question--passing events between programs, Alex Holden
Next by date: 29 Jan 2002 17:00:58 -0000 Re: No BLACK with True Types?, Greg Haerr
Previous in thread:
Next in thread: 29 Jan 2002 17:00:58 -0000 Re: No BLACK with True Types?, Greg Haerr


Powered by ezmlm-browse 0.20.