// calcola dimensioni rettangolo testo groupbox
VOID SizeGroupText(PCTL pgb) {
   HPS hps = WinGetPS(pgb->hwnd);
   POINTL aptl[3];
   PSZ psz;
   pgb->wrtxt.cx = 0;
   // calculate text rectangle size
   if ((pgb->fl & DT_MNEMONIC) &&
       NULL != (psz = strchr(pgb->psz, '~'))) {
      if (psz - pgb->psz) {  // se la tilde non Š primo char
         GpiQueryTextBox(hps, psz - pgb->psz, pgb->psz, 3, aptl);
         pgb->wrtxt.cx = aptl[2].x - aptl[0].x;
      } // end if              se tilde non Š ultimo char
      if (pgb->cbtxt - (psz - pgb->psz) - 1) {
         GpiQueryTextBox(hps, pgb->cbtxt - (psz - pgb->psz) - 1,
                         psz + 1, 3, aptl);
         pgb->wrtxt.cx += aptl[2].x - aptl[0].x + 2;
      } /* endif */
      //pgb->wrtxt.cy = aptl[0].y - aptl[1].y;
   } else {
      GpiQueryTextBox(hps, pgb->cbtxt, pgb->psz, 3, aptl);
      //pgb->wrtxt.cy = aptl[0].y - aptl[1].y;
      pgb->wrtxt.cx = aptl[2].x - aptl[0].x + 2;
   } /* endif */
   WinReleasePS(hps);
} /* endif */
MRESULT InitMainWindow(HWND hwnd,      /* handle to the main client window */
                       MPARAM mp1,     /* first parameter of WM_CREATE message */
                       MPARAM mp2)     /* second parameter of WM_CREATE message */
{
   FONTMETRICS fm;
   HPS         hps;

   hps = WinGetPS (hwnd) ;
   GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;

   cxChar = fm.lAveCharWidth ;
   cxCaps = fm.lEmInc ;
   cyChar = fm.lMaxBaselineExt ;
   cyDesc = fm.lMaxDescender ;

   WinReleasePS (hps) ;

   cxTextTotal = MESSAGE_LEN * cxChar ;

   hwndHscroll = WinWindowFromID (
                       WinQueryWindow (hwnd, QW_PARENT),
                       FID_HORZSCROLL) ;

   hwndVscroll = WinWindowFromID (
                       WinQueryWindow (hwnd, QW_PARENT),
                       FID_VERTSCROLL) ;

   return (MRFROMLONG(0));
}
/*@ XBitmap::Load(const char* filename, XBitmapFilter * params, BOOL releaseParams)
@group loading a bitmap
@remarks Load a bitmap from a file. <P><I>If this method is used, GBM.DLL and OLLGLIB.DLL must be in the LIBPATH.</I> <P>Due a bug (?) in OS/2-GPI you should specify params->cBitCount = BFP_BPP_TRUECOLOR if you want to modify or resave the bitmap.
@parameters    <t 'ø' c=2>
               øchar * fileName           øfilename of the file to load
               øXBitmapFilter * params    øfiletype specific filter informations. An initialized structure has to be created by XBitmap :: GetImportFilterStruct () or XGLibFileDialog. (default is NULL)
               øBOOL releaseParams        øfilter informations will be released after usages
               <\t>
@exceptions   If the method fails to create a new bitmap an exception of the type XException is thrown.
*/
void XBitmap :: Load (const char* filename, XBitmapFilter* params, BOOL releaseParams)
{
   if (hbm) GpiDeleteBitmap(hbm); hbm = NULLHANDLE;

   XResourceLibrary* lib = new XResourceLibrary ("OOLGLIB");
   XGLibProcIO* func = (XGLibProcIO*) lib->LoadFunction ("OOL_GLIB_IMP");
   DosSleep(100);

   if (NULL != func) {
      if (owner) hps = WinGetPS (owner->GetHandle());

      ULONG rc;
      if (NULL == params) params = GetImportFilterStruct (filename);
      params->hps = hps;
      params->hbm = hbm;
      params->hab = XApplication :: GetApplication ()->GetAnchorBlock ();
      if (BFE_OK != (rc = func (filename, __XBMFProfile__, params, 0))) {
         if (releaseParams) ReleaseFilterStruct (params);
         OOLThrow (GetLastErrorMessage (lib, &rc, params), rc);
      }
      hbm = params->hbm;
      if (releaseParams) ReleaseFilterStruct (params);
      lib->UnLoadFunction ((PFNWP) func);
   } else {
      if (releaseParams) ReleaseFilterStruct (params);
      ULONG error = WinGetLastError (XApplication :: GetApplication ()->GetAnchorBlock ());
      OOLThrow("Could not load function \"OOL_GLIB_IMP\" from library \"OOLGLIB.DLL\".", error);
   }

   delete lib;
   XSize s;
   GetDimensions(&s);
   width = cx = s.GetWidth();
   height = cy = s.GetHeight();
}
示例#4
0
MRESULT clbPPchange(PCLBOX pclb, ULONG fl) {
   HPS hps;
   if (pclb && NULLHANDLE != (hps = WinGetPS(pclb->hwnd))) {
      switch (fl) {
         case PP_FOREGROUNDCOLOR:
         case PP_FOREGROUNDCOLORINDEX:
            pclb->lfgnd = WgetCtlClr(pclb->hwnd, hps, PP_FOREGROUNDCOLOR,
                         PP_FOREGROUNDCOLORINDEX, SYSCLR_WINDOWSTATICTEXT);
            break;
         case PP_BACKGROUNDCOLOR:
         case PP_BACKGROUNDCOLORINDEX:
            pclb->lbkgnd = WgetCtlClr(pclb->hwnd, hps, PP_BACKGROUNDCOLOR,
                         PP_BACKGROUNDCOLORINDEX, SYSCLR_DIALOGBACKGROUND);
            break;
         case PP_FONTNAMESIZE:
            if ((pclb->cyFont = stSizeFont(hps)) % 2) ++pclb->cyFont;
            clbSize(pclb);
            clbMove(pclb);
            break;
      } /* endswitch */
      WinReleasePS(pclb->hwnd);
      WinRefreshWin(pclb->hwnd);
   }
   return (MRESULT)FALSE;
}
/*--------------------------------------------------
 * Sets a new font to be used by the window
 *--------------------------------------------------*/
