Exemplo n.º 1
0
/* Open the win_dib driver */
static int
win_dib_open(gx_device * dev)
{
    int code = win_open(dev);

    if (code < 0)
	return code;

#ifdef __WIN32__
    if (!is_win32s)
	wdev->hmtx = CreateMutex(NULL, FALSE, NULL);	/* unnamed mutex, initially unowned */
#endif
    if (gdev_mem_device_for_bits(dev->color_info.depth) == 0) {
	win_close(dev);
	return gs_error_rangecheck;
    }
    code = win_dib_alloc_bitmap((gx_device_win *) dev, dev);
    if (code < 0) {
	win_close(dev);
	return code;
    }
    /* notify caller about new device */
    if (pgsdll_callback) {
	(*pgsdll_callback) (GSDLL_DEVICE, (unsigned char *)dev, 1);
	(*pgsdll_callback) (GSDLL_SIZE, (unsigned char *)dev,
			(dev->width & 0xffff) +
			((ulong) (dev->height & 0xffff) << 16));
    }
    return code;
}
Exemplo n.º 2
0
// --------------------------------------------------------------------------------
// ODBCSourceList
// Crea una lista con ARMAKER delle Sorgenti di dati presenti nel sistema
// Filtra i dati cercando la parola passata con *lpDriver nel driver collegato
// alla sorgente 
// --------------------------------------------------------------------------------
SINT ODBCDriverList(CHAR *lpDriver)
{
	SQLCHAR szServerName[180];
	SQLCHAR szServerDesc[180];
	SQLSMALLINT iServerName;
	SQLSMALLINT iServerDesc;
	SQLRETURN sqlReturn;
//	CHAR Buffer[500];

	// -------------------------------
	// Elenco server disponibili
	//
	
	ARMaker(WS_OPEN,NULL);
	win_open(EHWP_SCREENCENTER,50,232,59,-1,3,ON,"Lettura Data Source Name");

	sqlReturn=SQLDataSources(EhOdbc.hEnv,SQL_FETCH_FIRST,
							szServerName,sizeof(szServerName)-1,&iServerName,
							szServerDesc,sizeof(szServerDesc)-1,&iServerDesc);
	do 
	{
		if (!strstr(szServerDesc,lpDriver)) continue;
//		sprintf(Buffer,"%s - %s",szServerName,szServerDesc);
		ARMaker(WS_ADD,szServerDesc);
	} while (SQLDataSources(EhOdbc.hEnv,SQL_FETCH_NEXT,
							szServerName,
							sizeof(szServerName)-1,&iServerName,
							szServerDesc,
							sizeof(szServerDesc)-1,&iServerDesc)==SQL_SUCCESS);

	win_close();
	return ARMaker(WS_CLOSE,"ODBCSource");
}
Exemplo n.º 3
0
Arquivo: win.c Projeto: songtzu/study
void 
HariMain(void)
{
  int win;
  win = win_open(buf, 150, 50, -1, "Hello-Win");

  api_end();
}
int win_truncate(const char *path, off_t length)
{
    int fd, ret, saved_errno;

    fd = win_open(path, O_WRONLY);
    if (fd < 0)
	return -1;
    ret = chsize(fd, length);
    saved_errno = errno;
    win_close(fd);
    errno = saved_errno;

    return ret;
}
Exemplo n.º 5
0
/* Open the win_ddb driver */
static int
win_ddb_open(gx_device * dev)
{
    int code = win_open(dev);
    HDC hdc;

    if (code < 0)
	return code;

    if (wdev->BitsPerPixel > 8)
	return gs_error_limitcheck;	/* don't support 24 bit/pixel */

    /* Create the backing bitmap. */
    code = win_ddb_alloc_bitmap((gx_device_win *) dev, dev);
    if (code < 0)
	return code;

    /* Create the bitmap and DC for copy_mono. */
    hdc = GetDC(wdev->hwndimg);
    wdev->hbmmono = CreateBitmap(bmWidthBits, bmHeight, 1, 1, NULL);
    wdev->hdcmono = CreateCompatibleDC(hdc);
    if (wdev->hbmmono == NULL || wdev->hdcmono == NULL) {
	win_ddb_free_bitmap((gx_device_win *) dev);
	ReleaseDC(wdev->hwndimg, hdc);
	return win_nomemory();
    }
    SetMapMode(wdev->hdcmono, GetMapMode(hdc));
    SelectObject(wdev->hdcmono, wdev->hbmmono);
    wdev->bm_id = gx_no_bitmap_id;
    ReleaseDC(wdev->hwndimg, hdc);

    /* create palette and tools for bitmap */
    if ((wdev->lpalette = win_makepalette((gx_device_win *) dev))
	== (LPLOGPALETTE) NULL)
	return win_nomemory();
    wdev->hpalette = CreatePalette(wdev->lpalette);
    (void)SelectPalette(wdev->hdcbit, wdev->hpalette, NULL);
    RealizePalette(wdev->hdcbit);
    win_maketools(wdev, wdev->hdcbit);

    wdev->hdctext = wdev->hdcbit;	/* draw text here */

    return 0;
}
Exemplo n.º 6
0
void 
HariMain(void)
{
  char* buf;
  int win, x, y;

  init_mem();

  buf = (char*)malloc(144 * 164);
  win = win_open(buf, 144, 164, -1, "WIN-COLOR2");
  for (y = 0; y < 128; ++y) {
    for (x = 0; x < 128; ++x) 
      buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y);
  }
  win_refresh(win, 8, 28, 136, 156);
  getkey(1);

  api_end();
}
Exemplo n.º 7
0
void 
HariMain(void)
{
  char* buf;
  int win;
  int i;

  init_mem();

  buf = (char*)malloc(160 * 100);
  win = win_open(buf, 160, 100, -1, "Win-Lines");
  for (i = 0; i < 8; ++i) {
    win_line(win + 1, 8, 26, 77, i * 9 + 26, i);
    win_line(win + 1, 88, 26, i * 9 + 88, 89, i);
  }
  win_refresh(win, 6, 26, 154, 90);

  win_close(win);

  api_end();
}
Exemplo n.º 8
0
// -------------------------------------------------
// ODBCConnect()
//
BOOL ODBCConnect(CHAR *lpServerName,CHAR *lpUserName,CHAR *lpPassword)
{
	win_open(EHWP_SCREENCENTER,50,300,59,-1,3,ON,"Connessione a ...");
	dispfm(10,27,1,-1,STYLE_BOLD,"#Arial",25,lpServerName);
	
	// --------------------------------------------------------------------
	// Mi connetto al server
	//
	EhOdbc.sqlLastError=SQLConnect(EhOdbc.hConn,    // Handle della connessione
								   lpServerName,    // Nome del server
								   SQL_NTS, // Nome del file / Driver da usare
								   lpUserName,SQL_NTS, // UserName
								   lpPassword,SQL_NTS); // Password
	if (EhOdbc.sqlLastError!=SQL_SUCCESS&&EhOdbc.sqlLastError!=SQL_SUCCESS_WITH_INFO) 
		{if (!EhOdbc.fNoErrorView) ODBCError("Connect"); 
		 win_close();
	     return TRUE;
		}

	// --------------------------------------------------------------------
	// Alloca memoria per comandi (ritorna puntatore in hStmt)
	//
	// sqlReturn=SQLAllocStmt(EhOdbc.hConn, &EhOdbc.hStmt);
	//
	EhOdbc.sqlLastError=SQLAllocHandle(SQL_HANDLE_STMT, EhOdbc.hConn, &EhOdbc.hStmt);
	if (EhOdbc.sqlLastError!=SQL_SUCCESS) {ODBCError("SQLAllocHandle/Env");  PRG_end("Ambiente stantment:?");}

	SQLSetStmtAttr(EhOdbc.hStmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_READ_ONLY, 0);
	SQLSetStmtAttr(EhOdbc.hStmt, SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE , 0);
	SQLSetCursorName(EhOdbc.hStmt, "SQL_CURSOR", SQL_NTS);

	SQLTRY(SQL_HANDLE_STMT,"SET1",EhOdbc.hStmt,SQLSetStmtAttr(EhOdbc.hStmt, SQL_ATTR_ROW_BIND_TYPE, SQL_BIND_BY_COLUMN, 0));
	SQLTRY(SQL_HANDLE_STMT,"SET2",EhOdbc.hStmt,SQLSetStmtAttr(EhOdbc.hStmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) 1, 0));
	SQLTRY(SQL_HANDLE_STMT,"SET3",EhOdbc.hStmt,SQLSetStmtAttr(EhOdbc.hStmt, SQL_ATTR_ROW_STATUS_PTR, NULL, 0));
	SQLTRY(SQL_HANDLE_STMT,"SET4",EhOdbc.hStmt,SQLSetStmtAttr(EhOdbc.hStmt, SQL_ATTR_ROWS_FETCHED_PTR, NULL, 0));

	win_close();
	return FALSE;
}
Exemplo n.º 9
0
Arquivo: main.c Projeto: pzl/piwm
static int run_command(uint8_t command, char *data, uint32_t datalen, Client *client, ClientWindow *gfx) {
	int running=1;

	printf("Command from packet: %02X\n", command);
	switch (command) {
		case PIWM_CMD_OPEN:			running = win_open(client,gfx,data,datalen); break;
		case PIWM_CMD_DRAW:			running = draw(client,gfx,data,datalen); break;
		case PIWM_CMD_CLOSE:		running = 0; break;
		case PIWM_CMD_RESIZE:		running = win_resize(client,gfx,data,datalen); break;
		case PIWM_CMD_VGENABLE:		running = enable_openvg(client,gfx,data,datalen); break;
		case PIWM_CMD_VGDISABLE:	running = disable_openvg(client,gfx,data,datalen); break;
		case PIWM_CMD_RESERVED:
		case PIWM_CMD_VGCMD:
			printf("command not implemented\n");
			break;
		default:
			printf("invalid command byte: %02X\n", command);
			running=0;
			break;
	}

	return running;
}
Exemplo n.º 10
0
int
PicBuf_to_X11 ( const GEN_PAR * pg,  OUT_PAR * po)
/**
 ** Interface to higher-level routines,
 **   similar in structure to other previewers
 **/
{
  int row_c, x, y;
  int saved_col=0,saved_row=0;
  int xref = 0, yref = 0;
  const RowBuf *row;
  const PicBuf *pb;
  struct timeval tv;
  tv.tv_usec = 10;

  if (pg == NULL || po == NULL)
    return ERROR;
  pb = po->picbuf;
  if (pb == NULL)
    return ERROR;

  if (!pg->quiet)
    {
      Eprintf ("\nX11 preview follows.\n");
      Eprintf ("Press any key to end graphics mode\n");
    }

  if (win_open (pg, po->outfile, (int) (po->xoff * po->dpi_x / 25.4),
		(int) (po->yoff * po->dpi_y / 25.4), pb->nb << 3, pb->nr))
    return ERROR;
REDRAW:
  /* Backward since highest index is lowest line on screen! */
  for (row_c = row_start, y = MIN (height-row_start, pb->nr - 1);
       row_c < pb->nr; row_c++, y--)
    {
   row =NULL;
   if (row_c>=0) row = get_RowBuf (pb, row_c);
      /*if (row == NULL)
	return 0;*/
      for (x = col_start; x < pb->nc; x++)
	{
        if (row_c <0 || x < 0) setXcolor(GRAY);
         else
	  switch (index_from_RowBuf (row, x, pb))
	    {

	    case xxBackground:
	      continue;
/*	    case xxForeground:
	      setXcolor (WHITE);
	      break;*/
	    default:
	      setXcolor (index_from_RowBuf (row, x, pb));
	      break;
	    }
	  XDrawPoint (XDisplay, XWin, XGcWin, x - col_start, y + row_start);
	}
    }

/* Wait for KeyPress or mouse Button  - exit on keypress or button 3 */
  do
    {
      XNextEvent (XDisplay, &WaitEvent);
      if (WaitEvent.type == ButtonPress)
	{
	  if (WaitEvent.xbutton.button == Button1)
	    {
	      xref = WaitEvent.xbutton.x;
	      yref = WaitEvent.xbutton.y;
	    }
	  if (WaitEvent.xbutton.button == Button2)
	    {
	    if (!zoomed){
	      zoomed=1;
	       po->HP_to_xdots *=2;
	       po->HP_to_ydots *=2;
	       po->dpi_x *=2;
	       po->dpi_y *=2;
		saved_row=row_start;
		saved_col=col_start;
		  row_start = height-WaitEvent.xbutton.y+2*saved_row;
		  if (height < scr_height) row_start = height-WaitEvent.xbutton.y;
		  col_start =  WaitEvent.xbutton.x+col_start;
	    } else {
	      zoomed=0;
	      po->dpi_x = po->dpi_x/2;
	      po->dpi_y = po->dpi_y/2;
	       po->HP_to_xdots = po->HP_to_xdots/2;
	       po->HP_to_ydots = po->HP_to_ydots/2;
		row_start=saved_row;
		col_start=saved_col;

		}	
		free(po->picbuf);
		po->picbuf=NULL;    
	      TMP_to_BUF(pg, po);
	      pb=po->picbuf;
	    }
	  if (WaitEvent.xbutton.button == Button3) {win_close();return(0);}
	}
      else if (WaitEvent.type == ButtonRelease)
	{
	  if (WaitEvent.xbutton.button == Button1)
	    {
	      if (oversized)
		{
		  row_start += WaitEvent.xbutton.y - yref;
		  col_start += xref - WaitEvent.xbutton.x;
		}
	      XSetForeground (XDisplay, XGcWin,
			      WhitePixel (XDisplay, XScreen));
	      XFillRectangle (XDisplay, XWin, XGcWin, 0, 0, scr_width,
			      scr_height);
	      goto REDRAW;	/* yes, goto in C is ugly */
	    }
	  if (WaitEvent.xbutton.button == Button2){
	      XSetForeground (XDisplay, XGcWin,
			      WhitePixel (XDisplay, XScreen));
	      XFillRectangle (XDisplay, XWin, XGcWin, 0, 0, scr_width,
			      scr_height);
	      goto REDRAW;	/* yes, goto in C is ugly */
		} 	
	  break;
/*	  select (0, NULL, NULL, NULL, &tv);*/
	}
    }
  while (WaitEvent.type != KeyPress );

  win_close ();
  return 0;
}
Exemplo n.º 11
0
ao_instance_t * ao_windolby_open (void)
{
    return win_open (DCA_DOLBY);
}
Exemplo n.º 12
0
ao_instance_t * ao_win_open (void)
{
    return win_open (DCA_STEREO);
}
Exemplo n.º 13
0
// -------------------------------------------------
// ODBCFileOpen()
// Apre un file ODBC
// Ricerca in base all'estensione il driver da utilizzare
// 
BOOL ODBCFileOpen(CHAR *lpFileName)
{
	CHAR *lpBuf;
	SQLCHAR szConnStr[255];
    SWORD cbConnStr;
	SINT a,Hdl;
	CHAR **Driver;
	CHAR *lpExt;
	SINT nDriver=-1;
	
	win_open(EHWP_SCREENCENTER,50,300,59,-1,3,ON,"Connessione a ...");
	dispfm(10,27,1,-1,STYLE_BOLD,"#Arial",25,file_name(lpFileName));
	
	lpExt=rstrstr(lpFileName,"."); 
	if (lpExt==NULL) 
	{
		win_infoarg("Il file non contiene estensione [%s]",lpFileName);
		win_close(); return TRUE;
	}

	Hdl=ODBCDriverList("");
	Driver=memo_heap(Hdl);

	nDriver=-1;
	for (a=0;;a++)
	{
		if (Driver[a]==NULL) break;
		if (strstr(Driver[a],lpExt)) {nDriver=a; break;}
	}

	if (nDriver==-1)
	{
		memo_libera(Hdl,"?");
		win_infoarg("Driver sconosciuto per [%s]",lpExt);
		win_close();
	    return TRUE;
	}
/*
	sqlReturn=SQLConnect(EhOdbc.hConn,    // Handle della connessione
						 lpFileName,    // Handle della Windows
						 SQL_NTS, // Nome del file / Driver da usare
						 "",SQL_NTS, // UserName
						 "",SQL_NTS); // Password

	if (sqlReturn!=SQL_SUCCESS) 
		{ODBCError("Connect",sqlReturn); 
		 win_close();
	     return TRUE;
		}
iCheck=ODBCConnect("DBQ=C:\\Convert\\pa.xls;DRIVER={Microsoft Excel Driver (*.xls)}");
 */
	lpBuf=malloc(1024);
	sprintf(lpBuf,"DBQ=%s;DRIVER={%s}",lpFileName,Driver[nDriver]);
	EhOdbc.sqlLastError=SQLDriverConnect(EhOdbc.hConn,    // Handle della connessione
			                  NULL,    // Handle della Windows
							  lpBuf, // Nome del file / Driver da usare
							  (SQLSMALLINT) strlen(lpBuf), // Lunghezza
							  szConnStr, // Connection string di ritorno
							  (SQLSMALLINT) sizeof(szConnStr), 
							  &cbConnStr, 
							  SQL_DRIVER_NOPROMPT);
	free(lpBuf);

	if (EhOdbc.sqlLastError!=SQL_SUCCESS) 
		{
		 memo_libera(Hdl,"?");
		 if (!EhOdbc.fNoErrorView) ODBCError("ODBCFileOpen"); 
		 win_close();
	     return TRUE;
		}

	// --------------------------------------------------------------------
	// Alloca memoria per comandi (ritorna puntatore in hStmt)
	//
	//sqlReturn=SQLAllocStmt(EhOdbc.hConn, &EhOdbc.hStmt);
	EhOdbc.sqlLastError=SQLAllocHandle(SQL_HANDLE_STMT, EhOdbc.hConn, &EhOdbc.hStmt);
	if (EhOdbc.sqlLastError!=SQL_SUCCESS) {ODBCError("SQLAllocHandle/Env");  PRG_end("Ambiente stantment:?");}
	memo_libera(Hdl,"?");

	win_close();
	return FALSE;

/*
 iCheck=ODBCConnect("DBQ=C:\\Convert\\pa.xls;DRIVER={Microsoft Excel Driver (*.xls)}");
   // Alloca Ambiente ODBC
	SQLTRY("SQLAllocEnv", SQLAllocEnv(&EhOdbc->hEnv),EhOdbc);

    // Alloca Memoria per la connessione
	SQLTRY("SQLAllocConnect", SQLAllocConnect(EhOdbc->hEnv, &EhOdbc->hDBC),EhOdbc);

    // Carica il driver 
	SQLTRY("SQLDriverConnect", 
	        SQDriverConnect(EhOdbc->hDBC,    // Handle della connessione
			                 NULL,    // Handle della Windows
							 File, // Nome del file / Driver da usare
							 strlen(File), // Lunghezza
							 szConnStr, // Connection string di ritorno
							 sizeof(szConnStr), 
							 &cbConnStr, 
							 SQL_DRIVER_NOPROMPT),
							 EhOdbc);

	// Alloca memoria per i comandi (ritorna puntatore in hStmt)
	SQLTRY("SQLAllocStmt", SQLAllocStmt(EhOdbc->hDBC, &EhOdbc->hStmt),EhOdbc);
	return NULL;
}
*/
}