예제 #1
0
void UpdateWindowSize(DialogData* pdd, const int cx, const int cy, HWND hwnd) {
    const int nDeltaX = cx - pdd->sizeClient.dx;
    const int nDeltaY = cy - pdd->sizeClient.dy;

    HDWP hdwp = BeginDeferWindowPos(pdd->nItemCount);
    for (int i = 0; i < pdd->nItemCount; i++) {
        const DialogSizerSizingItem* psd = pdd->psd + i;
        HWND hwndChild = GetDlgItem(hwnd, psd->uControlID);
        RectI rect = MapRectToWindow(WindowRect(hwndChild), HWND_DESKTOP, hwnd);

        // Adjust the window horizontally
        if (psd->uSizeInfo & DS_MoveX)
            rect.x += nDeltaX;
        // Adjust the window vertically
        if (psd->uSizeInfo & DS_MoveY)
            rect.y += nDeltaY;
        // Size the window horizontally
        if (psd->uSizeInfo & DS_SizeX)
            rect.dx += nDeltaX;
        // Size the window vertically
        if (psd->uSizeInfo & DS_SizeY)
            rect.dy += nDeltaY;

        DeferWindowPos(hdwp, hwndChild, nullptr, rect.x, rect.y, rect.dx, rect.dy, SWP_NOACTIVATE | SWP_NOZORDER);
    }
    EndDeferWindowPos(hdwp);

    pdd->sizeClient = SizeI(cx, cy);
    // If we have a sizing grip enabled then adjust it's position
    pdd->UpdateGripper();
}
예제 #2
0
void Notifications::MoveBelow(NotificationWnd *fix, NotificationWnd *move)
{
    RectI rect = WindowRect(fix->hwnd());
    rect = MapRectToWindow(rect, HWND_DESKTOP, GetParent(fix->hwnd()));
    SetWindowPos(move->hwnd(), NULL,
                 GetWndX(move), rect.y + rect.dy + NotificationWnd::TL_MARGIN,
                 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
예제 #3
0
bool LinuxWindowCapture::WindowFound() {
  if ( mWindow == 0 )
    mWindow = FindWindow( WM_WINDOW_INSTANCE, WM_CLASS );

  if ( mWindow != 0 && !WindowRect() )
    mWindow = 0;

  return mWindow != 0;
}
예제 #4
0
void NotificationWnd::UpdateWindowPosition(const WCHAR *message, bool init)
{
    // compute the length of the message
    RECT rc = ClientRect(self).ToRECT();

    HDC hdc = GetDC(self);
    HFONT oldfnt = SelectFont(hdc, font);
    DrawText(hdc, message, -1, &rc, DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX);
    SelectFont(hdc, oldfnt);
    ReleaseDC(self, hdc);

    RectI rectMsg = RectI::FromRECT(rc);
    if (hasCancel) {
        rectMsg.dy = std::max(rectMsg.dy, 16);
        rectMsg.dx += 20;
    }
    rectMsg.Inflate(PADDING, PADDING);

    if (shrinkLimit < 1.0f) {
        ClientRect rcOrig(self);
        if (rectMsg.dx < rcOrig.dx && rectMsg.dx > rcOrig.dx * shrinkLimit)
            rectMsg.dx = rcOrig.dx;
    }

    // adjust the window to fit the message (only shrink the window when there's no progress bar)
    if (!hasProgress) {
        SetWindowPos(self, nullptr, 0, 0, rectMsg.dx, rectMsg.dy, SWP_NOMOVE | SWP_NOZORDER);
    } else if (init) {
        RectI rect = WindowRect(self);
        rect.dx = std::max(progressWidth + 2 * PADDING, rectMsg.dx);
        rect.dy = rectMsg.dy + PROGRESS_HEIGHT + PADDING / 2;
        SetWindowPos(self, nullptr, 0, 0, rect.dx, rect.dy, SWP_NOMOVE | SWP_NOZORDER);
    } else if (rectMsg.dx > progressWidth + 2 * PADDING) {
        SetWindowPos(self, nullptr, 0, 0, rectMsg.dx, WindowRect(self).dy, SWP_NOMOVE | SWP_NOZORDER);
    }

    // move the window to the right for a right-to-left layout
    if (IsUIRightToLeft()) {
        HWND parent = GetParent(self);
        RectI rect = MapRectToWindow(WindowRect(self), HWND_DESKTOP, parent);
        rect.x = WindowRect(parent).dx - rect.dx - TL_MARGIN - GetSystemMetrics(SM_CXVSCROLL);
        SetWindowPos(self, nullptr, rect.x, rect.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    }
}
예제 #5
0
void CenterDialog(HWND hDlg, HWND hParent)
{
    if (!hParent)
        hParent = GetParent(hDlg);

    RectI rcDialog = WindowRect(hDlg);
    rcDialog.Offset(-rcDialog.x, -rcDialog.y);
    RectI rcOwner = WindowRect(hParent ? hParent : GetDesktopWindow());
    RectI rcRect = rcOwner;
    rcRect.Offset(-rcRect.x, -rcRect.y);

    // center dialog on its parent window
    rcDialog.Offset(rcOwner.x + (rcRect.x - rcDialog.x + rcRect.dx - rcDialog.dx) / 2,
                    rcOwner.y + (rcRect.y - rcDialog.y + rcRect.dy - rcDialog.dy) / 2);
    // ensure that the dialog is fully visible on one monitor
    rcDialog = ShiftRectToWorkArea(rcDialog, true);

    SetWindowPos(hDlg, 0, rcDialog.x, rcDialog.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
예제 #6
0
bool OSXWindowCapture::WindowFound() {
  if( mWinId == 0 ) {
    mWinId = FindWindow( "Hearthstone" );
  }

  if( mWinId && !WindowRect( mWinId, &mRect ) ) {
    // Window became invalid
    mWinId = 0;
  }

  return mWinId != 0;
}
예제 #7
0
static void RemoveDialogItem(HWND hDlg, int itemId, int prevId=0)
{
    HWND hItem = GetDlgItem(hDlg, itemId);
    RectI itemRc = MapRectToWindow(WindowRect(hItem), HWND_DESKTOP, hDlg);
    // shrink by the distance to the previous item
    HWND hPrev = prevId ? GetDlgItem(hDlg, prevId) : GetWindow(hItem, GW_HWNDPREV);
    RectI prevRc = MapRectToWindow(WindowRect(hPrev), HWND_DESKTOP, hDlg);
    int shrink = itemRc.y - prevRc.y + itemRc.dy - prevRc.dy;
    // move items below up, shrink container items and hide contained items
    for (HWND item = GetWindow(hDlg, GW_CHILD); item; item = GetWindow(item, GW_HWNDNEXT)) {
        RectI rc = MapRectToWindow(WindowRect(item), HWND_DESKTOP, hDlg);
        if (rc.y >= itemRc.y + itemRc.dy) // below
            MoveWindow(item, rc.x, rc.y - shrink, rc.dx, rc.dy, TRUE);
        else if (rc.Intersect(itemRc) == rc) // contained (or self)
            ShowWindow(item, SW_HIDE);
        else if (itemRc.Intersect(rc) == itemRc) // container
            MoveWindow(item, rc.x, rc.y, rc.dx, rc.dy - shrink, TRUE);
    }
    // shrink the dialog
    WindowRect dlgRc(hDlg);
    MoveWindow(hDlg, dlgRc.x, dlgRc.y, dlgRc.dx, dlgRc.dy - shrink, TRUE);
}
예제 #8
0
/* --- Window processing module for MENUBAR window class --- */
int MenuBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
{
    int rtn;

    switch (msg)    {
        case CREATE_WINDOW:
            reset_menubar(wnd);
            break;
        case SETFOCUS:
			return SetFocusMsg(wnd, p1);
        case BUILDMENU:
            BuildMenuMsg(wnd, p1);
            break;
        case PAINT:    
            if (!isVisible(wnd) || GetText(wnd) == NULL)
                break;
            PaintMsg(wnd);
            return FALSE;
        case BORDER:
		    if (mwnd == NULL)
				SendMessage(wnd, PAINT, 0, 0);
            return TRUE;
        case KEYBOARD:
            KeyboardMsg(wnd, p1);
            return TRUE;
        case LEFT_BUTTON:
            LeftButtonMsg(wnd, p1);
            return TRUE;
        case MB_SELECTION:
            SelectionMsg(wnd, p1, p2);
            break;
        case COMMAND:
            CommandMsg(wnd, p1, p2);
            return TRUE;
        case INSIDE_WINDOW:
            return InsideRect(p1, p2, WindowRect(wnd));
        case CLOSE_POPDOWN:
            ClosePopdownMsg(wnd);
            return TRUE;
        case CLOSE_WINDOW:
            rtn = BaseWndProc(MENUBAR, wnd, msg, p1, p2);
            CloseWindowMsg(wnd);
            return rtn;
        default:
            break;
    }
    return BaseWndProc(MENUBAR, wnd, msg, p1, p2);
}
예제 #9
0
void Notifications::Relayout()
{
    if (wnds.Count() == 0)
        return;

    HWND hwndCanvas = GetParent(wnds.At(0)->hwnd());
    ClientRect frame(hwndCanvas);
    for (size_t i = 0; i < wnds.Count(); i++) {
        RectI rect = WindowRect(wnds.At(i)->hwnd());
        rect = MapRectToWindow(rect, HWND_DESKTOP, hwndCanvas);
        if (IsUIRightToLeft())
            rect.x = frame.dx - rect.dx - NotificationWnd::TL_MARGIN - GetSystemMetrics(SM_CXVSCROLL);
        else
            rect.x = NotificationWnd::TL_MARGIN;
        SetWindowPos(wnds.At(i)->hwnd(), NULL, rect.x, rect.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    }
}
예제 #10
0
/* ----------- MOUSE_MOVED Message ---------- */
static int MouseMovedMsg(WINDOW wnd, PARAM p1, PARAM p2)
{
    int MouseX = (int) p1 - GetClientLeft(wnd);
    int MouseY = (int) p2 - GetClientTop(wnd);
    RECT rc = ClientRect(wnd);
    if (!InsideRect(p1, p2, rc))
        return FALSE;
    if (MouseY > wnd->wlines-1)
        return FALSE;
    if (ButtonDown)    {
        SetAnchor(wnd, ButtonX+wnd->wleft, ButtonY+wnd->wtop);
        TextMarking = TRUE;
		rc = WindowRect(wnd);
        SendMessage(NULL,MOUSE_TRAVEL,(PARAM) &rc, 0);
        ButtonDown = FALSE;
    }
    if (TextMarking && !(WindowMoving || WindowSizing))    {
        ExtendBlock(wnd, MouseX, MouseY);
        return TRUE;
    }
    return FALSE;
}
예제 #11
0
static bool CreatePropertiesWindow(HWND hParent, PropertiesLayout* layoutData)
{
    CrashIf(layoutData->hwnd);
    HWND hwnd = CreateWindow(
           PROPERTIES_CLASS_NAME, PROPERTIES_WIN_TITLE,
           WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
           CW_USEDEFAULT, CW_USEDEFAULT,
           CW_USEDEFAULT, CW_USEDEFAULT,
           NULL, NULL,
           ghinst, NULL);
    if (!hwnd)
        return false;

    layoutData->hwnd = hwnd;
    layoutData->hwndParent = hParent;
    ToggleWindowStyle(hwnd, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, IsUIRightToLeft(), GWL_EXSTYLE);

    // get the dimensions required for the about box's content
    RectI rc;
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);
    UpdatePropertiesLayout(layoutData, hdc, &rc);
    EndPaint(hwnd, &ps);

    // resize the new window to just match these dimensions
    // (as long as they fit into the current monitor's work area)
    WindowRect wRc(hwnd);
    ClientRect cRc(hwnd);
    RectI work = GetWorkAreaRect(WindowRect(hParent));
    wRc.dx = min(rc.dx + wRc.dx - cRc.dx, work.dx);
    wRc.dy = min(rc.dy + wRc.dy - cRc.dy, work.dy);
    MoveWindow(hwnd, wRc.x, wRc.y, wRc.dx, wRc.dy, FALSE);
    CenterDialog(hwnd, hParent);

    ShowWindow(hwnd, SW_SHOW);
    return true;
}
예제 #12
0
int Notifications::GetWndX(NotificationWnd *wnd)
{
    RectI rect = WindowRect(wnd->hwnd());
    rect = MapRectToWindow(rect, HWND_DESKTOP, GetParent(wnd->hwnd()));
    return rect.x;
}
예제 #13
0
EXPORT_C
void AknPopupLayouts::HandleSizeChanged( TAknPopupWindowLayoutDef &aDef,
                                         TAknPopupLayouts aLayout_1,
                                         TAknPopupLayoutsNode *aNode)
    {
    CAknPopupHeadingPane *aHeading = (CAknPopupHeadingPane*)FindControl(aNode, EHeadingNode);
    CEikListBox *aListBox = (CEikListBox*)FindControl(aNode, EListNode);
    CCoeControl *aWindowOwningControl = FindControl(aNode, EWindowOwningNode);
    CAknMessageQueryControl *aMsgQueryCtrl = (CAknMessageQueryControl*)FindControl(aNode, EMessageBoxNode);
    
    TInt aLayout = aLayout_1;
    TInt numofitems = aListBox->Model()->NumberOfItems();

    aListBox->View()->ItemDrawer()->SetSkinEnabledL(ETrue);
    
    TInt maxListHeight = GetMaxListHeight();

    // position popup window's bottom correctly
    TRect clientRect;
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EPopupParent, clientRect);
    // set windowrect to minimum size - this will be adjusted later    
    TAknLayoutRect windowRect;
    windowRect.LayoutRect( clientRect, AknLayoutScalable_Avkon::popup_menu_window(8));
    aDef.iWindowRect = windowRect.Rect();
    TRAP_IGNORE( aListBox->View()->ItemDrawer()->SetSkinEnabledL(ETrue) );
    
    // Popup window when the size does not change based on
    // the number of items.
    TBool fixedWindowSize = EFalse;
    if ( (aLayout & EAknPopupLayoutsDynamic) || numofitems == 0 ||
         (aLayout & EAknPopupLayoutsFind) )
        {
        aLayout &= ~EAknPopupLayoutsDynamic;
        fixedWindowSize = ETrue;
        }
        
    // heading =============================================================
    TInt spaceForHeading = 0;
    if (aHeading)
        {
        aHeading->SetLayout( CAknPopupHeadingPane::EListHeadingPane ); 
        TAknLayoutRect tempHeadingRect;
        tempHeadingRect.LayoutRect(clientRect,
            AknLayoutScalable_Avkon::heading_pane(0));
        spaceForHeading = tempHeadingRect.Rect().Height();
        maxListHeight -= spaceForHeading;
        }
    aDef.iPopupMenuWindowOffset=TPoint(0,spaceForHeading);
        
    
    // findbox =============================================================
    TBool windowSizeFind = EFalse;
    TInt spaceForFind = 0;
    if (aLayout & EAknPopupLayoutsFind)
        {
        aLayout &= ~EAknPopupLayoutsFind;
        windowSizeFind = ETrue;
        // calculate space needed for find
        TAknLayoutRect tempFindRect;
        tempFindRect.LayoutRect(clientRect,AknLayoutScalable_Avkon::find_popup_pane_cp2(0));
        spaceForFind = tempFindRect.Rect().Height();
        maxListHeight -= spaceForFind;
        }
    
    // messagebox ==========================================================
    TRect messageRect;
    TInt messageNumOfLines = 0;
    TBool messageBox = EFalse;
    if (aMsgQueryCtrl && aMsgQueryCtrl->Lines() > 0)
        {
        messageBox = ETrue;
        messageNumOfLines = aMsgQueryCtrl->Lines();
        TInt varietyIndex = 0;
        switch(messageNumOfLines)
            {
            case (0):
            case (1): varietyIndex = 0;
            break;          
            case (2): varietyIndex = 1;
            break;
            default : varietyIndex = 2;
            }           
        TAknWindowLineLayout lay = AknLayoutScalable_Apps::loc_type_pane(varietyIndex).LayoutLine();
        TAknLayoutRect layout;
        layout.LayoutRect( TRect(0,0,0,0), lay );           
        messageRect =  layout.Rect();           
        maxListHeight -= messageRect.Height();
        }
    
    TInt minItems = 1;
    
    TRect scrollBarRect(0,0,0,0);
    
    TAknWindowLineLayout listLayout;
    TAknLayoutScalableParameterLimits listLimits;
    
    switch(aLayout)
        {
        case EPopupSNotePopupWindow:
        case EMenuUnknownColumnWindow:
        case EMenuUnknownFormattedCellWindow:
        case EMenuWindow:
            {
            minItems = aHeading ? 5 : 6;
            listLayout = AknLayoutScalable_Avkon::list_single_pane_cp2(0);
            listLimits = AknLayoutScalable_Avkon::list_single_pane_cp2_ParamLimits();
            break;
            }
        case EMenuGraphicWindow:
            {
            minItems = 5;
            listLayout = AknLayoutScalable_Avkon::list_single_graphic_pane_cp2(0);
            listLimits = AknLayoutScalable_Avkon::list_single_graphic_pane_cp2_ParamLimits();
            break;
            }
        case EMenuGraphicHeadingWindow:
            {
            minItems = 5;
            listLayout = AknLayoutScalable_Avkon::list_single_graphic_heading_pane_cp2(0);
            listLimits = AknLayoutScalable_Avkon::list_single_graphic_heading_pane_cp2_ParamLimits();
            break;
            }
        case EMenuDoubleWindow:
            {
            minItems = 3;
            listLayout = AknLayoutScalable_Avkon::list_double_pane_cp2(0);
            listLimits = AknLayoutScalable_Avkon::list_double_pane_cp2_ParamLimits();
            break;
            }
        case EMenuDoubleLargeGraphicWindow:
            {
            minItems = 3;
            listLayout = AknLayoutScalable_Avkon::list_double_large_graphic_pane_cp2(0);
            listLimits = AknLayoutScalable_Avkon::list_double_large_graphic_pane_cp2_ParamLimits();
            break;
            }
        }
        
    if (!fixedWindowSize)
        {
        minItems = 1;
        }

    TInt maxLayoutItems = listLimits.LastRow() + 1; // last row is a zero based index, we need num items which is 1 based
        
    //aDef.iVertLineExt1.LayoutRect(TRect(1,1,1,1), 0, 0,0, ELayoutEmpty, ELayoutEmpty, 0,0);
    //aDef.iVertLineExt2.LayoutRect(TRect(1,1,1,1), 0, 0,0, ELayoutEmpty, ELayoutEmpty, 0,0);
        
    TAknLayoutRect listItemRect;
    listItemRect.LayoutRect( aDef.iWindowRect, listLayout);
    TInt listItemHeight = listItemRect.Rect().Height();
    TInt maxItems = maxListHeight / listItemHeight;
    // minItems == 1 only if the popuplist is dynamically changeable
    if ( (numofitems > 1) && (minItems == 1) )
        {
        minItems = numofitems;
        }
    if (minItems > maxItems)
        {
        minItems = maxItems;
        }
    // maxItems might be greater than max items from layout -> use layout's maximum
    if (minItems > maxLayoutItems)
        {
        minItems = maxLayoutItems;
        }

    TRect window_rect = AknPopupLayouts::MenuRect(aDef);

    TAknLayoutRect temp, layout;
    TRect screenRect;
    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); 
    TAknWindowLineLayout lineLayout = AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine();
 
    // Layout data of listscroll_menu_pane are changed for CR 417-35260.
    // The change is just for QHD landscape model.
    // The CR makes listscroll_menu_pane's ir or il bigger than normal,
    // so that width of list item is smaller than needs. Then, first cell 
    // of list item can not be drawn on proper position.
    // Adjustment of layout is a solution for this problem. This is not a perfect idea, but
    // creating a new layout for popuplist is too complex to do that. Adjustment is a must.
    if(Layout_Meta_Data::IsLandscapeOrientation())       
        {
        TInt offset  = AknListBoxLayouts::AdjustPopupLayoutData( screenRect );
        if (!AknLayoutUtils::LayoutMirrored())
            {
            lineLayout.ir -= offset;
            }
        else
            {
            lineLayout.il -= offset;
            }
        }
    temp.LayoutRect( window_rect, lineLayout);        

    layout.LayoutRect( temp.Rect(), AknLayoutScalable_Avkon::list_menu_pane(0));
    TRect tempListRect = layout.Rect(); // this is list's rect for the whole window
    
    // subtract heading, findbox and messagebox from tempListRect
    tempListRect.iBr.iY -= spaceForFind;
    tempListRect.iTl.iY += spaceForHeading;
    tempListRect.iTl.iY += messageRect.Height();
    
    // We really don't want parent relative list layout here because findbox will be overwritten.
    // Just calculate list height and use that.
    TRect nullRect(0,0,0,0);
    listLayout.iH = (TInt16)(minItems * listItemHeight);
    listLayout.ib = ELayoutEmpty;

    aDef.iListRect.LayoutRect(tempListRect,
        listLayout);

    // we have to scale iWindowRect to list rect - layout is not (yet) correct
    TInt usedHeight = aDef.iListRect.Rect().Height()
        + spaceForFind
        + spaceForHeading
        + messageRect.Height();
        
    // popupwindow's inside area
    TInt varietyIndex = Layout_Meta_Data::IsLandscapeOrientation();
    
    TAknLayoutRect insideArea;
    insideArea.LayoutRect(
        window_rect,
        AknLayoutScalable_Avkon::bg_popup_window_pane_g1(varietyIndex) );

    if (layout.Rect().Height() < usedHeight)
        {
        aDef.iWindowRect.iTl.iY -= (usedHeight - layout.Rect().Height());
        }
    
    AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();    
        
    // In landscape we have to center (on y-axis) popup window (but not with bottom CBA)
    if (varietyIndex == 1 && cbaLocation != AknLayoutUtils::EAknCbaLocationBottom)
        {
        TRect mainPane;
        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent, mainPane );
        TInt diff = (mainPane.Height()-aDef.iWindowRect.Height()) / 2;
        aDef.iWindowRect.iTl.iY -= diff;
        aDef.iWindowRect.iBr.iY -= diff;
                        
        // with right CBA, move window to the right side of the screen
        if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight)
            {
            TInt offset = mainPane.Width()-aDef.iWindowRect.iBr.iX;
            aDef.iWindowRect.iTl.iX += offset;
            aDef.iWindowRect.iBr.iX += offset;
            }        
        
        //should this be uncommented??
        // If we have left CBA, we move window to left side of screen (on x-axis).       
        /*else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft)
            {
            TInt xOffset = aDef.iWindowRect.iTl.iX;
            if ( xOffset > 0 )
                {
                aDef.iWindowRect.iTl.iX = 0;
                aDef.iWindowRect.iBr.iX -= xOffset;
                }
            }*/
        }                                                                              
      
    TRect screen;
        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );
        
    TAknLayoutRect cbaRect;
    cbaRect.LayoutRect( screen, 
        AknLayoutScalable_Avkon::popup_sk_window( 0  ).LayoutLine() );
            
    if ( AknLayoutUtils::PenEnabled() )
        {
        TSize size( aDef.iWindowRect.Size() );
        // add softkey height
        size.iHeight += cbaRect.Rect().Height();
        
        // Reduce listbox's and popup's height if total height is more than
        // screen height.
        if ( size.iHeight > screen.Height() )
            {
            listLayout.iH -= ( size.iHeight - screen.Height() );
            aDef.iListRect.LayoutRect( tempListRect, listLayout );
            
            size.iHeight = screen.Height();
            }

        aDef.iWindowRect.SetRect( AknPopupUtils::Position( size, ETrue ), size );
        }

    // now we finally know the window rect: first setup heading
    if (aHeading)
        {
        aDef.iHeadingRect.LayoutRect(AknPopupLayouts::MenuRect(aDef),
            AknLayoutScalable_Avkon::heading_pane(0));
        }
    
    MenuPopupWindowGraphics(aDef);
    aWindowOwningControl->SetRect(WindowRect(aDef));
    HandleSizeAndPositionOfComponents(aDef, aListBox, aHeading);

    layout.LayoutRect(MenuRect(aDef), lineLayout);
    TRect scrollBarClientRect(layout.Rect());
        
    if ( AknLayoutUtils::PenEnabled() )
        {
        // remove softkey height that was added earlier so that
        // scroll bar doesn't get behind the softkey 
        scrollBarClientRect.iBr.iY -= cbaRect.Rect().Height();
        }

    if (aHeading)
        {
        scrollBarClientRect.iTl.iY += spaceForHeading;                
        }
        
    if (windowSizeFind)
        {
        scrollBarClientRect.iBr.iY -= spaceForFind;
        }
        
    if (messageBox)
        {
        scrollBarClientRect.iTl.iY += messageRect.Height();
        }
    varietyIndex = 0;
    AknLayoutUtils::LayoutVerticalScrollBar(
        aListBox->ScrollBarFrame(),
        scrollBarClientRect, 
        AknLayoutScalable_Avkon::scroll_pane_cp25(varietyIndex).LayoutLine() ) ;
        
    if (messageBox)
        {
        TAknLayoutRect msgQuery;
      
        TInt varietyIndex = 0;
        switch(messageNumOfLines)
            {
            case (0):
            case (1): varietyIndex = 0;
            break;          
            case (2): varietyIndex = 1;
            break;
            default : varietyIndex = 2;
            }
        msgQuery.LayoutRect( AknPopupLayouts::MenuRect(aDef),
           AknLayoutScalable_Apps::loc_type_pane(varietyIndex).LayoutLine() );
        aMsgQueryCtrl->SetRect(msgQuery.Rect());
        }

    window_rect = WindowRect(aDef);
    MAknsControlContext *cc = AknsDrawUtils::ControlContext( aListBox );
    TBool defaultContext = EFalse;
    if (!cc)
        {
        cc = aListBox->View()->ItemDrawer()->SkinBackgroundControlContext();
        defaultContext = ETrue;
        }
    if (cc)
        {
        CAknsBasicBackgroundControlContext *bcc = (CAknsBasicBackgroundControlContext*)cc;
        TAknLayoutRect popupBgRect;
        popupBgRect.LayoutRect(window_rect,
                               SkinLayout::Popup_windows_skin_placing__background_slice__Line_1(window_rect));
        bcc->SetBitmap(KAknsIIDQsnFrPopupCenter);
        if (defaultContext) bcc->SetRect(popupBgRect.Rect());
        bcc->SetParentPos(aWindowOwningControl->PositionRelativeToScreen());
        if (defaultContext)
            bcc->SetParentPos(TPoint(0,0));
        }
// handled in CFormattedCellListBoxDataExtension, since listbox does not always cover whole
// window rect (listquery/popup list), especially when items are added after construction        
/*
    // note, that cleanup is done in ~CFormattedCellListBoxData()
    // or ( shudder ) in ~CColumnListBoxData()
    MTouchFeedback* feedback = MTouchFeedback::Instance();
    if( feedback )
        {       
        feedback->SetFeedbackArea( aListBox, 0, aListBox->Rect(), 
                    ETouchFeedbackBasic, ETouchEventStylusDown );                                   
        }
*/
}