Example #1
0
void MpMessageDialog::Redraw (void)
{
  // redraw the panel
  MpCanvas::Redraw();

  // redraw text
  PlaceText(text,trec,Mp.theBoldFont);

  // redraw icon
  switch (icon) {
    case InfoIcon:
	if (Mp.theInfoPixmap)
	    XCopyArea(Mp.theDisplay,Mp.theInfoPixmap,Win(),Mp.theTextGC,
		      0,0, icon_size,icon_size, margin,margin);
	break;
    case AskIcon:
	if (Mp.theAskPixmap)
	    XCopyArea(Mp.theDisplay,Mp.theAskPixmap,Win(),Mp.theTextGC,
		      0,0, icon_size,icon_size, margin,margin);
	break;
    case WarnIcon:
	if (Mp.theWarnPixmap)
	    XCopyArea(Mp.theDisplay,Mp.theWarnPixmap,Win(),Mp.theTextGC,
		      0,0, icon_size,icon_size, margin,margin);
	break;
    case ErrorIcon:
	if (Mp.theErrorPixmap)
	    XCopyArea(Mp.theDisplay,Mp.theErrorPixmap,Win(),Mp.theTextGC,
		      0,0, icon_size,icon_size, margin,margin);
	break;
    default:
      break;
  }  
}
void MpScrollWindow::Redraw (void)
{
  // if both scrollbars are visible the little corner square must be filled
  if (ScrollHorizontal && ScrollVertical)
    XFillRectangle(Mp.theDisplay,Win(),Mp.theCanvasGC,
		   Width()-ShifterWidth,Height()-ShifterWidth,
		   ShifterWidth,ShifterWidth);

  int w = Width(), h = Height();
  if (ScrollHorizontal) h -= ShifterWidth;
  if (ScrollVertical) w -= ShifterWidth;

  // draw frame around clip_win
  int fs = FrameStyle & MpCanvas::ShadowMask, 
      os = FrameStyle & MpCanvas::OutlineMask,
      ViewFrmWid = FrameWidth+FrameMidWidth;
  Mp.Rectangle(Win(), fs|os, FrameWidth, 0,0, w-1,h-1); 
  Mp.Rectangle(Win(), MpCanvas::Flat, FrameMidWidth, FrameWidth,FrameWidth, 
	       w-2*FrameWidth-1,h-2*FrameWidth-1); 
  
  if ((FrameStyle & MpCanvas::TypeMask) == MpCanvas::Box) {
    Mp.Rectangle(Win(), 
		 fs==MpCanvas::Sunken ? MpCanvas::Raised 
		 : fs==MpCanvas::Raised ? MpCanvas::Sunken : fs, 
		 FrameWidth, ViewFrmWid, ViewFrmWid, 
		 w-1-2*ViewFrmWid, h-1-2*ViewFrmWid); 
  }
}
void MpViewXYZMarker::Redraw (void)
{
  MpViewPanel::Redraw();

  int w = Width()-2*BO, h = 2*BH+VO+2*BO, y = BH+2*BO+VO;
  Mp.GroupingFrame(Win(),"Import Marker Data", w,h,BO,y);
  y += h + BO;
  Mp.GroupingFrame(Win(),"Marker Layout", w,h,BO,y);
}
void MpViewArray2dRegrid::Redraw (void)
{
  MpViewPanel::Redraw();
  int w = Width()-2*BO,
      y = 2*(BH+BO)+2*VO,
      h = 2*BH+VO+2*BO;
  Mp.GroupingFrame(Win(),"New Array Dimensions", w,h,BO,y);
  y += h+BO;
  h = 2*BH+VO+2*BO;
  Mp.GroupingFrame(Win(),"Quadratic Bivariate Interpolation", w,h,BO,y);
}
void MpViewArray3dTrafo::Redraw (void)
{
  MpViewPanel::Redraw();
  int w = Width()-2*BO,
      y = 2*(BH+BO)+2*VO,
      h = 4*BH+2*BO+3*VO;
  Mp.GroupingFrame(Win(),"Crop Array", w,h,BO,y);
  y += h+BO;
  h = BH+2*BO;
  Mp.GroupingFrame(Win(),"Transformation", w,h,BO,y);
  y += h+BO;
  h = 2*BH+VO+2*BO;
  Mp.GroupingFrame(Win(),"Cyclic Shift", w,h,BO,y);
}
TInt CPrimaryColoursWin::CountUniquePlottedColours()
	{
	iNumColours = 0;
	TPoint lhsAbs = Win()->AbsPosition();
	
	for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < 3; channelnum++, channelmul <<=8 , xoordinate += kPlotWithMargin)
		{
		TRgb lastPixel(255, 255, 255, 255);
		
		for(TInt colour = 0; colour < 256; colour++)
			{
			TRgb readPixel;
 			TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4));
			TheClient->iScreen->GetPixel(readPixel, lhsAbs + point);
			
			if(readPixel != lastPixel)
				{
				lastPixel = readPixel;
				iNumColours++;
				iBadPixels[channelnum][colour] = EFalse;
				}
			else
				{
				iBadPixels[channelnum][colour] = ETrue;
				}
			} // for loop 
		} // for loop
		
	return iNumColours;
	}
