Example #1
0
void traite_pleinecran(GEM_WINDOW *gwnd)
{
  GEM_WINDOW *wprog ;
  VXIMAGE    *vimage ;
  MFDB       out ;
  float      x_level, y_level, level ;
  int        xy[8] ;
  int        cp ;

  if ( gwnd == NULL ) return ;
  vimage = (VXIMAGE *) gwnd->Extension ;

  mouse_busy() ;
  x_level = (float)(Xmax-2)/(float)vimage->raster.fd_w ;
  y_level = (float)(Ymax-2)/(float)vimage->raster.fd_h ;
  if (x_level > y_level) level = y_level ;
  else                   level = x_level ;
  wprog = DisplayStdProg(msg[MSG_CALCREDUC], "", "", CLOSER ) ;
  out.fd_addr = NULL ;
  out.fd_w    = (int) ( 0.5 + (float)vimage->raster.fd_w * level ) ;
  out.fd_h    = (int) ( 0.5 + (float)vimage->raster.fd_h * level ) ;
/*  if (raster_pczoom(&vimage->raster, &out, level, level, wprog))*/
  if ( RasterZoom( &vimage->raster, &out, wprog ) )
  {
    GWDestroyWindow( wprog ) ;
    form_error(8) ;
    mouse_restore() ;
    return ;
  }
  GWDestroyWindow( wprog ) ;

  mouse_restore() ;

  cp = config.color_protect ;
  config.color_protect = 0 ;
  set_imgpalette( vimage ) ;
  cls_gemscreen() ;

  clear_buffers( MU_KEYBD | MU_BUTTON ) ;
  xy[0] = 0 ;
  xy[1] = 0 ;
  xy[2] = out.fd_w-1 ;
  xy[3] = out.fd_h-1 ;
  xy[4] = (Xmax-xy[2])/2 ;
  xy[5] = (Ymax-xy[3])/2 ;
  xy[6] = xy[4]+xy[2] ;
  xy[7] = xy[5]+xy[3] ;
  v_hide_c(handle) ;

  wind_update(BEG_UPDATE) ;
  vro_cpyfm(handle, S_ONLY, xy, &out, &screen) ;
  wait_for( MU_KEYBD | MU_BUTTON ) ;
  wind_update(END_UPDATE) ;

  free(out.fd_addr) ;
  restore_gemscreen(GemApp.Menu) ;
  v_show_c(handle, 1) ;
  config.color_protect = cp ;
  set_imgpalette( vimage ) ;
}
Example #2
0
void new_edit_vximage(WBROWSER *wb)
{
  GEM_WINDOW *new_wnd ;
  VXIMAGE    *new_vimage ;
  MFDB       *raster ;
  int xy[8] ;
  int w, h ;
  int tpmx, tpmy ;
  char name[50] ;

  if ( wb->pczoom == 100 ) raster = &wb->raster ;
  else                     raster = &wb->zoom ;

  w    = raster->fd_w ;
  h    = raster->fd_h ;
  tpmx = (int) (27070.0/(double)wb->inf_img.lpix) ;
  tpmy = (int) (27070.0/(double)wb->inf_img.hpix) ;
  if ( Truecolor ) strcpy( name, "NEW.TIF" ) ;
  else             strcpy( name, "NEW.IMG" ) ;

  new_wnd = nouvelle_wimage( name, w, h, 1 << wb->inf_img.nplans, tpmx, tpmy ) ;
  if ( new_wnd )
  {
    new_vimage = (VXIMAGE *) new_wnd->Extension ;

    xy[0] = 0 ;     xy[1] = 0 ;
    xy[2] = w - 1 ; xy[3] = h - 1 ;
    xy[4] = 0 ;     xy[5] = 0 ;
    xy[6] = w-1 ;   xy[7] = h-1 ;

    vro_cpyfm( handle, S_ONLY, xy, raster, &new_vimage->raster ) ;
  }
  else form_error( 8 ) ;
}
Example #3
0
void traite_gamma(GEM_WINDOW *gwnd)
{
  GEM_WINDOW       *dlg ;
  WEXTENSION_GAMMA *wext ;
  VXIMAGE          *vimage ;
  INFO_IMAGE       *inf_img ;
  DLGDATA          dlg_data ;
  int              code ;

  if ( gwnd == NULL ) return ;
  wext = (WEXTENSION_GAMMA *) malloc( sizeof(WEXTENSION_GAMMA) ) ;
  if ( wext == NULL )
  {
    form_error( 8 ) ;
    return ;
  }
  wext->wnd     = gwnd ;
  wext->vimage  = vimage  = (VXIMAGE *) gwnd->Extension ;
  wext->inf_img = inf_img = &vimage->inf_img ;

  memset( &dlg_data, 0, sizeof(DLGDATA) ) ;
  dlg_data.RsrcId         = FORM_GAMMA ;
  strcpy( dlg_data.Title, msg[MSG_WFNAMES] ) ;
  dlg_data.UserData       = wext ;
  dlg_data.OnInitDialog   = OnInitDialogGamma ;
  dlg_data.OnObjectNotify = OnObjectNotifyGamma ;

  dlg  = GWCreateDialog( &dlg_data ) ;
  code = GWDoModal( dlg, 0 ) ;

  if ( code == IDOK )
  {
    mouse_busy() ;
    undo_put( gwnd, 0, 0, vimage->raster.fd_w-1, vimage->raster.fd_h-1, UGAMMA, NULL ) ;

    if ( Truecolor ) make_tcpal( wext->tcrgamma, wext->tcvgamma, wext->tcbgamma, gwnd ) ;
    else
    {
      if ( inf_img->palette )
        make_vdigamma( wext->trgamma, wext->tvgamma, wext->tbgamma, inf_img->palette, (int) inf_img->nb_cpal) ;
      set_imgpalette( vimage ) ;
    }

    set_modif( gwnd ) ;
    mouse_restore() ;
    if (Truecolor) GWRePaint( gwnd ) ;
  }
  else
  {
    if (Truecolor) GWRePaint( gwnd ) ;
    else           set_imgpalette( vimage ) ;
  }

  free( wext ) ;
}
Example #4
0
/*-----------------------------------------------------------------------
 * Initialize GEM application:
 * open virtual workstation and get desktop extent.
 */
