Exemple #1
0
int d_aphoton_button_proc(int msg, DIALOG *d, int c)
{
    int top_color, bottom_color, shift;
        
    if (msg == MSG_DRAW) {
        photon_container(screen, d->x, d->y, d->w, d->h);
    
        /* internal frame */
        if (d->flags & D_SELECTED) {
            top_color = button_border_gray;
            bottom_color = white;
            shift = 1;   
        }
        else {
            top_color = white;
            bottom_color = button_border_gray;
            shift = 0;
        }
        
        hline(screen, d->x+2, d->y+2, d->x+d->w-3, top_color);
        vline(screen, d->x+2, d->y+2, d->y+d->h-3, top_color);
        hline(screen, d->x+2, d->y+d->h-3, d->x+d->w-3, bottom_color);
        vline(screen, d->x+d->w-3, d->y+2, d->y+d->h-3, bottom_color);
        	rectgouraud(screen, d->x+3, d->y+3, d->x+d->w-4, d->y+d->h-4, &button_gray_range, FALSE);
	    
	if (d->dp)
	    photon_textout(screen, (char *)d->dp, d->x+d->w/2+shift,
	                   d->y+d->h/2-text_height(font)/2+shift, d->flags, TRUE);
	    
	return D_O_K;
    }

    return d_button_proc(msg, d, c);
}
Exemple #2
0
/* dialog procedure for codepage selection objects */
int codepage_proc(int msg, DIALOG *d, int c)
{
   int fg, bg, ret;

   if (msg == MSG_DRAW) {
      if (d->flags & D_SELECTED) {
	 fg = (d->d1 == codepage) ? 1 : 8;
	 bg = 16;
      }
      else if (d->flags & D_GOTFOCUS) {
	 fg = 16;
	 bg = (d->d1 == codepage) ? 1 : 8;
      }
      else { 
	 fg = 255;
	 bg = (d->d1 == codepage) ? 1 : 8;
      }

      rectfill(screen, d->x+1, d->y+1, d->x+d->w-1, d->y+d->h-1, bg);
      rect(screen, d->x, d->y, d->x+d->w, d->y+d->h, 255);

      textprintf_centre_ex(screen, font, d->x+d->w/2, d->y+4, fg, -1, "%04X", d->d1<<8);

      return D_O_K;
   }

   ret = d_button_proc(msg, d, c);

   if (ret & D_CLOSE) {
      codepage = d->d1;
      return D_REDRAW;
   }

   return ret;
}
Exemple #3
0
int d_aphoton_check_proc(int msg, DIALOG *d, int c)
{  
    if (msg == MSG_DRAW) {
        draw_base(screen, d);
        photon_container(screen, d->x+3, d->y+d->h/2-7, 14, 14);
        rectfillwh(screen, d->x+5, d->y+d->h/2-5, 10, 10, white);
		
	if (d->flags & D_SELECTED) {
	    /* shadow */
	    line(screen, d->x+6, d->y+d->h/2-3, d->x+12, d->y+d->h/2+3, check_gray1);
	    line(screen, d->x+7, d->y+d->h/2-4, d->x+13, d->y+d->h/2+2, check_gray1);
	    line(screen, d->x+6, d->y+d->h/2+2, d->x+12, d->y+d->h/2-4, check_gray1);
	    line(screen, d->x+7, d->y+d->h/2+3, d->x+13, d->y+d->h/2-3, check_gray1);
	    
	    /* cross */
	    line(screen, d->x+6, d->y+d->h/2-4, d->x+13, d->y+d->h/2+3, check_black);
	    line(screen, d->x+6, d->y+d->h/2+3, d->x+13, d->y+d->h/2-4, check_black);
	}
	else {
  	    rect(screen, d->x+6, d->y+d->h/2-4, d->x+13, d->y+d->h/2+3, check_gray2);
	}
	
	if (d->dp)
	    photon_textout(screen, (char *)d->dp, d->x+20,
	                   d->y+d->h/2-text_height(font)/2, d->flags, FALSE);
	
	return D_O_K;
    }

    return d_button_proc(msg, d, c);
}
Exemple #4
0
/* A custom dialog procedure, derived from d_button_proc. It intercepts
 * the D_CLOSE return of d_button_proc, and calls the function in dp3.
 */
