예제 #1
0
/*************************************<->*************************************
 *
 *  int BaseWindowY (pcd)
 *
 *
 *  Description:
 *  -----------
 *  Returns the Y coord of the base window in the frame
 *
 *  Inputs:
 *  ------
 *  pcd			- pointer to client data record
 * 
 *  Outputs:
 *  -------
 *  BaseWindowY
 *
 *  Comments:
 *  --------
 * 
 *************************************<->***********************************/
int BaseWindowY (ClientData *pcd)
{
    int rval;

    if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
	rval = UpperBorderWidth (pcd) + TitleBarHeight(pcd);
    else
	rval = TitleBarHeight(pcd);
    
    return (rval);
}
예제 #2
0
/*************************************<->*************************************
 *
 *  unsigned int FrameHeight (pcd)
 *
 *
 *  Description:
 *  -----------
 *  Returns the height of the frame
 *
 *  Inputs:
 *  ------
 *  pcd			- pointer to client data record
 * 
 *  Outputs:
 *  -------
 *  FrameHeight	-  position of frame
 *
 *  Comments:
 *  --------
 * 
 *************************************<->***********************************/
unsigned int FrameHeight (ClientData *pcd)
{
    unsigned int frameHeight;

    if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
    {
	frameHeight = ((pcd->maxConfig) ? 
			  pcd->maxHeight : pcd->clientHeight) +
		      2*pcd->matteWidth + LowerBorderWidth (pcd) + 
		      UpperBorderWidth (pcd) + TitleBarHeight(pcd);
    }
    else 
    {
	frameHeight = ((pcd->maxConfig) ? 
			  pcd->maxHeight : pcd->clientHeight) +
		      2*pcd->matteWidth + 2*LowerBorderWidth (pcd) + 
		      TitleBarHeight(pcd);
    }

    return (frameHeight);
}
예제 #3
0
/*************************************<->*************************************
 *
 *  int FrameY (pcd)
 *
 *
 *  Description:
 *  -----------
 *  Returns the Y-coordinate of the frame for the window
 *
 *  Inputs:
 *  ------
 *  pcd			- pointer to client data record
 * 
 *  Outputs:
 *  -------
 *  FrameY		- Y position of frame
 *
 *  Comments:
 *  --------
 * 
 *************************************<->***********************************/
int FrameY (ClientData *pcd)
{
    int frameY;

    frameY = ((pcd->maxConfig) ? pcd->maxY : pcd->clientY) 
	 - UpperBorderWidth (pcd) 
	 - TitleBarHeight (pcd) - pcd->matteWidth;

    if ((pcd->decor & MWM_DECOR_TITLE) && 
	!(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) &&
	!(pcd->matteWidth))
    {
	frameY -= pcd->xBorderWidth;
    }

    return (frameY);
}
예제 #4
0
/*************************************<->*************************************
 *
 *  Boolean GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)
 *
 *
 *  Description:
 *  -----------
 *  Gets frame relative position and size of the specified frame part
 *
 *
 *  Inputs:
 *  ------
 *  pcd		- pointer to client data
 *  part	- part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
 *  pX		- pointer to x-coord return value
 *  pY		- pointer to y-coord return value
 *  pWidth	- pointer to width return value
 *  pHeight	- pointer to width return value
 *
 * 
 *  Outputs:
 *  -------
 *  Return 	- True if values returned, false if no such part for this
 * 		  frame (values undefined).
 *
 *
 *  Comments:
 *  --------
 * 
 *************************************<->***********************************/
