コード例 #1
0
// calcola dimensioni rettangolo testo groupbox
VOID SizeGroupText(PCTL pgb) {
   HPS hps = WinGetPS(pgb->hwnd);
   POINTL aptl[3];
   PSZ psz;
   pgb->wrtxt.cx = 0;
   // calculate text rectangle size
   if ((pgb->fl & DT_MNEMONIC) &&
       NULL != (psz = strchr(pgb->psz, '~'))) {
      if (psz - pgb->psz) {  // se la tilde non Š primo char
         GpiQueryTextBox(hps, psz - pgb->psz, pgb->psz, 3, aptl);
         pgb->wrtxt.cx = aptl[2].x - aptl[0].x;
      } // end if              se tilde non Š ultimo char
      if (pgb->cbtxt - (psz - pgb->psz) - 1) {
         GpiQueryTextBox(hps, pgb->cbtxt - (psz - pgb->psz) - 1,
                         psz + 1, 3, aptl);
         pgb->wrtxt.cx += aptl[2].x - aptl[0].x + 2;
      } /* endif */
      //pgb->wrtxt.cy = aptl[0].y - aptl[1].y;
   } else {
      GpiQueryTextBox(hps, pgb->cbtxt, pgb->psz, 3, aptl);
      //pgb->wrtxt.cy = aptl[0].y - aptl[1].y;
      pgb->wrtxt.cx = aptl[2].x - aptl[0].x + 2;
   } /* endif */
   WinReleasePS(hps);
} /* endif */
コード例 #2
0
//----------------------------------------------------------------------------
// Method: NewControl::paintWindow
//
// Description: 'paintWindow' is called in response to a paint event, 'evt'.
//              It establishes the colors to paint as well as determines
//              how large and where to draw the text.
//----------------------------------------------------------------------------
Boolean NewControl::paintWindow(IPaintEvent& evt)
   {
   IColor clrBackground(defclrBackground);
   IColor clrForeground(defclrForeground);
   IColor clrHilite(defclrHilite);

   IPresSpaceHandle hps = evt.presSpaceHandle();

   // Should make a separate method which sets the logical
   // color table for the HPS into RGB mode and sets all our
   // colors. Also, colors could be cached in private data
   // and only updated when presparams change.
   establishColor(clrBackground, background, defclrBackground);
   establishColor(clrForeground, foreground, defclrForeground);
   establishColor(clrHilite, hilite, defclrHilite);

   evt.clearBackground(clrBackground);

   // Create the text to draw
   IString theText(dummyText);
   IString theNumber(clicks);
   theNumber.rightJustify(4);
   IString both(theText + theNumber);

   POINTL aptl[TXTBOX_COUNT];
   POINTL ptl = {0,0};

   // Find where we're going to draw our text and how big it will be.
   GpiQueryTextBox(hps,
                   strlen((char*)both),
                   (char*)both,
                   TXTBOX_COUNT,
                   aptl);

   long textWidth = MAX(aptl[TXTBOX_TOPRIGHT].x,
                        aptl[TXTBOX_BOTTOMRIGHT].x);
   long textHeight = MAX(aptl[TXTBOX_TOPLEFT].y,
                         aptl[TXTBOX_TOPRIGHT].y);

   // Center the text before drawing it.
   long x = (cx - textWidth) / 2;
   long y = (cy - textHeight) / 2;

   evt.drawText(theText, IPoint(x, y), clrForeground);

   GpiQueryTextBox(hps,
                   strlen((char*)theText),
                   (char*)theText,
                   TXTBOX_COUNT,
                   aptl);

   // Draw the number to the side of the text
   x += aptl[TXTBOX_CONCAT].x;
   evt.drawText(theNumber, IPoint(x, y), clrHilite);

   return true;
   }
コード例 #3
0
 static USHORT setControlPos(HWND hwnd, USHORT x, USHORT y, USHORT ySize)
 {
    char   buffer[0x0100];
    POINTL aptl[TXTBOX_COUNT];
    HPS    hps;

    ULONG  flag        = SWP_SIZE;

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

    hps = WinGetPS(hwnd);

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

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

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

    return x+aptl[TXTBOX_TOPRIGHT].x;

 }
コード例 #4
0
void XText::GetTextBox(XGraphicDevice * dev, XRect * r)
{
   POINTL ptl[TXTBOX_COUNT];

   SetupDevice(dev);
   GpiQueryTextBox(dev->hps, text.GetLength(), (PSZ) (char*) text, TXTBOX_COUNT, ptl);
   r->SetX(ptl[TXTBOX_BOTTOMLEFT].x);
   r->SetWidth(ptl[TXTBOX_BOTTOMRIGHT].x - ptl[TXTBOX_BOTTOMLEFT].x);
   r->SetY(ptl[TXTBOX_BOTTOMLEFT].y);
   r->SetWidth(ptl[TXTBOX_TOPLEFT].y - ptl[TXTBOX_BOTTOMLEFT].y);
}
コード例 #5
0
void MyRenderWin::calcWinSize(MiniWin* win)
{
	char sampleString[64];

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

	const ULONG sampleLen = strlen(sampleString);

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

	POINTL aptl[TXTBOX_COUNT];

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

	ULONG x;
	ULONG y;

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

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

  WinReleasePS(hps);

  win->size(x + 6, y + 6);   // 2 border & 1 blank on each edge
}
コード例 #6
0
static void internal_GetStaticTextSize(HWND hwnd, ULONG ulID, int *piCX, int *piCY) {
	HPS hps;
	char achTemp[512];
	POINTL aptl[TXTBOX_COUNT];

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

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

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

	WinReleasePS(hps);
}
コード例 #7
0
ファイル: MSEMON2.C プロジェクト: OS2World/UTIL-MOUSE-MSE
static void SetMonitorSize (HWND hwnd,HWND hwndMenu,SWP *swpH,char *s) {

  HPS    hps;
  POINTL aptl[TXTBOX_COUNT];
  SWP    swp;
  ULONG  fl = SWP_SIZE | SWP_SHOW | SWP_MOVE;
  long   cx,cy;

  if(s) {
    WinSetWindowText(hwnd,s);
    if(*s) {
      hps = WinGetPS(hwnd);
      GpiQueryTextBox(hps,
                      strlen(s),
                      s,
                      TXTBOX_COUNT,
                      aptl);
      WinReleasePS(hps);
      cx = aptl[TXTBOX_TOPRIGHT].x + 4;
      cy = aptl[TXTBOX_TOPRIGHT].y + 4;
      WinQueryWindowPos(hwnd,
                        &swp);
      if(swp.cx == cx &&
         swp.cy == cy)
        fl = 0;
      if(swpH->x + cx > xScreen)
        swpH->x = xScreen - cx;
      if(swpH->y + cy > yScreen)
        swpH->y = yScreen - cy;
      if(fSwapFloat &&
         !hwndMenu)
        fl |= SWP_ZORDER;
      if(fl)
        WinSetWindowPos(hwnd,
                        HWND_TOP,
                        swpH->x,
                        swpH->y,
                        cx,
                        cy,
                        fl);
    }
  }
}
コード例 #8
0
ファイル: WaWEConfig.c プロジェクト: OS2World/MM-SOUND-WaWE
static void AddNotebookTab( HWND hwndNotebook, HWND hwndNotebookPage, USHORT usType, char *szTabText, char *szStatusText,
                            ULONG *pulPageID, unsigned short *pusTabTextLength, unsigned short *pusTabTextHeight )
{
  HPS hps;
  FONTMETRICS fmFontMetrics;
  POINTL aptlTabText[TXTBOX_COUNT];

  // Query dimensions of this tab text:
  hps = WinGetPS(hwndNotebook);
  memset(&fmFontMetrics, 0, sizeof(FONTMETRICS));
  if ((GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &fmFontMetrics)) &&
      (*pusTabTextHeight < fmFontMetrics.lMaxBaselineExt*2))
    *pusTabTextHeight = fmFontMetrics.lMaxBaselineExt*2;

  if ((GpiQueryTextBox(hps, strlen(szTabText), szTabText, TXTBOX_COUNT, aptlTabText)) &&
      (*pusTabTextLength < aptlTabText[TXTBOX_CONCAT].x))
    *pusTabTextLength = aptlTabText[TXTBOX_CONCAT].x;

  // Now add page
  *pulPageID = (ULONG) WinSendMsg( hwndNotebook,
                                 BKM_INSERTPAGE,
                                 0L,
                                 MPFROM2SHORT( (BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | usType ),
					       BKA_LAST ) );
  // And set text for it
  WinSendMsg( hwndNotebook,
              BKM_SETTABTEXT,
              MPFROMLONG( *pulPageID ),
              MPFROMP( szTabText ) );
  WinSendMsg( hwndNotebook,
              BKM_SETSTATUSLINETEXT,
              MPFROMLONG( *pulPageID ),
              MPFROMP( szStatusText ) );
  WinSendMsg(hwndNotebook,
             BKM_SETPAGEWINDOWHWND,
             MPFROMP(*pulPageID),
             MPFROMP(hwndNotebookPage));
}
コード例 #9
0
void PaintClient (HPS hps, SHORT cxClient, SHORT cyClient)
     {
     static CHAR szText [] = "Hello!" ;
     FONTMETRICS fm ;
     int         iPtHt, iPtWd ;
     POINTL      ptl, aptl[TXTBOX_COUNT] ;

          // Create the logical font, select it, and scale it

     CreateOutlineFont (hps, LCID_FONT, "Helvetica", 0, 0) ;
     GpiSetCharSet (hps, LCID_FONT) ;
     ScaleOutlineFont (hps, 120, 120) ;

          // Scale font to client window size

     GpiQueryTextBox (hps, strlen (szText), szText, TXTBOX_COUNT, aptl) ;

     iPtHt = (int) (120 * cyClient / (aptl[TXTBOX_TOPLEFT].y -
                                      aptl[TXTBOX_BOTTOMLEFT].y)) ;
     iPtWd = (int) (120 * cxClient /  aptl[TXTBOX_CONCAT].x) ;

     ScaleOutlineFont (hps, iPtHt, iPtWd) ;

          // Display the text string

     GpiQueryFontMetrics (hps, sizeof (FONTMETRICS), &fm) ;

     ptl.x = 0 ;
     ptl.y = cyClient - fm.lMaxAscender ;

     GpiCharStringAt (hps, &ptl, strlen (szText), szText) ;

          // Select the default font; delete the logical font

     GpiSetCharSet (hps, LCID_DEFAULT) ;
     GpiDeleteSetId (hps, LCID_FONT) ;
     }