PMWindow& PMWindow::set_font( const char* font )
{
  static int   have_warpsans = -1;
  const  char* used_font = font;

  if( strcmp( font, "9.WarpSans" ) == 0 )
  {
    if( have_warpsans == -1 )
    {
      LONG rc;
      LONG fonts = 0;
      HPS  hps;

      hps = WinGetPS( HWND_DESKTOP );
      rc  = GpiQueryFonts( hps, QF_PUBLIC, "WarpSans", &fonts, 0, NULL );
      WinReleasePS( hps );

      have_warpsans = ( rc > 0 && rc != GPI_ALTERROR );
    }

    if( !have_warpsans ) {
      used_font = "8.Helv";
    }
  }

  if( !WinSetPresParam( win_handle, PP_FONTNAMESIZE, strlen(used_font)+1, (PVOID)used_font ))
    PM_THROW_GUIERROR();

  return *this;
}
void ValueSample::init()
{
 COLOR color[] = { CLR_RED, CLR_GREEN, CLR_BLUE, CLR_YELLOW };

 logo.showLogo(1500);

 createDlg();
 if (!hwnd)
   OThrowPM("Dialog creation failed.", 0, OException::unrecoverable);

 VSet.inherit(hwnd);
 VSet.setItemAttr(1, 0, VIA_ICON);
 VSet.setItemAttr(2, 0, VIA_BITMAP);
 VSet.setItemAttr(3, 0, VIA_COLORINDEX);

 if ((VSet.selected.icon = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, VALUE_ICON)) == NULLHANDLE)
   OThrowPM("Loading icon failed.", 0, OException::unrecoverable);
 
 if (!VSet.setItem(1, 0, (ULONG)VSet.selected.icon))
   OThrowPM("Could not set icons.", 0, OException::unrecoverable);

 if ((VSet.selected.bitmap = GpiLoadBitmap(WinGetPS(hwnd), NULLHANDLE, VALUE_BMP, 0, 0)) == NULLHANDLE)
   OThrowPM("Loading bitmap failed.", 0, OException::unrecoverable);

 if (!VSet.setItem(2, 0, (ULONG)VSet.selected.bitmap))
   OThrowPM("Could not set bitmaps.", 0, OException::unrecoverable);

 for (ULONG count = 1; count <= 4; count++)
   if (!VSet.setItem(3, count, color[count-1]))
     OThrowPM("Could not set color.", 0, OException::unrecoverable);
 
 centerDlg();
 showDlg();
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static HBITMAP hbm ;
     HPS            hps ;
     RECTL          rcl ;

     switch (msg)
          {
          case WM_CREATE:
               hps = WinGetPS (hwnd) ;
               hbm = GpiLoadBitmap (hps, 0, IDB_HELLO, 0L, 0L) ;
               WinReleasePS (hps) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               WinQueryWindowRect (hwnd, &rcl) ;

               if (hbm)
                    WinDrawBitmap (hps, hbm, NULL, (PPOINTL) &rcl,
                                   CLR_BACKGROUND, CLR_NEUTRAL, DBM_STRETCH) ;

               WinEndPaint (hps) ;
               return 0 ;

          case WM_DESTROY:
               if (hbm)
                    GpiDeleteBitmap (hbm) ;               
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
示例#8
0
void  FontSelectDialog( HWND hwndWnd )
{
   /*
    * Bring up the font selection dialog; display only FIXED-pitch fonts!
    * Save the client window handle in the ulUser field.
    */

   fdFontDlg.hpsScreen = WinGetPS( hwndWnd );
   fdFontDlg.cbSize = sizeof( FONTDLG );
   fdFontDlg.pszFamilyname = achFamily;
   fdFontDlg.usFamilyBufLen = sizeof( achFamily );
   fdFontDlg.clrFore = CLR_BLACK;
   fdFontDlg.pszPreview = "AaBb";
   fdFontDlg.fl = FNTS_CENTER | FNTS_FIXEDWIDTHONLY | FNTS_INITFROMFATTRS |
                  FNTS_HELPBUTTON | FNTS_RESETBUTTON | FNTS_APPLYBUTTON;
   fdFontDlg.pfnDlgProc = FontDlgProc;
   fdFontDlg.ulUser = (ULONG)hwndWnd;
   WinFontDlg( HWND_DESKTOP, hwndWnd, (PFONTDLG)&fdFontDlg );
   WinReleasePS( fdFontDlg.hpsScreen );

   /*
    * If a font was successfully selected, copy its attributes into achFont and
    * use that to set the default PM font parameter for the client window.
    */

   if ( fdFontDlg.lReturn == DID_OK )
   {
      sprintf( achFont, "%d.%s", FIXEDINT( fdFontDlg.fxPointSize ), fdFontDlg.fAttrs.szFacename );
      WinSetPresParam( hwndWnd, PP_FONTNAMESIZE, strlen( achFont ) + 1, achFont );
      GetFontMetrics( hwndWnd, FALSE );
      UpdateScreenLimits( hwndWnd, TRUE );
   }
}
示例#9
0
/*
	SaverWindowProc
	This is the window procedure of the screen-size window that is
	created when the saver starts.
	There should be no reason to alter the code.
	Note that we do not process WM_PAINT messages. They are forwarded to
	the default window procedure, which just validates the window area
	and does no drawing. All drawing to the window should be done in
	the drawing-thread. Therefore, if you want to blank the screen before
	drawing on it for instance, issue a WinFillRect call at the beginning
	of your drawing-thread.
*/
MRESULT EXPENTRY SaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
	switch(msg){
	case WM_CREATE:
		// reset the "stop" flag
		stop_draw_thread = FALSE;
		// store window handle
		hwndSaver = hwnd;
		// get presentation space
		hps = WinGetPS(hwnd);
		// start the drawing-thread
		tidDraw = _beginthread(draw_thread, NULL, STACKSIZE, NULL);
		// create thread to control priority of drawing thread
		if(low_priority){
			stop_priority_thread = FALSE;
			DosCreateThread(&tidPriority, (PFNTHREAD)priority_thread, 0, 2L, 1000);
		}
		return (MRESULT)FALSE;
	case WM_DESTROY:
		// release the presentation space
		WinReleasePS(hps);
		break;
	case WM_PAINT:
		// just validate the update area. all drawing is done
		// in the drawing-thread.
		return WinDefWindowProc(hwnd, msg, mp1, mp2);
	}
	return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
示例#10
0
 static USHORT setControlPos(HWND hwnd, USHORT x, USHORT y, USHORT ySize)
 {
    char   buffer[0x0100];
    POINTL aptl[TXTBOX_COUNT];
    HPS    hps;

    ULONG  flag        = SWP_SIZE;

    WinQueryWindowText(hwnd,0xFF,buffer);
    *(buffer+0xFF) = 0;

    hps = WinGetPS(hwnd);

    GpiQueryTextBox(      hps,
                          strlen(buffer),
                          (char *) buffer,
                          TXTBOX_COUNT,
                          aptl);
    WinReleasePS(hps);

    if(x != 0xFFFF && y != 0xFFFF)
       flag |= SWP_MOVE|SWP_SHOW;

    WinSetWindowPos(hwnd, 0, x, y, aptl[TXTBOX_TOPRIGHT].x, ySize, flag);

    return x+aptl[TXTBOX_TOPRIGHT].x;

 }
void DrawBox( HWND hwnd )
{
  HPS hps;
  POINTL pointl;

  // Get a cached PS for the window

  hps = WinGetPS( hwnd );

  pointl.x = pointl.y = 0;

  // Set the current position to (0,0)

  GpiSetCurrentPosition( hps, &pointl );

  pointl.x = pointl.y = 10;

  // Draw a 10 by 10 box from the current position in the
  // current color.

  GpiBox( hps, DRO_OUTLINE, &pointl,0,0 );

  // Free the cached PS

  WinReleasePS( hps );

 }
示例#12
0
MRESULT clbSCchange(PCLBOX pclb) {
   HPS hps;
   if (pclb && NULLHANDLE != (hps = WinGetPS(pclb->hwnd))) {
      clbUpdColors(pclb, hps);
      WinReleasePS(hps);
      WinRefreshWin(pclb->hwnd);
   } /* endif */
   return (MRESULT)FALSE;
}
示例#13
0
QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h)
{
    QPixmap pm;

    if (w == 0 || h == 0)
        return pm;

    RECTL rcl;
    if (!WinQueryWindowRect(winId, &rcl))
        return pm;

    if (w < 0)
        w = rcl.xRight;
    if (h < 0)
        h = rcl.yTop;

    // flip y coordinate
    y = rcl.yTop - (y + h);

    HPS hps = qt_alloc_mem_ps(w, h);
    if (hps == NULLHANDLE)
        return pm;

    HBITMAP hbm = NULLHANDLE;

    // bitmap header + 2 palette entries (for the mask)
    BITMAPINFOHEADER2 bmh;
    bmh.cbFix = sizeof(BITMAPINFOHEADER2);

    // create the uninitialized bitmap to hold window pixels
    bmh.cx = w;
    bmh.cy = h;
    bmh.cPlanes = 1;
    bmh.cBitCount = 32;
    hbm = GpiCreateBitmap(hps, &bmh, 0, 0, 0);

    if (hbm != NULLHANDLE) {
        GpiSetBitmap(hps, hbm);
        HPS hpsWin = WinGetPS(winId);
        if (hpsWin != NULLHANDLE) {
            POINTL pnts[] = { {0, 0}, {w, h}, {x, y} };
            if (GpiBitBlt(hps, hpsWin, 3, pnts,
                          ROP_SRCCOPY, BBO_IGNORE) != GPI_ERROR) {
                GpiSetBitmap(hps, NULLHANDLE);
                pm = fromPmHBITMAP(hbm);
            }
            WinReleasePS(hpsWin);
        }
        GpiDeleteBitmap(hbm);
    }

    qt_free_mem_ps(hps);

    return pm;
}
/****************************************************************\
 * Routine to start semaphore example                           *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:     StartSemExample(VOID)                             *
 *                                                              *
 *  Purpose:  Calls routines to create semaphores and draw      *
 *            resources.  Creates consumer threads.             *
 *                                                              *
 *  Usage:    Called in file usercmd.c when the user selects    *
 *            start from the semaphore menu.                    *
 *                                                              *
 *  Method:   Uses routines in paint.c to draw consumers and    *
 *            resources.  This is done by creating a paint      *
 *            message, not calling the draw routines directly.  *
 *                                                              *
 *  Returns:  TRUE if start succeeds, FALSE if start fails      *
 *                                                              *
\****************************************************************/
INT   StartSemExample(VOID)
{
    TID         tid=0;
    ULONG       rc;
    INT         i;
    FONTMETRICS fntmet;
    HPS         hps;
    SWP         swp;

    InitSemaphExample();

    rc = CreateAllSems();

    if (rc)
        return FALSE;
    /****************************************************************\
     * Create consumer threads. Note that values can be passed to   *
     * threads in OS/2 2.0. We pass the ordinal number of the child *
     * to each child.                                               *
    \****************************************************************/

    for (usConsumerThreadsCreated = 0;
     usConsumerThreadsCreated < cNumUsers; usConsumerThreadsCreated++)
    {
        rc = DosCreateThread((PTID) &tid, (PFNTHREAD)ThreadConsumer,
             (ULONG) usConsumerThreadsCreated, (ULONG)1,(ULONG) STACKSIZE);
        if (rc)
        {
            SemError("DosCreateThread",rc);
            return FALSE;
        }
        else
        {
            thrConsumers[usConsumerThreadsCreated].tid = tid;
            thrConsumers[usConsumerThreadsCreated].lHits = 0L;
        }
    }
    for (i = 0; i < (INT) cNumUsers; i++)
    {
        DosResumeThread (thrConsumers[i].tid);
    }
    hps = WinGetPS (hwndMain);
    if (hps)
    {
        GpiQueryFontMetrics (hps, (LONG) sizeof fntmet, &fntmet);
        WinQueryWindowPos (hwndMain, &swp);
        SetRectPositions((SHORT)swp.cx, (SHORT)swp.cy,
                         (SHORT) fntmet.lMaxBaselineExt,
                         (SHORT) fntmet.lMaxDescender);
        DrawRects (hps);
        WinReleasePS (hps);
    }
    return TRUE;
}
示例#15
0
/*DOC
CLASS    XPalette
FUNCTION XPalette
GROUP    x-games/constructors/destructor
REMARKS  Default constructor for a palette object. Queries the WPS colors (0-9, 246-255) and stores
         them.
*/
XPalette::XPalette()
{
        int     i;

        // get HPS and HDC of the root window
        hpsDesktop = WinGetPS( HWND_DESKTOP );
        hdcDesktop = GpiQueryDevice( hpsDesktop );

        // get WPS colors
        GpiQueryRealColors( hpsDesktop, 0, 0, 256, (PLONG)aulWPSPalette );
        memcpy( &aulData[0], &aulWPSPalette[0], 256 * sizeof( ULONG ) );
} // XPalette::XPalette
示例#16
0
void EXPENTRY wmPaint(HWND hwnd)
{
    video_canvas_t c=(video_canvas_t)WinQueryWindowPtr(hwnd,QWL_USER); // Ptr to usr resources
    HPS    hps=WinGetPS(hwnd);                   // Handle to Presentation Space

    // next time call cavas_refresh, refresh the whole canvas
    if  (c->init_ready) c->exposure_handler(c->width, c->height);
    else c->init_ready=TRUE;  // First call=canvas initialize ended

    WinBeginPaint(hwnd, hps, NULL); // Set Region in hps to blit;
    WinEndPaint  (hps); // must be done every time WM_PAINT was sent
}
示例#17
0
void CairoDrawThread(void *pParam)
{
  HWND hwndClientWindow = (HWND) pParam;
  HPS hpsClientWindow;
  SWP swpTemp;

  // Query HPS of HWND
  hpsClientWindow = WinGetPS(hwndClientWindow);
  WinQueryWindowPos(hwndClientWindow, &swpTemp);

  // Set FPU state which might have been changed by some Win* calls!
  // (Workaround for a PM bug)
  DisableFPUException();

  // Initialize cairo support
  cairo_os2_init();

  // Create cairo surface
  pCairoSurface = cairo_os2_surface_create(hpsClientWindow,
                                           swpTemp.cx,
                                           swpTemp.cy);

  // Tell the surface the HWND too, so if the application decides
  // that it wants to draw itself, then it will be able to turn
  // on blit_as_changes.
  cairo_os2_surface_set_hwnd(pCairoSurface, hwndClientWindow);

  // Make sure that the changes will be shown only
  // when we tell so
  cairo_os2_surface_set_manual_window_refresh(pCairoSurface,
                                              TRUE);


  // Create Cairo drawing handle for the surface
  pCairoHandle = cairo_create(pCairoSurface);

  // Do the main drawing loop as long as needed!
  bShutdownDrawing = 0;
  CairoDrawLoop(hwndClientWindow,
                swpTemp.cx, swpTemp.cy,
                pCairoSurface,
                pCairoHandle);

  // Clean up!
  cairo_destroy(pCairoHandle);
  cairo_surface_destroy(pCairoSurface);

  cairo_os2_fini();

  WinReleasePS(hpsClientWindow);

  _endthread();
}
示例#18
0
/*
	SaverWindowProc
	This is the window procedure of the screen-size window that is
	created when the saver starts.
	There should be no reason to alter the code.
	Note that we do not process WM_PAINT messages. They are forwarded to
	the default window procedure, which just validates the window area
	and does no drawing. All drawing to the window should be done in
	the drawing-thread. Therefore, if you want to blank the screen before
	drawing on it for instance, issue a WinFillRect call at the beginning
	of your drawing-thread.
*/
MRESULT EXPENTRY SaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
	switch(msg){
	case WM_CREATE:
		/* reset the "stop" flag */
		stop_draw_thread = FALSE;
		/* store window handle */
		hwndSaver = hwnd;
		/* get presentation space */
		hps = WinGetPS(hwnd);
		/* start the drawing-thread */
/*
		$$$$$ note $$$$$
		Some compilers use another parameter ordering for
		_beginthread. The _beginthread call below works with EMX,
		ICC and BCC. Check your compiler docs for other compilers.
*/
#if defined(__BORLANDC__)
		/* for Borland C++ */
		tidDraw = _beginthread(draw_thread, STACKSIZE, NULL);
#elif defined(__EMX__) || defined(__IBMC__)
		/* for EMX and ICC */
		tidDraw = _beginthread(draw_thread, NULL, STACKSIZE, NULL);
#endif
		/* create thread to control priority of drawing thread */
		if(low_priority){
			stop_priority_thread = FALSE;
			DosCreateThread(&tidPriority, (PFNTHREAD)priority_thread, 0, 2L, 1000);
		}
		/* create timer that moves the saver window to top regularly */
		WinStartTimer(hab, hwndSaver, IDT_ZORDERTIMER, ZORDERTIMERSTEP);
		return (MRESULT)FALSE;
	case WM_TIMER:
		if(SHORT1FROMMP(mp1) == IDT_ZORDERTIMER){
			/* move saver window to top */
			WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
			return (MRESULT)0;
		}
		break;
	case WM_DESTROY:
		/* release the presentation space */
		WinReleasePS(hps);
		/* stop the z-order timer */
		WinStopTimer(hab, hwndSaver, IDT_ZORDERTIMER);
		break;
	case WM_PAINT:
		/* just validate the update area. all drawing is done */
		/* in the drawing-thread.                             */
		return WinDefWindowProc(hwnd, msg, mp1, mp2);
	}
	return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
