Ejemplo n.º 1
0
 static void erase(HWND hwnd, HPS hps, PRECTL rcl)
 {
    POINTL    p;
    ICQFRAME  *cfg = WinQueryWindowPtr(hwnd,0);

    hps = WinBeginPaint(hwnd,NULLHANDLE,rcl);

    icqskin_loadPallete(hps, 0, cfg->pal);

#ifdef SKINNED_GUI
    if(cfg->bg == NO_IMAGE)
    {
       WinFillRect(hps, rcl, ICQCLR_BACKGROUND);
    }
    else
    {
       p.x = rcl->xLeft;
       p.y = rcl->yBottom;
       WinDrawBitmap(hps, cfg->bg, rcl, &p, CLR_WHITE, CLR_BLACK, DBM_NORMAL);
    }
#else
    WinFillRect(hps, rcl, ICQCLR_BACKGROUND);
#endif

    icqskin_drawContents(hwnd,hps);

    WinEndPaint(hps);
 }
Ejemplo n.º 2
0
/****************************************************************************
   SysMenu Dialog Procedure
*****************************************************************************/
MRESULT EXPENTRY SysMenuProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    {
        BOOL    Handled = TRUE;
        MRESULT mReturn  = 0;
        RECTL   Rectl;
        POINTL  Pointl;
        ULONG   temp;
        HPS     hps;
        HBITMAP hbm;

        switch (msg)
            {
                case    WM_PAINT:
                    hps = WinBeginPaint(hWnd, 0, 0);
                    WinQueryWindowRect(hWnd,&Rectl);
                    WinFillRect(hps, &Rectl, CLR_BLACK);
                    hbm = PointerInfo.hbmMiniColor;
                    WinInflateRect(hab, &Rectl, -1L, -1L);
                    WinDrawBitmap(hps, hbm, NULL, (PPOINTL)&Rectl, 0L, 0L, DBM_NORMAL);
                    WinEndPaint(hps);
                    break;
                case WM_ERASEBACKGROUND:
                    WinFillRect((HPS)LONGFROMMP(mp1),PVOIDFROMMP(mp2),CLR_BLACK);
                    mReturn = MRFROMLONG(1L);
                    break;
                default:
                    Handled = FALSE;
                    break;
            }
        if (!Handled) mReturn =  (*SysMenuDefProc)(hWnd, msg, mp1, mp2);
        return (mReturn);
    }
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) ;
     }
Ejemplo n.º 4
0
Archivo: draw.c Proyecto: docwhat/cwimp
/*
 * This function is based on the DrawIntro and DrawBlinds
 * functions in Vexed, a Cool GPL Palm Game by
 * "James McCombe" <*****@*****.**>
 * http://spacetube.tsx.org
 */
void
DrawIntro () {
  VoidHand Title_Handle;
  BitmapPtr Title;
  char text[40];
  SWord penx, peny;
  Boolean bstate;

  /* If a game is on, don't do the splash */
  if( stor.currplayer >= 0 ) return;

  // load bitmap resource and get handle
  Title_Handle = DmGet1Resource ('Tbmp', bmpTitle);
  // lock the bitmap resource into memory and get a pointer to it
  Title = MemHandleLock (Title_Handle);

  // draw the bitmap ( 160x160 )
  WinDrawBitmap (Title, 0, 0);

  /* Text Strings */
  StrPrintF (text, IntroVersionString, VERSION);
  WinDrawChars (text, StrLen (text), 5, 6);

  StrPrintF (text, IntroForPalmString, 153);
  WinDrawChars (text, StrLen (text), 52, 50);

  StrPrintF (text, IntroTapHereString, VERSION);
  WinDrawChars (text, StrLen (text), 45, 85);

  // unload the bitmap from memory (unlock)
  MemHandleUnlock (Title_Handle);

  // Loop till screen is tapped
  while (bstate)
    EvtGetPen (&penx, &peny, &bstate);
  while (!bstate)
    EvtGetPen (&penx, &peny, &bstate);

  /* If the user clicked in the drawing area, then
   * do a Draw Blinds and clear the PenQueue.
   */
  if( peny < 160 ) {
    // DrawBlinds
    int i, x;
    float delay;

    EvtFlushPenQueue();

    delay = .01 * SysTicksPerSecond();

    for (i = 0; i < 16; i++) {
      for (x = i; x < 160; x += 16) {
        WinEraseLine( 0,x, 159,x );
      }
      SysTaskDelay(delay);
    }
  } /* if( peny < 160 ) */

}
Ejemplo n.º 5
0
/*
** DrawBitmap
*/
static void DrawBitmap(UInt16 bitmapID, Coord x, Coord y) {
  const MemHandle bitmapH = DmGetResource(bitmapRsc, bitmapID);

  WinDrawBitmap(MemHandleLock(bitmapH), x, y);
  
  /* Clean up */
  MemHandleUnlock(bitmapH);
  DmReleaseResource(bitmapH);
}
Ejemplo n.º 6
0
void
_WinDrawBitmap(BitmapPtr bmp, Coord x, Coord y)
{
	if (hires) {
		HRWinDrawBitmap(hires, bmp, x, y);
	} else {
		WinDrawBitmap(bmp, x, y);
	}
}
Ejemplo n.º 7
0
/* DrawBitmap -- Places a bitmap at a specified location
 * Args:    
 *     Word  BitmapID  -- ID for bitmap, see the cwimp.rpc file
 *     int   formX     -- X location on the form
 *     int   formY     -- Y location on the form
 * Returns: None
 */