コード例 #10
0
/*---------------------------------------------------------------------------*/
void paintText( HPS hps,WINDOWINFO *pwi,POBJECT pObj,RECTL *prcl, int iMode )
{
   int        iBreakCount, iSurplus ;
   PCHAR      pStart, pEnd ;
   PCHAR      pText;
   POINTL     ptlStart, aptlTextBox [TXTBOX_COUNT] ;
   blocktext *pT;
   RECTL      rclColumn;
   SIZEF      sizfx;
   FIXED      fxBreakExtra;
   int        iLineBreak;
   int        iLen;
   iSurplus = 0;


   pT = (blocktext *)pObj;

   if (iMode != MODE_PREPPRINTING)
   {
      if (pwi->usdrawlayer != pT->bt.usLayer)
         return;
   }
   /*
   ** Just in case the text starts with a linebreak...
   */
   memset ((void *)aptlTextBox,0,( sizeof(POINTL) * TXTBOX_COUNT)); 
   /*
   ** Get column rectangle of first column..
   */
   getColumnOutline(pT,&rclColumn,pwi,0,(BOOL)(iMode == MODE_PREPPRINTING));

   pText = (PCHAR)pT->pszText;
     
   ptlStart.y = rclColumn.yTop ;

   if (!pText)
      return;

   if (prcl)
   {
      RECTL rclDest;
      /*
      ** prcl is only true for screen operations!
      ** For this moment we only check on the first column
      ** TODO !!! All columns
      */
      if (!WinIntersectRect(hab,&rclDest,prcl,&rclColumn))
         return;
   }

   if (iMode == MODE_PREPPRINTING)
   {
      sizfx.cx = pT->sizfx.fcx * pwi->usWidth;
      sizfx.cy = pT->sizfx.fcy * pwi->usHeight;
   }
   else
   {
      sizfx.cx = pT->sizfx.fcx * pwi->usFormWidth;
      sizfx.cy = pT->sizfx.fcy * pwi->usFormHeight;
   }

   setFont(pwi,&pT->fattrs,sizfx);

   if (iMode == MODE_PREPPRINTING)
      GpiQueryWidthTable(pwi->hps,0,MAX_NRWIDTH,pObj->lWidth);

  if (paintColumn(hps,pwi,pObj,rclColumn,iMode))
  {
     rclColumn.xLeft   += 20;
     rclColumn.yBottom += 20;
     rclColumn.xRight  -= 20;
     rclColumn.yTop    -= 20;
  }

   if (iMode != MODE_OUTLINE)
      GpiSetColor(hps,pT->bt.fColor);

   if (pwi->bPrinter)
   {
      /*
      ** Set the text on paper and get out!!
      */
      PrintBlockText(pObj,pwi);
      return;
   }


   do                                 // until end of text
   {
          iBreakCount  = 0;
          fxBreakExtra = 0;
          iLineBreak   = 0;

          while (*pText == ' ')         // Skip over leading blanks
               pText++ ;

          pStart = pText ;

          do                            // until line is known
               {
               iLineBreak   = 0;

               while (*pText == ' ')    // Skip over leading blanks
                    pText++ ;

                                        // Find next break point

               while (*pText != '\x00' && *pText != ' ' && 
                      *pText != '\r' && *pText != '\n')
                    pText++ ;

               if (*pText == '\r'|| *pText == '\n')
               {
                  pText++;
                  iLineBreak = 1;
                  if (*pText == '\n' || *pText == '\r')
                  {
                     pText++;
                     iLineBreak = 2;
                  }
               }
               /*
               ** A line with only a cariage return linefeed?
               */
               if ( ((pText - pStart) - iLineBreak) <= 0)
               {
                  pEnd  = pText ;
                  break;
               }
                                        // Determine text width

               GpiQueryTextBox (hps, (pText - pStart) - iLineBreak, pStart,
                                TXTBOX_COUNT, aptlTextBox) ;

                         // Normal case: text less wide than column

               if (aptlTextBox[TXTBOX_CONCAT].x < (rclColumn.xRight - rclColumn.xLeft))
                    {
                    iBreakCount++ ;
                    pEnd  = pText;
                    }

                         // Text wider than window with only one word

               else if (iBreakCount == 0)
                    {
                    pEnd  = pText ;
                    break ;
                    }

                         // Text wider than window, so fix up and get out
               else
                    {
                    iBreakCount-- ;
                    pText = pEnd ;
                    /*
                    ** Although we could have found a line break the
                    ** text did not fit the line at all. So...
                    */
                    iLineBreak = 0;
                    break ;
                    }
               }
          while (*pText != '\x00' && !iLineBreak) ;

                         // Get the final text box

          iLen = (int)(pEnd - pStart);
          if (iLen - iLineBreak > 0)
             GpiQueryTextBox (hps, (pEnd - pStart)-iLineBreak, pStart,
                              TXTBOX_COUNT, aptlTextBox) ;

                         // Drop down by maximum ascender

          ptlStart.y -= aptlTextBox[TXTBOX_TOPLEFT].y ;

                         // Find surplus space in text line

          iSurplus = rclColumn.xRight - rclColumn.xLeft -
                     aptlTextBox[TXTBOX_CONCAT].x ;

                        // Adjust starting position and
                        // space and character spacing

          switch (pT->nAlign)
               {
               case ALIGN_LEFT:
                    ptlStart.x = rclColumn.xLeft ;
                    break ;

               case ALIGN_RIGHT:
                    ptlStart.x = rclColumn.xLeft + iSurplus ;
                    break ;

               case ALIGN_CENTER:
                    ptlStart.x = rclColumn.xLeft + iSurplus / 2 ;
                    break ;

               case ALIGN_JUST:
                    ptlStart.x = rclColumn.xLeft ;

                    if (*pText == '\x00')
                         break ;

                    if (iBreakCount > 0)
                    {
                         fxBreakExtra = 65536 * iSurplus / iBreakCount;
                         GpiSetCharBreakExtra (hps,fxBreakExtra);
                    }
                    else if (pEnd - pStart - 1 > 0)
                    {
                         fxBreakExtra = 65536 * iSurplus / (pEnd - pStart - 1 - iLineBreak);
                         GpiSetCharExtra (hps,fxBreakExtra);
                    }
                    break ;
               }

                         // Drop down by maximum descender

          if (pT->nSpace != SPACE_NONE)
             ptlStart.y += aptlTextBox[TXTBOX_BOTTOMLEFT].y ;

                         // Display the string & return to normal
          if ((pEnd - pStart))
             GpiCharStringAt (hps, &ptlStart, (pEnd - pStart ) - iLineBreak, pStart) ;

          if (iMode == MODE_PREPPRINTING)
          {
             bTextMakePrintBlock(pObj,
                                 pwi,
                                 fxBreakExtra,
                                 iBreakCount,
                                 ptlStart,
                                 (LONG)((pEnd - pStart) -iLineBreak),
                                 pStart);
          }
          GpiSetCharExtra (hps, 0) ;
          GpiSetCharBreakExtra (hps, 0) ;

                         // Do additional line-spacing

          switch (pT->nSpace)
               {
               case SPACE_HALF:
                    ptlStart.y -= (aptlTextBox[TXTBOX_TOPLEFT].y -
                                   aptlTextBox[TXTBOX_BOTTOMLEFT].y) / 2 ;
                    break ;

               case SPACE_DOUBLE:
                    ptlStart.y -= aptlTextBox[TXTBOX_TOPLEFT].y -
                                  aptlTextBox[TXTBOX_BOTTOMLEFT].y ;
                    break ;
               }
          }

     while (*pText != '\x00' && ptlStart.y > rclColumn.yBottom) ;
}
コード例 #11
0
ファイル: DMLB.C プロジェクト: OS2World/DEV-SAMPLES-PM-mclb
/*----------------------------------------------------------------------*/
SHORT DMLBLocateListboxItem( HWND hwnd, HWND RelHwnd, SHORT Y, SHORT Option )
/*----------------------------------------------------------------------*/
/* Parameters:                                                          */
/*   hwnd         Listbox of interest                                   */
/*   RelHwnd      Window to which Y is relative to                      */
/*   Y            Y position of the pointer                             */
/*   Option       LLI_UNDER to return index of item under pointer,      */
/*                LLI_INSERTPOINT to index of item nearest insert point */
/*----------------------------------------------------------------------*/
/* Given a Y window coordinate, this function will calculate the item   */
/* number of the listbox item at that position.  The LLI_UNDER option   */
/* will return the item directly under the pointer.  The LLI_INSERTPOINT*/
/* option will return the item number *before* which an insertion should*/
/* be made (drop zones are calculated as the half-way points through    */
/* each item).                                                          */
/*----------------------------------------------------------------------*/
{
   RECTL   Rect;
   POINTL  Points[2];
   HPS     hps;
   LONG    VertSize;
   SHORT   ItemNum;
   char    ClassName[10];

   /* Map coordinate from window it is relative to, to win of interst*/
   Points[0].x = 0;
   Points[0].y = Y;
   WinMapWindowPoints(RelHwnd, hwnd, &(Points[0]), 1L);
   Y = Points[0].y;

   /* If this is actually a MultiColumn ListBox, we must find the    */
   /* real listbox which is the first column and use it for our      */
   /* location calculations.  Since we only care about the Y         */
   /* coordinate we only need to look at the 1st column of the MCLB. */

   WinQueryClassName(hwnd, sizeof(ClassName), ClassName);
   if (!strcmp("MCLBCls", ClassName))
     hwnd = WinWindowFromID(hwnd, 1);   /* Get handle of 1st column's listbox */

   /* If this is an OWNERDRAW listbox, ask owner how big items are.  */

   VertSize = 0;
   if (WinQueryWindowULong(hwnd, QWL_STYLE) & LS_OWNERDRAW)
     VertSize = SHORT1FROMMR(                               // Take returned Height
                WinSendMsg(WinQueryWindow(hwnd, QW_OWNER),  // Query owner of listbox
                   WM_MEASUREITEM,                          // Ask owner the size
                   MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),  // Listbox ID
                   MPFROMSHORT(0)));                        // First item

   if (VertSize == 0) {
     /* For a normal listbox, items are the size of the font.  To */
     /* determine the size we get the bounding box of a space.    */
     hps = WinGetPS(hwnd);
     GpiQueryTextBox(hps, 1L, " ", 2, Points);
     VertSize = Points[TXTBOX_TOPLEFT].y - Points[TXTBOX_BOTTOMLEFT].y;
     WinReleasePS(hps);
   }

   WinQueryWindowRect(hwnd, &Rect);
   Rect.yTop = Rect.yTop-2;         /* Listbox frame is 2 pixels */

   /* Calculate item number of item under the pointer */
   ItemNum = (SHORT)WinSendMsg(hwnd, LM_QUERYTOPINDEX, 0L, 0L)
             + ((Rect.yTop-Y)/VertSize);

   /* Return item under pointer, or insertion point */

   switch (Option) {
     case LLI_UNDER:
       return ItemNum;
     case LLI_INSERTPOINT:
       if (((Rect.yTop-Y) % VertSize) <= (VertSize / 2))
         return ItemNum;
       return ItemNum+1;  /* Note: May exceed num of items in list */
   }
}
コード例 #12
0
ファイル: os2nb.c プロジェクト: ErisBlastar/osfree
//  SET THE DIMENSIONS OF THE NOTEBOOK TABS. 
BOOL SetTabDimensions(PNBHDR pNotebookHdr)
{
	HWND hwndNB = pNotebookHdr->hwndNB;
	HPS hps = WinGetPS(hwndNB);
	FONTMETRICS fm;
	POINTL aptl[TXTBOX_COUNT];
	INT i, iSize, iLongestMajText = 0, iLongestMinText = 0;

	if (!hps)
		return FALSE;

	memset(&fm, 0, sizeof(FONTMETRICS));

	// Calculate the height of a tab as the height of an average font character
	// plus a margin value.
	if (GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &fm))
		fm.lMaxBaselineExt += (TAB_HEIGHT_MARGIN * 2);
	else
		fm.lMaxBaselineExt = DEFAULT_NB_TAB_HEIGHT + (TAB_HEIGHT_MARGIN * 2);

	// Calculate the longest tab text for both the MAJOR and MINOR pages
	for (i = 0; i < pNotebookHdr->nPages; i++) {
	
		if (!GpiQueryTextBox(hps, strlen(pNotebookHdr->PageArray[i].pszTabText), pNotebookHdr->PageArray[i].pszTabText, TXTBOX_COUNT, aptl))
			iSize = 0;
		else
			iSize = aptl[TXTBOX_CONCAT].x;

		if (pNotebookHdr->PageArray[i].usTabType == BKA_MAJOR) {
			if (iSize > iLongestMajText)
				iLongestMajText = iSize;
		} else {
			if (iSize > iLongestMinText)
				iLongestMinText = iSize;
		}
	}

	WinReleasePS(hps);

	// Add a margin amount to the longest tab text

	if (iLongestMajText)
		iLongestMajText += TAB_WIDTH_MARGIN;

	if (iLongestMinText)
		iLongestMinText += TAB_WIDTH_MARGIN;

	// Set the tab dimensions for the MAJOR and MINOR pages. Note that the
	// docs as of this writing say to use BKA_MAJOR and BKA_MINOR in mp2 but
	// you really need BKA_MAJORTAB and BKA_MINORTAB.

	if (iLongestMajText) {
		if (!WinSendMsg(hwndNB, BKM_SETDIMENSIONS, MPFROM2SHORT(iLongestMajText, (SHORT)fm.lMaxBaselineExt), MPFROMSHORT(BKA_MAJORTAB)))
			return FALSE;
	}

	// If no minor tab text, set dimensions to 0
	if (!WinSendMsg(hwndNB, BKM_SETDIMENSIONS, (iLongestMinText ? MPFROM2SHORT(iLongestMinText, (SHORT)fm.lMaxBaselineExt) : MP0), MPFROMSHORT(BKA_MINORTAB)))
		return FALSE;

	return TRUE;
}
コード例 #13
0
bool PaintButton( VRIconButton *somSelf, PUSERBUTTON pbtn )
{
    FONTMETRICS fm;
    HAB    hab;
    RECTL  rcl,
           rclTxt,
           rclImg;
    POINTL ptl,
           aptl[ TXTBOX_COUNT ];
    LONG   lFlags,
           flPic,
           flTxt,
           lStrW,
           lStrH,
           lOffset,
           lClr;
    ULONG  cb;
    BOOL   fPosition;

//FILE *f = fopen("c:\\iconbtn.log", "a");

    VRIconButtonData *somThis = VRIconButtonGetData(somSelf);
    lFlags = _vrGetWindowFlags( somSelf );

//fprintf(f, "----[ Entering PaintButton ] ----\n");

    if ( !pbtn || ( ! WinQueryWindowRect( pbtn->hwnd, &rcl )))
        return FALSE;

    // Get the current background colour
    cb = WinQueryPresParam( pbtn->hwnd, PP_BACKGROUNDCOLOR,
                            PP_BACKGROUNDCOLORINDEX, NULL,
                            sizeof( lClr ), &lClr, QPF_ID2COLORINDEX );
    if ( cb )
        GpiCreateLogColorTable( pbtn->hps, 0, LCOLF_RGB, 0, 0, NULL );
    else
        lClr = GpiQueryRGBColor( pbtn->hps, 0, SYSCLR_BUTTONMIDDLE );

    // Fill in the button background
    WinFillRect( pbtn->hps, &rcl, lClr );

    ptl.x = rcl.xLeft;
    ptl.y = rcl.yBottom;
    GpiMove( pbtn->hps, &ptl );
    ptl.x = rcl.xRight - 1;
    ptl.y = rcl.yTop - 1;
    // Draw the "default" state outline if applicable
    if ( pbtn->fsState & BDS_DEFAULT ) {
        GpiSetColor( pbtn->hps, SYSCLR_BUTTONDEFAULT );
        GpiBox( pbtn->hps, DRO_OUTLINE, &ptl, 0, 0 );
    }
    else {
        cb = WinQueryPresParam( WinQueryWindow( pbtn->hwnd, QW_PARENT ),
                                PP_BACKGROUNDCOLOR, PP_BACKGROUNDCOLORINDEX,
                                NULL, sizeof( lClr ), &lClr, QPF_ID2COLORINDEX );
        if ( cb )
            GpiSetColor( pbtn->hps, lClr );
        else
            GpiSetColor( pbtn->hps, SYSCLR_DIALOGBACKGROUND );
        GpiBox( pbtn->hps, DRO_OUTLINE, &ptl, 0, 0 );
    }

    if ( !( lFlags & BS_NOBORDER )) {
        /* Draw the button border (if appropriate) depending on the current
         * state(s).
         */
        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                CLR_BLACK: SYSCLR_BUTTONDARK );
        ptl.x = rcl.xLeft + 1;
        ptl.y = rcl.yBottom + 2;
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 2;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 2;
        GpiLine( pbtn->hps, &ptl );
        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                SYSCLR_BUTTONDARK: CLR_BLACK );
        ptl.x = rcl.xLeft + 1;
        ptl.y = rcl.yBottom + 1;
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 2;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 3;
        GpiLine( pbtn->hps, &ptl );

        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                SYSCLR_BUTTONLIGHT: SYSCLR_BUTTONDARK );
        ptl.x = rcl.xLeft + 2;
        ptl.y = rcl.yBottom + 2;
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 3;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 3;
        GpiLine( pbtn->hps, &ptl );
        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                SYSCLR_BUTTONDARK: SYSCLR_BUTTONLIGHT );
        ptl.x = rcl.xLeft + 2;
        ptl.y = rcl.yBottom + 3;
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 3;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 3;
        GpiLine( pbtn->hps, &ptl );

        if ( pbtn->fsState & BDS_HILITED ) {
            GpiSetColor( pbtn->hps, SYSCLR_BUTTONLIGHT );
            ptl.x = rcl.xLeft + 3;
            ptl.y = rcl.yBottom + 3;
            GpiMove( pbtn->hps, &ptl );
            ptl.x = rcl.xRight - 4;
            GpiLine( pbtn->hps, &ptl );
            GpiMove( pbtn->hps, &ptl );
            ptl.y = rcl.yTop - 4;
            GpiLine( pbtn->hps, &ptl );
            GpiSetColor( pbtn->hps, SYSCLR_BUTTONDARK );
            ptl.x = rcl.xLeft + 3;
            ptl.y = rcl.yBottom + 4;
            GpiMove( pbtn->hps, &ptl );
            ptl.y = rcl.yTop - 4;
            GpiLine( pbtn->hps, &ptl );
            GpiMove( pbtn->hps, &ptl );
            ptl.x = rcl.xRight - 4;
            GpiLine( pbtn->hps, &ptl );
        }

    } // if ( !( lFlags & BS_NOBORDER ))

    /* After this point, rcl is used for the clipping boundaries of the entire
     * button contents exclusive of the border.  Separate bounding rectangles
     * for the image and the text will now be calculated within this area.
     */
    if ( rcl.xRight > 6 ) {
        rcl.xLeft += 3;
        rcl.xRight -= 3;
    }
    if ( rcl.yTop > 6 ) {
        rcl.yBottom += 3;
        rcl.yTop -= 3;
    }
    memcpy( &rclTxt, &rcl, sizeof( RECTL ));
    if ( RECTL_WIDTH( rclTxt ) > 4 ) {
        rclTxt.xLeft += 2;
        rclTxt.xRight -= 2;
    }
    if ( RECTL_WIDTH( rclTxt ) > 4 ) {
        rclTxt.yBottom += 2;
        rclTxt.yTop -= 2;
    }
    if ( _pPic && ( _pPic->type & MEMP_BITMAP ) && _fResize )
        memcpy( &rclImg, &rcl, sizeof( RECTL ));
    else {
        rclImg.xLeft   = ( RECTL_WIDTH( rclTxt ) > 6 )  ?
                         rclTxt.xLeft + 3   : rclTxt.xLeft;
        rclImg.xRight  = ( RECTL_WIDTH( rclTxt ) > 6 )  ?
                         rclTxt.xRight - 3  : rclTxt.xRight;
        rclImg.yBottom = ( RECTL_HEIGHT( rclTxt ) > 6 ) ?
                         rclTxt.yBottom + 3 : rclTxt.yBottom;
        rclImg.yTop    = ( RECTL_HEIGHT( rclTxt ) > 6 ) ?
                         rclTxt.yTop - 3    : rclTxt.yTop;
    }