示例#19
0
void MyRenderWin::calcWinSize(MiniWin* win)
{
	char sampleString[64];

  switch (timeFmt)
    {
    case 0:   // 12 hour
      strcpy(sampleString, "77:77aI");
      break;
    case 1:   // 24 hour
      strcpy(sampleString, "77:77I");
      break;
    default:
      strcpy(sampleString, "?time?");
      break;
    }

	const ULONG sampleLen = strlen(sampleString);

	HPS hps = WinGetPS(win->client());

	POINTL aptl[TXTBOX_COUNT];

	BOOL success = GpiQueryTextBox(hps,
																 sampleLen,
																 (PSZ)sampleString,
																 TXTBOX_COUNT,
																 aptl);

	ULONG x;
	ULONG y;

	if (success == TRUE)
		{
			ULONG hgt1 = Max(aptl[TXTBOX_TOPRIGHT].y, aptl[TXTBOX_TOPLEFT].y);
			ULONG hgt2 = Min(aptl[TXTBOX_BOTTOMRIGHT].y, aptl[TXTBOX_BOTTOMLEFT].y);
			ULONG wid1 = Max(aptl[TXTBOX_TOPRIGHT].x, aptl[TXTBOX_BOTTOMRIGHT].x);
			ULONG wid2 = Min(aptl[TXTBOX_TOPLEFT].x, aptl[TXTBOX_BOTTOMLEFT].x);

			x = wid1 - wid2;
			y = hgt1 - hgt2;
		}
	else
		{
			x = strlen(sampleString) * 12;
      y = 20;
    }

  WinReleasePS(hps);

  win->size(x + 6, y + 6);   // 2 border & 1 blank on each edge
}
示例#20
0
/*
 * _ClearWindow - erase a window
 */