void DrawBitmap (Word BitmapID, int formX, int formY)
{
  VoidHand resourceHandle;
  BitmapPtr bitmapPntr;

  resourceHandle = DmGetResource(bitmapRsc, BitmapID);
  bitmapPntr = MemHandleLock(resourceHandle);
  WinDrawBitmap(bitmapPntr, formX, formY);
  MemPtrUnlock(bitmapPntr);
  DmReleaseResource(resourceHandle);
}
Ejemplo n.º 8
0
void Graphics::drawBitmap(uint_t bitmapId, const Point& topLeft)
{
    MemHandle handle=DmGet1Resource(bitmapRsc, bitmapId);
    if (handle) 
    {
        BitmapType* bmp=static_cast<BitmapType*>(MemHandleLock(handle));
        if (bmp) 
        {
            WinDrawBitmap(bmp, topLeft.x, topLeft.y);
            MemHandleUnlock(handle);
        }
        DmReleaseResource(handle);
    }
}
Ejemplo n.º 9
0
/*
** DrawPlugBitmap
*/
static void DrawPlugBitmap(Int16 plugindex, UInt16 rscID, Coord x, Coord y) {
  SysDBListItemType *pluglistP = MemHandleLock(d.xfer.pluglistH);
  DmOpenRef dbR = DmOpenDatabase(pluglistP[plugindex].cardNo,
				 pluglistP[plugindex].dbID, dmModeReadOnly);
  MemHandle plugH = DmGet1Resource('BooG', rscID);

  ASSERT(dbR);
  ASSERT(plugH);

  WinDrawBitmap(MemHandleLock(plugH), x, y);

  /* Clean up */
  MemHandleUnlock(d.xfer.pluglistH);
  MemHandleUnlock(plugH);
  DmReleaseResource(plugH);
  DmCloseDatabase(dbR);
}
Ejemplo n.º 10
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) );
}
Ejemplo n.º 11
0
static Int16 LoadIcon(Int16 start)
{
	FormPtr     frmP = FrmGetActiveForm();
	Int8	    i;
    Int16       num;
    Int16       iconButtonID = IconSelectIcon1Button;
    BitmapPtr   pbmp;
    MemHandle   h;
    Int16       x, y;
    RectangleType r;

    num = DmNumResources(IconDB);
    if (start > num) start = 0;
    
	for (i = 0; i < 9*8; i++) {
        UInt16 idx = FrmGetObjectIndex(frmP, iconButtonID + i);

        FrmGetObjectPosition(frmP, idx, &x, &y);
        FrmGetObjectBounds(frmP, idx, &r);

        r.topLeft.x = x;
        r.topLeft.y = y;

        WinEraseRectangle(&r, 0);

        if (i+start <num) {
            h = (MemPtr)GetIconByIndex(IconDB, i + start);
            pbmp = (h) ? MemHandleLock(h) : NULL;

            if (pbmp) {
                WinDrawBitmap(pbmp, x, y);
                                
                MemHandleUnlock(h);
                DmReleaseResource(h);
                ShowObject(frmP, iconButtonID + i);
            }
            else {
                HideObject(frmP, iconButtonID + i);
            }
        }
        else {
            HideObject(frmP, iconButtonID + i);
        }
	}
    return num;
}
Ejemplo n.º 12
0
VOID GRAPHBOARD::DrawPMMark( const HPS hps, const char Row, const char Col )
{
    POINTL Point;
    ULONG Bitmap;
    HBITMAP hbm;

    if( GetDiscovered( Row, Col ) != -1 ) return;
    if( GetMarked( Row, Col ) ) Bitmap = BMP_UNMARK;
    else Bitmap = BMP_MARK;
    Point.x = LowerLeftPlace.x + (Col - 1)*dist - dist/6;
    Point.y = LowerLeftPlace.y + (Row - 1)*dist - dist/6;
    hbm = GpiLoadBitmap( hps, (HMODULE)NULL, Bitmap, dist/3, dist/3);
//	if( hbm == NULLHANDLE ) DosBeep( 500, 150 );
//	if( !(WinDrawBitmap( hps, hbm, NULL, &Point, 0, 0, DBM_NORMAL ) ))
//		DosBeep( 1000, 150 );
    WinDrawBitmap(hps, hbm, NULL, &Point, 0, 0, DBM_NORMAL);
    GpiDeleteBitmap( hbm );		// releases the bitmap-handle
    ToggleMarked( Row, Col );
}
Ejemplo n.º 13
0
static void paint(HWND hwnd)
{
   RECTL        rcl;
   SLIDERDATA   *cfg = WinQueryWindowPtr(hwnd,0);
   HPS          hps;
   POINTL       p;
   XBITMAP      *btm;
   ULONG        ySize;
   ULONG        rows;

   if(!(cfg->btm+cfg->current)->masc)
      selectBitmap(hwnd,BITMAP_NORMAL);

   btm = cfg->btm+cfg->current;

   hps = WinBeginPaint(hwnd,NULLHANDLE,&rcl);

   /* WinFillRect(hps, &rcl, CLR_RED); */

   if(cfg->bg)
   {
      p.x = p.y = 0;
      WinDrawBitmap(    hps,
                        cfg->bg,
                        0,
                        &p,
                        SKC_FOREGROUND,
                        SKC_BACKGROUND,
                        DBM_NORMAL);
   }

   if(cfg->selVal <= cfg->maxVal && cfg->maxVal > cfg->minVal && cfg->yCursor)
   {
      WinQueryWindowRect(hwnd, &rcl);
      ySize = (rcl.yTop - rcl.yBottom) - cfg->yCursor;
      rows  = cfg->maxVal - cfg->minVal;
      p.x = 0;
      p.y = ((rows-cfg->selVal) * ySize) / rows;
      drawTransparent(hps, &p, btm);
   }

   WinEndPaint(hps);
}
Ejemplo n.º 14
0
static Int16 DrawIconBitmap(UInt16 iconID, Coord x, Coord y)
{
	MemHandle pointH;
	BitmapPtr pbmp;
	
	if (IconDB) {
	 	pointH = DmGet1Resource('Tbmp', iconID);
		pbmp = (pointH) ? MemHandleLock(pointH) : NULL;

	    if (pbmp) {
	    	WinDrawBitmap(pbmp, x, y); 
	    	
	        MemHandleUnlock(pointH);
	        DmReleaseResource(pointH);
            return 1;
		}
	}

	return 0;
}
Ejemplo n.º 15
0
VOID GRAPHBOARD::DrawPMPlace( const HPS hps, const char Row,
										const char Col, INT Value,
										const BOOL fSwap )
{
    POINTL Point;
    ULONG Bitmap;
    HBITMAP hbm;

    Point.x = LowerLeftPlace.x + (Col - 1)*dist - dist/3;
    Point.y = LowerLeftPlace.y + (Row - 1)*dist - dist/3;
    if( !fSwap ){
	if( Value >= 50 ) Value -= 50;
	else if(Value <= 4 ) Value += 50;
    }
				// fSwap indicates if a number
				// will be swapped into a circle or vice versa
    if ( Value >= 50 ) {	// a number has already been found and will be
				// replaced by a circle now
	Bitmap = BMP_FCIRCLE;
	SetDiscovered( Row, Col, (SHORT)(Value - 50) );
    } else {
	switch( Value ){
	case 0: Bitmap = BMP_F0; break;
	case 1: Bitmap = BMP_F1; break;
	case 2: Bitmap = BMP_F2; break;
	case 3: Bitmap = BMP_F3; break;
	case 4: Bitmap = BMP_F4; break;
	default: Bitmap = BMP_SHIP;
	}
	if( Value != GetShipNumber() + 10 )
	    SetDiscovered( Row, Col, (SHORT)(Value + 50) );
    }
    hbm = GpiLoadBitmap( hps, (HMODULE)NULL, Bitmap, dist*2/3, dist*2/3);
//	if( hbm == NULLHANDLE ) DosBeep( 500, 150 );
//	if( !(WinDrawBitmap( hps, hbm, NULL, &Point, 0, 0, DBM_NORMAL ) ))
//		DosBeep( 1000, 150 );
    WinDrawBitmap(hps, hbm, NULL, &Point, 0, 0, DBM_NORMAL);
    GpiDeleteBitmap( hbm );		// releases the bitmap-handle
}
Ejemplo n.º 16
0
Boolean CBiddingForm::OnNilEvent(EventPtr pEvent, Boolean& bHandled) {

	if ( gManager->Status() == GetHandBids ) {

		HighlightActiveBidder();

		FormPtr frmP = FrmGetActiveForm();

		Int16 player_index = (*gManager->tbl->current_bidder)->playerIndex;


		//
		// if this is a human player, we need to render the screen widgets for their bid
		//
		if ( player_index == gManager->humanIndex && player_has_bid == false ) {

			player_hand.Render(true);

			Int16 current_bid = 0;

			if ( (*gManager->tbl->dealer)->playerIndex != gManager->humanIndex || ! gManager->dealer_take_bid ) {
				current_bid = gManager->tbl->high_bid;
			}
			else {
				current_bid = gManager->tbl->high_bid - 1;
			}
			
			if ( (*gManager->tbl->dealer)->playerIndex == gManager->humanIndex && gManager->tbl->high_bid < 2 ) {
				CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid4PushButton )), false);	
				CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid4PushButton )), "-4-");
				CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid3PushButton )), false);
				CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid3PushButton )), "-3-");
				CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBidPassPushButton )), false);
				CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBidPassPushButton )), "-Pass-");
			}
			else {
				switch (current_bid) {
					case 5:
						CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBidSmudgePushButton )), false);	
						CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBidSmudgePushButton )), "-S-");
					case 4:
						CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid4PushButton )), false);	
						CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid4PushButton )), "-4-");
					case 3:
						CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid3PushButton )), false);
						CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid3PushButton )), "-3-");
					case 2:
						CtlSetEnabled((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid2PushButton )), false);
						CtlSetLabel ((ControlType *)FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, PlayerBid2PushButton )), "-2-");
				}
			}

		} // if if ( player_index == 3 && player_has_bid == false )


		//
		// handle processing actual bids here - get one automatically if this player isn't
		// a human, or if the human has already bid
		//
		if ( player_index != gManager->humanIndex || player_has_bid == true ) {

			Boolean player_did_bid = gManager->GetNextBid(gManager->trk, false );
			Int16 tmp_bid = (*gManager->tbl->current_bidder)->Bid();

			if ( player_did_bid && 
					gManager->tbl->current_bidder == gManager->tbl->winning_bidder &&
					(tmp_bid >= 2) ) {

				char x[10];
				StrPrintF(x, "bids %d", tmp_bid );
				bidstr = x;
			}
			else {
				bidstr = "passes";
			}
				
			bids[(*gManager->tbl->current_bidder)->playerIndex].Replace(bidstr);


			//
			// if we just got the dealer's bid, then we are all done
			//
			if ( gManager->tbl->current_bidder == gManager->tbl->dealer ) {

				//
				// at this point we need to set trump...
				//	
				gManager->Status(SetHandTrump);


				if ( (*gManager->tbl->winning_bidder)->playerIndex == gManager->humanIndex ) {
					CPlayerTrumpForm frmPlayerTrump;
					frmPlayerTrump.DoModal();
				}

				FrmDrawForm(frmP);

				//
				// ... and display the final results
				//

				Card::suit_t foo = (*gManager->tbl->winning_bidder)->Trump();
				gManager->tbl->trump = foo;
				gManager->trk->no_trump_first_trick = (*gManager->tbl->winning_bidder)->NoTrumpFirstTrickP();

				MemHandle hRsc;
				BitmapType* bitmapP;

				switch ( gManager->tbl->trump ) {

					case Card::heart:
						hRsc = DmGetResource(bitmapRsc, HeartBitmapFamily );
						break;
					case Card::diamond:
						hRsc = DmGetResource(bitmapRsc, DiamondBitmapFamily );
						break;
					case Card::club:
						hRsc = DmGetResource(bitmapRsc, ClubBitmapFamily );
						break;
					case Card::spade:
						hRsc = DmGetResource(bitmapRsc, SpadeBitmapFamily );
						break;
				}

				if ( gManager->trk->no_trump_first_trick ) {
					FrmCustomAlert(NoTrumpFirstTrickAlert, (*gManager->tbl->winning_bidder)->name, "", "");
				}


				RectangleType bounds;

				UInt16 gadgetIndex = FrmGetObjectIndex(frmP, BiddingTrumpGadget);
				FrmGetObjectBounds(frmP, gadgetIndex, &bounds);
				WinPaintChars("Trump Is: ", StrLen("Trump Is: "), bounds.topLeft.x, bounds.topLeft.y );

				ErrFatalDisplayIf(!hRsc, "Could not get bitmap family resource");
				bitmapP = (BitmapType*) MemHandleLock(hRsc);
				WinDrawBitmap (bitmapP, bounds.topLeft.x + 40, bounds.topLeft.y);
				MemHandleUnlock(hRsc);
				DmReleaseResource(hRsc);

				UInt32 hsStatusVersion;
				
				if (FtrGet (hsFtrCreator, hsFtrIDNavigationSupported, &hsStatusVersion) == 0) {
					FrmGlueNavObjectTakeFocus(FrmGetActiveForm(), BiddingOKButton );
				}

			
			} // if ( dealer bid )

			else {

				// move along to the next player
				gManager->tbl->current_bidder = gManager->getNextPlayerIter(gManager->tbl->current_bidder);

				EventType event;
				event.eType = nilEvent;
				EvtAddEventToQueue (&event);

				// pause here
//				SysTaskDelay(SysTicksPerSecond());
				gManager->ShortDelay();
			
			}


		} // if ( player_index != 3 || player_has_bid == true )


	} // if GetHandBids

	bHandled = false;
	return true;
}
Ejemplo n.º 17
0
MRESULT EXPENTRY ProgressDlgProc(HWND hwnd,
                                 ULONG msg,
                                 MPARAM mp1,
                                 MPARAM mp2) {
   switch (msg) {
   // init -----------------------------------------------------------------
      case WM_INITDLG: {
         PPRGSAPPDATA pad = (PPRGSAPPDATA)mp2;
         ULONG ul;
         POINTL aptl[] = {{1, 36}, {220, 24}}; 
         WinSetWindowPtr(hwnd, 0L, (PVOID)mp2);
         WinSetWindowText(hwnd, pad->ppd->pszTitle);
         // dimensioni-coordinate varie
         pad->cyTitle = uGetSval(SV_CYTITLEBAR);
         pad->hButton = WinWindowFromID(hwnd, BTN_STOP);
         WinQueryWindowPos(pad->hButton, &pad->swp);
         WinQueryWindowRect(hwnd, &pad->rcl);
         WinMapDlgPoints(hwnd, aptl, 2, TRUE);
         pad->sldd.cbSize = sizeof(SLDCDATA);
         pad->sldd.usScale1Increments = 11;
         pad->sldd.usScale1Spacing = (pad->rcl.xRight - 2 * pad->cyTitle) / 10 - 1;
         pad->hProgress = WinCreateWindow(hwnd, WC_SLIDER, (PSZ)NULL,
                                          SLS_BOTTOM | SLS_OWNERDRAW |
                                          SLS_READONLY | SLS_RIBBONSTRIP |
                                          WS_VISIBLE, 3, aptl[0].y,
                                          pad->rcl.xRight - 6, aptl[1].y,
                                          hwnd, HWND_TOP, SLDR_PROGRESS,
                                          (PVOID)&pad->sldd, NULL);
         // controlla versione S.O. e setta font slider e bottone
         DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR,
                         &ul, sizeof(ULONG));
         if (ul < 40) {
            WinSetPresParam(pad->hProgress, PP_FONTNAMESIZE, 7, "8.Helv");
            WinSetPresParam(pad->hButton, PP_FONTNAMESIZE, 7, "8.Helv");
         } else {
            WinSetPresParam(pad->hProgress, PP_FONTNAMESIZE, 11, "9.WarpSans");
         } /* endif */
         // rileva larghezza progress bar
         pad->cxPrgs = LOUSHORT((ULONG)WinSendMsg(pad->hProgress,
                                                 SLM_QUERYSLIDERINFO,
                                         MPFROM2SHORT(SMA_SHAFTDIMENSIONS, 0),
                                         MPVOID)) - 6;
         // setta altezza barra pari a altezza barra titolo
         WinSendMsg(pad->hProgress, SLM_SETSLIDERINFO,
                    MPFROM2SHORT(SMA_SHAFTDIMENSIONS, 0), (MPARAM)pad->cyTitle);
         // setta testo e altezza barra graduata
         WinSendMsg(pad->hProgress, SLM_SETTICKSIZE,
                    MPFROM2SHORT(SMA_SETALLTICKS, pad->cyTitle / 3), MPVOID);
         WinSendMsg(pad->hProgress, SLM_SETSCALETEXT, (MPARAM)0, (MPARAM)"0%");
         WinSendMsg(pad->hProgress, SLM_SETSCALETEXT, (MPARAM)5, (MPARAM)"50%");
         WinSendMsg(pad->hProgress, SLM_SETSCALETEXT, (MPARAM)10, (MPARAM)"100%");
         // testo iniziale progesso e elapsed time:
         sprintf(pad->achElapsed, "%s: 00:00:00", pad->ppd->pszTime);
         WinSetDlgItemText(hwnd, TXT_TIME, pad->achElapsed);
         sprintf(pad->achCurPrg, "%s:   0%%", pad->ppd->pszPrgrss);
         WinSetDlgItemText(hwnd, TXT_PERCENT, pad->achCurPrg);
         // se specificato setta nuovo font dialogo
         if (pad->ppd->fl & PRGSS_FONT)
            WsetDlgFonts(hwnd, NULLHANDLE, pad->ppd->FontNameSize);
         // posiziona finestra al centro Parent window
         if (pad->ppd->fl & PRGSS_CENTER) {
            WcenterInWindow(hwnd, pad->ppd->hPos);
         } else {
            SWP swp;
            swp.hwnd = pad->ppd->hPos;
            swp.x = pad->ppd->ptl.x;
            swp.y = pad->ppd->ptl.y;
            swp.cx = swp.cy = 0;
            swp.fl = SWP_MOVE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER;
            swp.hwndInsertBehind = HWND_TOP;
            WsetRelativePos(hwnd, &swp);
         } // end if
         // notifica creazione dialogo
         WinPostMsg(pad->ppd->hNotify, WM_PRGRSREADY, (MPARAM)hwnd, (MPARAM)0);
         break;
      } // end case WM_INITDLG
      case WM_DRAWITEM:
         if (((POWNERITEM)mp2)->idItem == SDA_RIBBONSTRIP) {
            PPRGSAPPDATA pad = GetData(hwnd);
            if (pad->ppd->fl & PRGSS_BITMAP) {   // se deve disegnare la bitmap
               RECTL rcl = {0, 0, ((POWNERITEM)mp2)->rclItem.xRight -
                            ((POWNERITEM)mp2)->rclItem.xLeft, pad->cyTitle};
               POINTL ptl = {((POWNERITEM)mp2)->rclItem.xLeft,
                             ((POWNERITEM)mp2)->rclItem.yBottom};
               while (ptl.x < ((POWNERITEM)mp2)->rclItem.xRight) {
                  WinDrawBitmap(((POWNERITEM)mp2)->hps, pad->ppd->hbmp, &rcl,
                                &ptl, 0L, 0L, DBM_NORMAL);
                  ptl.x += pad->cxbmp;
                  rcl.xRight = ((POWNERITEM)mp2)->rclItem.xRight - ptl.x;
               } /* endwhile */
            } else {                       // colore
               GpiCreateLogColorTable(((POWNERITEM)mp2)->hps,
                                      0, LCOLF_RGB, 0, 0, NULL);
               WinFillRect(((POWNERITEM)mp2)->hps,
                           &((POWNERITEM)mp2)->rclItem, pad->ppd->color);
            } /* endif */
            return (MRESULT)TRUE;
         } // end if
         break;
      case PRGSM_INCREMENT: { // notifica incremento
         PPRGSAPPDATA pad = GetData(hwnd);
         ULONG ul;
         pad->incr = (ULONG)mp1;
         WinSendMsg(pad->hProgress,
                    SLM_SETSLIDERINFO,
                    MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                    (MPARAM)((pad->incr * pad->cxPrgs) / 1000));
         ul = WinGetCurrentTime(pad->hab) / 1000;
         if (pad->current != ul) {
            pad->current = ul;
            pad->elapsed = pad->current - pad->start;
            sprintf(pad->achElapsed, "%s: %02d:%02d:%02d", pad->ppd->pszTime,
                    pad->elapsed / 3600, (pad->elapsed % 3600) / 60,
                    pad->elapsed % 60);
            WinSetDlgItemText(hwnd, TXT_TIME, pad->achElapsed);
         } // end if
         if (pad->ulCurPrg != (ul = (ULONG)mp1 / 10)) {
            pad->ulCurPrg = ul;
            sprintf(pad->achCurPrg, "%s: %3d %%",
                    pad->ppd->pszPrgrss, pad->ulCurPrg);
            WinSetDlgItemText(hwnd, TXT_PERCENT, pad->achCurPrg);
         } // end if
         return (MRESULT)pad->flStop;
      } // end case PRGSM_INCREMENT
      case PRGSM_MSG:
         return (MRESULT)Wprint(hwnd, (PSZ)mp1, (ULONG)mp2);
      case WM_COMMAND:
         if ((ULONG)mp1 == BTN_STOP) {
            PPRGSAPPDATA pad = GetData(hwnd);
            pad->flStop = TRUE;
            WinEnableWindow(pad->hButton, FALSE);
         } /* endif */
         break;
      case WM_CLOSE: {
         PPRGSAPPDATA pad = GetData(hwnd);
         // se elaborazione ancora in corso mostra messaggio
         if (pad->incr > 0 && pad->incr < 1000) {
            PSZ psz;
            if (!(psz = (PSZ)malloc(1024)) ||
            // se la notify window restituisce NULL
                (BOOL)WinSendMsg(pad->ppd->hNotify, WM_PRGRSQUIT,
                                 (MPARAM)psz, MPVOID) ||
            // o se la chiusura Š confermata
                Wprint(hwnd, psz, PMPRNT_QUERY)) {
               WinPostMsg(hwnd, PRGSM_END, MPVOID, MPVOID);
               WinPostMsg(pad->hOwner, WM_CLOSE, MPVOID, MPVOID);
            // se nel frattempo Š terminato
            } else {
               pad->qQuit.msg = 0;
               if (!pad->incr || pad->incr >= 1000) {
                  WinPostMsg(hwnd, PRGSM_END, MPVOID, MPVOID);
               } else if ((BOOL)mp1) {
                  WinCancelShutdown((HMQ)WinQueryWindowULong(hwnd, QWL_HMQ),
                                    FALSE);
               } // end if
            } // end if
            free (psz);
         } /* endif */
      }  break;
      default:
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
   } /* endswitch */
   return (MRESULT)FALSE;
}
Ejemplo n.º 18
0
MRESULT EXPENTRY EDImgWinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   // alla creazione estrae dal testo del controllo il nome della libreria
   // e l'ID della risorsa da cui ricavare l'immagine
   switch (msg) {
      case WM_CREATE: {
         LHANDLE himg;        // handle immagine
         PSZ psz;             // per ricavare nome modulo e id risorsa
         ULONG idres;         // id risorsa
         HLIB hlib;
         HAB hab;
         SIZEL szl;
   
         hab = WinQueryAnchorBlock(hwnd);
         // cerca primo tab lo cambia in 0 e carica lib
         if (!(psz = memchr((PVOID)((PCREATESTRUCT)mp2)->pszText, '\t', 9)))
            goto error0;
         *psz = 0;                          
         if (!(hlib = WinLoadLibrary(hab, ((PCREATESTRUCT)mp2)->pszText)))
            goto error0;
         // ottiene handle e dimensione immagine
         if (!(idres = strtoul(++psz, NULL, 10))) goto error1;
         if (((PCREATESTRUCT)mp2)->flStyle & (ESI_PTR | ESI_ICON | ESI_MINI)) {
            if (!(himg = WinLoadPointer(HWND_DESKTOP, hlib, idres)))
               goto error1;
            if (((PCREATESTRUCT)mp2)->flStyle & ESI_PTR) {          // pointer
               szl.cx = WgetSysValue(SV_CXPOINTER);
               szl.cy = WgetSysValue(SV_CYPOINTER);
            } else if (((PCREATESTRUCT)mp2)->flStyle & ESI_ICON) {  // icona
               szl.cx = WgetSysValue(SV_CXICON);
               szl.cy = WgetSysValue(SV_CYICON);
            } else {                               // minicona
               szl.cx = WgetSysValue(SV_CXICON) / 2;
               szl.cy = WgetSysValue(SV_CYICON) / 2;
            } // end if
         } else {                                  // bitmap
            if (!(himg = WloadBitmap(hwnd, hlib, idres)))
               goto error1;                                   
            if (!WqueryBitmapSize(himg, &szl))
               goto error2;
         } // end if
         WinDeleteLibrary(hab, hlib);
         // memorizza handle immagine
         WinSetWindowULong(hwnd, cbWCstc, (ULONG)himg);
         *((PCREATESTRUCT)mp2)->pszText = 0;
         //break;
         WinSetWindowPos(hwnd, 0, 0, 0, szl.cx, szl.cy, SWP_SIZE|SWP_NOADJUST);
         break;
         
         error2: GpiDeleteBitmap(himg);
         error1: WinDeleteLibrary(hab, hlib);
         error0: return (MRESULT)TRUE;
      } // end case WM_CREATE
      case WM_ADJUSTWINDOWPOS:    // default window processing
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
      case WM_PAINT: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         ULONG flStyle = WinQueryWindowULong(hwnd, QWL_STYLE);
         HPS hps;
         hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
         if (flStyle & (ESI_PTR | ESI_ICON | ESI_MINI)) {
            WinDrawPointer(hps, 0, 0, himg,
                           (flStyle & ESI_MINI? DP_MINI: DP_NORMAL));
         } else {
            POINTL ptl = {0,0};
            WinDrawBitmap(hps, himg, NULL, &ptl, 0, 0, DBM_NORMAL);
         } // end if
         WinEndPaint(hps);
         return (MRESULT)FALSE;
      }  // end case WM_PAINT
      // restituisce handle immagine corrente
      case SM_QUERYHANDLE:
         return (MPARAM)WinQueryWindowULong(hwnd, cbWCstc);
      // memorizza nuovo handle immagine, forza repaint e restituisce
      // handle precedente immagine
      case SM_SETHANDLE: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         if (!WinSetWindowULong(hwnd, cbWCstc, (ULONG)mp1))
            return NULLHANDLE;
         WinRefreshWin(hwnd);
         return (MRESULT)himg;
      } // end case SM_SETHANDLE
      case WM_MATCHMNEMONIC:
         return (MRESULT)FALSE;
      case WM_DESTROY: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         if (WinQueryWindowULong(hwnd, QWL_STYLE) &
                                (ESI_PTR | ESI_ICON | ESI_MINI)) {
            WinDestroyPointer(himg);
         } else {
            GpiDeleteBitmap(himg);
         } // end if
      }  break;
   } /* endswitch */
   return pfnwpWCstc(hwnd, msg, mp1, mp2); // default static controls processing
}
Ejemplo n.º 19
0
MRESULT EXPENTRY ToolBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
    if (msg == WM_CREATE) {
        WinSetWindowPtr(hwnd, QWL_USER, PVOIDFROMMP(mp1));
    } else {
        ToolBarData *td = (ToolBarData *)WinQueryWindowPtr(hwnd, QWL_USER);
        ToolBarItem *items = td->pItems;

        switch (msg) {
        case WM_DESTROY:
            free(td);
            free(items);
            break;

        case WM_PAINT:
        {
            HPS hps;
            RECTL rcl;
            POINTL ptl;
            SWP swp;
            int xpos, ypos, item;

            WinQueryWindowPos(hwnd, &swp);

            hps = WinBeginPaint(hwnd, 0, &rcl);

            /* top outside 3D border */
            if (rcl.yBottom < 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.x = rcl.xLeft;
                ptl.y = 0;
                GpiMove(hps, &ptl);
                ptl.x = Min(rcl.xRight, swp.cx - 2);
                GpiLine(hps, &ptl);
            }

            /* bottom outside 3D border */
            if (rcl.yTop >= swp.cy - 1 - 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.x = Max(rcl.xLeft, 1);
                ptl.y = swp.cy - 1;
                GpiMove(hps, &ptl);
                ptl.x = rcl.xRight;
                GpiLine(hps, &ptl);
            }

            /* 3D corners */
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = 0;
            ptl.y = 0;
            GpiSetPel(hps, &ptl);
            ptl.x = swp.cx - 1;
            ptl.y = swp.cy - 1;
            GpiSetPel(hps, &ptl);

            /* bottom space */
            if (rcl.yBottom < TYBORDER - 1) {
                for (ptl.y = 1; ptl.y < TYBORDER - 2; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* top space */
            if (rcl.yTop >= swp.cy - TYBORDER + 2) {
                for (ptl.y = swp.cy - TYBORDER + 2; ptl.y < swp.cy - 1; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* left outside 3D border */
            if (rcl.xLeft < 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.y = Max(1, rcl.yBottom);
                ptl.x = 0;
                GpiMove(hps, &ptl);
                ptl.y = rcl.yTop;
                GpiLine(hps, &ptl);
            }

            /* right outside 3D border */
            if (rcl.xRight >= swp.cx - 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.y = rcl.yBottom;
                ptl.x = swp.cx - 1;
                GpiMove(hps, &ptl);
                ptl.y = Min(swp.cy - 2, rcl.yTop);
                GpiLine(hps, &ptl);
            }

            /* left border */
            if (rcl.xLeft < TXBORDER - 2) {
                GpiSetColor(hps, CLR_PALEGRAY);
                for (ptl.x = 1; ptl.x < TXBORDER - 2; ptl.x++) {
                    ptl.y = Max(1, rcl.yBottom);
                    GpiMove(hps, &ptl);
                    ptl.y = Min(swp.cy - 2, rcl.yTop);
                    GpiLine(hps, &ptl);
                }
            }

            /* draw toolbar items */
            xpos = TXBORDER;
            ypos = TYBORDER;

            for (item = 0; item < td->ulCount; item++) {
                if (items[item].ulType == tiBITMAP) {
                    if (rcl.xRight >= xpos - 2 && rcl.xLeft <= xpos + TXICON + 1) {
                        GpiSetColor(hps, CLR_BLACK);
                        ptl.x = xpos - 2;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXICON + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
                        if (item == td->ulDepressed && (items[item].ulFlags & tfDEPRESSED)) {
                            ptl.x = xpos + 1;
                            ptl.y = ypos - 1;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_DARKGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON;
                            GpiLine(hps, &ptl);
                            ptl.y--;
                            GpiMove(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                        } else {
                            ptl.x = xpos;
                            ptl.y = ypos;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiSetPel(hps, &ptl);
                            GpiSetColor(hps, CLR_WHITE);
                            ptl.y++;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON - 1;
                            GpiLine(hps, &ptl);
                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x++;
                            GpiSetPel(hps, &ptl);
                            ptl.y--;
                            GpiSetColor(hps, CLR_DARKGRAY);
                            GpiMove(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                        }
                    }
                    xpos += TXICON + 3;
                } else if (items[item].ulType == tiSEPARATOR) {
                    if (rcl.xRight >= xpos - 1 && rcl.xLeft <= xpos + TXSEPARATOR + 1) {
                        GpiSetColor(hps, CLR_PALEGRAY);
                        ptl.x = xpos - 1;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXSEPARATOR + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_FILL, &ptl, 0, 0);
                    }
                    xpos += TXSEPARATOR + 3;
                }
            }
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = xpos - 1;
            ptl.y = ypos - 2;
            GpiMove(hps, &ptl);
            ptl.x = swp.cx - 2;
            ptl.y = swp.cy - TYBORDER + 1;
            GpiBox(hps, DRO_FILL, &ptl, 0, 0);

            WinEndPaint(hps);
        }
        break;

        case WM_ADJUSTWINDOWPOS:
        {
            PSWP pswp = (PSWP)PVOIDFROMMP(mp1);
            pswp->cy = TYBORDER + TYICON + TYBORDER;
        }
        break;

        case WM_BUTTON1DOWN:
        case WM_BUTTON1DBLCLK:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                        rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                        td->pItems[item].ulType == tiBITMAP &&
                        (td->pItems[item].ulFlags & tfDISABLED) == 0)
                {
                    td->ulDepressed = item;
                    td->pItems[item].ulFlags |= tfDEPRESSED;
                    WinInvalidateRect(hwnd, &rcl, FALSE);
                    WinSetCapture(HWND_DESKTOP, hwnd);
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_MOUSEMOVE:
        {
            STARTFUNC("ToolBarProc[WM_MOUSEMOVE]");
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            LOG << "Depressed: " << td-> ulDepressed << ENDLINE;
            for (item = 0; item < td->ulCount; item++) {
                LOG << "Checking item " << item << ENDLINE;
                LOG << "  pItem -> " << (void*)(td->pItems + item) << ENDLINE;
                if (item == td->ulDepressed) {
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y)
                    {
                        if ((td->pItems[item].ulFlags & tfDEPRESSED) == 0) {
                            td->pItems[item].ulFlags |= tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    } else {
                        if (td->pItems[item].ulFlags & tfDEPRESSED) {
                            td->pItems[item].ulFlags &= ~tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    }
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_BUTTON1UP:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (item == td->ulDepressed) {
                    WinSetCapture(HWND_DESKTOP, (HWND)0);
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                            td->pItems[item].ulFlags & tfDEPRESSED)
                    {
                        td->pItems[item].ulFlags &= ~tfDEPRESSED;
                        WinInvalidateRect(hwnd, &rcl, FALSE);

                        // message
                        WinPostMsg(WinQueryWindow(hwnd, QW_OWNER), WM_COMMAND, MPFROM2SHORT(td->pItems[item].ulCommand, 0), MPFROM2SHORT(CMDSRC_OTHER, TRUE));

                        break;
                    }
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
            td->ulDepressed = -1;
        }
        break;
        }
    }
    return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Ejemplo n.º 20
0
//===========================================================================
// Draw the titlebar.
// Parameters --------------------------------------------------------------
// PSTLRFRAME p : windows data.
// Return value ------------------------------------------------------------
// VOID
//===========================================================================
static
VOID DrawTitlebar(PSTLRFRAME p) {
   PTBARAIOPT ptbo = p->is.tbhilited? &o.tb.a : &o.tb.i;
   POINTL apt[3];
   INT i;
   GpiCreateLogColorTable(p->hps, 0, LCOLF_RGB, 0, 0, NULL);
   // background ----------------------------------------------------------
   switch (ptbo->bkgnd) {
      // shade --------------------------------------------------------
      case TBARBKGNDSHADE:
         if (ptbo->shade) {         // sfumatura orizzontale
            WsetRect(apt, 0, 0, p->wrclTitle.cx, p->wrclTitle.cy);
            WinDrawBitmap(p->hps, ptbo->hbmp, NULL, apt, 0, 0, DBM_STRETCH);
         } else {                        // sfumatura verticale
            WsetRect(apt, 0, 0, p->wrclTitle.cx, SHADEH_CY);
            for (i = 0; i < p->wrclTitle.cy; i += 2) {
               WinDrawBitmap(p->hps, ptbo->hbmp, NULL, apt, 0, 0, DBM_STRETCH);
               ((PRECTL)apt)->yBottom += SHADEH_CY;
               ((PRECTL)apt)->yTop += SHADEH_CY;
            } /* endfor */
         } /* endif */
         break;
      // bitmap -------------------------------------------------------
      case TBARBKGNDBMP:
         WsetRect(&apt[1], 0, 0, p->wrclTitle.cx, p->wrclTitle.cy);
         if (ptbo->strch) {
            WinDrawBitmap(p->hps, ptbo->hbmp, NULL, &apt[1], 0, 0, DBM_STRETCH);
         } else {
            apt[0].x = apt[0].y = 0;
            while (apt[0].x <= p->wrclTitle.cx) {
               WinDrawBitmap(p->hps, ptbo->hbmp, (PRECTL)&apt[1], apt, 0, 0, 0);
               apt[0].x += ptbo->size.cx;
               apt[2].x = p->wrclTitle.cx - apt[0].x;
            } /* endwhile */
         } /* endif */
         break;
      // solid color --------------------------------------------------
      default:
         apt[0].x = p->wrclTitle.cx - 1;
         apt[0].y = p->wrclTitle.cy - 1;
         GpiSetColor(p->hps, ptbo->clrLeftTop.l);
         GpiBox(p->hps, DRO_OUTLINEFILL, apt, 0L, 0L);
         break;
   } /* endswitch */
   // text ----------------------------------------------------------------
   if (!p->cyfont) {
      GpiQueryTextBox(p->hps, p->cchTxt, p->achTxt, 3, apt);
      p->yfont = - apt[1].y;
      p->cyfont = apt[0].y - apt[1].y;
      p->cxfont = apt[2].x - apt[0].x;
   } /* endif */
   // se il testo Š pi— largo della finestra viene comunque allineato a sin.
   i = (p->cxfont < p->wrclTitle.cx) ? 8: 0;
   apt[0].x = (ptbo->center && i)? (p->wrclTitle.cx - p->cxfont) / 2 + 1: i + 3;
   apt[0].y = (p->wrclTitle.cy - p->cyfont) / 2 + p->yfont;
   apt[1].x = 0;
   apt[1].y = 0;
   apt[2].x = p->wrclTitle.cx - 1;
   apt[2].y = p->wrclTitle.cy - 1;
   if (ptbo->_3DTxt) {                         // disegna ombra testo
      GpiSetColor(p->hps, ptbo->clrBgTxt.l);
      GpiCharStringPosAt(p->hps, apt, (PRECTL)(apt + 1), CHS_CLIP,
                         p->cchTxt, p->achTxt, NULL);
   } /* endif */
   apt[0].x--;
   apt[0].y++;
   GpiSetColor(p->hps, ptbo->clrFgTxt.l);
   GpiCharStringPosAt(p->hps, apt, (PRECTL)(apt + 1), CHS_CLIP,
                      p->cchTxt, p->achTxt, NULL);
   // border --------------------------------------------------------------
   if (ptbo->border) {
      GpiMove(p->hps, &apt[1]);
      apt[1].y = apt[2].y;
      GpiSetColor(p->hps, ptbo->clrHiBkgnd.l);
      GpiPolyLine(p->hps, 2, &apt[1]);
      apt[1].x = apt[2].x;
      apt[1].y = 0;
      apt[2].x = 1;
      apt[2].y = 0;
      GpiSetColor(p->hps, ptbo->clrShBkgnd.l);
      GpiPolyLine(p->hps, 2, &apt[1]);
   } /* endif */
}
Ejemplo n.º 21
0
MRESULT	EXPENTRY ROPsTestWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)

{
CHAR			szTitle[300];  /* Title	Bar Text		*/
HPS			hPS;	   /* Presentation Space Handle		*/
LONG			lClrBack;  /* Colour Holder			*/
LONG			lClrFore;  /* Colour Holder			*/
LONG			lScrollInc;/* Scroll Increment			*/
PBITMAPARRAYFILEHEADER	pbafh;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPARRAYFILEHEADER2	pbafh2;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPFILEHEADER	pbfh;	   /* Bitmap File Header Pointer	*/
PBITMAPFILEHEADER2	pbfh2;	   /* Bitmap File Header Pointer	*/
PBITMAPINFO		pbmi;	   /* Bitmap Info Pointer		*/
PBITMAPINFO2		pbmi2;	   /* Bitmap Info Pointer		*/
POINTL			ptl;	   /* Pointer Position			*/
RECTL			rcl;	   /* Window Rectangle			*/
register INT i;			   /* Index				*/

switch ( msg )
   {
/************************************************************************/
/* Window being	created, perform window	initialization			*/
/************************************************************************/

   case	WM_CREATE :

       hptrWait	 = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT,	FALSE);
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);

       cxScreen	= WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);

       hmenuROPs = WinWindowFromID(WinQueryWindow(hWnd,	QW_PARENT), FID_MENU);
       hwndHScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_HORZSCROLL);
       hwndVScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_VERTSCROLL);

		       /************************************************/
		       /* PDSGetTemplate is used to allow controls in  */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       PDSGetTemplate(hWnd, WIN_ROPSTEST);
       break;

/************************************************************************/
/* Window being	sized							*/
/************************************************************************/

   case	WM_SIZE	:
       if ( cBitmaps )
	   SizeBitmapStack(hWnd);

       WinQueryWindowRect(hWnd,	&rcl);

       if ( (lHorzRange	= cxROP	- (cxWindow = rcl.xRight - rcl.xLeft)) < 0L )
	   {
	   lHorzRange =	0L;
	   rclROP.xLeft	 = 0L;
	   rclROP.xRight = cxROP;
	   }
       else
	   rclROP.xRight = rclROP.xLeft	+ cxWindow;
       if ( (lVertRange	= cyROP	- (cyWindow = rcl.yTop - rcl.yBottom)) < 0L )
	   {
	   lVertRange =	0L;
	   rclROP.yBottom  = 0L;
	   rclROP.yTop	   = cyROP;
	   }
       else
	   rclROP.yBottom = (rclROP.yTop = cyROP - lVertPos) - cyWindow;

       WinSendMsg(hwndVScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos),
		  MPFROM2SHORT(0, lVertRange));
       WinSendMsg(hwndVScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow,	cyROP),	0L);

       WinSendMsg(hwndHScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos),
		  MPFROM2SHORT(0, lHorzRange));
       WinSendMsg(hwndHScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow,	cxROP),	0L);
       WinInvalidateRect(hWnd, NULL, FALSE);
       break;