//fprintf(f, "rcl     = {%d %d %d %d}, width = %d, height= %d\n", rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop, RECTL_WIDTH(rcl), RECTL_HEIGHT(rcl) );
//fprintf(f, "rclImg  = {%d %d %d %d}, width = %d, height= %d\n", rclImg.xLeft, rclImg.yBottom, rclImg.xRight, rclImg.yTop, RECTL_WIDTH(rclImg), RECTL_HEIGHT(rclImg) );

    fPosition = _pPic && ( !_fResize || _pPic->type & MEMP_ICON ) &&
                (( _bAlign == ALIGN_LEFT ) || ( _bAlign == ALIGN_RIGHT )) ?
                TRUE : FALSE;

    /* We won't draw the text until after the image... but unless we're scaling
     * the image into the whole button, we need to calculate how much space the
     * text is going to require so we can fit the image next to it.  (Note that
     * we behave differently for top/bottom alignment vs left/right alignment -
     * with top/bottom, the text area is fixed to the height of the string plus
     * a certain margin.  With left/right alignment, the image rectangle is set
     * to the physical image size, and the text rectangle is offset from that.)
     */
    lStrW = 0;
    lStrH = 0;
    GpiQueryFontMetrics( pbtn->hps, sizeof( FONTMETRICS ), &fm );
    if ( _pszText && *_pszText ) {

        // Get the width of the text as it would be rendered in the current font
        GpiQueryTextBox( pbtn->hps, strlen( _pszText ),
                         _pszText, TXTBOX_COUNT, aptl );

        lStrW = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x;
        lStrW += ( 2 * fm.lAveCharWidth );
        lStrH = fm.lMaxBaselineExt + fm.lInternalLeading + fm.lMaxDescender;

        // Adjust the bounding rectangles for the text and image
        switch ( _bAlign ) {
            case ALIGN_TOP:
                rclTxt.yBottom = rclTxt.yTop - lStrH;
                if ( _pPic && ( !_fResize || _pPic->type & MEMP_ICON )) {
                    if (( rclTxt.yBottom - rclImg.yBottom ) > _pPic->height )
                        rclImg.yTop = rclTxt.yBottom - 1;
                    else if (( rcl.yTop - rclImg.yBottom ) > _pPic->height )
                        rclImg.yTop = rcl.yBottom + _pPic->height;
                }
                break;
            case ALIGN_BOTTOM:
                rclTxt.yTop = rclTxt.yBottom + lStrH;
                if ( _pPic && ( !_fResize || _pPic->type & MEMP_ICON )) {
                    if ((( rclImg.yTop - rclTxt.yTop ) > _pPic->height ))
                        rclImg.yBottom = rclTxt.yTop + 1;
                    else if (( rclImg.yTop - rcl.yBottom ) > _pPic->height )
                        rclImg.yBottom = (LONG) ( rcl.yTop - _pPic->height );
                }
                break;
            case ALIGN_LEFT:
                if ( fPosition ) {
                    if (( rclTxt.xLeft + lStrW + _pPic->width ) < rclImg.xRight ) {
                        rclImg.xLeft = rclImg.xRight - _pPic->width;
                        rclTxt.xRight = rclImg.xLeft - 1;
                    }
                    else  {
                        rclTxt.xRight = rclTxt.xLeft + lStrW;
                        if (( rclImg.xRight - _pPic->width ) < RECTL_WIDTH( rcl ))
                            rclImg.xLeft = (LONG) ( rclImg.xRight - _pPic->width );
                    }
                }
                else
                    rclTxt.xRight = rclTxt.xLeft + lStrW;
                break;
            case ALIGN_RIGHT:
                if ( fPosition ) {
                    if (( rclImg.xLeft + _pPic->width + lStrW ) < rclImg.xRight ) {
                        rclImg.xRight = rclImg.xLeft + _pPic->width;
                        rclTxt.xLeft = rclImg.xRight + 1;
                    }
                    else {
                        rclTxt.xLeft = rclTxt.xRight - lStrW;
                        if (( rclImg.xLeft + _pPic->width ) < RECTL_WIDTH( rcl ))
                            rclImg.xRight = rclImg.xLeft + _pPic->width;
                    }
                }
                else
                    rclTxt.xLeft = rclTxt.xRight - lStrW;
                break;
            default: break;   // ALIGN_CENTER, no adjustment needed
        }
        if ( rclTxt.yBottom < rcl.yBottom ) rclTxt.yBottom = rcl.yBottom;
        if ( rclTxt.yTop > rcl.yTop ) rclTxt.yTop = rcl.yTop;
        if ( rclTxt.xLeft < rcl.xLeft ) rclTxt.xLeft = rcl.xLeft;
        if ( rclTxt.xRight > rcl.xRight ) rclTxt.xRight = rcl.xRight;
    }

    // Draw the image, if one is defined
    if ( _pPic ) {

        if (( pbtn->fsState & BDS_HILITED ) &&
            !( _fResize && ( _pPic->type & MEMP_BITMAP )))
        {
            rclImg.xLeft++;
            rclImg.xRight++;
            rclImg.yBottom--;
            rclImg.yTop--;
        }

        flPic = PICTDRAW_CENTER_ICON;
        if ( pbtn->fsState & BDS_DISABLED ) flPic |= PICTDRAW_DISABLE;
        if ( _pPic->type & MEMP_BITMAP ) {
            if ( _fResize )
                flPic |= PICTDRAW_STRETCH_BITMAP;
            else {
                ptl.x = ((LONG)( RECTL_WIDTH( rclImg ) - _pPic->width ) / 2 );
                ptl.y = ((LONG)( RECTL_HEIGHT( rclImg ) - _pPic->height ) / 2 );
                if ( ptl.x > 0 ) rclImg.xLeft += ptl.x;
                if ( ptl.y > 0 ) rclImg.yBottom += ptl.y;
            }
        }

        VRPictDisplay( pbtn->hwnd, pbtn->hps, _pPic, &rclImg, flPic );
    }

    // Now draw the text, if any
    if ( _pszText && *_pszText ) {

        // Get the current foreground colour
        if ( pbtn->fsState & BDS_DISABLED )
            lClr = GpiQueryRGBColor( pbtn->hps, 0, SYSCLR_MENUDISABLEDTEXT );
        else {
            cb = WinQueryPresParam( pbtn->hwnd, PP_FOREGROUNDCOLOR,
                                    PP_FOREGROUNDCOLORINDEX, NULL,
                                    sizeof( lClr ), &lClr, QPF_ID2COLORINDEX );
            if ( !cb )
                lClr = GpiQueryRGBColor( pbtn->hps, 0, SYSCLR_WINDOWTEXT );
        }
        GpiSetColor( pbtn->hps, lClr );

        // Now position and draw the button text
        switch ( _bAlign ) {

            case ALIGN_TOP:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + ( RECTL_WIDTH( rclTxt ) / 2 );
                ptl.y = ( RECTL_HEIGHT( rclTxt ) < lStrH ) ? rclTxt.yTop :
                        rclTxt.yTop - ( 2 * fm.lInternalLeading );
                GpiSetTextAlignment( pbtn->hps, TA_CENTER, TA_TOP );
#else
                flTxt = DT_CENTER | (( RECTL_HEIGHT( rclTxt ) < lStrH )
                                    ? DT_TOP : DT_VCENTER ) |
                        DT_TEXTATTRS | DT_MNEMONIC;
#endif
                break;

            case ALIGN_BOTTOM:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + ( RECTL_WIDTH( rclTxt ) / 2 );
                ptl.y = ( RECTL_HEIGHT( rclTxt ) < lStrH ) ? rclTxt.yBottom :
                        rclTxt.yBottom + ( 2 * fm.lInternalLeading );
                GpiSetTextAlignment( pbtn->hps, TA_CENTER, TA_BOTTOM );
#else
                flTxt = DT_CENTER | (( RECTL_HEIGHT( rclTxt ) < lStrH ) ?
                                    DT_BOTTOM : DT_VCENTER ) |
                        DT_TEXTATTRS | DT_MNEMONIC;
#endif
                break;

            case ALIGN_LEFT:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + fm.lAveCharWidth;
                ptl.y = rclTxt.yBottom + (( RECTL_HEIGHT( rclTxt ) - fm.lXHeight ) / 2 );
                GpiSetTextAlignment( pbtn->hps, TA_NORMAL_HORIZ, TA_BASE );
#else
                flTxt = DT_LEFT | DT_VCENTER | DT_TEXTATTRS | DT_MNEMONIC;
                rclTxt.xLeft += fm.lAveCharWidth;
#endif
                break;

            case ALIGN_RIGHT:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + fm.lAveCharWidth;
                ptl.y = rclTxt.yBottom + (( RECTL_HEIGHT( rclTxt ) - fm.lXHeight ) / 2 );
                GpiSetTextAlignment( pbtn->hps, TA_NORMAL_HORIZ, TA_BASE );
#else
                flTxt = (fPosition? DT_LEFT: DT_RIGHT) | DT_VCENTER | DT_TEXTATTRS | DT_MNEMONIC;
                if ( RECTL_WIDTH( rclTxt ) > fm.lAveCharWidth ) {
                    if ( fPosition )
                        rclTxt.xLeft += fm.lAveCharWidth;
                    else
                        rclTxt.xRight -= fm.lAveCharWidth;
                }
#endif
                break;

            default:    // ALIGN_CENTER
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + ( RECTL_WIDTH( rclTxt ) / 2 );
                ptl.y = rclTxt.yBottom + (( RECTL_HEIGHT( rclTxt ) - fm.lXHeight ) / 2 );
                GpiSetTextAlignment( pbtn->hps, TA_CENTER, TA_BASE );
#else
                flTxt = DT_CENTER | DT_VCENTER | DT_TEXTATTRS | DT_MNEMONIC;
#endif
                break;
        }
        if ( pbtn->fsState & BDS_HILITED ) {
            ptl.x++;
            ptl.y--;
        }
        cb = strlen( _pszText );
#ifdef GPI_DRAWTEXT
        GpiCharStringPosAt( pbtn->hps, &ptl, &rclTxt, CHS_CLIP, cb, _pszText, NULL );
#else
        WinDrawText( pbtn->hps, cb, _pszText, &rclTxt, 0, 0, flTxt );
#endif
    }