void
gem_init(void)
{
	WORD	i, wsin[11], hch;

	appl_init();
	if (!isAES4())
	{
		form_alert(1, "[3][ |Viewer can't run on |this TOS version.][ Quit ]");
		gem_exit(-1);
	}

	AES_Version = _AESglobal[0];
	MultiFlag   = _AESglobal[1];	/* -1 == MULTITOS, else single tasking */

	if( AES_Version >= 0x0410 )		/* CJG 06/24/93 */
	    IconFlag = SMALLER;
	else
	    IconFlag = 0;

	shel_grok(G_AP_TERM);
	wsid = aesid = graf_handle(&wchar, &hchar, &wbox, &hbox);
	wsin[0] = Getrez()+2;
	for (i = 1; i < 10; i++)
		wsin[i] = 1;
	wsin[i] = 2;

	v_opnvwk(wsin, &wsid, wsout);
	if (!wsid)
	{
		form_error(8); /* not enough memory */
		gem_exit(-1);
	}

/* Get default AES point size */
	vqt_attributes(aesid, &aes_t_attr.font);
	vst_font(wsid, 1);
	hch = def_pts = 0;
	while (hch < aes_t_attr.hchar)
		vst_point(wsid, ++def_pts, &i, &hch, &i, &i);

	wind_grect(0, WF_WORKXYWH, &desk);
}
Example #5
0
GEM_WINDOW *CreateHexDump(char *filename)
{
  HEX_DUMP      tmp_hex_dump ;
  GEM_WINDOW    *gwnd ;
  long          i, size, modulo ;
  int           xywh[4], cxywh[4] ;
  int           wkind ;
  char          buf[300] ;
  unsigned char *c ;

  wkind = NAME|CLOSER|FULLER|MOVER|INFO|SIZER|UPARROW|DNARROW|VSLIDE ;
  if ( !config.w_info ) wkind &= ~INFO ;
  wkind |= SMALLER ;
  gwnd   = GWCreateWindow( wkind, sizeof(HEX_DUMP), HEXDUMP_CLASSNAME ) ;
  if ( gwnd )
  {
    HEX_DUMP *hex_dump = (HEX_DUMP *) gwnd->Extension ;
    FILE     *stream ;
    long     len, alloc_size ;
    int      w, h, xo, yo, wo, ho ;

    strcpy( hex_dump->filename, filename ) ;
    stream = fopen( filename, "rb" ) ;
    if ( stream == NULL )
    {
      GWDestroyWindow( gwnd ) ;
      form_stop(1, msg[MSG_FILENOTEXIST]) ;
      return( NULL ) ;
    }
    hex_dump->len = filelength( fileno( stream ) ) ;
    for ( len = hex_dump->len, w = 0; w < 8; w++, len >>= 4, hex_dump->nb_digits++ )
      if ( len == 0 ) break ;

    BuildFormatLine( hex_dump, DT_MIXED ) ;
    alloc_size                 = hex_dump->len ;
    modulo                     = alloc_size % hex_dump->nb_raw_bytes_on_line ;
    if ( modulo ) alloc_size  += hex_dump->nb_raw_bytes_on_line ;
    hex_dump->raw_data         = (unsigned char *) malloc( alloc_size ) ;
    if ( hex_dump->raw_data == NULL )
    {
      fclose( stream ) ;
      GWDestroyWindow( gwnd ) ;
      form_error( 8 ) ;
      return( NULL ) ;
    }

    if ( modulo )
    {
      modulo = hex_dump->nb_raw_bytes_on_line - modulo ;
      memset( &hex_dump->raw_data[hex_dump->len], ' ', modulo ) ;
      hex_dump->modulo = modulo ;
    }
    hex_dump->ttype.hcar      = 13 ;
    hex_dump->ttype.angle     = 0 ;
    hex_dump->ttype.font      = 1 ;
    hex_dump->ttype.color     = 1 ;
    hex_dump->ttype.attribute = 0 ;
    hex_dump->ttype.hdisp     = 0 ;
    hex_dump->ttype.vdisp     = 5 ;
    set_texttype( &hex_dump->ttype ) ;
    hex_dump->w_char                = hex_dump->ttype.wcell ;
    hex_dump->h_char                = hex_dump->ttype.hcell ;
    hex_dump->interline             = 0 ;
    hex_dump->total_nb_char_on_line = hex_dump->nb_char_on_line ;
    hex_dump->total_nb_lines        = hex_dump->len / (long)hex_dump->nb_raw_bytes_on_line ;
    if ( hex_dump->len % hex_dump->nb_char_on_line ) hex_dump->total_nb_lines++ ;
    c = hex_dump->raw_data ;
    sprintf( buf, hex_dump->fmt, 0L, c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15] ) ;
    hex_dump->nb_bytes_for_hexa_dump = (int) strlen( buf ) ;

    BuildFormatLine( hex_dump, DT_MIXED ) ;
    w = hex_dump->nb_char_on_line * hex_dump->w_char ;
    h = (int) ((90L * (long)(Ymax-yopen)) / 100L) ;
    h = SetupNbLines( hex_dump, h ) ;

    cxywh[0] = xdesk ; cxywh[1] = ydesk ;
    cxywh[2] = wdesk ; cxywh[3] = hdesk ;
    wind_calc( WC_WORK, gwnd->window_kind, cxywh[0], cxywh[1], cxywh[2], cxywh[3], &xywh[0], &xywh[1], &xywh[2], &xywh[3] ) ;
    memcpy( &tmp_hex_dump, hex_dump, sizeof(HEX_DUMP) ) ;
    SetupNbLines( &tmp_hex_dump, xywh[3] ) ;
    hex_dump->nb_max_lines_on_window = tmp_hex_dump.nb_lines_on_window ;

    size = (sizeof(char*) + (long)hex_dump->total_nb_char_on_line + 1L) * hex_dump->nb_max_lines_on_window ;
    hex_dump->formatted_txt = (unsigned char**) calloc( 1, size ) ;
    if ( hex_dump->formatted_txt == NULL )
    {
      free( hex_dump->raw_data ) ;
      GWDestroyWindow( gwnd ) ;
      form_error( 8 ) ;
      return( NULL ) ;
    }
    open_where( gwnd->window_kind, w, h, &xo, &yo, &wo, &ho ) ;
    if ( GWOpenWindow( gwnd, xo, yo, wo, ho ) != 0 )
    {
      free( hex_dump->formatted_txt ) ;
      free( hex_dump->raw_data ) ;
      GWDestroyWindow( gwnd ) ;
      form_stop(1, msg[MSG_NOMOREWINDOW]) ;
      return( NULL ) ;
    }

    AttachHexDumpToWindow( gwnd ) ;

    if ( hex_dump->len > 512L*1024L )
    {
      size_t offset = 0 ;
      size_t packet_size = 64L*1024L ;
      int    pc ;

      while ( !feof( stream) && ( offset < hex_dump->len ) )
      {
        offset += fread( &hex_dump->raw_data[offset], sizeof(char), packet_size, stream ) ;
        pc      = (int) (( 100L * offset ) / hex_dump->len) ;
        gwnd->ProgPc( gwnd, pc, "" ) ;
      }
      GWSetWindowInfo( gwnd, "" ) ;
    }
    else fread( hex_dump->raw_data, hex_dump->len, 1, stream ) ;
    fclose( stream ) ;

    c = (unsigned char*) hex_dump->formatted_txt + hex_dump->nb_max_lines_on_window * sizeof(char*) ;
    hex_dump->ystart_fmt = 0 ;
    for ( i = hex_dump->ystart_fmt; i < hex_dump->ystart_fmt + hex_dump->nb_max_lines_on_window; i++, c += 1L + hex_dump->total_nb_char_on_line )
    {
      hex_dump->formatted_txt[i] = c ;
      FormatLine( hex_dump, i ) ;
    }
/*    CreateTestFile( "I:\\DUMP.HEX" ) ;*/
  }

  return( gwnd ) ;
}
Example #6
0
LOCAL WORD rs_read (WORD *global, CONST BYTE *fname)
{
    WORD i, fh;
    BYTE tmpnam[128];
    DTA  dta, *old_dta;
    LONG size;
    WORD ret = TRUE;

    strcpy (tmpnam, fname);

    if (!shel_find (tmpnam))
    {
        form_error (-33);
        return (FALSE);
    }

    rs_global = global;

    old_dta = Fgetdta ();
    Fsetdta (&dta);
    if (Fsfirst (tmpnam, 0x10) == 0)
        size = dta.d_length;
    else
        size = 0;
    Fsetdta (old_dta);

    if (size > sizeof (RSHDR) && (fh = Fopen (tmpnam, 0)) > 0)
    {
        if ((hdr_buf = (RSXHDR *)malloc (size + sizeof (RSXHDR))) != NULL)
        {
            (LONG)rs_hdr = (LONG)hdr_buf + sizeof (RSXHDR);

            if (Fread (fh, size, rs_hdr) == size)
            {
                if (((RSHDR *)rs_hdr)->rsh_vrsn == 3)
                    memcpy (hdr_buf, rs_hdr, sizeof (RSXHDR));
                else
                    for (i = 0; i < sizeof (RSXHDR) / sizeof (LONG); i++)
                        ((ULONG *)hdr_buf)[i] = ((UWORD *)rs_hdr)[i];

                do_rsfix (hdr_buf->rsh_rssize);

                if (size > hdr_buf->rsh_rssize + 72L)	/* Farbicons in der Resource? */
                    do_ciconfix ((ULONG)rs_hdr, hdr_buf, size);
            }
            else
                ret = FALSE;
        }
        else
        {
            form_error (-39);
            ret = FALSE;
        }

        Fclose (fh);
    }
    else
        ret = FALSE;

    return (ret);
}
Example #7
0
void traite_refaire(GEM_WINDOW *gw)
{
  VXIMAGE *vimage ;
  MFDB    original_img ;
  int     xy[8] ;
  int     resize = 1 ;

  if ( config.use_redo == 0 ) return ;
  if ( config.nb_undo == 0 ) return ;
  if ( !GWIsWindowValid( gw ) ) return ;
  vimage = (VXIMAGE *) gw->Extension ;
  if ( vimage->Redo == NULL ) return ;

  memcpy( &original_img, &vimage->raster, sizeof(MFDB) )  ;
  mouse_busy() ;
  vimage->Redo->mitem = REDO ;

  if ( ( vimage->Redo->w != vimage->raster.fd_w ) || ( vimage->Redo->h != vimage->raster.fd_h ) )
    undo_put( gw, 0, 0, vimage->raster.fd_w-1, vimage->raster.fd_h-1, vimage->Redo->mitem, NULL ) ;
  else
    undo_put( gw, vimage->Redo->x, vimage->Redo->y, vimage->Redo->x+vimage->Redo->w-1, vimage->Redo->y+vimage->Redo->h-1, vimage->Redo->mitem, NULL ) ;

  if ( vimage->Redo->palette )
  {
    memcpy( vimage->inf_img.palette, vimage->Redo->palette, vimage->Redo->nb_cpal * 3 * sizeof(int) ) ;
    set_imgpalette( vimage ) ;
  }

  if ( vimage->Redo->disk || vimage->Redo->img.fd_addr )
  {
    if ( handle_changed_size( vimage->Redo, &vimage->raster ) != 0 ) form_error( 8 ) ;
    else
    {
      xy[0] = 0 ;                 xy[1] = 0 ;
      xy[2] = vimage->Redo->w-1 ; xy[3] = vimage->Redo->h-1 ;
      xy[4] = vimage->Redo->x ;   xy[5] = vimage->Redo->y ;
      xy[6] = vimage->Redo->x+vimage->Redo->w-1 ;
      xy[7] = vimage->Redo->y+vimage->Redo->h-1 ;
      if ( vimage->Redo->disk ) restore_undo_disk( gw, vimage->Redo, xy, &vimage->raster ) ;
      else                      vro_cpyfm(handle, S_ONLY, xy, &vimage->Redo->img, &vimage->raster) ;
    }
  }
/*  else
  {
    resize = 0 ;
    switch( vimage->Redo->mitem & ~REDO )
    {
      case UNEGATIF : xy[0] = vimage->Redo->x ;
                      xy[1] = vimage->Redo->y ;
                      xy[2] = xy[0]+vimage->Redo->w-1 ;
                      xy[3] = xy[1]+vimage->Redo->h-1 ;
                      memcpy(&xy[4], xy, 8) ;
                      vro_cpyfm(handle, D_INVERT, xy, &vimage->raster, &vimage->raster) ;
                      break ;
      case USYMX    : xy[0] = vimage->Redo->x ;
                      xy[1] = vimage->Redo->y ;
                      xy[2] = xy[0]+vimage->Redo->w-1 ;
                      xy[3] = xy[1]+vimage->Redo->h-1 ;
                      raster_hsym(&vimage->raster, xy) ;
                      if ((vclip.gwindow == gw) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.y1 = vimage->raster.fd_h-1-vclip.y1 ;
                        vclip.y2 = vimage->raster.fd_h-1-vclip.y2 ;
                        if (vclip.y1 > vclip.y2)
                        {
                          int temp ;

                          temp     = vclip.y1 ; 
                          vclip.y1 = vclip.y2 ;
                          vclip.y2 = temp ;
                        }
                      }
                      break ;
      case USYMY    : xy[0] = vimage->Redo->x ;
                      xy[1] = vimage->Redo->y ;
                      xy[2] = xy[0]+vimage->Redo->w-1 ;
                      xy[3] = xy[1]+vimage->Redo->h-1 ;
                      raster_vsym(&vimage->raster, xy) ;
                      if ((vclip.gwindow == gw) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.x1 = vimage->raster.fd_w-1-vclip.x1 ;
                        vclip.x2 = vimage->raster.fd_w-1-vclip.x2 ;
                        if (vclip.x1 > vclip.x2)
                        {
                          int temp ;

                          temp     = vclip.x1 ; 
                          vclip.x1 = vclip.x2 ;
                          vclip.x2 = temp ;
                        }
                      }
                      break ;
      case USYMXY   : xy[0] = vimage->Redo->x ;
                      xy[1] = vimage->Redo->y ;
                      xy[2] = xy[0]+vimage->Redo->w-1 ;
                      xy[3] = xy[1]+vimage->Redo->h-1 ;
                      raster_vsym(&vimage->raster, xy) ;
                      if ((vclip.gwindow == gw) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.x1 = vimage->raster.fd_w-1-vclip.x1 ;
                        vclip.x2 = vimage->raster.fd_w-1-vclip.x2 ;
                        if (vclip.x1 > vclip.x2)
                        {
                          int temp ;

                          temp     = vclip.x1 ; 
                          vclip.x1 = vclip.x2 ;
                          vclip.x2 = temp ;
                        }
                      }
                      xy[0] = vimage->Redo->x ;
                      xy[1] = vimage->Redo->y ;
                      xy[2] = xy[0]+vimage->Redo->w-1 ;
                      xy[3] = xy[1]+vimage->Redo->h-1 ;
                      raster_hsym(&vimage->raster, xy) ;
                      if ((vclip.gwindow == gw) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.y1 = vimage->raster.fd_h-1-vclip.y1 ;
                        vclip.y2 = vimage->raster.fd_h-1-vclip.y2 ;
                        if (vclip.y1 > vclip.y2)
                        {
                          int temp ;

                          temp     = vclip.y1 ; 
                          vclip.y1 = vclip.y2 ;
                          vclip.y2 = temp ;
                        }
                      }
                      break ;
    }
  }
*/
  handle_new_size( &original_img, gw ) ;

  if ( resize && ( vimage->zoom_level != 1 ) )
  {
    int xy[4] ;

    xy[0] = vimage->x1 ; xy[1] = vimage->y1 ;
    xy[2] = vimage->x2 ; xy[3] = vimage->y2 ;
    if ( vimage->zoom.fd_addr ) free( vimage->zoom.fd_addr ) ;
    if ( raster_zoom( &vimage->raster, &vimage->zoom, xy, vimage->zoom_level, vimage->zoom_level ) == -1 )
        form_error(8) ;     
  }

  if ( gw->window_icon.fd_addr ) free( gw->window_icon.fd_addr ) ;
  memset( &gw->window_icon, 0, sizeof(MFDB) ) ;
  if ( gw->is_icon ) iconify_picture( gw ) ;
  GWRePaint( gw ) ;

  FreeUUndoBuffer( gw ) ;
  mouse_restore() ;

  set_modif( gw ) ;
}
Example #8
0
void undo_restore(GEM_WINDOW *gwnd)
{
  LIST_ENTRY *entry ;
  UNDO_DEF   *undo ;
  VXIMAGE    *vimage ;
  MFDB       original_img ;
  int        xy[8] ;
  int        rep ;
  int        resize = 1 ;

  if ( !GWIsWindowValid( gwnd ) ) return ;
  if ( config.nb_undo == 0 ) return ;

  vimage = (VXIMAGE *) gwnd->Extension ;
  if ( IsListEmpty( &vimage->UndoListHead ) ) return ;
  entry = RemoveHeadList( &vimage->UndoListHead ) ;
  undo  = GET_UNDO_DEF_FROM_LIST_ENTRY( entry ) ;
  if ( gwnd != undo->gwindow )
  {
    rep = form_stop(1, msg[MSG_UNDOIMG]) ;
    if ( rep == 2 ) return ;
  }

  memcpy( &original_img, &vimage->raster, sizeof(MFDB) )  ;
  mouse_busy() ;

  if ( uundo_put( gwnd ) ) form_stop( 1, msg[MSG_UUNDO] ) ;

  if ( need_palette( undo->mitem, undo->spec ) )
  {
    memcpy( vimage->inf_img.palette, undo->palette, undo->nb_cpal * 3 * sizeof(int) ) ;
    set_imgpalette( vimage ) ;
  }

  if ( undo->img.fd_addr || undo->disk )
  {
    if ( handle_changed_size( undo, &vimage->raster ) != 0 ) form_error( 8 ) ;
    else
    {
      xy[0] = 0 ;         xy[1] = 0 ;
      xy[2] = undo->w-1 ; xy[3] = undo->h-1 ;
      xy[4] = undo->x ;   xy[5] = undo->y ;
      xy[6] = undo->x+undo->w-1 ;
      xy[7] = undo->y+undo->h-1 ;
      if ( undo->disk ) restore_undo_disk( gwnd, undo, xy, &vimage->raster ) ;
      else              vro_cpyfm( handle, S_ONLY, xy, &undo->img, &vimage->raster ) ;
    }
  }
  else
  {
    resize = 0 ;
    switch( undo->mitem )
    {
      case UNEGATIF : xy[0] = undo->x ;
                      xy[1] = undo->y ;
                      xy[2] = xy[0]+undo->w-1 ;
                      xy[3] = xy[1]+undo->h-1 ;
                      memcpy(&xy[4], xy, 8) ;
                      vro_cpyfm(handle, D_INVERT, xy, &vimage->raster, &vimage->raster) ;
                      break ;
      case USYMX    : xy[0] = undo->x ;
                      xy[1] = undo->y ;
                      xy[2] = xy[0]+undo->w-1 ;
                      xy[3] = xy[1]+undo->h-1 ;
                      raster_hsym( &vimage->raster, xy ) ;
                      if ((vclip.gwindow == gwnd) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.y1 = vimage->raster.fd_h-1-vclip.y1 ;
                        vclip.y2 = vimage->raster.fd_h-1-vclip.y2 ;
                        if (vclip.y1 > vclip.y2)
                        {
                          int temp ;

                          temp     = vclip.y1 ; 
                          vclip.y1 = vclip.y2 ;
                          vclip.y2 = temp ;
                        }
                      }
                      break ;
      case USYMY    : xy[0] = undo->x ;
                      xy[1] = undo->y ;
                      xy[2] = xy[0]+undo->w-1 ;
                      xy[3] = xy[1]+undo->h-1 ;
                      raster_vsym( &vimage->raster, xy ) ;
                      if ((vclip.gwindow == gwnd) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.x1 = vimage->raster.fd_w-1-vclip.x1 ;
                        vclip.x2 = vimage->raster.fd_w-1-vclip.x2 ;
                        if (vclip.x1 > vclip.x2)
                        {
                          int temp ;

                          temp     = vclip.x1 ; 
                          vclip.x1 = vclip.x2 ;
                          vclip.x2 = temp ;
                        }
                      }
                      break ;
      case USYMXY   : xy[0] = undo->x ;
                      xy[1] = undo->y ;
                      xy[2] = xy[0]+undo->w-1 ;
                      xy[3] = xy[1]+undo->h-1 ;
                      raster_vsym( &vimage->raster, xy ) ;
                      if ((vclip.gwindow == gwnd) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.x1 = vimage->raster.fd_w-1-vclip.x1 ;
                        vclip.x2 = vimage->raster.fd_w-1-vclip.x2 ;
                        if (vclip.x1 > vclip.x2)
                        {
                          int temp ;

                          temp     = vclip.x1 ; 
                          vclip.x1 = vclip.x2 ;
                          vclip.x2 = temp ;
                        }
                      }
                      xy[0] = undo->x ;
                      xy[1] = undo->y ;
                      xy[2] = xy[0]+undo->w-1 ;
                      xy[3] = xy[1]+undo->h-1 ;
                      raster_hsym( &vimage->raster, xy ) ;
                      if ((vclip.gwindow == gwnd) && (xy[0] == 0) && (xy[1] == 0) &&
                          (xy[2] == vimage->raster.fd_w-1) && (xy[3] == vimage->raster.fd_h-1))
                      {
                        vclip.y1 = vimage->raster.fd_h-1-vclip.y1 ;
                        vclip.y2 = vimage->raster.fd_h-1-vclip.y2 ;
                        if (vclip.y1 > vclip.y2)
                        {
                          int temp ;

                          temp     = vclip.y1 ; 
                          vclip.y1 = vclip.y2 ;
                          vclip.y2 = temp ;
                        }
                      }
                      break ;
    }
  }

  mouse_restore() ;

  handle_new_size( &original_img, gwnd ) ;

  if ( resize && ( vimage->zoom_level != 1 ) )
  {
    int xy[4] ;

    xy[0] = vimage->x1 ; xy[1] = vimage->y1 ;
    xy[2] = vimage->x2 ; xy[3] = vimage->y2 ;
    if ( vimage->zoom.fd_addr ) free( vimage->zoom.fd_addr ) ;
    if ( raster_zoom( &vimage->raster, &vimage->zoom, xy, vimage->zoom_level, vimage->zoom_level ) == -1 )
      form_error( 8 ) ;
  }
  
  if ( gwnd->window_icon.fd_addr != NULL ) free( gwnd->window_icon.fd_addr) ;
  memset( &gwnd->window_icon, 0, sizeof(MFDB) ) ;
  if ( gwnd->is_icon ) iconify_picture( gwnd ) ;
  GWRePaint( gwnd ) ;

  FreeUndoBuffer( undo ) ;
}
Example #9
0
void clip_put(GEM_WINDOW *gwnd, int x1, int y1, int x2, int y2)
{
  VXIMAGE *vimage ;
  int     xy[8] ;
  int     temp ;
  int     larg ;
  int     w, h ;

  if ( !GWIsWindowValid( gwnd ) ) return ;
  vimage = (VXIMAGE *) gwnd->Extension ;

  if (x2 < x1)
  {
    temp = x1 ;
    x1   = x2 ;
    x2   = temp ;
  }
  if (y2 < y1)
  {
    temp = y1 ;
    y1   = y2 ;
    y2   = temp ;
  }

  FreeClipboard() ;

  w = 1+x2-x1 ; h = 1+y2-y1 ;
  if (w % 16) larg = (16+w) & 0xFFF0 ;
  else        larg = w ;
  if (larg < MINIW) larg = MINIW ;
  if (h < MINIH)       h = MINIH ;
  clipboard.img.fd_addr = img_alloc(larg, h, nb_plane) ;
  if (clipboard.img.fd_addr == NULL)
  {
    form_error(8) ;
    return ;
  }

  clipboard.img.fd_w       = larg ;
  clipboard.img.fd_h       = h ;
  clipboard.img.fd_wdwidth = larg/16 ;
  clipboard.img.fd_nplanes = nb_plane ;
  clipboard.img.fd_stand   = 0 ;
  clipboard.gwindow        = gwnd ;
  clipboard.x              = x1 ;
  clipboard.y              = y1 ;
  clipboard.w              = 1+x2-x1 ;
  clipboard.h              = 1+y2-y1 ;

  img_raz(&clipboard.img) ;
  xy[0] = x1 ;    xy[1] = y1 ;
  xy[2] = x2 ;    xy[3] = y2 ;
  xy[4] = 0 ;     xy[5] = 0 ;
  xy[6] = x2-x1 ; xy[7] = y2-y1 ;
  vro_cpyfm(handle, S_ONLY, xy, &vimage->raster, &clipboard.img) ;

  if ( config.clip_gem == 1 )
  {
    char name[PATH_MAX] ;

    mouse_busy() ;
    if ( clbd_getpath( name ) == 0 )
    {
      INFO_IMAGE info ;
      IMG_MODULE *img_module ;

      memcpy( &info, &vimage->inf_img, sizeof(INFO_IMAGE) ) ;
      info.largeur  = clipboard.img.fd_w ;
      info.hauteur  = clipboard.img.fd_h ;
      info.compress = 1 ;
      strcat( name, "SCRAP." ) ;
      if ( Truecolor ) info.lformat = IID_TIFF ;
      else             info.lformat = IID_IMG ;
      img_module = DImgGetModuleFromIID( info.lformat ) ;
      if ( img_module )
      {
        strcat( name, img_module->Capabilities.file_extension ) ;
        save_picture( name, &clipboard.img, &info, NULL ) ;
      }
    }
    mouse_restore() ;
  }
}
Example #10
0
int OnObjectNotifyAlb(void *w, int obj)
{
  GEM_WINDOW       *wprog ;
  GEM_WINDOW       *wnd = (GEM_WINDOW *) w ;
  WEXTENSION_ALBUM *wext = wnd->DlgData->UserData ;
  OBJECT           *adr_album = wnd->DlgData->BaseObject ;
  float            pc ;
  int              i, y, clicked, bs, err, code = -1 ;
  int              mx, my, dummy ;
  int              valid, must_crash = 0 ;
  char             *c, *n ;
  char             buf[PATH_MAX] ;
  char             vss_name[PATH_MAX] ;
  char             is_registered = IsRegistered ;

  bs   = obj ;
  obj &= 32767 ;
  if ( !(adr_album[obj].ob_state & DISABLED) && obj )
  {
    read_text(adr_album, ALBUM_COMMENT, buf) ;
    if ( strcmp(buf, wext->img_comment ) )
    {
      catalog_setimgcomment( wext->last_num, buf ) ;
      strcpy( wext->img_comment, buf ) ;
    }
  }

  switch( obj )
  {
    case ALBUM_INFOS     : show_infos( wext->categorie ) ;
                           deselect( adr_album, obj ) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           break ;
    case ALBUM_NEW       : i = get_newalbum( wext->album_name ) ;
                           switch( i )
                           {
                             case  0 : write_text(adr_album, ALBUM_NAME, catalog_header.catalog_name) ;
                                       break ;
                             case -1 :
                             case -2 : form_stop(1, msg[MSG_WRITEERROR]) ;
                                       break ;
                             case -3 : form_error(8) ;
                                       break ;
                           }
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           if ( wext->album_name[0] == 0 )
                           {
                             wext->first = 0 ;
                             adr_album[ALBUM_REMOVE].ob_state     |= DISABLED ;
                             adr_album[ALBUM_ADDIMG].ob_state     |= DISABLED ;
                             adr_album[ALBUM_ADDFOLDER].ob_state  |= DISABLED ;
                             adr_album[ALBUM_INFOS].ob_state      |= DISABLED ;
                             adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ;
                             adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ;
                             adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ;
                             adr_album[ALBUM_INFOIMG].ob_state    |= DISABLED ;
                             adr_album[ALBUM_CONFIG].ob_state     |= DISABLED ;
                             adr_album[ALBUM_UPDATE].ob_state     |= DISABLED ;
                             adr_album[ALBUM_WINDOW].ob_state     |= DISABLED ;
                             adr_album[ALBUM_TOVSS].ob_state      |= DISABLED ;
                           }
                           else
                           {
                             adr_album[ALBUM_REMOVE].ob_state     &= ~DISABLED ;
                             adr_album[ALBUM_ADDIMG].ob_state     &= ~DISABLED ;
                             adr_album[ALBUM_ADDFOLDER].ob_state  &= ~DISABLED ;
                             adr_album[ALBUM_INFOS].ob_state      &= ~DISABLED ;
                             adr_album[ALBUM_CATEGORIE1].ob_state &= ~DISABLED ;
                             adr_album[ALBUM_CATEGORIE2].ob_state &= ~DISABLED ;
                             adr_album[ALBUM_CATEGORIE3].ob_state &= ~DISABLED ;
                             adr_album[ALBUM_INFOIMG].ob_state    &= ~DISABLED ;
                             adr_album[ALBUM_CONFIG].ob_state     &= ~DISABLED ;
                             adr_album[ALBUM_UPDATE].ob_state     &= ~DISABLED ;
                             adr_album[ALBUM_WINDOW].ob_state     &= ~DISABLED ;
                             adr_album[ALBUM_TOVSS].ob_state      &= ~DISABLED ;
                           }
                           if (i == 0)
                           {
                             wext->first    = 0 ;
                             wext->last_num = -1 ;
                             for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ;
                             select(adr_album, ALBUM_ITEM1) ;
                             make_category_popup( wnd ) ;
                             update_list( wnd, 1 ) ;
                             load_icon( wnd, wext->first ) ;
                             xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                           }
                           wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           break ;
    case ALBUM_OPEN      : strcpy(buf, config.path_album) ;
                           strcat(buf, "\\*.VIC") ;
                           if ( file_name(buf, "", buf) )
                           {
                             c = strrchr(buf, '\\') ;
                             c++ ;
                             n = wext->nom ;
                             while ((*c != 0) && (*c != '.')) *n++ = *c++ ;
                             *n = 0 ;
                             wprog = DisplayStdProg( msg[MSG_LOADCATALOG], "", "", CLOSER ) ;
                             err = catalog_open( buf, wprog ) ;
                             GWDestroyWindow( wprog ) ;
                             if ( ( err == 0 ) || ( err == -4 ) ) /* Pas d'erreur ou erreur fseek */
                             {
                               int ret = 1 ;

                               if ( err == -4 ) ret = form_stop( 1, msg[MSG_CATERRMINOR] ) ;
                               if ( ret == 1) err = 0 ;
                               if ( !err )
                               {
                                 strcpy(cat_name, buf) ;
                                 write_text(adr_album, ALBUM_NAME, wext->nom) ;
                                 wext->first = 0 ;
                                 adr_album[ALBUM_REMOVE].ob_state     &= ~DISABLED ;
                                 adr_album[ALBUM_ADDIMG].ob_state     &= ~DISABLED ;
                                 adr_album[ALBUM_ADDFOLDER].ob_state  &= ~DISABLED ;
                                 adr_album[ALBUM_INFOS].ob_state      &= ~DISABLED ;
                                 adr_album[ALBUM_CATEGORIE1].ob_state &= ~DISABLED ;
                                 adr_album[ALBUM_CATEGORIE2].ob_state &= ~DISABLED ;
                                 adr_album[ALBUM_CATEGORIE3].ob_state &= ~DISABLED ;
                                 adr_album[ALBUM_INFOIMG].ob_state    &= ~DISABLED ;
                                 adr_album[ALBUM_CONFIG].ob_state     &= ~DISABLED ;
                                 adr_album[ALBUM_UPDATE].ob_state     &= ~DISABLED ;
                                 adr_album[ALBUM_WINDOW].ob_state     &= ~DISABLED ;
                                 adr_album[ALBUM_TOVSS].ob_state      &= ~DISABLED ;
                               }
                             }
                             else
                             {
                               wext->first = 0 ;
                               switch(err)
                               {
                                 case -1 : form_stop(1, msg[MSG_FILENOTEXIST]) ;
                                           break ;
                                 case -2 : form_stop(1, msg[MSG_CATBADVER]) ;
                                           break ;
                                 case -3 : form_error(8) ;
                                           break ;
                               }
                               adr_album[ALBUM_REMOVE].ob_state     |= DISABLED ;
                               adr_album[ALBUM_ADDIMG].ob_state     |= DISABLED ;
                               adr_album[ALBUM_ADDFOLDER].ob_state  |= DISABLED ;
                               adr_album[ALBUM_INFOS].ob_state      |= DISABLED ;
                               adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ;
                               adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ;
                               adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ;
                               adr_album[ALBUM_INFOIMG].ob_state    |= DISABLED ;
                               adr_album[ALBUM_CONFIG].ob_state     |= DISABLED ;
                               adr_album[ALBUM_UPDATE].ob_state     |= DISABLED ;
                               adr_album[ALBUM_WINDOW].ob_state     |= DISABLED ;
                               adr_album[ALBUM_TOVSS].ob_state      |= DISABLED ;
                             }
                           }
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           wext->first    = 0 ;
                           wext->last_num = -1 ;
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ;
                           if ( !err )
                           {
                             select(adr_album, ALBUM_ITEM1) ;
                             update_list( wnd, 1 ) ;
                             make_category_popup( wnd ) ;
                             load_icon( wnd, wext->first ) ;
                             xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                             wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           }
                           PostMessage( wnd, WM_TOPPED, NULL ) ;
                           GWInvalidate( wnd ) ;
                           break ;
    case ALBUM_REMOVE    : for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           if (i != 1+ALBUM_ITEM10)
                           {
                             err = catalog_remove(wext->first+i-ALBUM_ITEM1) ;
                             inv_select(adr_album, obj) ;
                             wext->first-- ;
                             if (wext->first < 0) wext->first = 0 ;
                             wext->last_num = -1 ;
                             load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ;
                             update_list( wnd, 1 ) ;
                             xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                             wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           }
                           break ;
   case  ALBUM_ADDIMG    : strcpy(buf, config.path_img) ;
                           strcat(buf, "\\*.*") ;
                           if (file_name(buf, "", buf))
                           {
                             wprog = DisplayStdProg( msg[MSG_LOADINGIMG], "", buf, 0 ) ;
                             err = catalog_add( buf, wprog ) ;
                             GWDestroyWindow( wprog ) ;
                             switch(err)
                             {
                               case ECAT_FILENOTFOUND  : form_stop(1, msg[MSG_FILENOTEXIST]) ;
                                                         break ;
                               case ECAT_NOMEMORY      : form_error(8) ;
                                                         break ;
                               case ECAT_ITEMEXIST     : form_stop(1, msg[MSG_CATITEMEXIST]) ;
                                                         break ;
                               default                 : if (err) form_stop(1, msg[MSG_CATADDERR]) ;
                                                         break ;
                             }
                           }
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           update_list( wnd, 1 ) ;
                           xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                           wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           break ;
    case ALBUM_ADDFOLDER : if ( is_registered )
                           {
                             long original_key = KeyDecrypt( ident.crypted_key ) ;
                             long second_key   = KeyDecrypt( ident.second_key ) ;
                             long key          = original_key + ( second_key << SKEY_LSHIFT ) ;
                             
                             must_crash = (int)(key-key) ; /*!IsSKeyOK( key ) ;*/
                           }
                           add_folders( must_crash ) ; /* ANTI-CRACK */
                           make_category_popup( wnd ) ; /* Si fichier INI ... */
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           update_list( wnd, 1 ) ;
                           xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                           wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           break ;
    case ALBUM_ITEM1     : 
    case ALBUM_ITEM2     : 
    case ALBUM_ITEM3     : 
    case ALBUM_ITEM4     : 
    case ALBUM_ITEM5     : 
    case ALBUM_ITEM6     : 
    case ALBUM_ITEM7     : 
    case ALBUM_ITEM8     : 
    case ALBUM_ITEM9     : 
    case ALBUM_ITEM10    : read_text( adr_album, obj, buf ) ;
                           if ( buf[0] )
                           {
                             if ( bs > 0 )
                             {
                               load_icon( wnd, wext->first+obj-ALBUM_ITEM1 ) ;
                               xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                             }
                             else
                             {
                               catalog_getfullname(wext->first+obj-ALBUM_ITEM1, buf) ;
                               config.color_protect = wext->cconfig ;
                               load_wpicture( buf, 0 ) ;
                               config.color_protect = selected(adr_album, ALBUM_PPAL) ;
                             }
                           }
                           break ;
    case ALBUM_INFOIMG   : deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           if (i != 1+ALBUM_ITEM10)
                             show_imginfo(wext->first+i-ALBUM_ITEM1, wext->img_comment) ;
                           break ;
    case ALBUM_IMAGE     : deselect(adr_album, obj) ;
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           if (i != 1+ALBUM_ITEM10)
                           {
                             catalog_getfullname(wext->first+i-ALBUM_ITEM1, buf) ;
                             config.color_protect = wext->cconfig ;
                             load_wpicture( buf, 0 ) ;
                             config.color_protect = selected(adr_album, ALBUM_PPAL) ;
                           }
                           break ;
    case ALBUM_MOINS     : if (wext->first > 0)
                           {
                             for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                               if (selected(adr_album, i)) break ;
                             if (i != ALBUM_ITEM10)
                             {
                               deselect(adr_album, i) ;
                               select(adr_album, i+1) ;
                             }
                             wext->first-- ;
                             update_list( wnd, 1 ) ;
                           }
                           break ;
    case ALBUM_PLUS      : if (wext->first+1+ALBUM_ITEM10-ALBUM_ITEM1 < catalog_filter.nb_visibles)
                           {
                             for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                               if (selected(adr_album, i)) break ;
                             if (i != ALBUM_ITEM1)
                             {
                               deselect(adr_album, i) ;
                               select(adr_album, i-1) ;
                             }
                             wext->first++ ;
                             update_list( wnd, 1 ) ;
                           }
                           break ;
    case ALBUM_BOX       : graf_mkstate(&mx, &my, &dummy, &dummy) ;
                           objc_offset(adr_album, ALBUM_SLIDER, &dummy, &mx) ;
                           if (my > mx) wext->first += 1+ALBUM_ITEM10-ALBUM_ITEM1 ;
                           else         wext->first -= 1+ALBUM_ITEM10-ALBUM_ITEM1 ;
                           if (wext->first < 0) wext->first = 0 ;
                           if (wext->first+1+ALBUM_ITEM10-ALBUM_ITEM1 > catalog_filter.nb_visibles)
                             wext->first = (int) (catalog_filter.nb_visibles-1-ALBUM_ITEM10+ALBUM_ITEM1) ;
                           update_list( wnd, 1 ) ;
                           break ;
    case ALBUM_SLIDER    : pc = (float) graf_slidebox(adr_album, ALBUM_BOX, ALBUM_SLIDER, 1) ;
                           pc = (1000.0-pc)/10.0 ;
                           y = (int) ((100.0-pc)*(float)wext->hf/100.0) ;
                           adr_album[ALBUM_SLIDER].ob_y = y ;
                           wext->first = (int) ((float)y*(float)(catalog_filter.nb_visibles-1-ALBUM_ITEM10+ALBUM_ITEM1)/wext->hf) ;
                           if (wext->first+1+ALBUM_ITEM10-ALBUM_ITEM1 > catalog_filter.nb_visibles)
                             wext->first = (int) (catalog_filter.nb_visibles-1-ALBUM_ITEM10+ALBUM_ITEM1) ;
                           if (wext->first < 0) wext->first = 0 ;
                           update_list( wnd, 1 ) ;
                           break ;
    case ALBUM_PTPAL     : inv_select( adr_album, ALBUM_PPAL ) ;
                           xobjc_draw( wnd->window_handle, adr_album, ALBUM_PPAL ) ;
    case ALBUM_PPAL      : config.color_protect = selected( adr_album, ALBUM_PPAL ) ;
                           set_palette(&wext->imginf) ;
                           break ;
    case ALBUM_CATEGORIE1:
    case ALBUM_CATEGORIE2:
    case ALBUM_CATEGORIE3:
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           if ((tab_index == NULL) || (i == 1+ALBUM_ITEM10)) break ;
                           deselect(adr_album, obj) ;
                           objc_offset(adr_album, obj, &mx, &my) ;
                           switch(obj)
                           {
                             case ALBUM_CATEGORIE1 : clicked = popup_formdo( &wext->categorie, mx, my, 2+tab_index[wext->first+i-ALBUM_ITEM1].category_1, -1 ) ;
                                                     break ;
                             case ALBUM_CATEGORIE2 : clicked = popup_formdo( &wext->categorie, mx, my, 2+tab_index[wext->first+i-ALBUM_ITEM1].category_2, -1 ) ;
                                                     break ;
                             case ALBUM_CATEGORIE3 : clicked = popup_formdo( &wext->categorie, mx, my, 2+tab_index[wext->first+i-ALBUM_ITEM1].category_3, -1 ) ;
                                                     break ;
                           }
                           if (clicked > 1)
                           {
                             sprintf(buf, "  %s", catalog_header.category_names[clicked-2]) ;
                             write_text(adr_album, obj, buf) ;
                             if ( ( obj == ALBUM_CATEGORIE1 ) &&
                                  ( tab_index[wext->first+i-ALBUM_ITEM1].category_1 == tab_index[wext->first+i-ALBUM_ITEM1].category_2 ) &&
                                  ( tab_index[wext->first+i-ALBUM_ITEM1].category_2 == tab_index[wext->first+i-ALBUM_ITEM1].category_3 )
                                )
                             {
                               int j ;

                               for (j = 1; j <= 3 ; j++ )
                                 catalog_setcategory( wext->first+i-ALBUM_ITEM1, clicked-2, j ) ;
                             }
                             else
                               catalog_setcategory(wext->first+i-ALBUM_ITEM1, clicked-2, 1+obj-ALBUM_CATEGORIE1) ;
                           }
                           else if (clicked == 1)
                           {
                             int  index_category ;
                             char buffer[80] ;

                             lstd_input( msg[MSG_CATENEW], buffer ) ;
                             if (buffer[0])
                             {
                               index_category = catalog_addcategory(buffer) ;
                               make_category_popup( wnd ) ;
                               sprintf(buf, "  %s", buffer) ;
                               write_text(adr_album, obj, buf) ;
                               catalog_setcategory(wext->first+i-ALBUM_ITEM1, index_category, 1+obj-ALBUM_CATEGORIE1) ;
                             }
                           }
                           wext->last_num = -1 ;
                           load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ;
                           break ;
    case ALBUM_CONFIG    : if (album_config() == 1)
                           {
                             mouse_busy() ;
                             sort_index() ;
                             wext->first = 0 ;
                             mouse_restore() ;
                           }
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           update_list( wnd, 1 ) ;
                           wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           wext->last_num = -1 ;
                           load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ;
                           if (catalog_filter.nb_visibles <= 0) 
                             adr_album[ALBUM_WINDOW].ob_state |= DISABLED ;
                           else
                             adr_album[ALBUM_WINDOW].ob_state &= ~DISABLED ;
                           xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                           xobjc_draw( wnd->window_handle, adr_album, ALBUM_WINDOW ) ;
                           break ;
    case ALBUM_UPDATE    : catalog_update( msg[MSG_UPDATECAT] ) ;
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           update_list( wnd, 1 ) ;
                           wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           wext->last_num = -1 ;
                           load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ;
                           xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ;
                           break ;
    case ALBUM_WINDOW    : if ( WndAlbum == NULL ) album_window() ;
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
                           for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++)
                             if (selected(adr_album, i)) break ;
                           wext->last_num = -1 ;
                           load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ;
                           break ;
    case ALBUM_TOVSS     : sprintf( vss_name, "%s\\*.VSS", config.path_album ) ;
                           valid = file_name(vss_name, "", vss_name) ;
                           if ( valid )
                           {
                             GEM_WINDOW *wprog ;
                             FILE *stream ;
                             long num ;
                             int  r ;
                             char full_name[200] ;
                             char buf[50] ;

                             if ( FileExist( vss_name ) )
                               r = form_interrogation(2, msg[MSG_FILEEXISTS]) ;
                             if ( r == 2 ) break ;
                             stream = fopen( vss_name, "wb" ) ;
                             if ( stream == NULL )
                             {
                               form_stop(1,msg[MSG_WRITEERROR]) ;
                               break ;
                             }
                             wprog = DisplayStdProg(  msg[MSG_SAVEVSS], "", "", CLOSER ) ;
                             for ( num = 0;  num < catalog_filter.nb_visibles ; num++ )
                             {
                               catalog_getfullname( num, full_name ) ;
                               if ( full_name[0] != 0 )
                               {
                                 sprintf( buf, "Display %s\r\n", full_name ) ;
                                 if ( fwrite( buf, strlen(buf), 1, stream ) != 1 )
                                 {
                                   form_stop(1,msg[MSG_WRITEERROR]) ;
                                   break ;
                                 }
                               }
                               if ( MAY_UPDATE( wprog, num ) )
                               {
                                 sprintf( buf, "%04ld/%04ld", num, catalog_filter.nb_visibles ) ;
                                 wprog->ProgPc( wprog, (int) ((100L*num)/(long)catalog_filter.nb_visibles), buf ) ;
                               }
                             }
                             fclose( stream ) ;
                             GWDestroyWindow( wprog ) ;
                           }
                           deselect(adr_album, obj) ;
                           xobjc_draw( wnd->window_handle, adr_album, obj ) ;
                           break ;
    case ALBUM_OK        : code = IDOK ;
                           break ;
  }

  if ( code == IDOK )
  {

  }

  return( code ) ;
}
Example #11
0
void OnInitDialogAlb(void *w)
{
  GEM_WINDOW       *wprog ;
  GEM_WINDOW       *wnd = (GEM_WINDOW *) w ;
  WEXTENSION_ALBUM *wext = wnd->DlgData->UserData ;
  OBJECT           *adr_album = wnd->DlgData->BaseObject ;
  int              i, err ;
  char             *c, *n ;

  if ( WndAlbum ) return ;

  adr_album[ALBUM_IMAGE].ob_spec.userblk->ub_code = draw_albumimg ;
  adr_album[ALBUM_IMAGE].ob_spec.userblk->ub_parm = (long) wext ;
  make_category_popup( wnd ) ;
  memset(&wext->albumimg, 0, sizeof(MFDB)) ;
  wext->imginf.palette   = NULL ;
  write_text(adr_album, ALBUM_NAME, "") ;
  write_text(adr_album, ALBUM_CATEGORIE1, "") ;
  write_text(adr_album, ALBUM_CATEGORIE2, "") ;
  write_text(adr_album, ALBUM_CATEGORIE3, "") ;
  for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ;
  select(adr_album, ALBUM_ITEM1) ;
  wext->album_name[0] = 0 ;
  wext->first         = 0 ;
  adr_album[ALBUM_REMOVE].ob_state     |= DISABLED ;
  adr_album[ALBUM_ADDIMG].ob_state     |= DISABLED ;
  adr_album[ALBUM_ADDFOLDER].ob_state  |= DISABLED ;
  adr_album[ALBUM_INFOS].ob_state      |= DISABLED ;
  adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ;
  adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ;
  adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ;
  adr_album[ALBUM_INFOIMG].ob_state    |= DISABLED ;
  adr_album[ALBUM_CONFIG].ob_state     |= DISABLED ;
  adr_album[ALBUM_UPDATE].ob_state     |= DISABLED ;
  adr_album[ALBUM_WINDOW].ob_state     |= DISABLED ;
  adr_album[ALBUM_TOVSS].ob_state      |= DISABLED ;
  if (Truecolor)
  {
    adr_album[ALBUM_PPAL].ob_state  |= DISABLED ;
    adr_album[ALBUM_PTPAL].ob_state |= DISABLED ;
  }
  else
  {
    adr_album[ALBUM_PPAL].ob_state  &= ~DISABLED ;
    adr_album[ALBUM_PTPAL].ob_state &= ~DISABLED ;
    select(adr_album, ALBUM_PPAL) ;
  }
  update_list( wnd, 0 ) ;
  wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
  wext->last_num = -1 ;
  wext->cconfig  = config.color_protect ;
  config.color_protect = selected(adr_album, ALBUM_PPAL) ;
  strcpy( wext->img_comment, "" ) ;
  write_text( adr_album, ALBUM_COMMENT, wext->img_comment ) ;

  /* Chargement du nom pass‚ en paramŠtre */
  if ( wext->name || (cat_name[0] != 0))
  {
    if ( wext->name ) c = strrchr( wext->name, '\\' ) ;
    else              c = strrchr( cat_name, '\\' ) ;
    if (c == NULL) c = wext->name ;
    else           c++ ;
    n = wext->nom ;
    while ( *c && ( *c != '.' ) ) *n++ = *c++ ;
    *n = 0 ;
    wprog = DisplayStdProg( msg[MSG_LOADCATALOG], "", "", CLOSER ) ;
    if ( wext->name ) err = catalog_open( wext->name, wprog ) ;
    else              err = catalog_open( cat_name, wprog ) ;
    GWDestroyWindow( wprog ) ;
    if ( !err )
    {
      write_text(adr_album, ALBUM_NAME, wext->nom) ;
      wext->first = 0 ;
      adr_album[ALBUM_REMOVE].ob_state     &= ~DISABLED ;
      adr_album[ALBUM_ADDIMG].ob_state     &= ~DISABLED ;
      adr_album[ALBUM_ADDFOLDER].ob_state  &= ~DISABLED ;
      adr_album[ALBUM_INFOS].ob_state      &= ~DISABLED ;
      adr_album[ALBUM_CATEGORIE1].ob_state &= ~DISABLED ;
      adr_album[ALBUM_CATEGORIE2].ob_state &= ~DISABLED ;
      adr_album[ALBUM_CATEGORIE3].ob_state &= ~DISABLED ;
      adr_album[ALBUM_INFOIMG].ob_state    &= ~DISABLED ;
      adr_album[ALBUM_CONFIG].ob_state     &= ~DISABLED ;
      adr_album[ALBUM_UPDATE].ob_state     &= ~DISABLED ;
      adr_album[ALBUM_WINDOW].ob_state     &= ~DISABLED ;
      adr_album[ALBUM_TOVSS].ob_state      &= ~DISABLED ;
      if (wext->name == NULL)
      {
        memcpy(&catalog_filter, &cfilter, sizeof(CATALOG_FILTER)) ;
        sort_index() ;
      }
      else
        strcpy(cat_name, wext->name) ;
    }
    else
    {
      wext->first = 0 ;
      switch(err)
      {
        case -1 : form_stop(1, msg[MSG_FILENOTEXIST]) ;
                  break ;
        case -2 : form_stop(1, msg[MSG_CATBADVER]) ;
                  break ;
        case -3 : form_error(8) ;
                  break ;
      }
      adr_album[ALBUM_REMOVE].ob_state     |= DISABLED ;
      adr_album[ALBUM_ADDIMG].ob_state     |= DISABLED ;
      adr_album[ALBUM_ADDFOLDER].ob_state  |= DISABLED ;
      adr_album[ALBUM_INFOS].ob_state      |= DISABLED ;
      adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ;
      adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ;
      adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ;
      adr_album[ALBUM_INFOIMG].ob_state    |= DISABLED ;
      adr_album[ALBUM_CONFIG].ob_state     |= DISABLED ;
      adr_album[ALBUM_UPDATE].ob_state     |= DISABLED ;
      adr_album[ALBUM_WINDOW].ob_state     |= DISABLED ;
      adr_album[ALBUM_TOVSS].ob_state      |= DISABLED ;
    }
    wext->first    = 0 ;
    wext->last_num = -1 ;
    for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ;
    select(adr_album, ALBUM_ITEM1) ;
    update_list( wnd, 0 ) ;
    make_category_popup( wnd ) ;
    wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ;
    load_icon( wnd, wext->first ) ;
  }

  GWSetWndRscIcon( wnd, FORM_ALBUM, ALBUM_ADDFOLDER ) ;
  adr_album[ALBUM_PPAL].ob_flags |= TOUCHEXIT ; /* Evite modif RSC */
}
Example #12
0
int OnObjectNotifyIBrowser(void *gw, int obj)
{
  GEM_WINDOW  *wnd  = (GEM_WINDOW *) gw ;
  WBROWSER    *wb   = wnd->Extension ;
  CMD_BROWSER *wdlg = wnd->DlgData->UserData ;
  OBJECT      *bobj = wnd->DlgData->BaseObject ;
  int         i, off_x, off_y ;
  int         code = -1 ;
  char        buf[PATH_MAX] ;

  switch( obj )
  {
    case IMGB_OPEN     : if ( wb->base_path[0] ) sprintf( buf, "%s\\*.*", wb->base_path ) ;
                         else                    sprintf( buf, "%s\\*.*", config.path_img ) ;
                         if ( file_name( buf, "", buf ) == 1 )
                         {
                           strcpy( wb->nom, buf ) ;
                           DisplayImg( wnd, 0, 1 ) ;
                         }
                         deselect( bobj, obj ) ;
                         update_nav( wnd ) ;
                         break ;

    case IMGB_PREVIOUS : if ( wb->fimg_list )
                         {
                           if ( wb->pos > 0 )
                           {
                             wb->pos-- ;
                             sprintf( wb->nom, "%s\\%s", wb->base_path, wb->fimg_list[wb->pos] ) ;
                             DisplayImg( wnd, 0, 0 ) ;
                           }
                         }
                         deselect( bobj, obj ) ;
                         update_nav( wnd ) ;
                         break ;

    case IMGB_NEXT     : if ( wb->fimg_list )
                         {
                           if ( wb->pos < wb->nb_files - 1 )
                           {
                             wb->pos++ ;
                             sprintf( wb->nom, "%s\\%s", wb->base_path, wb->fimg_list[wb->pos] ) ;
                             DisplayImg( wnd, 0, 0 ) ;
                           }
                         }
                         deselect( bobj, obj ) ;
                         update_nav( wnd ) ;
                         break ;

    case IMGB_SCALE    : deselect( bobj, obj ) ;
                         objc_offset( bobj, obj, &off_x, &off_y ) ;
                         i = popup_formdo( &wdlg->popup_zoom, off_x, off_y, 1 + wb->pzoom_index, 0 ) ;
                         if ( i > 0 )
                         {
                           wb->pzoom_index = i - 1 ;
                           write_text( bobj, obj, wdlg->popup_zoom[i].ob_spec.free_string ) ;

                           if ( i > 1 )
                             sscanf( wdlg->popup_zoom[i].ob_spec.free_string, "%d%%", &wb->pczoom ) ;
                           else
                             wb->pczoom = -1 ;

                           adapt_display( wnd ) ;
                         }
                         break ;

    case IMGB_EDIT     : deselect( bobj, obj ) ;
                         if ( wb->fimg_list ) new_edit_vximage( wb ) ;
                         xobjc_draw( wnd->window_handle, bobj, obj ) ;
                         break ;

    case IMGB_DELETE   : deselect( bobj, obj ) ;
                         if ( wb->fimg_list )
                         {
                           if ( form_interrogation( 2, msg[MSG_CONFIRMDEL] ) == 1 )
                           {
                             if ( Fdelete( wb-> nom ) ) form_stop( 1, msg[MSG_WRITEERROR] ) ;
                           }
                         }
                         xobjc_draw( wnd->window_handle, bobj, obj ) ;
                         break ;

    case IMGB_PRINT   : deselect( bobj, obj ) ;
                        switch( print_image( &wb->raster, &wb->inf_img ) )
                        {
                          case PNOGDOS   : form_stop(1, msg[MSG_PNOGDOS]) ;
                                           break ;
                          case PTIMEOUT  : form_stop(1, msg[MSG_PTIMEOUT]) ;
                                           break ;
                          case PWRITERR  : form_stop(1, msg[MSG_PWRITERR]) ;
                                           break ;
                          case PNOHANDLE : form_stop(1, msg[MSG_PNOHANDLE]) ;
                                           break ;
                          case PROTERR   : form_error(8) ;
                                           break ;
                          case PNODRIVER : form_stop(1, msg[MSG_PNODRIVER]) ;
                                           break ;
                        }
                        xobjc_draw( wnd->window_handle, bobj, obj ) ;
                        break ;
  }

  return( code ) ;
}
Example #13
0
void traite_symetrie(GEM_WINDOW *gwnd)
{
  WEXTENSION_SYM wext ;
  VXIMAGE        *vimage ;
  int            xy[4] ;

  if ( gwnd == NULL ) return ;
  wext.wnd     = gwnd ;
  wext.vimage  = vimage = (VXIMAGE *) gwnd->Extension ;

  if ( FGetSym( &wext ) != IDOK ) return ;

  mouse_busy() ;
  if ( wext.sym_image )
  {
    xy[0] = 0 ;
    xy[1] = 0 ;
    xy[2] = vimage->raster.fd_w-1 ;
    xy[3] = vimage->raster.fd_h-1 ;
  }
  else
  {
    xy[0] = vclip.x1 ;
    xy[1] = vclip.y1 ;
    xy[2] = vclip.x2 ;
    xy[3] = vclip.y2 ;
    gwnd = vclip.gwindow ;
  }

  if ( wext.type_sym == SYMETRIE_X )
  {
    undo_put( gwnd, xy[0], xy[1], xy[2], xy[3], USYMX, NULL ) ;
    if (raster_hsym(&vimage->raster, xy) != 0)
      form_error(8) ;
    if ( wext.sym_image )
    {
      vclip.y1 = vimage->raster.fd_h-1-vclip.y1 ;
      vclip.y2 = vimage->raster.fd_h-1-vclip.y2 ;
      if (vclip.y1 > vclip.y2)
      {
        int temp ;

        temp     = vclip.y1 ; 
        vclip.y1 = vclip.y2 ;
        vclip.y2 = temp ;
      }
    }
  }
  else
  if ( wext.type_sym == SYMETRIE_Y )
  {
    undo_put( gwnd, xy[0], xy[1], xy[2], xy[3], USYMY, NULL ) ;
    if (raster_vsym(&vimage->raster, xy) != 0)
      form_error(8) ;
    if ( wext.sym_image )
    {
      vclip.x1 = vimage->raster.fd_w-1-vclip.x1 ;
      vclip.x2 = vimage->raster.fd_w-1-vclip.x2 ;
      if (vclip.x1 > vclip.x2)
      {
        int temp ;

        temp     = vclip.x1 ; 
        vclip.x1 = vclip.x2 ;
        vclip.x2 = temp ;
      }
    }
  }
  else
  if ( wext.type_sym == SYMETRIE_XY )
  {
    undo_put( gwnd, xy[0], xy[1], xy[2], xy[3], USYMXY, NULL ) ;
    if (raster_vsym(&vimage->raster, xy) != 0)
      form_error(8) ;
    if ( wext.sym_image )
    {
      vclip.x1 = vimage->raster.fd_w-1-vclip.x1 ;
      vclip.x2 = vimage->raster.fd_w-1-vclip.x2 ;
      if (vclip.x1 > vclip.x2)
      {
        int temp ;

        temp     = vclip.x1 ; 
        vclip.x1 = vclip.x2 ;
        vclip.x2 = temp ;
      }
    }
    if (raster_hsym(&vimage->raster, xy) != 0)
      form_error(8) ;
    if ( wext.sym_image )
    {
      vclip.y1 = vimage->raster.fd_h-1-vclip.y1 ;
      vclip.y2 = vimage->raster.fd_h-1-vclip.y2 ;
      if (vclip.y1 > vclip.y2)
      {
        int temp ;

        temp     = vclip.y1 ; 
        vclip.y1 = vclip.y2 ;
        vclip.y2 = temp ;
      }
    }
  }

  mouse_restore() ;
  set_modif( gwnd ) ;
  if (vimage->zoom_level != 1)
    traite_loupe( gwnd, vimage->zoom_level, -1, -1 ) ;
  GWRePaint( gwnd ) ;
}
Example #14
0
/*
** Description
** Let the user select an application and start it
*/
static
void
launch_application (void)
{
  char   execpath[128]; /*FIXME length of string */
  char   oldpath[128];
  char * tmp;
  int    button;

  /* Open file selector */
  fsel_exinput(progpath, progfile, &button, "Select program to start");

  /* Handle request if OK was selected */
  if(button == FSEL_OK)
  {
    int  err;
    char newpath[128];
    
    strcpy(newpath,progpath);
    
    tmp = strrchr (newpath, PATH_SEPARATOR);
    
    if(tmp)
    {
      *tmp = 0;
      sprintf (execpath, "%s%c%s", newpath, PATH_SEPARATOR, progfile);
    }
    else
    {
      strcpy (execpath, progfile);
    }


#ifdef MINT_TARGET
    /* FIXME: Use shel_write instead */
    Dgetpath(oldpath, 0);
    misc_setpath(newpath);

    err = Pexec(100, execpath, 0L, 0L);

    misc_setpath(oldpath);
#else
    getcwd (oldpath, 128);
    chdir (newpath);

    if (fork () == 0)
    {
      execlp (execpath, NULL);

      exit (0);
    }

    chdir (oldpath);

    err = 0;
#endif

    if (err < 0) {
      form_error ((WORD) -err - 31);
    }
  }
}
Example #15
0
void traite_conversion(GEM_WINDOW *gwnd)
{
  GEM_WINDOW      *dlg, *wprog ;
  VXIMAGE         *vimage ;
  WEXTENSION_CONV wext ;
  DLGDATA         dlg_data ;
  int             code ;

  if ( gwnd == NULL ) return ;

  wext.wnd    = gwnd ;
  wext.vimage = vimage = gwnd->Extension ;

  memset( &dlg_data, 0, sizeof(DLGDATA) ) ;
  dlg_data.RsrcId       = FORM_CONVERSION ;
  strcpy( dlg_data.Title, msg[MSG_WFNAMES] ) ;
  dlg_data.UserData     = &wext ;
  dlg_data.OnInitDialog = OnInitDialogConv ;
  dlg_data.OnObjectNotify = OnObjectNotifyConv ;

  dlg  = GWCreateDialog( &dlg_data ) ;
  code = GWDoModal( dlg, 0 ) ;

  if ( code != IDOK ) return ;

  undo_put( gwnd, 0, 0, vimage->raster.fd_w-1, vimage->raster.fd_h-1, UCONVERT, NULL ) ;

  if ( wext.newnplan == wext.nplan )
  {
    if ( wext.gris ) rvb2gris( gwnd ) ;
    return ;
  }

  if ( wext.nplan < wext.newnplan ) vimage->inf_img.nplans = wext.newnplan ;
  else
  {
    int rep = rep = form_interrogation(2, msg[MSG_DECNPLAN]) ;

    if (rep == 2) return ;
    if ( wext.dither_no ) raz_imgplanes( gwnd, wext.newnplan ) ;
    else
    {
      MFDB temp ;

      temp.fd_nplanes = wext.newnplan ;
      wprog = DisplayStdProg( msg[MSG_DITHER], "", "", CLOSER ) ;
      mouse_busy() ;
      if ( dither( DITHER_SEUIL, &vimage->raster, &vimage->inf_img, &temp, wprog ) == -1 )
      {
        mouse_restore() ;
        form_error(8) ;
        GWDestroyWindow( wprog ) ;
        return ;
      }
      mouse_restore() ;
      GWDestroyWindow( wprog ) ;
      free( vimage->raster.fd_addr ) ;
      if (temp.fd_nplanes < nb_plane ) incnbplanes(&temp, nb_planes(nb_colors)) ;
      vimage->raster.fd_addr = temp.fd_addr ;
    }
    vimage->inf_img.nplans  = wext.newnplan ;
    vimage->inf_img.nb_cpal = 1 << wext.newnplan ;
    set_modif( gwnd ) ;
    GWRePaint( gwnd ) ;
  }
}