/************************************************************************/
/* Perform menu	initialization						*/
/************************************************************************/

   case	WM_INITMENU :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_DISPLAY :
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_BITMAPARRAY, TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? MIA_CHECKED : 0));
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_ROPARRAY,	TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? 0 : MIA_CHECKED));
	       break;

	   case	IDM_FILE :
	       break;

	   }
       break;

/************************************************************************/
/* Process key press from keyboard					*/
/************************************************************************/

   case	WM_CHAR	:
       if ( CHARMSG(&msg)->fs &	KC_VIRTUALKEY )
	   switch ( CHARMSG(&msg)->vkey	)
	       {
	       case VK_PAGEUP :
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEUP));
		   return(0L);

	       case VK_PAGEDOWN	:
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEDOWN));
		   return(0L);
	       }
		       /************************************************/
		       /* PDSKeyProc is	used to	allow controls in      */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       return(PDSKeyProc(hWnd, msg, mp1, mp2));

/************************************************************************/
/* Button 2 being depressed						*/
/************************************************************************/

   case	WM_BUTTON2DOWN :
       if ( !fBitmapArray && hbmROP )
	   {
	   lHorzPos = SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
	   lVertPos = SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));

	   lRop	= (lVertPos + (cyWindow	- SHORT2FROMMP(mp1))) /	cyImage	* 16 + (lHorzPos + SHORT1FROMMP(mp1)) /	cxImage;
	   WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)ViewROPDlgProc,
		     (HMODULE)NULL, DLG_VIEWROP, NULL);
	   }
       break;