Boolean GetFramePartInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
{
    unsigned int boxdim = TitleBarHeight (pcd);
    unsigned long decor = pcd->decor;
    int vert, horiz;
    Boolean rval = FALSE;
    
    switch (part) 
    {
	case FRAME_SYSTEM:
		if (decor & MWM_DECOR_MENU) {
		    *pX = pcd->frameInfo.upperBorderWidth;
		    *pY = pcd->frameInfo.upperBorderWidth;
		    *pWidth = boxdim;
		    *pHeight = boxdim;
		    rval = TRUE;
		}
		break;

	case FRAME_TITLE:
		if (decor & MWM_DECOR_TITLE) {
		    *pX = pcd->frameInfo.upperBorderWidth + 
			    ((decor & MWM_DECOR_MENU) ? boxdim : 0);
		    *pY = pcd->frameInfo.upperBorderWidth;
		    *pWidth = pcd->frameInfo.width - 
			    2*pcd->frameInfo.upperBorderWidth - 
			    ((decor & MWM_DECOR_MENU) ? boxdim : 0) -
			    ((decor & MWM_DECOR_MINIMIZE) ? boxdim : 0) -
			    ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
		    *pHeight = boxdim;
		    rval = TRUE;
		}
		break;
#ifdef WSM

	case FRAME_TITLEBAR:
		if (decor & MWM_DECOR_TITLE) {
		    *pX = pcd->frameInfo.upperBorderWidth;
		    *pY = pcd->frameInfo.upperBorderWidth;
		    *pWidth = pcd->frameInfo.width - 
			    2*pcd->frameInfo.upperBorderWidth;
		    *pHeight = boxdim;
		    rval = TRUE;
		}
		break;
#endif /* WSM */

	case FRAME_MINIMIZE:
		if (decor & MWM_DECOR_MINIMIZE) {
		    *pX = pcd->frameInfo.width - 
			    pcd->frameInfo.upperBorderWidth - boxdim -
			    ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
		    *pY = pcd->frameInfo.upperBorderWidth;
		    *pWidth= boxdim;
		    *pHeight = boxdim;
		    rval = TRUE;
		}
		break;

	case FRAME_MAXIMIZE:
		if (decor & MWM_DECOR_MAXIMIZE) {
		    *pX = pcd->frameInfo.width - 
			    pcd->frameInfo.upperBorderWidth - boxdim;
		    *pY = pcd->frameInfo.upperBorderWidth;
		    *pWidth = boxdim;
		    *pHeight = boxdim;
		    rval = TRUE;
		}
		break;

	/*
	 * For very small windows, the resize pieces will shrink
	 * equally until the corner pieces get within two pixels
	 * of the resize border width. At this point the "side" section
	 * is killed off (by giving it a zero length) and the corner
	 * pieces claim the additional space
	 */
	case FRAME_RESIZE_NW:
		if (decor & MWM_DECOR_RESIZEH) {
		    *pX = 0;
		    *pY = 0;

		    if ((int)pcd->frameInfo.cornerWidth > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pWidth = pcd->frameInfo.cornerWidth;
		    }
		    else {
			horiz = pcd->frameInfo.width - 
				2*pcd->frameInfo.cornerWidth;
			*pWidth = pcd->frameInfo.cornerWidth + 
				horiz/2 + horiz%2;
		    }

		    if ((int)pcd->frameInfo.cornerHeight > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pHeight = pcd->frameInfo.cornerHeight;
		    }
		    else {
			vert = pcd->frameInfo.height - 
				2*pcd->frameInfo.cornerHeight;
			*pHeight = pcd->frameInfo.cornerHeight + 
				vert/2 + vert%2;
		    }
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_N:
		if (decor & MWM_DECOR_RESIZEH) {
		    *pX = pcd->frameInfo.cornerWidth;
		    *pY = 0;
		    *pHeight = pcd->frameInfo.upperBorderWidth;
		    if ((int)pcd->frameInfo.cornerWidth > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pWidth = pcd->frameInfo.width - 
				2*pcd->frameInfo.cornerWidth;
		    }
		    else {
			*pWidth = 0;
		    }
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_NE:
		if (decor & MWM_DECOR_RESIZEH) {
		    if ((int)pcd->frameInfo.cornerWidth > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pWidth = pcd->frameInfo.cornerWidth;
		    }
		    else {
			horiz = pcd->frameInfo.width - 
			    2*pcd->frameInfo.cornerWidth;
			*pWidth = pcd->frameInfo.cornerWidth + horiz/2;
		    }
		    *pX = pcd->frameInfo.width - *pWidth;

		    if ((int)pcd->frameInfo.cornerHeight > 
			   (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pHeight = pcd->frameInfo.cornerHeight;
		    }
		    else {
			vert = pcd->frameInfo.height - 
				2*pcd->frameInfo.cornerHeight;
			*pHeight = pcd->frameInfo.cornerHeight + 
				vert/2 + vert%2;
		    }
		    *pY = 0;
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_E:
		if (decor & MWM_DECOR_RESIZEH) {
		    *pX = pcd->frameInfo.width - 
		            pcd->frameInfo.lowerBorderWidth;
		    *pY = pcd->frameInfo.cornerHeight;
		    *pWidth = pcd->frameInfo.lowerBorderWidth;
		    if ((int)pcd->frameInfo.cornerHeight > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pHeight = pcd->frameInfo.height - 
				2*pcd->frameInfo.cornerHeight;
		    }
		    else {
			*pHeight = 0;
		    }
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_SE:
		if (decor & MWM_DECOR_RESIZEH) {
		    if ((int)pcd->frameInfo.cornerWidth > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pWidth = pcd->frameInfo.cornerWidth;
		    }
		    else {
			horiz = pcd->frameInfo.width - 
				2*pcd->frameInfo.cornerWidth;
			*pWidth = pcd->frameInfo.cornerWidth + horiz/2;
		    }
		    *pX = pcd->frameInfo.width - *pWidth;

		    if ((int)pcd->frameInfo.cornerHeight > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pHeight = pcd->frameInfo.cornerHeight;
		    }
		    else {
			vert = pcd->frameInfo.height - 
				2*pcd->frameInfo.cornerHeight;
			*pHeight = pcd->frameInfo.cornerHeight + vert/2;
		    }
		    *pY = pcd->frameInfo.height - *pHeight;
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_S:
		if (decor & MWM_DECOR_RESIZEH) {
		    *pX = pcd->frameInfo.cornerWidth;
		    *pY = pcd->frameInfo.height - 
			    pcd->frameInfo.lowerBorderWidth;
		    if ((int)pcd->frameInfo.cornerWidth > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pWidth = pcd->frameInfo.width - 
				2*pcd->frameInfo.cornerWidth;
		    }
		    else {
			*pWidth = 0;
		    }
		    *pHeight = pcd->frameInfo.lowerBorderWidth;
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_SW:
		if (decor & MWM_DECOR_RESIZEH) {
		    if ((int)pcd->frameInfo.cornerWidth > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pWidth = pcd->frameInfo.cornerWidth;
		    }
		    else {
			horiz = pcd->frameInfo.width - 
			        2*pcd->frameInfo.cornerWidth;
			*pWidth = pcd->frameInfo.cornerWidth + 
				horiz/2 + horiz%2;
		    }
		    *pX = 0;

		    if ((int)pcd->frameInfo.cornerHeight > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pHeight = pcd->frameInfo.cornerHeight;
		    }
		    else {
			vert = pcd->frameInfo.height - 
				2*pcd->frameInfo.cornerHeight;
			*pHeight = pcd->frameInfo.cornerHeight + vert/2;
		    }
		    *pY = pcd->frameInfo.height - *pHeight;
		    rval = TRUE;
		}
		break;
	    
	case FRAME_RESIZE_W:
		if (decor & MWM_DECOR_RESIZEH) {
		    *pX = 0;
		    *pY = pcd->frameInfo.cornerHeight;
		    *pWidth = pcd->frameInfo.lowerBorderWidth;
		    if ((int)pcd->frameInfo.cornerHeight > 
			    (int)pcd->frameInfo.lowerBorderWidth+2) {
			*pHeight = pcd->frameInfo.height - 
				2*pcd->frameInfo.cornerHeight;
		    }
		    else {
			*pHeight = 0;
		    }
		    rval = TRUE;
		}
		break;
	    
	default:
		break;
    }
    return(rval);
}
예제 #5
0
//-----------------------------------------------------------------------
//
//-----------------------------------------------------------------------
void tWifiClientSettingsDialog::OnTriggered()
{
    tDialogWidget* pSender = static_cast<tDialogWidget*>( sender() );
    Q_ASSERT(pSender);

    tWifiClientSettings* pWifiClientSettings = g_xWirelessMgr->WifiClientSettings();
    if (pWifiClientSettings == 0)
    {
        return;
    }

    QString orgSSID = m_widgetOrgSSID[pSender];
    QString SSID = pSender->TitleText();
    if (orgSSID.isEmpty())
    {
        orgSSID = SSID;
    }

    QStringList list;
    if (pWifiClientSettings->ConnectAutomatically(orgSSID))
    {
        list << tr("Don't connect Automatically");
    }
    else
    {
        list << tr("Connect Automatically");
    }
    list  << tr("Delete");
    bool accepted = false;
    int result = tInputDialog::GetItem( this, SSID, "", list, 0, &accepted );
    if (accepted == true)
    {
        switch (result)
        {
            case 0:
            {
                // Switch connect automatically
                QString key = pWifiClientSettings->Key(orgSSID);
                QString authMode = pWifiClientSettings->AuthMode(orgSSID);
                QString encryptType = pWifiClientSettings->EncryptType(orgSSID);
                bool bConnect = pWifiClientSettings->ConnectAutomatically(orgSSID);

                pWifiClientSettings->AddClient(orgSSID, authMode, encryptType, key, !bConnect);

                pSender->SetBodyText( GetClientText(orgSSID) );
            }
            break;

            case 1:
            {
                // Delete
                tMessageBox::tStandardButton button = tMessageBox::Question( this, SSID,
                    tr( "Are you sure you want to delete?" ),
                    tMessageBox::YES | tMessageBox::NO,
                    tMessageBox::NO );
                if( button == tMessageBox::YES )
                {
                    pWifiClientSettings->DeleteClient(orgSSID);
                    QSize singleElement = pSender->size();
                    uint clientCount    =  pWifiClientSettings->ClientCount();
                    pSender->deleteLater();
                    if( clientCount > 0 )
                    {
                        int dialogHeight = static_cast<int>(clientCount)*singleElement.height() + TitleBarHeight();
                        if( dialogHeight < size().height() )
                        {
                            QSize dialogSize = QSize( size().width(), dialogHeight + 2);
                            resize(dialogSize); 
                        }
                    }
                    else
                    {
                        RefreshClients();
                    }
                }
            }
            break;

            default: break;
        }
    }
}