Example #7
0
void MpButton::AddIcon (const char *pxmap[], int align, bool bitmask)
{
  // remove possible previous icon
  DeleteIcon();

  // allocate pixmap
  int status = XpmCreatePixmapFromData(Mp.theDisplay, Win(), 
				       (char**) pxmap,
				       &pixmap, 
				       (bitmask) ? &mask : NULL, 
				       NULL); 
  if (status)      
    Mp.Warn("MpButton::AddIcon(XPM): Can't allocate icon pixmap");
  else {

    // parse size
    long w, h;
    char *endptr,*dummy;
    w = strtol(pxmap[0],&endptr,10);
    h = strtol(endptr,&dummy,10);

    // remember size
    icon_width  = short(w);
    icon_height = short(h);
    // remember alignment
    if (align & AlignLeft) 
      state |= icon_align_left;
    else if (align & AlignRight)
      state |= icon_align_right;
  }
}
Example #8
0
void Own2::AI(uint8 inp)
{
    hash = ZobristHash(hash,inp,choose,0);
    ChessBoard *rootChessBoard = new ChessBoard(a,hash);
    int16 output = rootChessBoard->run();
    delete rootChessBoard;
    int p = 0;
//    while (p == 0)
//    {
//        (time(NULL)) ;//通过系统时间初始化随机数种子
        int m = output / 16;
        int n = output % 16;
        int q = 3-choose;

        if(a[m][n] == 0 )
        {
            a[m][n] = q;
            p = 1;
            if(Win(m, n))
            {
                update();
                int ch = choose;
                if (ch==2) QMessageBox::information(this, "Win", "Black Win", QMessageBox::Ok);

                if (ch==1) QMessageBox::information(this, "Win", "White Win", QMessageBox::Ok);
            }
        }
//    }
        realPly++;
}
Example #9
0
void Own2::mouseReleaseEvent(QMouseEvent *e)
{
    if(choose == 0) QMessageBox::information(this,"warning","You haven't set color", QMessageBox::Ok);
    else{
      int x, y;
      if(e->x() >= 20 && e->x() < 660 && e->y() >= 20 && e->y() < 660)
      {
        x = (e->x() - 20) / 40;
        y = (e->y() - 20) / 40;

        if (!a[x][y])
        {
            a[x][y] = choose;
            realPly++;
            AI(x*16+y);
        }
        if(Win(x, y))
        {
            update();
            int m = choose;
            if (m==1) QMessageBox::information(this, "Win", "Black Win", QMessageBox::Ok);

            if (m==2) QMessageBox::information(this, "Win", "White Win", QMessageBox::Ok);
        }

      }
    }
    update();
}
update_status ModuleGameplay::Update()
{
    if (App->player->IsEnabled())
    {
        if (App->player->pause == true) {

            Mix_PauseMusic();
            App->render->Blit(pause, 0, 0, &pausing);

        }

        else
        {
            Mix_ResumeMusic();

            //App->textures->Unload(pause);
        }
        if (App->player->godmode == true) {

            App->render->Blit(godm, 500, 1, &gmode);
        }
        /*else
        	App->textures->Unload(godm);*/
        if (App->board->CheckWin()/*|| App->input->keyboard[SDL_SCANCODE_W] == KEY_STATE::KEY_DOWN*/)
        {
            if (App->level_3->IsEnabled()) {
                Congratulations();

            }

            else
                Win();


            if (check_time == 0)check_time = SDL_GetTicks();
        }

        else if (App->player->LoseCondition == true)
        {
            Lose();
            if (check_time == 0)check_time = SDL_GetTicks();
        }


        if (check_time != 0)
        {

            if (SDL_GetTicks() - check_time >= 2000)
            {
                check_time = 0;

            }

        }
    }


    return UPDATE_CONTINUE;
}
Example #11
0
// win function that gets called from a trickscript
// checks that the calling minigame is the current minigame
bool CBettingGuy::Win( uint32 goalId )
{
	if ( IsActive() && m_currentMinigame == goalId )
	{
		// this is the right minigame!
		return Win();
	}
	return false;
}
void MpScrollImageBase::MapXImage (void)
{
    // draw the XImage to the window (if there is one)
    if (theXImage)
	XPutImage(Mp.theDisplay,Win(),Mp.theDrawGC,theXImage, 
		  0,0, 				  	// offset in source image
		  0,0,					// offset in destination
		  image->GetWidth(), image->GetLength()); // the size of image
}
void MpView3DPlots::Redraw (void)
{
  MpViewPanel::Redraw(); 
  int y,w,h;
  
  // draw the grouping frame
  y = 10*BH+8*VO+3*BO;
  w = Width()-2*BO;
  h = 2*BH+2*BO+VO;
  Mp.GroupingFrame(Win(),"Stacking",w,h,BO,y);
}
Example #14
0
void MpButton::AddIcon (const char *btmp, int w, int h, int align, bool bitmask)
{
  // remove possible previous icon
  DeleteIcon();

  // link bitmap
  bitmap = btmp;
  icon_width  = w;
  icon_height = h;

  pixmap = XCreatePixmapFromBitmapData(Mp.theDisplay, Win(), 
                                       (char*) btmp, w, h, 
                                       Mp.TextColor.Pixel(),   // foreground 
                                       Mp.CanvasColor.Pixel(), // background
                                       Mp.theDepth);

  if (bitmask) {
    mask = XCreatePixmapFromBitmapData(Mp.theDisplay, Win(), 
                                       (char*) btmp, w, h, 
                                       Mp.WhiteColor.Pixel(),  // foreground 
                                       Mp.BlackColor.Pixel(),  // background
                                       1);
    if (!mask) Mp.Warn("MpButton::AddIcon(XBM): Can't allocate icon bitmap mask");
  }

  if (pixmap) {
    // remember size
    icon_width  = w;
    icon_height = h;
    // remember alignment
    if (align == MpBase::AlignLeft) 
      state |= icon_align_left;
    else if (align == MpBase::AlignRight)
      state |= icon_align_right;
  } else
    Mp.Warn("MpButton::AddIcon(XBM): Can't allocate icon pixmap");
}
Example #15
0
void MpImageWindow::MapXImage (void) // virtual
{
  // draw the XImage to the window (if there is one)
  if (theXImage) {  

    int f = GetFrameTotalWidth(),
        w = MpMin( Width()-2*f,image->GetWidth() ),
        h = MpMin( Height()-2*f,image->GetLength() );

    XPutImage(Mp.theDisplay,Win(),Mp.theDrawGC,theXImage, 
	      0,0,  // offset in source image
	      f,f,  // offset in destination
	      w,h); // effective size to draw
  }
}
void CPrimaryColoursWin::Draw()
	{
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
	iGc->SetPenColor(TRgb(255, 255, 255));
	iGc->SetBrushColor(TRgb(0, 0, 0));
	TSize winSize = Size();
	iGc->DrawRect(TRect(winSize));
	
	CFont* font;
	TFontSpec fontSpec(_L(""), 300);
	TheClient->iScreen->GetNearestFontInTwips(font, fontSpec);
	
	if (font)
		{
		iGc->UseFont(font);
		TRect r(TPoint(0, 0), Size());
		r.Shrink(kMinHeight, kMinHeight);
		iGc->DrawText(iDisplayText, r, font->AscentInPixels(), iGc->ECenter, 0);
		iGc->DiscardFont();
		TheClient->iScreen->ReleaseFont(font);
		}
	
	iNumColours = 0;
	TPoint lhsAbs = Win()->AbsPosition();
	
	for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < KNumChannels; channelnum++, channelmul <<= 8, xoordinate += kPlotWithMargin)
		{
		TRgb lastPixel(255, 255, 255, 255);
		
		for(TInt colour = 0; colour < KNumColours; colour++)
			{
			if(!iBadPixels[channelnum][colour])
				{
				iGc->SetPenColor(TRgb(colour * channelmul));				
				}
			else
				{
				iGc->SetPenColor(TRgb(255, 255, 255));			
				}

			TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4));
			iGc->Plot(point);
			}
		}
		
	iDrawn=ETrue;
	}