/************************************************************************/
/* Process vertical scroll requests					*/
/************************************************************************/

   case	WM_VSCROLL :
       lVertPos	= SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINEUP :
	       lScrollInc = -cyImage;
	       break;

	   case	SB_LINEDOWN :
	       lScrollInc = cyImage;
	       break;

	   case	SB_PAGEUP :
	       lScrollInc = -cyWindow;
	       break;

	   case	SB_PAGEDOWN :
	       lScrollInc = cyWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lVertPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lVertPos,	min(lScrollInc,	lVertRange - lVertPos))	)
	   {
	   rclROP.yBottom = (rclROP.yTop = cyROP - (lVertPos +=	lScrollInc)) - cyWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndVScroll, SBM_SETPOS, MPFROM2SHORT(lVertPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process horizontal scroll requests					*/
/************************************************************************/

   case	WM_HSCROLL :
       lHorzPos	= SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINELEFT :
	       lScrollInc = -cxImage;
	       break;

	   case	SB_LINERIGHT :
	       lScrollInc = cxImage;
	       break;

	   case	SB_PAGELEFT :
	       lScrollInc = -cxWindow;
	       break;

	   case	SB_PAGERIGHT :
	       lScrollInc = cxWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lHorzPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lHorzPos,	min(lScrollInc,	lHorzRange - lHorzPos))	)
	   {
	   rclROP.xRight = (rclROP.xLeft = (lHorzPos +=	lScrollInc)) + cxWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndHScroll, SBM_SETPOS, MPFROM2SHORT(lHorzPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process control selections						*/
/************************************************************************/

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
	   }
       break;

/************************************************************************/
/* Process menu	and button selections					*/
/************************************************************************/

   case	WM_COMMAND :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_OPTIONS :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OptionsDlgProc,
			      (HMODULE)NULL, DLG_OPTIONS, NULL)	)
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;
	   case	IDM_OPEN :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OpenBitmapDlgProc,
			      (HMODULE)NULL, DLG_OPENBITMAP, NULL) )
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   hbmView = hbmGetBitmap(szBitmapFile);
		   SizeBitmap(hWnd);
		   if (	cBitmaps )
		       SizeBitmapStack(hWnd);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   strcat(memcpy(szTitle, "Bitmap Viewer - ", 17), szBitmapFile);
		   if (	fWindowsBitmap )
		       strcat(szTitle, " [Windows 3.x format]");
		   else
		       if ( f20Bitmap )
			   strcat(szTitle, " [OS/2 2.x format]");
		       else
			   strcat(szTitle, " [OS/2 1.x format]");
		   WinSetWindowText(hwndROPsFrame, szTitle);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;

	   case	IDM_ROPARRAY :
	       fBitmapArray = FALSE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;

	   case	IDM_BITMAPARRAY	:
	       fBitmapArray = TRUE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;
	   }
       break;