//fprintf(f, "----[ Leaving PaintButton ] ----\n\n");
//fclose(f);

    return TRUE;
}
コード例 #14
0
void SetAutoSize( VRIconButton *somSelf )
{
    FONTMETRICS fm;
    HWND   hwnd;
    HPS    hps;
    POINTL aptl[ TXTBOX_COUNT ];
    LONG   lMinW = 8,   // We always require border+margin of at least 8 pixels
           lMinH = 8,
           lStrW = 0,
           lStrH = 0;

    VRIconButtonData *somThis = VRIconButtonGetData(somSelf);
    hwnd = _vrGetWindowHandle( somSelf );

    if ( _pszText && *_pszText ) {

        // Get the required size for the text string
        hps = WinGetPS( hwnd );
        GpiQueryFontMetrics( hps, sizeof( FONTMETRICS ), &fm );
        GpiQueryTextBox( hps, strlen( _pszText ),
                         _pszText, TXTBOX_COUNT, aptl );
        WinReleasePS( hps );
        lStrW = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x;
        lStrW += ( 2 * fm.lAveCharWidth );
        lStrH = fm.lMaxBaselineExt + fm.lInternalLeading + fm.lMaxDescender;

        // We have an image as well as text
        if ( _pPic && ( !_fResize || ( _pPic->type & MEMP_ICON ))) {
            switch ( _bAlign ) {
                case ALIGN_LEFT:
                case ALIGN_RIGHT:
                    lMinW += _pPic->width + lStrW + 7;
                    lMinH += max( _pPic->height + 6, lStrH );
                    break;

                case ALIGN_TOP:
                case ALIGN_BOTTOM:
                    lMinW += max( _pPic->width + 6, lStrW );
                    lMinH += _pPic->height + lStrH + 7;
                    break;

                default:    // ALIGN_CENTER
                    lMinW += max( _pPic->width + 6, lStrW );
                    lMinH += max( _pPic->height + 6, lStrH );
                    break;
            }
        }

        // We have only text (or if there is an image, it's auto-scaled)
        else {
            lMinW += lStrW;
            lMinH += lStrH;
        }
    }
    else if ( _pPic ) {
        // Image (non-rescaled) only
        lMinW += _pPic->width + 6;
        lMinH += _pPic->height + 6;
    }

    WinSetWindowPos( hwnd, NULLHANDLE, 0, 0, lMinW, lMinH, SWP_SIZE );
}
コード例 #15
0
BOOL SetUpPage( HPS hps, PPAGECONSTANTS pPgConsts, int *pcxTab, int *pcxPage,
                int *pcyPage )
{
    BOOL      fSuccess = TRUE;
    ULONG     ulPageId;
    PPAGEDATA pPageData;

    // Insert a page into the notebook. Specify that it is to have status text
    // and the window associated with each page will be automatically sized by
    // the notebook according to the size of the page.

    ulPageId = (ULONG) WinSendMsg( hwndBook, BKM_INSERTPAGE, NULL,
                                   MPFROM2SHORT( BKA_MAJOR | BKA_STATUSTEXTON |
                                   BKA_AUTOPAGESIZE, BKA_LAST ) );

    if( ulPageId )
    {
        POINTL aptl[ TXTBOX_COUNT ];

        pPageData = (PPAGEDATA) malloc( sizeof( PAGEDATA ) );

        if( pPageData )
        {
            memset( pPageData, 0, sizeof *pPageData );
            pPageData->cb       = sizeof *pPageData;
            pPageData->pfnwpDlg = pPgConsts->pfnwpDlg;
            pPageData->idDlg    = pPgConsts->idDlg;
            pPageData->idPage   = pPgConsts->idPage;

            // Insert a pointer to this page's info into the space available
            // in each page (its PAGE DATA that is available to the application).

            fSuccess = (BOOL) WinSendMsg( hwndBook, BKM_SETPAGEDATA,
                                          MPFROMLONG( ulPageId ),
                                          MPFROMP( pPageData ) );

            // Set the text into the status line.

            if( fSuccess )
            {
                fSuccess = (BOOL) WinSendMsg( hwndBook, BKM_SETSTATUSLINETEXT,
                                       MPFROMP( ulPageId ),
                                       MPFROMP( pPgConsts->szStatusLineText ) );

                if( fSuccess )
                    fSuccess = (BOOL) WinSendMsg( hwndBook, BKM_SETTABTEXT,
                                       MPFROMP( ulPageId ),
                                       MPFROMP( pPgConsts->szTabText ) );

                else
                    Msg( "BKM_SETSTATUSLINETEXT RC(%X)", HWNDERR( hwndBook ) );
            }
            else
                Msg( "BKM_SETPAGEDATA RC(%X)", HWNDERR( hwndBook ) );

            if( fSuccess )
            {
                // Get the size, in pixels, of the tab text for this page. If
                // it is longer than the currently longest text, set it as the
                // new longest text.

                if( GpiQueryTextBox( hps, strlen( pPgConsts->szTabText ),
                                   pPgConsts->szTabText, TXTBOX_COUNT, aptl ) )
                {
                    if( aptl[ TXTBOX_CONCAT ].x > *pcxTab )
                        *pcxTab = aptl[ TXTBOX_CONCAT ].x;
                }
                else
                {
                    fSuccess = FALSE;
                    Msg( "SetUpPage GpiQueryTextBox RC(%X)", HWNDERR( hwndBook ) );
                }
            }
        }
        else
        {
            fSuccess = FALSE;
            Msg( "Out of memory in SetUpPage!" );
        }
    }
    else
    {
        fSuccess = FALSE;
        Msg( "SetUpPage BKM_INSERTPAGE RC(%X)", HWNDERR( hwndBook ) );
    }

    if( fSuccess )
    {
        LONG cx, cy;

        // Keep an ongoing count of the widest and tallest dialog
        // dimensions needed for an optimal notebook size.

        if( GetDialogDimensions( pPgConsts->idDlg, &cx, &cy ) )
        {
            if( cx > *pcxPage )
                *pcxPage = cx;
            if( cy > *pcyPage )
                *pcyPage = cy;
        }
    }

    return fSuccess;
}
コード例 #16
0
static MRESULT EXPENTRY launchPadWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  WPFolder* thisPtr;
  launchPad * lp;
  LPObject *lpo;
  static USHORT id=0;//Initialisation new in V1.00a 

  switch(msg)
    {
#if 0
    case DM_ENDCONVERSATION:
    case DM_DRAGFILECOMPLETE:
    case DM_DROPNOTIFY:
    case DM_FILERENDERED:
    case DM_RENDERCOMPLETE:

break;
      return (MRESULT)FALSE;
    case WM_ENDDRAG:

      break;
      return (MRESULT)TRUE;
#endif
    case WM_PAINT:
      {
      RECTL rcl;
      launchPad * lp;

      HPS hps=WinBeginPaint(hwnd,NULLHANDLE, &rcl);
      WinFillRect(hps, &rcl, SYSCLR_DIALOGBACKGROUND);
      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()==0) {
          WinQueryWindowRect(hwnd,&rcl);
          WinDrawBorder(hps,&rcl,1,1,SYSCLR_WINDOWFRAME,SYSCLR_DIALOGBACKGROUND, DB_STANDARD);
        }
      }
      WinEndPaint(hps);
      return (MRESULT) 0;
      }
    case DM_DRAGOVER:
      return handleDragOver(hwnd, mp1, mp2);
    case DM_DROP:
      {
        ULONG ulCount;
        ULONG ulNumberOfObjects;
        PDRAGITEM pDragItem;
        SOMClass *folderClass;
        WPObject * wpObject;
        PDRAGINFO pDragInfo;
       
        TRY_LOUD(LP_FRAMEDROP) { 
          /* A new object dropped on the launchpad */
          pDragInfo=(PDRAGINFO)mp1;
          if(DrgAccessDraginfo(pDragInfo)) {
            /* Get number of items */
            ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);           
            if(ulNumberOfObjects>1){
              /* Free the draginfo */
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
            else { 
              ulCount=0;
              
              pDragItem=DrgQueryDragitemPtr( pDragInfo, ulCount);
              wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID);
              lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
              if(lp) {
                if(somIsObj(wpObject)) {
  
                  POINTL ptl;
                  int numB;
                  SWP swp;
                  
                  WinQueryWindowPos(hwnd,&swp);
                  ptl.x=pDragInfo->xDrop;
                  ptl.y=pDragInfo->yDrop;
                  /* Pos in window coords */
                  WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
                  numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
                  numB=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);

                  /* Do a link */
                  lp->lpAddButton(wpObject, numB);
                  handleDragLeave(hwnd, mp1, mp2);
                }
              }
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
          }
          handleDragLeave(hwnd, mp1, mp2);
        }
        CATCH(LP_FRAMEDROP)
          {
          } END_CATCH;
          
          break;
      }
    case DM_DRAGLEAVE:
      return handleDragLeave(hwnd, mp1, mp2);
      break;
    case WM_COMMAND:
      if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) {
        /* It's a push button */
        lpo=(LPObject*)WinQueryWindowULong(WinWindowFromID(hwnd,SHORT1FROMMP(mp1)),QWL_USER);
        if(lpo) {
          if(somIsObj(lpo->wpObject))
            lpo->wpObject->wpViewObject(NULLHANDLE, OPEN_DEFAULT,0);
        }
      }
      return (MRESULT)FALSE;
      /***********************************************/
      /* Stuff for fly over help                     */ 
    case WM_MOUSEMOVE:
      launchPad * lp;

      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()!=0) {
          break;
        }
      }
      