int my_button_proc(int msg, DIALOG *d, int c)
{
   int ret = d_button_proc(msg, d, c);
   if (ret == D_CLOSE && d->dp3)
      return ((int (*)(void))d->dp3)();
   return ret;
}
Exemple #5
0
int
d_abitmap_button_proc (int msg, DIALOG *d, int c)
{
	if (msg == MSG_DRAW) {
		int b = d->flags & D_SELECTED ? B_BUTTON_DOWN : B_BUTTON;
		abitmap_draw_box (d, b);
		abitmap_draw_text (d, b, 0, 0, d->flags & D_SELECTED, 1, 1);
		return D_O_K;
	}
	return d_button_proc (msg, d, c);
}
Exemple #6
0
int
d_abitmap_check_proc (int msg, DIALOG *d, int c)
{
	if (msg == MSG_DRAW) {
		int b = d->flags & D_SELECTED ? B_CHECK_DOWN : B_CHECK;
		int bi = d->flags & D_SELECTED ? B_CHECK_ITEM_DOWN : B_CHECK_ITEM;
		abitmap_draw_box (d, b);
		abitmap_draw_area (d, bi, 0, 0, 12, 12, 0, 1);
		abitmap_draw_text (d, b, 14, 0, 0, 0, 1);
		return D_O_K;
	}
	return d_button_proc (msg, d, c);
}
int clear_codes_proc(int msg, DIALOG *d, int c)
{
   int ret;
   switch (msg)
   {
      case MSG_READ_CODES: case MSG_CLEAR_CODES:
         // if we are currently reading or clearing codes, and the button is enabled,
         if (!(d->flags & D_DISABLED))
         {
            d->flags |= D_DISABLED;     // disable the button
            return D_REDRAWME;
         }
         break;
         
      case MSG_READY:
         // if we're not reading or clearing codes, and the button is disabled,
         if (d->flags & D_DISABLED)
         {
            d->flags &= ~D_DISABLED;   // enable it
            return D_REDRAWME;
         }
         break;
   }
   
   ret = d_button_proc(msg, d, c);

   if (ret == D_CLOSE)
   {
      while (!simulate && comport.status != READY)
      {
         if (alert("Port is not ready.", "Please check that you specified the correct port", "and that no other application is using it", "Configure &Port", "&Cancel", 'p', 'c') == 1)
            display_options(); // let the user choose correct settings
         else
            return D_REDRAWME;
      }
      
      // if user confirmed that he wants to erase the codes,
      if(popup_dialog(confirm_clear_dialog, 6) == 5)
      {
         if (simulate)
            trouble_codes_simulator(FALSE);
         else
            broadcast_dialog_message(MSG_CLEAR_CODES, 0);  //send everyone MSG_CLEAR_CODES
      }
      
      return D_REDRAWME;
   }

   return ret;
}
Exemple #8
0
int d_agtk_check_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
        BITMAP *bmp = gui_get_screen();
        draw_base(bmp, d);
        gtk_bevel(bmp, d->x+3, d->y+d->h/2-5, 10, 10, (d->flags & D_SELECTED) ? 2 : 1);
        if (d->dp) {
            gui_textout_ex(bmp, (char *)d->dp,
                           d->x+18, d->y+d->h/2-text_height(font)/2,
                           (d->flags & D_DISABLED) ? nshadow : black, -1, FALSE);
        }
        return D_O_K;
    }

    return d_button_proc(msg, d, c);
}
Exemple #9
0
int d_soundbutton_proc(int msg,DIALOG *d,int c)
{
	int ans;
	ans = d_button_proc(msg,d,c);
	
	if(ans==D_EXIT)
	{
		//FSOUND_StopSound(FSOUND_ALL);
		//FSOUND_PlaySound(FSOUND_FREE, sound_info[emitsound_chosen].sound);
		return D_REDRAW;
		
	}
	

	return ans;
}
Exemple #10
0
static int common_change_button_proc(
    const char *title, 
    const char **names, 
    int msg, DIALOG *d, int c)
{
    int result = d_button_proc(msg, d, c);
    if (result == D_CLOSE) {

        std::vector<std::string> gui_list;
        for (int i = 0; names[i] != NULL; i++)
            gui_list.push_back(names[i]);

        if (gui_list.size() > 1)
            d->d1 = gui_select_from_list(D_WIDTH, D_HEIGHT, title, gui_list, d->d1);
        fixup_unit_info();
        return D_REDRAW;
    }
    return result;
}
Exemple #11
0
int d_aase_check_proc(int msg, DIALOG *d, int c)
{
  if (msg == MSG_DRAW) {
    int y = d->y+d->h/2, rtm;
    int size = 12;

    ase_rectbox(screen, d->x, y-size/2, d->x+size-1, y-size/2+size-1, d->flags);

    rtm = text_mode(-1);
    gui_textout(screen, (char *)d->dp,
      d->x+size+4, y-text_height(font)/2,
      ((d->flags & D_DISABLED)? makecol(128, 128, 128): makecol(0, 0, 0)),
      FALSE);
    text_mode(rtm);

    return D_O_K;
  }

  return d_button_proc(msg, d, c);
}
Exemple #12
0
int d_aase_button_proc(int msg, DIALOG *d, int c)
{
  if (msg == MSG_DRAW) {
    ase_rectbox(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1, d->flags);

    if (d->dp) {
      int rtm = text_mode(-1);
      gui_textout(screen, (char *)d->dp,
        ((d->flags & D_SELECTED)? 1: 0) + d->x+d->w/2,
        ((d->flags & D_SELECTED)? 1: 0) + d->y+d->h/2-text_height(font)/2,
        ((d->flags & D_DISABLED)? makecol(128, 128, 128): makecol(0, 0, 0)),
        TRUE);
      text_mode(rtm);
    }

    return D_O_K;
  }

  return d_button_proc(msg, d, c);
}
int read_tr_codes_proc(int msg, DIALOG *d, int c)
{
   int ret;
   
   switch (msg)
   {
      case MSG_READ_CODES: case MSG_CLEAR_CODES:
         // if we are currently reading or clearing codes, and the button is enabled,
         if (!(d->flags & D_DISABLED))
         {
            d->flags |= D_DISABLED;     // disable the button
            return D_REDRAWME;
         }
         break;
         
      case MSG_READY:
         // if we're not reading or clearing codes, and the button is disabled,
         if (d->flags & D_DISABLED)
         {
            d->flags &= ~D_DISABLED;   // enable it
            return D_REDRAWME;
         }
         break;
   }

   ret = d_button_proc(msg, d, c);

   if (ret == D_CLOSE)
   {
      if (simulate)
         trouble_codes_simulator(TRUE);
      else
         read_codes();
      
      return D_REDRAWME;
   }

   return ret;
}
Exemple #14
0
/* dialog procedure for ASCII character objects */
int ascii_proc(int msg, DIALOG *d, int c)
{
   int fg, bg, mg, k;

   if (msg == MSG_DRAW) {
      if (d->flags & D_SELECTED) {
	 fg = 16;
	 bg = 255;
	 mg = 8;
      }
      else if (d->flags & D_GOTFOCUS) {
	 fg = 255;
	 bg = 8;
	 mg = 16;
      }
      else {
	 fg = 255;
	 bg = 16;
	 mg = 8;
      }

      rectfill(screen, d->x+1, d->y+1, d->x+d->w-1, d->y+d->h-1, bg);
      rect(screen, d->x, d->y, d->x+d->w, d->y+d->h, fg);

      textprintf_ex(screen, font, d->x+4, d->y+4, mg, -1, "%02X", d->d1);

      k = (codepage << 8) | d->d1;

      if (k >= ' ')
	 textprintf_centre_ex(screen, font, d->x+d->w-8, d->y+4, fg, -1, "%c", k);
      else
	 textprintf_centre_ex(screen, font, d->x+d->w-8, d->y+4, fg, -1, "%s", ascii_name[k]);

      return D_O_K;
   }

   return d_button_proc(msg, d, c);
}
Exemple #15
0
int d_agtk_button_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
        BITMAP *bmp = gui_get_screen();
        int x;
        if (d->flags & D_SELECTED)
            x = 2;
        else if (d->flags & D_GOTFOCUS)
            x = 1;
        else
            x = 0;
        gtk_box(bmp, d->x, d->y, d->w, d->h, x, d->flags & D_GOTFOCUS);

        if (d->dp) {
            gui_textout_ex(bmp, (char *)d->dp,
                           d->x+d->w/2, d->y+d->h/2-text_height(font)/2,
                           (d->flags & D_DISABLED) ? nshadow : black, -1, TRUE);
        }
        return D_O_K;
    }

    return d_button_proc(msg, d, c);
}
int p_proc(int msg, DIALOG *d, int c) {
    
   int ret;

   /* call the parent object */
   ret = d_button_proc(msg, d, c);
   
   if (ret == D_CLOSE) {
   
      if (p==0) {
         set_palette(desktop_palette);
         p=1;
         return 0;
      } else { 
         if (p==1) {
            set_palette(default_palette);
            p=0;
            return 0;
         }
      }            
   }
   return ret;
}
Exemple #17
0
/* nostretch_icon_proc:
 *  Custom version of d_icon_proc.  Instead of stretching the bitmap to fit
 *  the dimensions w & h, it directly blit()'s it.
 */