/************************************************************************/
/* Erase window	background						*/
/************************************************************************/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)LONGFROMMP(mp1), &rcl, CLR_PALEGRAY);
       break;

/************************************************************************/
/* Paint client	window							*/
/************************************************************************/

   case	WM_PAINT :
       GpiCreateLogColorTable(hPS = WinBeginPaint(hWnd,	(HPS)NULL, &rcl), 0UL, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

		       /* Display the bitmap array images side-by-side	*/
       if ( fBitmapArray )
	   {
	   WinFillRect(hPS, &rcl, RGBCLR_PALEGRAY);
	   for ( i = 0;	i < cBitmaps; i++ )
	       {
		       /* Check	to see if the image is a 2-colour which	*/
		       /* menas	that the colours have to be set		*/
		       /* explicitely					*/

	       if ( abm[i].cColours == 2L )
		   {
		   lClrBack = lClrFore = 0L;

		       /* Check	to see if a 2.x	format bitmap since the	*/
		       /* the structures are slightly different		*/

		   if (	f20Bitmap )
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh2 = (PBITMAPFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbfh2->bmp2;
			   }
		       else
			   {
			   pbafh2 = (PBITMAPARRAYFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbafh2->bfh2.bmp2;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi2->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi2->argbColor[1], 3);
		       }
		   else
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh	= (PBITMAPFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbfh->bmp;
			   }
		       else
			   {
			   pbafh = (PBITMAPARRAYFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbafh->bfh.bmp;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi->argbColor[1], 3);
		       }
			   /* Draw the 2-colour	bitmap using the	*/
			   /* provided colours from the	bitmap		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 lClrFore, lClrBack, DBM_NORMAL);
		   }
	       else
			   /* Draw the bitmap from the array		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 RGB_WHITE, RGB_BLACK, DBM_NORMAL);

			   /* Draw the 3-D frame around	the image	*/

	       GpiSetColor(hPS,	RGBCLR_SHADOW);
	       GpiMove(hPS, &abm[i].aptlArea[7]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[4]);

	       GpiSetColor(hPS,	RGB_WHITE);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[6]);

	       GpiSetColor(hPS,	RGB_BLACK);
	       GpiMove(hPS, &abm[i].aptlArea[3]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[0]);

	       GpiSetColor(hPS,	RGBCLR_PALEGRAY);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[2]);
	       }
	   }
       else
	   {
	   if (	(rclROP.xRight < cxWindow) || (rclROP.yTop < cyWindow) )
	       WinFillRect(hPS,	&rcl, RGBCLR_PALEGRAY);
	   ptl.x = ptl.y = 0L;
	   WinDrawBitmap(hPS, hbmROP, &rclROP, &ptl, 0L, 0L, DBM_NORMAL);
	   }
       WinEndPaint(hPS);
       break;