Example #17
0
void CHC_GameSystem::Refresh()
{
	/* Refresh */
	for (int i = 0; i != map_w; i++)
		for (int j = 0; j != map_h; j++) 
		if (!now_map[i][j].isSender()) {
			for (int k = 0; k != 4; k++)
				now_map[i][j].col[k].setColor(0, 0, 0); 
		} else {
			for (int k = 0; k != 4; k++)
				now_map[i][j].col[k] = ori_map[i][j].col[k]; 	
		}

	for (int stx = 0; stx != map_w; stx++)
		for (int sty = 0; sty != map_h; sty++) 
		if (now_map[stx][sty].isSender()) {
			int x = stx, y = sty, d = now_map[stx][sty].dir;
			CHC_Color col = now_map[stx][sty].col[d / 2];
			memset(mark, 0, sizeof(mark));
			RefreshBackTrace(x, y, d, col);
		}

	GameDraw();
	win_flag = Win();
	
	if (win_flag) {
		/* Win */
		/*
		glPushMatrix();
			glTranslated((float)map_w/2, 4, (float)map_h/2);
			glColor3f(0.1, 0.3, 0.3);
			glutSolidCube(map_w);
		glPopMatrix();
		*/
	}
}
Example #18
0
File: main.c Project: wdchang/OS
/*======================================================================*
                               Start
 *======================================================================*/