#if 0
      tempID=WinQueryWindowUShort(hwnd,QWS_ID);/*  get the id of the window under the pointer  */  			
      if(id!=tempID) {	// New Button?	
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
        id=tempID;  // Save ID 
      }
      else {
        if(!hwndBubbleWindow)
          WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay	
      }
#endif
      if(!hwndBubbleWindow)
        WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 2,(ULONG)iTBFlyOverDelay); // New timer for delay	

      break;
    case WM_DESTROY:
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
      if(hwndBubbleWindow)
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
      hwndBubbleWindow=0;
      /* Stop delay timer if running */
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd, 2);			
      break;

    case WM_NEWBUBBLE:
      ULONG bubbleEnabled;
      HWND hwndStore;
      POINTL ptl;
      RECTL  rclWork;
      LONG  ulWinTextLen;
      POINTL aptlPoints[TXTBOX_COUNT];
      LONG   deltaX,deltaY;
      HPS  hps;
      RECTL   rcl;
  
      /*  we have to build a new information window  */
      if(hwndBubbleWindow){// if(){...} new in V1.00a 
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
        hwndBubbleWindow=NULL;
      }
      // Query the pointer position
      WinQueryPointerPos(HWND_DESKTOP,&ptl);
      WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
      WinQueryWindowRect(hwnd,&rclWork);				
      if(!hwndBubbleWindow 
         && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
         && bTBFlyOverEnabled) {
        
        static HWND hwndBubbleClient;
        ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
        char winText[255];
        
        /* Get window text for size calculating */
            lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lp) {
          strncpy(winText, lp->lpQueryFlyOverText(), sizeof(winText));
          winText[sizeof(winText)-1]=0;
        }

        ulWinTextLen=(LONG)strlen(winText); // Query text length
        
        /* Delete 'Returns' in object title */
        char *pBuchst;
        char *pRest;
        pRest=winText;
        while((pBuchst=strchr(pRest,13))!=NULL) {
          *pBuchst=' ';
          pBuchst++;
          if(*pBuchst==10)
            *pBuchst=' ';
          pRest=pBuchst;
        }
        
        /* Create help window */
        hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
                                            0,
                                            &style,
                                            WC_STATIC,
                                            "",
                                            SS_TEXT|DT_CENTER|DT_VCENTER,
                                            NULLHANDLE,
                                            400,
                                            &hwndBubbleClient);

        hwndShadow=WinCreateWindow(HWND_DESKTOP,
                                   WC_STATIC,
                                   "",
                                   SS_TEXT|DT_CENTER|DT_VCENTER,
                                   0, 0,
                                   0, 0,
                                   hwndBubbleWindow,
                                   hwndBubbleWindow,
                                   401,
                                   NULLHANDLE,
                                   NULLHANDLE);
        oldProc=WinSubclassWindow(hwndShadow, shadowProc);

        // Set the font for the help
        WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,
                        sizeof(chrTBFlyFontName),
                        chrTBFlyFontName);
        /* Calculate text size in pixel */
        hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
        GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
        WinEndPaint(hps);
        
        /* Set colors */
        WinSetPresParam(hwndBubbleClient,
                        PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) ,
                        &rgbTBFlyBackground );
        WinSetPresParam(hwndBubbleClient,
                        PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) ,
                        &rgbTBFlyForeground );
        
        /* Calculate bubble positon and show bubble */
        WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
        WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x 
          > rcl.xRight 
          ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7 
	      : deltaX=0 ;
        
        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y 
          > rcl.yTop 
          ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
	      : deltaY=0 ;		
        WinSetWindowPos(hwndBubbleWindow,
                        HWND_TOP,
                        ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);

        WinSetWindowPos(hwndShadow,
                        hwndBubbleWindow,
                        ptl.x+xVal+deltaX+5
                        ,ptl.y+yVal+deltaY-5,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
        
        /* Set bubble text */
        WinSetWindowText(hwndBubbleClient,winText);
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35); 
      } // end if(!hwndBubbleWindow)
      break;
    case WM_TIMER:
      switch (SHORT1FROMMP(mp1))
        {
        case 1: //Intervall timer
          {
            POINTL ptl;
            RECTL  rclWork;

            /* Test pointer position */
            WinQueryPointerPos(HWND_DESKTOP, &ptl);
            WinMapWindowPoints(HWND_DESKTOP, hwnd,&ptl, 1);
            WinQueryWindowRect(hwnd, &rclWork);
            if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              {	// Window has changed				 
                WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 1);  // stop the running timer
                if(hwndBubbleWindow) 
                  WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
                hwndBubbleWindow=0;
                id=0;
              }			 			
          break;
          }
        case 2:// delay over
          {//our own timer.
            POINTL ptl;
            RECTL  rclWork;

            WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 2);//Stop the delay timer
            /* Check the pointer position */
            WinQueryPointerPos(HWND_DESKTOP,&ptl);
            WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
            WinQueryWindowRect(hwnd,&rclWork);
            if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
            return (MRESULT)FALSE;
          }
        default:
          break;
        }
      break;
    default:
      break;    
    }
  return pfnwpOldLPProc(hwnd, msg, mp1, mp2);
}
コード例 #17
0
ファイル: windisp.c プロジェクト: Azarien/open-watcom-v2
/*
 * _DisplayLineInWindowWithColor - as it sounds!
 */