/************************************************************************/
/* Window being	destroyed, perform clean-up operations			*/
/************************************************************************/

   case	WM_DESTROY :
       for ( i = 0; i <	cBitmaps; i++ )
	   GpiDeleteBitmap(abm[i].hbm);

       if ( hbmROP )
	   GpiDeleteBitmap(hbmROP);

       if ( pb )
	   free(pb);
       break;

			/* Default message processing			*/
   default :
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
Ejemplo n.º 22
0
/* Draw the actual buttons onto blank bitmaps, and set them as valid
   templates on the silkscreen */
static void DrawButtons( void )
{
    Err       err;
    BitmapPtr silkBitmap;
    BitmapPtr silkBitmapInv;
    WinHandle silkWindow;
    WinHandle silkWindowInv;
    WinHandle origWindow;
    UInt16    i;
    Coord     currentX;
    Coord     currentY;
    Coord     silkX;
    Coord     silkY;

    origWindow = WinGetDrawWindow();

    if ( currentSilkStatus == HANDERA_SILK_UP ) {
        SilkGetTemplateBitmaps( &silkBitmap, &silkBitmapInv, NULL, NULL );
    }
    else {
        SilkGetTemplateBitmaps( NULL, NULL, &silkBitmap, &silkBitmapInv );
    }
    BmpGlueGetDimensions( silkBitmap, &silkX, &silkY, NULL );
    silkWindow = WinCreateOffscreenWindow( silkX, silkY, screenFormat, &err );
    silkWindowInv = WinCreateOffscreenWindow( silkX, silkY, screenFormat, &err);
    WinSetDrawWindow( silkWindow );
    WinDrawBitmap( silkBitmap, 0, 0 );
    WinSetDrawWindow( silkWindowInv );
    WinDrawBitmap( silkBitmapInv, 0, 0 );

    /* We need to move down the existing silkscreen to make room for our
       own toolbar's buttons */
    if ( currentSilkStatus == HANDERA_SILK_UP ) {
        RectangleType area;
        UInt16        moveY;

        area.topLeft.x = 40;
        area.topLeft.y = 1;
        area.extent.x = 200;
        area.extent.y = 18;
        moveY         = 14;

        WinCopyRectangle( silkWindow, silkWindow, &area,
            area.topLeft.x, moveY, winPaint );
        WinCopyRectangle( silkWindowInv, silkWindowInv, &area,
            area.topLeft.x, moveY, winPaint );
        area.extent.y = moveY;
        WinSetDrawWindow( silkWindow );
        WinEraseRectangle( &area, 0 );
        WinSetDrawWindow( silkWindowInv );
        WinEraseRectangle( &area, 0 );
    }
    currentX = TOOLBAR_START_X;
    currentY = TOOLBAR_START_Y;

    for ( i = 0; i < TOTAL_ICONS; i++ ) {
        MemHandle bitmapH;
        BitmapPtr bitmap;
        Coord     width;
        Coord     height;

        if ( iconList[ i ].resourceId == 0 ) {
            /* This is just a placeholder for our '0' resourced offset image */
            width = 22;
            height = 13;
        }
        else {
            bitmapH = DmGetResource( bitmapRsc, iconList[ i ].resourceId );
            bitmap = MemHandleLock( bitmapH );
            BmpGlueGetDimensions( bitmap, &width, &height, NULL );

            WinSetDrawWindow( silkWindow );
            WinDrawBitmap( bitmap, currentX, currentY );
            WinSetDrawWindow( silkWindowInv );
            WinDrawBitmap( bitmap, currentX, currentY );

            MemPtrUnlock( bitmap );
            DmReleaseResource( bitmapH );
        }

        iconList[ i ].bounds[ currentSilkStatus ].topLeft.x = currentX;
        iconList[ i ].bounds[ currentSilkStatus ].topLeft.y = currentY;
        iconList[ i ].bounds[ currentSilkStatus ].extent.x = width;
        iconList[ i ].bounds[ currentSilkStatus ].extent.y = height;
        WinInvertRectangle( &( iconList[ i ].bounds[ currentSilkStatus ]), 0 );

        /* Because some icons are meant to appear right beside each other,
           they're defined here up top. Everything else is spaced so
           it fits nicely */
        switch ( iconList[ i ].resourceId ) {
            case bmpFind:
            case bmpAutoscrollDecr:
            case bmpAutoscrollStop:
            case bmpLeft:
            case bmpHome:
                currentX += width;
                break;

            default:
                currentX += width;
                if ( currentSilkStatus == HANDERA_SILK_UP )
                    currentX += 3;
                else if ( currentSilkStatus == HANDERA_SILK_DOWN )
                    currentX += 7;
                break;
        }
    }
    WinSetDrawWindow( origWindow );

    silkBitmap = WinGetBitmap( silkWindow );
    silkBitmapInv = WinGetBitmap( silkWindowInv );

    if ( currentSilkStatus == HANDERA_SILK_UP )
        SilkSetTemplateBitmaps( silkBitmap, silkBitmapInv, NULL, NULL );
    else
        SilkSetTemplateBitmaps( NULL, NULL, silkBitmap, silkBitmapInv );

    WinDeleteWindow( silkWindow, false );
    WinDeleteWindow( silkWindowInv, false );
}
/* This Proc handles the on-the-fly data CD writing */
MRESULT EXPENTRY waveinfoStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH*2 +10];
  char title[CCHMAXPATH];
  SWCNTRL swctl;
  PID pid;
  int a;


  switch (msg)
    {
    case WM_PAINT:
      {
        HPS hps;
        RECTL rcl, rclSource;
        POINTL ptl;
        LONG lTemp;
        BOOL bUseCustomPainting=TRUE;
        LONG lWidthX;
        LONG lWidthY;
        LONG  lColor;
        ULONG attrFound;


        if(bUseCustomPainting) {
          //          if(allBMPs[CTRLIDX_BG].hbm) {
          if(1) {
            hps=WinBeginPaint(hwnd, NULLHANDLE, &rcl);
            rclSource.xLeft=0;
            rclSource.yBottom=0;
#if 0
            rclSource.yTop=allBMPs[CTRLIDX_BG].bmpInfoHdr.cy;
            rclSource.xRight=allBMPs[CTRLIDX_BG].bmpInfoHdr.cx;
            lTemp=rcl.xLeft/rclSource.xRight;
            ptl.x=lTemp*rclSource.xRight;
            lTemp=rcl.yBottom/rclSource.yTop;
            lTemp*=rclSource.yTop;
#endif

            //    rcl.yBottom+=4;
            rclSource=rcl;
            rcl.yTop+=4;
            WinFillRect(hps, &rclSource, CLR_RED);

            /* Border */
            lWidthX=WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER);
            lWidthY=WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER);

            GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
#if 0
        if ( (WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, &attrFound, sizeof(attrFound),
                                                &lColor, QPF_PURERGBCOLOR)) == 0 )
           lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
#endif

            WinQueryWindowRect(hwnd, &rcl);
            ptl.x=1;
            ptl.y=0;
            GpiMove(hps, &ptl);
            GpiSetColor(hps, CLR_BLACK);
            ptl.x=rcl.xRight-1;
            GpiLine(hps,&ptl);
            ptl.y=rcl.yTop-1;
            GpiLine(hps,&ptl);
            GpiSetColor(hps, SYSCLR_SHADOW);
            ptl.x=rcl.xLeft;
            GpiLine(hps,&ptl);
            ptl.y=0;
            GpiLine(hps,&ptl);

            rcl.yTop-=1;
            rcl.yBottom+=1;
            rcl.xLeft+=1;
            rcl.xRight-=1;

            WinDrawBorder( hps,&rcl, 1, 1, 0, 0, 0x400);
            rcl.yTop-=1;
            rcl.yBottom+=1;
            rcl.xLeft+=1;
            rcl.xRight-=1;

            /* Get active border color */
            if(WinQueryActiveWindow(HWND_DESKTOP)==hwnd) {
              if ( (WinQueryPresParam(hwnd, PP_BORDERCOLOR, 0, &attrFound, sizeof(attrFound),
                                      &lColor, QPF_PURERGBCOLOR)) == 0 )
                lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
            }
            else {
              /* Inactive border color */
              if ( (WinQueryPresParam(hwnd, PP_INACTIVECOLOR, 0, &attrFound, sizeof(attrFound),
                                      &lColor, QPF_PURERGBCOLOR)) == 0 )
                lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
            }
            /*            Get Border size */
            WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP(&ptl),0);

            WinDrawBorder(hps,&rcl, ptl.x-2, ptl.y-2, lColor, 0, 0);