void _ClearWindow( LPWDATA w )
{
    HWND        hwnd;

    hwnd = w->hwnd;

    /*** Clear the w->image array ***/
#ifdef _MBCS
    {
        mb_char         mbc;
        int             count;

        mbc = _mbsnextc( (unsigned char *)" " );
        for( count=0; count < w->width * w->height; count++ ) {
            w->image[count] = mbc;              /* store space in w->image */
        }
    }
#else
    FARmemset( w->image, 0x20, w->width*w->height );
#endif

#if defined( __OS2__ )
    {
        HPS     ps;
        RECTL   rcl;

        ps = WinGetPS( hwnd );
        WinQueryWindowRect( hwnd, &rcl );
        WinFillRect( ps, &rcl, CLR_WHITE );
        WinReleasePS( ps );
    }
#else
    {
        RECT    rect;
        HDC     dc;

        dc = GetDC( hwnd );
    #ifndef __NT__
        UnrealizeObject( w->brush );
    #endif
        SelectObject( dc, w->brush );
    #ifdef __NT__
        SetBrushOrgEx( dc, 0, 0, NULL  );
    #endif
        GetClientRect( hwnd, &rect );
        FillRect( dc, &rect, w->brush );
        ReleaseDC( hwnd, dc );
    }
#endif

} /* _ClearWindow */
示例#21
0
TkRegion
TkCreateRegion()
{
    HRGN region;
    HPS hps;

    hps= WinGetPS(HWND_DESKTOP);
    region = GpiCreateRegion(hps, 0, NULL);
    WinReleasePS(hps);
#ifdef DEBUG
printf("TkCreateRegion region %x, hps %x\n", region, hps);
#endif
    return (TkRegion) region;
}
/*@ XToolBar::Draw(void)
@group display
@remarks Redraw the toolbar.
*/
void XToolBar::Draw(void)
{
   RECTL rect;
   WinQueryWindowRect(winhandle, &rect);
   HPS hps = WinGetPS(winhandle);
   GpiCreateLogColorTable(hps, LCOL_RESET, LCOLF_RGB, 0,0,NULL);
   WinFillRect( hps, &rect, SYSCLR_BUTTONMIDDLE);
   WinDrawBorder(hps, &rect, 1,1,0,0,DB_PATCOPY|DB_RAISED);
   HENUM e;
   HWND hwnd;

   e = WinBeginEnumWindows(winhandle);
   while ((hwnd = WinGetNextWindow(e)) != 0)
      WinInvalidateRegion(hwnd, NULLHANDLE, TRUE);
   WinEndEnumWindows(e);
}
void OListBox::auto_scroll()
{
 FONTMETRICS FontMetrics;

 WinQueryWindowRect(hwnd, &rcl);
 hps = WinGetPS(hwnd);
 GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &FontMetrics);
 WinReleasePS(hps);
 if (queryItemCount() > ((rcl.yTop - rcl.yBottom) / FontMetrics.lMaxBaselineExt))
  {
   if ((rcl.yTop - rcl.yBottom) % FontMetrics.lMaxBaselineExt)
     setToTop(queryTopItem()+2); 
   else
     setToTop(queryTopItem()+1); 
  }
}
示例#24
0
void PrintString(char szMessage[],ULONG ulLine)
{
    HPS    hps;
    RECTL  rcl;
    POINTL ptl;

    ptl.y = (ulWindowHeight - (ulLine * (stCell.cy + 3)));
    ptl.x = stCell.cx;
    rcl.yBottom = (ptl.y - 3);
    rcl.yTop = (ptl.y + stCell.cy);
    rcl.xLeft = 0;
    rcl.xRight = ulWindowWidth;
    hps = WinGetPS(hwndClient);
    WinFillRect(hps,&rcl,CLR_WHITE);
    GpiCharStringAt(hps,&ptl,strlen(szMessage),szMessage);
    WinReleasePS(hps);
}
示例#25
0
HPS gfxOS2Surface::GetPS()
{
    // Creating an HPS on-the-fly should never be needed because GetPS()
    // is only called for printing surfaces & mPS should only be null for
    // window surfaces.  It would be a bug if Cairo had an HPS but Thebes
    // didn't, but we'll check anyway to avoid leakage.  As a last resort,
    // if this is a window surface we'll create one & hang on to it.
    if (!mPS) {
        cairo_os2_surface_get_hps(CairoSurface(), &mPS);
        if (!mPS && mWnd) {
            mPS = WinGetPS(mWnd);
            cairo_os2_surface_set_hps(CairoSurface(), mPS);
        }
    }

    return mPS;
}
static void internal_GetStaticTextSize(HWND hwnd, ULONG ulID, int *piCX, int *piCY) {
	HPS hps;
	char achTemp[512];
	POINTL aptl[TXTBOX_COUNT];

	// This calculates how much space is needed for a given static text control
	// to hold its text.
	WinQueryDlgItemText(hwnd, ulID, sizeof(achTemp), achTemp);

	hps = WinGetPS(WinWindowFromID(hwnd, ulID));
	GpiQueryTextBox(hps, strlen(achTemp), achTemp, TXTBOX_COUNT, aptl);

	*piCX = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x;
	*piCY = aptl[TXTBOX_TOPRIGHT].y - aptl[TXTBOX_BOTTOMLEFT].y;

	WinReleasePS(hps);
}
示例#27
0
/*------------------------------------------------------------------------*/
MRESULT EXPENTRY SplashWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
   static HBITMAP hbm;
   static SWP     swp;
   HPS    hps;
   RECTL  rcl;

   switch(msg)
   {
      case WM_CREATE:
         hps = WinGetPS (hwnd);
         hbm = GpiLoadBitmap(hps,
                             (HMODULE)0L,
                             IDB_LOGO,
                             (ULONG)0,
                             (ULONG)0);
         WinReleasePS (hps);

         WinQueryWindowPos(hwnd, (PSWP)&swp);
         return (MRESULT)0;

      case WM_PAINT:
         hps = WinBeginPaint (hwnd, 
                              NULLHANDLE,  /* Get a cached PS */
                              (RECTL *)0);
         GpiErase (hps);
         
         GpiCreateLogColorTable (hps, LCOL_RESET, LCOLF_RGB,
                                 0L, 0L, NULL) ;
         rcl.xLeft   = 0;
         rcl.yBottom = 0;
         rcl.xRight  = swp.cx;
         rcl.yTop    = swp.cy;

         if ( hbm )
            WinDrawBitmap(hps,hbm, NULL, (PPOINTL) &rcl,
                          CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH );

         WinDrawBorder(hps, &rcl,2L,2L,0L, 0L, DB_DEPRESSED);
         WinEndPaint(hps);
         return (MRESULT)0;


   }
   return( WinDefWindowProc(hwnd, msg, mp1, mp2) );
}
示例#28
0
void ErrorNotify(char szMessage[])
{
    HPS    hps;
    RECTL  rcl;
    POINTL ptl;

    ptl.y = 2;
    ptl.x = stCell.cx;
    rcl.yBottom = 0;
    rcl.yTop = stCell.cy;
    rcl.xLeft = 0;
    rcl.xRight = ulWindowWidth;
    hps = WinGetPS(hwndClient);
    WinFillRect(hps,&rcl,CLR_WHITE);
    GpiCharStringAt(hps,&ptl,strlen(szMessage),szMessage);
    WinReleasePS(hps);
}
// -------------------------------------------------------------------------
HWND CreateToolbar(HWND hwndParent, HMODULE hmod, ULONG menuid)
{
  UCMINFO UCMInfo;
  ULONG   ulMCx, ulMCy, flgs = 0;
  HWND    hwndClient, hwndMenu, hTmp;

  WinRegisterClass( (HAB)0, "TOOLBAR", ClientWndProc, CS_SIZEREDRAW, 0);

  hwndClient = WinCreateWindow( hwndParent, "TOOLBAR", "", flgs, 8, 8, 0, 0,
                                hwndParent, HWND_TOP, menuid, NULL, NULL );

  memset(&UCMInfo, 0, sizeof(UCMINFO));
  UCMInfo.cb = sizeof(UCMINFO);

  UCMInfo.NbOfCols = 1;
  UCMInfo.NbOfRows = 7;
  UCMInfo.Style    = UCS_FRAMED    |          // Draw a 3D frame around the items
                     UCS_FORCESIZE |       // Force the size of the items
                     UCS_CHNGBMPBG |       // Use one of the bitmap colors as a background color
                     UCS_NO_DM     |       // No drag&drop manip
                     UCS_NO_CM;            // No context menu

  HPS hps = WinGetPS( hwndClient );
  // --  Set the color of the bitmaps which has to be replaced by the items background color
   UCMInfo.BgBmp     = GpiQueryRGBColor( hps, 0, CLR_PALEGRAY );
   UCMInfo.BgColor   = GpiQueryRGBColor( hps, 0, CLR_DARKGRAY );
  // -- Set the color of the items background
  UCMInfo.ItemBgColor = 0x00b0b0b0;
  WinReleasePS( hps );

  UCMInfo.cx = 24;   // Width of the items   ( used because UCS_FORCESIZE is set )
  UCMInfo.cy = 24;   // Height of the items
  UCMInfo.hModule = hmod;

  hwndMenu = UCMenuCreateFromResource( (HAB)0, hwndClient, hwndClient,
                                       CMS_MATRIX, 0, 0, 0, 0, HWND_TOP,
                                       FID_MENU, hmod, ID_TOOLS, &UCMInfo, &hTmp );

//  hide_scrollbars( hwndMenu );
  WinSendMsg( hwndMenu, UCMENU_QUERYSIZE, MPFROMP( &ulMCx ), MPFROMP( &ulMCy ) );
  WinSetWindowPos( hwndMenu, HWND_TOP, 0, 0, ulMCx, ulMCy, SWP_SIZE );
  WinSetWindowPos( hwndClient, HWND_TOP, 0, 0, ulMCx, ulMCy+8, SWP_SIZE );

  return hwndClient;
}
/*@ XBitmap::LoadBMP(const char* filename)
@group loading a bitmap
@remarks Load a bitmap from a file. This method works faster than Load() but can only load bitmpas in OS2-BMP format
@parameters   char * fileName   filename of the file to load
@exceptions   If the method fails to create a new bitmap an exception of the type XException is thrown.
*/
void XBitmap :: LoadBMP(const char* filename)
{
   if (hbm)
      GpiDeleteBitmap(hbm);
   hbm = 0;

   XFile file;
   PBITMAPFILEHEADER p;
   if (file.Open(filename, XFILE_FAIL_IF_NEW | XFILE_OPEN_EXISTING, XFILE_READONLY, XFILE_SHARE_DENYNONE ) == 0)
   {
      XFileInfo info;
      file.GetFileInfo(&info);
      file.Seek(0, XFILE_BEGIN);
      p = (PBITMAPFILEHEADER) malloc(info.GetFileSize());
      file.Read(p, info.GetFileSize());
      file.Close();
   }
   else
      OOLThrow( "couldnït open file!", -1);

   if (owner )
   {
      hps = WinGetPS(owner->GetHandle());
      hbm = GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) &p->bmp, CBM_INIT, (PBYTE) p + p->offBits, (PBITMAPINFO2) &p->bmp);
      if(hbm == 0)
         OOLThrow("error creating bitmap", 3);
   }
   else
      SetData((BITMAPINFOHEADER2 *) &p->bmp, p->offBits);
   free(p);
   XSize s;
   GetDimensions(&s);
   width = cx = s.GetWidth();
   height = cy = s.GetHeight();

   if (hbm == GPI_ERROR)
   {
      ULONG error = WinGetLastError(XApplication::GetApplication()->GetAnchorBlock());
      OOLThrow("couldnït load bitmap", error);
   }

   return;
}