int nostretch_icon_proc(int msg, DIALOG *d, int c)
{
   BITMAP *butimage = (BITMAP *)d->dp;

   if ((msg == MSG_DRAW) && (!(d->flags & D_HIDDEN)))
   {
      if ((d->dp2 != NULL) && (d->flags & D_GOTFOCUS))
      {
        butimage = (BITMAP *)d->dp2; //if we got focus, display dp2
      }
      if ((d->dp3 != NULL) && (d->flags & D_SELECTED))
      {
        butimage = (BITMAP *)d->dp3; // if the button was clicked, display d3
      }

      /* put the graphic on screen */
      blit(butimage, screen, 0, 0, d->x, d->y, butimage->w, butimage->h);

      return D_O_K;
   }

   return d_button_proc(msg, d, c);
}
Exemple #18
0
int save_options_proc(int msg, DIALOG *d, int c)
{
   int ret;
   int old_baud_rate;
   BITMAP *bmp;
   FILE *file;

   ret = d_button_proc(msg, d, c);

   if (ret == D_CLOSE)
   {
      old_baud_rate = comport.baud_rate;
      broadcast_dialog_message(MSG_SAVE_OPTIONS, 0);
      
      if (comport.baud_rate != old_baud_rate)
      {
         if (alert("WARNING!", "This operation may cause scan tool to stop responding.", "Are you sure you want to change the baud rate?", "Yes", "No", 0, 0) != 1)
         {
            comport.baud_rate = old_baud_rate;
            broadcast_dialog_message(MSG_REFRESH, 0);
            return D_O_K;
         }
      }

      close_comport(); // close current comport
      open_comport(); // try reinitializing comport (comport.status will be set)
      
      if ((!(display_mode & WINDOWED_MODE) && (display_mode & WINDOWED_MODE_SET)) || ((display_mode & WINDOWED_MODE) && !(display_mode & WINDOWED_MODE_SET)))
      {
         bmp = create_bitmap(SCREEN_W, SCREEN_H);
         if (bmp)
         {
            scare_mouse();
            blit(screen, bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
            unscare_mouse();

            if (display_mode & WINDOWED_MODE)
            {
               if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) == 0)
                  display_mode |= WINDOWED_MODE_SET;
               else
                  display_mode &= ~WINDOWED_MODE_SUPPORTED;
            }
            else
            {
               if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) == 0)
                  display_mode &= ~WINDOWED_MODE_SET;
               else
                  display_mode &= ~FULLSCREEN_MODE_SUPPORTED;
            }

            set_pallete(datafile[MAIN_PALETTE].dat);
            gui_fg_color = C_BLACK;  // set the foreground color
            gui_bg_color = C_WHITE;  // set the background color
            gui_mg_color = C_GRAY;   // set the disabled color
            set_mouse_sprite(NULL); // make mouse use current palette
            blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
            show_mouse(screen);
            destroy_bitmap(bmp);
         }
         else
            alert("Error switching display modes.", "Not enough memory to save screen.", NULL, "OK", NULL, 0, 0);
      }

      file = fopen(options_file_name, "a");

      if (file == NULL)
         alert("Options could not be saved, because file", options_file_name, "could not be open for writing", "OK", NULL, 0, 0);
      else
      {
         fclose(file);
         save_program_options();
      }
   }

   return ret;
}