#if 0
            while(ptl.x<rcl.xRight) {
              ptl.y=lTemp;
              while(ptl.y<rcl.yTop) {/* y direction */
                //DosBeep(5000,100);
                WinDrawBitmap(hps, allBMPs[CTRLIDX_BG].hbm,
                              &rclSource, 
                              (PPOINTL)&ptl,
                              0, 0,
                              DBM_IMAGEATTRS);
                ptl.y+=allBMPs[CTRLIDX_BG].bmpInfoHdr.cy;
                //DosSleep(200);
              };
              ptl.x+=allBMPs[CTRLIDX_BG].bmpInfoHdr.cx; 
            };
#endif
            WinEndPaint(hps);
            return (MRESULT)0;
          }
        }
        break;
      }

    case WM_DRAWITEM:
      switch(SHORT1FROMMP(mp1))
        {
        case SLIDERID:
          return drawSlider(hwnd, msg, mp1, mp2, SHORT1FROMMP(mp1));
        default:
          break;
        }              
      break;
    case WM_INITDLG:
      /* Add switch entry */
      memset(&swctl,0,sizeof(swctl));
      WinQueryWindowProcess(hwnd,&pid,NULL);
      swctl.hwnd=hwnd;
      swctl.uchVisibility=SWL_VISIBLE;
      swctl.idProcess=pid;
      swctl.bProgType=PROG_DEFAULT;
      swctl.fbJump=SWL_JUMPABLE;
      WinAddSwitchEntry(&swctl);

#if 0      
      WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "",
                     "",
                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