void _DisplayLineInWindowWithColor( LPWDATA w, int line, LPSTR text, int c1,
                        int c2, int extra, int startcol )
{
  #ifdef _MBCS
    LPBYTE          tmp;
  #else
    LPSTR           tmp;
  #endif
    char            buff[256];
    int             start,end,a,spend,cnt1,cnt2;
    WORD            i;
    HWND            hwnd;

    hwnd = w->hwnd;

    /*** Find dimensions of line ***/
  #ifdef _MBCS
    tmp = FAR_mbsninc( (LPBYTE)text, startcol );
    a = FAR_mbslen( tmp );
    if( line < 1 || line >= w->height )
        return;
    start = 0;
    spend = end = w->width - extra;
    if( end > a )
        end = a;
    cnt1 = FAR_mbsnbcnt( tmp, end - start );
    cnt2 = spend - end;
    FAR_mbsnbcpy( (LPBYTE)buff, tmp, cnt1 - start );
    FARmemset( buff + cnt1, ' ', cnt2 );
    tmp = FAR_mbsninc( (LPBYTE)buff, cnt1 + cnt2 );
    *tmp = '\0';
  #else
    tmp = text;
    tmp += startcol;
    a = FARstrlen( tmp );
    if( line < 1 || line >= w->height )
        return;
    start = 0;
    spend = end = w->width - extra;
    if( end > a )
        end = a;
    cnt1 = end - start;
    cnt2 = spend - end;
    FARmemcpy( buff, tmp, cnt1 );
    FARmemset( buff + cnt1, ' ', cnt2 );
    buff[cnt1 + cnt2] = 0;
  #endif
    line--;

#if defined( __OS2__ )
    {
        RECTL           rcl;
        HPS             ps;
        POINTL          ptl;
        POINTL          points[TXTBOX_COUNT];

        ptl.x = 0;
        ptl.y = (w->y2 - w->y1) - (line+1)*w->ychar + w->base_offset;
        ps = WinGetPS( hwnd );
        _SelectFont( ps );
        GpiQueryTextBox( ps, startcol, w->tmpbuff->data, TXTBOX_COUNT, points );
        rcl.xLeft = points[TXTBOX_BOTTOMRIGHT].x;
    #ifdef _MBCS
        GpiQueryTextBox( ps, __mbslen( (unsigned char *)buff ), buff, TXTBOX_COUNT, points );
    #else
        GpiQueryTextBox( ps, strlen( buff ), buff, TXTBOX_COUNT, points );
    #endif
        rcl.xRight = points[TXTBOX_BOTTOMRIGHT].x;
        rcl.yTop = (w->y2 - w->y1) - line*w->ychar;
        rcl.yBottom = rcl.yTop - w->ychar;
        WinFillRect( ps, &rcl, c1 );
        GpiSetColor( ps, c2 );
    #ifdef _MBCS
        GpiCharStringAt( ps, &ptl, _mbsnbcnt(buff,w->width), buff );
    #else
        GpiCharStringAt( ps, &ptl, w->width, buff );
    #endif
        WinReleasePS( ps );
    }
#else
    {
        HDC     dc;
//      SIZE    size;
//      RECT    rect;

        dc = GetDC( hwnd );
        _SetMyDC( dc, _ColorMap[c2], _ColorMap[c1] );
//      #ifdef __NT__
//          GetTextExtentPoint32( dc, buff, strlen(buff), &size );
//      #else
//          GetTextExtentPoint( dc, buff, strlen(buff), &size );
//      #endif
//
    #ifdef _MBCS
        TextOut( dc, 0, line * w->ychar, (LPSTR)buff, FAR_mbsnbcnt( (LPBYTE)buff, w->width ) );
    #else
        TextOut( dc, 0, line * w->ychar, buff, w->width );
    #endif

        /*** Clear to end of line to remove any residue ***/
//      GetClientRect( w->hwnd, &rect );
//      rect.top = line * w->ychar;
//      rect.bottom = (line+1) * w->ychar ;
//      rect.left = size.cx;
//      FillRect( dc, &rect, w->brush );
        ReleaseDC( hwnd, dc );
    }
#endif

    /*** Update the w->image array ***/
#ifdef _MBCS
    {
        mb_char         mbc;
        unsigned char   *curMbc;
        int             count;

        i = line * w->width + startcol;
        for( count = 0, curMbc = (unsigned char *)buff; count < w->width - startcol; count++ ) {
            mbc = _mbsnextc( curMbc );          /* get the character */
            curMbc = _mbsinc( curMbc );         /* point to next char */
            w->image[i + count] = mbc;          /* store it in w->image */
        }
    }
#else
    i = line * w->width + startcol;
    FARmemcpy( &w->image[i], buff, w->width - startcol );
#endif
} /* _DisplayLineInWindowWithColor */
コード例 #18
0
ファイル: titlebar.c プロジェクト: OS2World/UTIL-WPS-Styler_2
//===========================================================================
// 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 */
}