void Start()
{
	/*int ai;

	disp_pos = 0;

	for (ai = 0; ai < 80 * 25; ai++)
	{
		disp_str(" ");
	}

	disp_pos = 0;*/

	//memset(snake_map, 0, sizeof(char)*MAP_SIZE);

	/*int ai;

	for (ai = 0; ai < 80 * 25; ai++)
	{
		snake_map[ai] = ' ';
	}*/

	Reset();

	while (1){
		//proc_table[0].ticks = proc_table[0].priority = 150;
		milli_delay(3333);

		int hX, hY;
		int newHead;

		if (snake_direct == DIRECT_NULL) continue;

		hX = snake_path[snake_head] % MAP_LENGTH;
		hY = snake_path[snake_head] / MAP_LENGTH;
		switch (snake_direct)
		{
		case DIRECT_UP:
		{
			hY--;
			break;
		}
		case DIRECT_DOWN:{
			hY++;
			break;
		}
		case DIRECT_LEFT:{
			hX--;
			break;
		}
		case DIRECT_RIGHT:{
			hX++;
			break;
		}
		default:
			break;
		}
		
		newHead = hY*MAP_LENGTH + hX;

		if (newHead < 0 || newHead >= MAP_SIZE || hY >= MAP_HEIGHT || hY < 0 || hX < 0 || hX >= MAP_LENGTH){
			Lose();
			continue;
		}

		if (snake_map[newHead] == 'O' && newHead != snake_path[snake_tail]){
			Lose();
			continue;
		}

		if (snake_map[newHead] != '*'){
			disp_pos = snake_path[snake_tail] * 2;
			disp_str(" ");
			snake_map[snake_path[snake_tail]] = ' ';

			snake_tail++;
			if (snake_tail == MAP_SIZE) snake_tail = 0;
		}
		else{
			snake_length++;
		}

		disp_pos = snake_path[snake_head] * 2;
		disp_str("0");
		snake_map[snake_path[snake_head]] = 'O';
		
		snake_head++;
		if (snake_head == MAP_SIZE) snake_head = 0;
		snake_path[snake_head] = newHead;
		
		disp_pos = snake_path[snake_head] * 2;
		disp_str("@");
		snake_map[snake_path[snake_head]] = '@';

		if (snake_length == 6) {
			Win();
			continue;
		}
	}
}
Example #19
0
File: RPS.c Project: marcaj317/GAME
void RPSLS(){
	
	enum Hand{
		
	/*Rock = 0, Paper = 1, Scissors = 2, Lizard = 3, Spock = 4, EXIT = 5*/
	Rock, Paper, Scissor, Lizard, Spock, Exit
	
	};
	
	printf("\n You are playing ROCK/PAPER/SCISSORS/LIZARD/SPOCK \n");
    
    /*input rounds from the user */
    printf("\nEnter how many rounds you want to play: ");
	scanf("%i", &rounds);
	if(rounds <= 0){
	    do{
			printf("\nEnter how many rounds you want to play: ");
			scanf("%i", &rounds);
			if(rounds > 0)
				break;
		}while(rounds <= 0);
	}
	
	/*loop number of rounds*/
	for(int x = 0; x < rounds; x++){
		Computer = rand() % 4;
		
		printf("\nSelect a value... \n 0: Rock \n 1: Paper \n 2: Scissors \n 3: Lizard \n 4. Spock \n 5. Exit \n Enter Value: ");
		
		scanf("%i", &User);
		
		if(User == Exit)
  			break;
  
		if(User == Computer)
  			printf("\nDraw! Total Score: %i\n", TotalScore);
		
		/*check who wins and adjust score */  
		if(User == Rock && Computer == Paper)
		{
			Lose();
  			printf("\nYou Lose! You chose Rock, Computer chose Paper. Total Score: %i\n", TotalScore);
		}
		if(User == Rock && Computer == Scissor)
		{	
			Win();
 			printf("\nYou Win! You chose Rock, Computer chose Scissors. Total Score: %i\n", TotalScore);
 		}
 		
 		if(User == Rock && Computer == Lizard)
 		{
 			Win();
  			printf("\nYou win! You chose Rock, Computer chose lizard. Total Score: %i\n", TotalScore);
  		}
  		if(User == Rock && Computer == Spock)
  		{
			Lose();
  			printf("\nYou Lose! You chose Rock, Computer chose Spock. Total Score: %i\n", TotalScore);
  		}
		if(User == Paper && Computer == Rock)
		{
 			Win();
  			printf("\nYou win! You chose Paper, Computer chose Rock. Total Score: %i\n", TotalScore);
		}
		if(User == Paper && Computer == Scissor)
		{
			Lose();
  			printf("\nYou Lose! You chose Paper, Computer chose Scissor. Total Score: %i\n", TotalScore);
  		}
  		if(User == Paper && Computer == Lizard)
  		{
			Lose();
  			printf("\nYou Lose! You chose Paper, Computer chose Lizard. Total Score: %i\n", TotalScore);
  		}
  		if(User == Paper && Computer == Spock)
  		{
 			Win();
  			printf("\nYou win! You chose Paper, Computer chose Spock. Total Score: %i\n", TotalScore);
  		}
		if(User == Scissor && Computer == Paper)
		{
 			Win();
 			printf("\nYou win! You chose Scissor, Computer chose Paper. Total Score: %i\n", TotalScore);
  		}
		if(User == Scissor && Computer == Rock)
		{
			Lose();
  			printf("\nYou Lose! You chose Scissor, Computer chose Rock. Total Score: %i\n", TotalScore);
  		}
  		if(User == Scissor && Computer == Lizard)
  		{
 			Win();
 			printf("\nYou win! You chose Scissor, Computer chose Lizard. Total Score: %i\n", TotalScore);
 		}
 		if(User == Scissor && Computer == Spock)
 		{
			Lose();
 			printf("\nYou Lose! You chose Scissor, Computer chose Spock. Total Score: %i\n", TotalScore);
 		}
 		if(User == Lizard && Computer == Paper)
 		{
 			Win();
 			printf("\nYou Win! You chose Lizard, Computer chose Paper. Total Score: %i\n", TotalScore);
 		}
 		if(User == Lizard && Computer == Rock)
 		{
			Lose();
 			printf("\nYou Lose! You chose Lizard, Computer chose Rock. Total Score: %i\n", TotalScore);
 		}
 		if(User == Lizard && Computer == Scissor)
 		{
			Lose();
 			printf("\nYou Lose! You chose Lizard, Computer chose Scissor. Total Score: %i\n", TotalScore);
 		}
 		if(User == Lizard && Computer == Spock)
 		{
 			Win();
 			printf("\nYou Win! You chose Lizard, Computer chose Spock. Total Score: %i\n", TotalScore);
 		}
 		if(User == Spock && Computer == Lizard)
 		{
			Lose();
 			printf("\nYou Lose! You chose Spock, Computer chose Lizard. Total Score: %i\n", TotalScore);
 		}
 		if(User == Spock && Computer == Paper)
 		{
			Lose();
 			printf("\nYou Lose! You chose Spock, Computer chose Paper. Total Score: %i\n", TotalScore);
 		}
 		if(User == Spock && Computer == Scissor)
 		{
 			Win();
 			printf("\nYou Win! You chose Spock, Computer chose Scissor. Total Score: %i\n", TotalScore);
 		}
 		if(User == Spock && Computer == Rock)
 		{
 			Win();
 			printf("\nYou Win! You chose Spock, Computer chose Rock. Total Score: %i\n", TotalScore);
 		}
 		
 		/*if user enters invalid value*/
  		if(User > Exit || User < Rock)
			printf("\nError: Enter an acceptable value\n");
	}
}
Example #20
0
File: RPS.c Project: marcaj317/GAME
void RPS()
{
	enum Hands{
		
	/*Rock = 0, Paper = 1, Scissors = 2, EXIT = 3*/
	Rock, Paper, Scissor, Exit
	
	};
	
	printf("\n You are playing ROCK/PAPER/SCISSORS \n");
    
    /*input and check rounds from the user */
    printf("\nEnter how many rounds you want to play: ");
	scanf("%i", &rounds);
	if(rounds <= 0){
	    do{
			printf("\nEnter how many rounds you want to play: ");
			scanf("%i", &rounds);
			if(rounds > 0)
				break;
		}while(rounds <= 0);
	}
	
	/*Loop the number of rounds */
	for(int x = 0; x < rounds; x++){
	
		Computer = rand() % 2; /*random number between 0 and 2*/
		
		printf("\nSelect a value... \n 0: Rock \n 1: Paper \n 2: Scissors \n 3: Exit \n Enter Value: ");
		
		scanf("%i", &User);
		
		if(User == Exit) /*if user wants to exit, go back to main*/
  			break;
  
		if(User == Computer)
  			printf("\nDraw! Total Score: %i\n", TotalScore);
  		
  		/*Check who wins and adjust score*/
		if(User == Rock && Computer == Paper)
		{
			Lose();
  			printf("\nYou Lose! You chose Rock, Computer chose Paper. Total Score: %i\n", TotalScore);
  		}
  		
		if(User == Rock && Computer == Scissor)
 		{
 			Win();
		 	printf("\nYou Win! You chose Rock, Computer chose Scissors. Total Score: %i\n", TotalScore);
		}	
  
		if(User == Paper && Computer == Rock)
  		{
 			Win();	
			printf("\nYou win! You chose Paper, Computer chose Rock. Total Score: %i\n", TotalScore);
		} 
		 
		if(User == Paper && Computer == Scissor)
		{
			Lose();
  			printf("\nYou Lose! You chose Paper, Computer chose Scissor. Total Score: %i\n", TotalScore);
		}
		
		if(User == Scissor && Computer == Paper)
		{
 			Win();
 			printf("\nYou win! You chose Scissor, Computer chose Paper. Total Score: %i\n", TotalScore);
 		}
  
		if(User == Scissor && Computer == Rock)
		{
			Lose();
  			printf("\nYou Lose! You chose Scissor, Computer chose Rock. Total Score: %i\n", TotalScore);
  		}
  		
  		/*if user inputs invalid values*/
  		if(User > Exit || User < Rock)
			printf("\nError: Enter an acceptable value\n");
	}
}
Example #21
0
void MpButton::Draw (void) 
{
  // draw pixmap icon
  if (pixmap) {

    int // clip boundaries
        copy_w = MpMin((int)icon_width,Width()-2*GetFrameTotalWidth()), 
        copy_h = MpMin((int)icon_height,Height()-2*GetFrameTotalWidth()),
        src_x  = MpMin(0,icon_width-copy_w),
        src_y  = MpMin(0,icon_height-copy_h),

        // copy destination
        dest_x = (state & icon_align_left)          // left aligned icon
                   ? GetFrameTotalWidth()+GetXPadding()
                   : (state & icon_align_right)     // right aligned icon
                      ? Width()-GetFrameTotalWidth()-copy_w-GetXPadding()
                        : (Width()-copy_w)/2,       // centered icon
        dest_y = (Height()-copy_h)/2;

    // set clip mask
    if (mask) {
      XSetClipOrigin(Mp.theDisplay,Mp.theTextGC,dest_x,dest_y);
      XSetClipMask(Mp.theDisplay,Mp.theTextGC,mask); 
    }

    // draw icon
    XCopyArea(Mp.theDisplay,pixmap,Win(),Mp.theTextGC,
              src_x,src_y, copy_w,copy_h, dest_x,dest_y);

    // reset clip mask
    if (mask) 
      XSetClipMask(Mp.theDisplay,Mp.theTextGC,None);

    // draw label together with left or right aligned icon
    if (state & icon_align_left) {
      PlaceText(Get().c_str(), 
		MpRectangle<short>(GetFrameTotalWidth()+copy_w+GetXPadding(),
				   GetFrameTotalWidth()+GetYPadding(),
				   Width()-2*GetFrameTotalWidth()-copy_w-GetXPadding(),
				   Height()-2*GetFrameTotalWidth()-GetYPadding()),
		GetFont(), 
		(state & in_pulldown) 
	          ? ((GetMode() & ~AlignMask) | AlignLeft | AlignVCenter) 
                  :  GetMode());

    } else if (state & icon_align_right) {
      PlaceText(Get().c_str(), 
		MpRectangle<short>(GetFrameTotalWidth()+GetXPadding(),
				   GetFrameTotalWidth()+GetYPadding(),
				   Width()-2*GetFrameTotalWidth()-copy_w-GetXPadding(),
				   Height()-2*GetFrameTotalWidth()-GetYPadding()),
		GetFont(), 
		(state & in_pulldown) 
	          ? ((GetMode() & ~AlignMask) | AlignLeft | AlignVCenter) 
                  :  GetMode());
    } // else text string is not drawn

  // no icon 
  } else {
    // In a pulldown menu the labels are always aligned left, otherwise
    // the aligment is not overwritten.
    PlaceText(Get().c_str(), 
	      GetXPadding() + GetFrameTotalWidth(), 
	      GetYPadding() + GetFrameTotalWidth(), 
              GetFont(), 
	      (state & in_pulldown) 
	        ? ((GetMode() & ~AlignMask) | AlignLeft | AlignVCenter) 
                :  GetMode());
  }
}