#endif
      //      oldProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_TEXT), newProc);
      hwndNew=WinCreateWindow(hwnd, CLASS_NAME, "Title", WS_VISIBLE |WS_TABSTOP, 10,50, SLIDERID, 40, 
                              hwnd, HWND_TOP, SLIDERID, NULLHANDLE, NULLHANDLE);
      WinShowWindow(hwnd, TRUE);
      //      WinQueryWindowPos(hwndNew,&swpSl);
      return (MRESULT) TRUE;
      /* WM_APPTERMINATENOTIFY messages are sent from the helper programs e.g. format checker. */
    case WM_CLOSE:
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_CONTROL:
      {
        switch(SHORT2FROMMP(mp1))
          {
          case SLN_SLIDERTRACK:
            {
              switch(SHORT1FROMMP(mp1))
                {
                case SLIDERID:
                  DosBeep(5000, 10);
                  break;
                default:
                  break;
                }/* switch */
              return (MRESULT) 0;
              break;
            }
          case SLN_CHANGE:
            {
              switch(SHORT1FROMMP(mp1))
                {
                case SLIDERID:
                  DosBeep(500, 100);
                  break;
                default:
                  break;
                }/* switch */
              return (MRESULT)TRUE;
            }
          default:
            break;
          }/* switch */
        break;
      }/* WM_CONTROL */
      
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case DID_OK:
          /* User pressed the OK button */
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        case IDPB_RIGHT:
          WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
                      SLM_SETSLIDERINFO,
                      MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                      MPFROMLONG( (LONG) 70 ));
          
          break;
        case IDPB_LEFT:
          WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
                      SLM_SETSLIDERINFO,
                      MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                      MPFROMLONG( (LONG) 20 ));
          
          break;
        case IDPB_SIZE:
          {
            SWP swp;
              RXSTRING arg[2];                       /* argument string for REXX  */
              RXSTRING rexxretval;                /* return value from REXX    */
              APIRET   rc;                        /* return code from REXX     */
              SHORT    rexxrc = 0;                /* return code from function */
              char chrThis[20];
              char chrHwnd[20];

              char    *str = "These words will be swapped"; /* text to swap   */

#if 0
              RexxRegisterFunctionExe("CWRXFunc1", (PFN)rexxFunc1);
              

              sprintf(chrThis, "%d",123);
              sprintf(chrHwnd, "%d", WinQueryWindow(hwnd,QW_PARENT));

              /* By setting the strlength of the output RXSTRING to zero, we   */
              /* force the interpreter to allocate memory and return it to us. */
              /* We could provide a buffer for the interpreter to use instead. */
              rexxretval.strlength = 0L;          /* initialize return to empty*/
              
              MAKERXSTRING(arg[0], chrHwnd, strlen(chrHwnd));/* create input argument     */
              MAKERXSTRING(arg[1], chrThis, strlen(chrThis));/* create input argument     */

              /* Here we call the interpreter.  We don't really need to use    */
              /* all the casts in this call; they just help illustrate         */
              /* the data types used.                                          */
              rc=RexxStart((LONG)      2,             /* number of arguments   */
                           (PRXSTRING)  &arg,          /* array of arguments    */
                           (PSZ)        "G:\\Projects_working\\mmclasses-0.3.0\\testfunc.cwr",/* name of REXX file     */
                           (PRXSTRING)  0,             /* No INSTORE used       */
                           (PSZ)        "CWRXX",         /* Command env. name     */
                           (LONG)       RXSUBROUTINE,  /* Code for how invoked  */
                           (PRXSYSEXIT) 0,             /* No EXITs on this call */
                           (PSHORT)     &rexxrc,       /* Rexx program output   */
                           (PRXSTRING)  &rexxretval ); /* Rexx program output   */

              sprintf(text,"rc: %d, function return code: %d, %s ", 
                      rc, (int) rexxrc, rexxretval.strptr);

              WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
              
              DosFreeMem(rexxretval.strptr);          /* Release storage       
                                                         given to us by REXX.  */
              
#endif

              //            WinQueryWindowPos(hwndNew,&swp);
              //    WinSetWindowPos(hwndNew, NULLHANDLE, 0, 0, swp.cx-30, swp.cy+10,SWP_SIZE);
          break;
          }
        default:
          break;
        }
      return (MRESULT) FALSE;
    default:
      break;
    }/* switch */
  
  return WinDefDlgProc( hwnd, msg, mp1, mp2);
}
Ejemplo n.º 24
0
void CGameForm::OnDraw() {

	played_cards.Render(true);
	player_hand.Render(true);

	char bid_trump_str[2];
	StrPrintF(bid_trump_str, "%d", gManager->tbl->bid  );

	FormPtr frmP = FrmGetActiveForm();
/*
	RectangleType bounds;
	UInt16 gadgetIndex = FrmGetObjectIndex( frmP, MainBidTrumpGadget );
	FrmGetObjectBounds(frmP, gadgetIndex, &bounds);

	// draw the bid
	char bidval = bid_trump_str[0];
	WinPaintChar( bidval, bounds.topLeft.x, bounds.topLeft.y );

	Card foo(gManager->trk->getTrump(), (Card::face_t)1 );

	// now, draw the suit
	MemHandle hRsc = DmGetResource(bitmapRsc, foo.SuitBitmap(false) );
	ErrFatalDisplayIf(!hRsc, "Could not get bitmap family resource");
	BitmapType* bitmapP = (BitmapType*) MemHandleLock(hRsc);

	WinPaintBitmap (bitmapP, bounds.topLeft.x + 6, bounds.topLeft.y);

	MemHandleUnlock(hRsc);
	DmReleaseResource(hRsc);
*/
	// handle MainBidTrumpGadget here also
	MemHandle hRsc;
	BitmapType* bitmapP;

	switch ( gManager->tbl->trump ) {

		case Card::heart:
			hRsc = DmGetResource(bitmapRsc, HeartBitmapFamily );
			break;
		case Card::diamond:
			hRsc = DmGetResource(bitmapRsc, DiamondBitmapFamily );
			break;
		case Card::club:
			hRsc = DmGetResource(bitmapRsc, ClubBitmapFamily );
			break;
		case Card::spade:
			hRsc = DmGetResource(bitmapRsc, SpadeBitmapFamily );
			break;
	}

	RectangleType bounds;

//	FormPtr frmP = FrmGetActiveForm();
	UInt16 gadgetIndex = FrmGetObjectIndex(frmP, MainBidTrumpGadget);
	FrmGetObjectBounds(frmP, gadgetIndex, &bounds);
	char bidstr[4];
	StrPrintF(bidstr, "%d", gManager->tbl->bid);
	WinPaintChar(bidstr[0], bounds.topLeft.x, bounds.topLeft.y );

	ErrFatalDisplayIf(!hRsc, "Could not get bitmap family resource");
	bitmapP = (BitmapType*) MemHandleLock(hRsc);
	WinDrawBitmap (bitmapP, bounds.topLeft.x + FntCharWidth(bidstr[0]) + 1, bounds.topLeft.y);
	MemHandleUnlock(hRsc);
	DmReleaseResource(hRsc);

}
Ejemplo n.º 25
0
 HBITMAP icqskin_createBackground(HWND hwnd, HBITMAP base)
 {
    SIZEL                sizl    = { 0, 0 };
    DEVOPENSTRUC         dop     = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
    HAB                  hab     = WinQueryAnchorBlock(hwnd);
    HBITMAP              btm     = NO_IMAGE;
    HWND                 owner   = WinQueryWindow(hwnd, QW_OWNER);
    HPS                  hps;
    HDC                  hdc;
    SWP                  swp;
    BITMAPINFOHEADER2    bmih;
    BITMAPINFOHEADER     bmpData;
    RECTL                rcl;
    HBITMAP              img;
    HBITMAP              msk;
    HBITMAP				 bg;
    POINTL               aptlPoints[4];
    POINTL               p;
    int                  f;
    int                  sz;

    WinQueryWindowPos(hwnd, &swp);

    hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
    hps = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC);

    /* Make base images */
    GpiQueryBitmapParameters(base, &bmpData);

    memset(&bmih,0, sizeof(BITMAPINFOHEADER2));
    bmih.cbFix        = sizeof(bmih);
    bmih.cx           = bmpData.cx;
    bmih.cy           = bmpData.cy;
    bmih.cPlanes      = 1;
    bmih.cBitCount    = 1;
    msk               = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL);

    GpiSetBitmap(hps,msk);

    aptlPoints[0].x=0;
    aptlPoints[0].y=0;
    aptlPoints[1].x=aptlPoints[0].x+bmpData.cx-1;
    aptlPoints[1].y=aptlPoints[0].y+bmpData.cy-1;
    aptlPoints[2].x=0;
    aptlPoints[2].y=0;
    aptlPoints[3].x=aptlPoints[2].x+bmpData.cx;
    aptlPoints[3].y=aptlPoints[2].y+bmpData.cy;

    GpiSetColor(hps,CLR_WHITE);
    GpiSetBackColor(hps,CLR_PINK);
    GpiWCBitBlt(hps,base,4,aptlPoints,ROP_NOTSRCCOPY,BBO_IGNORE);

    /* Create base image */

    bmih.cbFix        = sizeof(bmih);
    bmih.cx           = bmpData.cx;
    bmih.cy           = bmpData.cy;
    bmih.cPlanes      = 1;
    bmih.cBitCount    = 24;
    img               = GpiCreateBitmap(  hps, &bmih, 0L, NULL, NULL);

    GpiSetBitmap(hps,img);
    GpiSetColor(hps,CLR_WHITE);
    GpiSetBackColor(hps,CLR_BLACK);

    GpiWCBitBlt( hps,msk,4,aptlPoints,ROP_NOTSRCCOPY,BBO_IGNORE);
    GpiWCBitBlt( hps,base,4,aptlPoints,ROP_SRCAND,BBO_IGNORE);

    /* Draw background */

    memset(&bmih,0, sizeof(BITMAPINFOHEADER2));
    bmih.cbFix        = sizeof(bmih);
    bmih.cx           = swp.cx;
    bmih.cy           = swp.cy;
    bmih.cPlanes      = 1;
    bmih.cBitCount    = 24;

    btm = GpiCreateBitmap(hps,&bmih,0L,NULL,NULL);
    GpiSetBitmap(hps, btm);

    // Ask owner window to draw the background
    icqskin_loadPallete(hps, 0, (const ULONG *) WinSendMsg(hwnd,WMICQ_QUERYPALLETE,0,0));

    rcl.xLeft   =
    rcl.yBottom = 0;
    rcl.xRight  = swp.cx;
    rcl.yTop    = swp.cy;

    bg = icqskin_queryBackground(owner);

    if(!bg || bg == NO_IMAGE)
    {
       WinFillRect(hps, &rcl, ICQCLR_BACKGROUND);
    }
    else
    {
       WinMapWindowPoints(hwnd, owner, (POINTL *) &rcl, 2);
       p.x = p.y = 0;
       WinDrawBitmap(hps, bg, &rcl, &p, CLR_WHITE, CLR_BLACK, DBM_NORMAL);
    }

    GpiSetColor(hps,CLR_WHITE);
    GpiSetBackColor(hps,CLR_BLACK);

    if(swp.cx > bmpData.cx)
    {
       sz = bmpData.cx / 3;
       for(f=sz;f<(swp.cx-(sz*2));f += sz)
          drawTransparent(hps, img, msk, f, 0, sz, bmpData.cy, sz, 0);
       drawTransparent(hps, img, msk, swp.cx-(sz*2), 0, sz, bmpData.cy, sz, 0);
       drawTransparent(hps, img, msk, 0, 0, sz, bmpData.cy, 0, 0);
       drawTransparent(hps, img, msk, swp.cx-sz, 0, sz, bmpData.cy, bmpData.cx-sz, 0);
    }
    else
    {
       sz = swp.cx / 2;
       drawTransparent(hps, img, msk, 0, 0, sz, bmpData.cy, 0, 0);
       drawTransparent(hps, img, msk, sz, 0, sz, bmpData.cy, bmpData.cx-sz, 0);
    }

    // Release resources
    GpiSetBitmap(hps, NULLHANDLE);
    GpiDeleteBitmap(img);
    GpiDeleteBitmap(msk);
    GpiDestroyPS(hps);
    DevCloseDC(hdc);

    return btm;
 }
// Handle the drawing of the list box items.
Boolean DrawHandler::drawItem( IListBoxDrawItemEvent& event,
                               Boolean selected)
{
  IListBox* list = (IListBox*)event.controlWindow();
  IRectangle rect = event.itemRect();
  RECTL rectl = rect.asRECTL();

  // Fill the background. 
  WinFillRect(event.itemPresSpaceHandle(), &rectl,
              selected?CLR_BLACK:SYSCLR_ENTRYFIELD);

  // Convert the item data from the list box item text
  ListItem* data = 
     (ListItem*)(list->itemText(event.itemId()).asUnsigned());

  // Determine the indent for the class based on the
  // number of inherited classes.
  if (data->inheritedClasses() != 0)
  {
     ISize indentSize = ISize(
                data->inheritedClasses() * (_indent+1), 0);
     rect.moveBy(indentSize);
  }

  // Draw a bitmap based on the collapsed flag
  // if the class is not a leaf.
  if(data->children())
  {
    // Make the bitmap a square the size of an item
    IRectangle rectBitmap(rect.bottomLeft(),
                        ISize(rect.height(),
                              rect.height()));
    rectl = rectBitmap.asRECTL();
    WinDrawBitmap(event.itemPresSpaceHandle(),
                data->collapsed()? _collapseIcon:_expandIcon,
                0, 
                (PPOINTL)&rectl,
                selected?CLR_WHITE:CLR_BLACK,
                selected?CLR_BLACK:SYSCLR_ENTRYFIELD,
                DBM_STRETCH );
  }

  // Calculate the rectangle for the text based
  // on the current font of the listbox.
  IFont font(list);
  rect
    .moveBy(ISize(rect.height(),0))
    .sizeTo(ISize(font.textWidth(data->text())+3,
            rect.size().height()));
  rectl = rect.asRECTL();
                          
  // Draw the text.
  unsigned long style =  DT_VCENTER | DT_LEFT;
  WinDrawText(event.itemPresSpaceHandle(), 
              -1,
              data->text(),
              &rectl, 
              selected?CLR_WHITE:CLR_BLACK,
              selected?CLR_BLACK:SYSCLR_ENTRYFIELD,
              style);
  return true;
}