~ubuntu-branches/ubuntu/maverick/wxwidgets2.8/maverick-proposed

« back to all changes in this revision

Viewing changes to src/msw/window.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2007-11-06 18:25:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071106182513-809agqds6igh7mqo
Tags: 2.8.6.1-0ubuntu1
* New upstream version, based on the upstream tarball
  wxPython-src-2.8.6.1.tar.bz2, renamed debian to debian-upstream.
* Provide a get-orig-source target to do the repackaging.
* Fix "substvar-source-version-is-deprecated" lintian warnings.
* Remove duplicate Description field in debian/control.
* Add "\" at the end of line 8 in debian/python-wxtools.menu to fix
  "bad-test-in-menu-item" lintian error.
* Provide .xpm icons to fix "menu-icon-not-in-xpm-format" lintian errors,
  changed Icon field in debian/python-wxtools.menu.
* Fix "wrong-name-for-upstream-changelog" lintian warnings.
* Remove "Application;" from Categories field in debian/pycrust.desktop,
  debian/pyshell.desktop, debian/xrced.desktop.
* Switch "Apps" to "Applications" in debian/python-wxtools.menu to fix
  "menu-item-uses-apps-section" lintian warnings.
* Drop the icon extension from debian/pycrust.desktop,
  debian/pyshell.desktop, debian/xrced.desktop.
* Add dpatch support.
* Add "WX_CONFIG" patch.
* debian/rules:
  - added .xpm icons to install-gtk-py-tools target
  - added "docs/changes.txt" to dh_installchangelogs in binary-common target
  - added "\" at the end of "install-examples install-msw-dev
    install-msw-dbg install-headers-msw" line in .PHONY

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// Author:      Julian Smart
5
5
// Modified by: VZ on 13.05.99: no more Default(), MSWOnXXX() reorganisation
6
6
// Created:     04/01/98
7
 
// RCS-ID:      $Id: window.cpp,v 1.730.2.4 2007/04/16 13:02:49 VZ Exp $
 
7
// RCS-ID:      $Id: window.cpp 49475 2007-10-26 22:35:54Z RD $
8
8
// Copyright:   (c) Julian Smart
9
9
// Licence:     wxWindows licence
10
10
/////////////////////////////////////////////////////////////////////////////
120
120
#endif
121
121
#endif
122
122
 
 
123
#if wxUSE_UXTHEME
 
124
    #include "wx/msw/uxtheme.h"
 
125
    #define EP_EDITTEXT         1
 
126
    #define ETS_NORMAL          1
 
127
    #define ETS_HOT             2
 
128
    #define ETS_SELECTED        3
 
129
    #define ETS_DISABLED        4
 
130
    #define ETS_FOCUSED         5
 
131
    #define ETS_READONLY        6
 
132
    #define ETS_ASSIST          7
 
133
#endif
 
134
 
123
135
#if defined(TME_LEAVE) && defined(WM_MOUSELEAVE) && wxUSE_DYNLIB_CLASS
124
136
    #define HAVE_TRACKMOUSEEVENT
125
137
#endif // everything needed for TrackMouseEvent()
1378
1390
 
1379
1391
            case wxBORDER_NONE:
1380
1392
            case wxBORDER_SIMPLE:
 
1393
            case wxBORDER_THEME:
1381
1394
                break;
1382
1395
 
1383
1396
            case wxBORDER_STATIC:
1393
1406
                style &= ~WS_BORDER;
1394
1407
                break;
1395
1408
 
1396
 
            case wxBORDER_DOUBLE:
1397
 
                *exstyle |= WS_EX_DLGMODALFRAME;
1398
 
                break;
 
1409
//            case wxBORDER_DOUBLE:
 
1410
//                *exstyle |= WS_EX_DLGMODALFRAME;
 
1411
//                break;
1399
1412
        }
1400
1413
 
1401
1414
        // wxUniv doesn't use Windows dialog navigation functions at all
1412
1425
    return style;
1413
1426
}
1414
1427
 
 
1428
// Helper for getting an appropriate theme style for the application. Unnecessary in
 
1429
// 2.9 and above.
 
1430
wxBorder wxWindowMSW::GetThemedBorderStyle() const
 
1431
{
 
1432
#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
 
1433
    return wxBORDER_SIMPLE;
 
1434
#elif wxUSE_UXTHEME
 
1435
    if (wxUxThemeEngine::GetIfActive())
 
1436
        return wxBORDER_THEME;
 
1437
#endif
 
1438
    return wxBORDER_SUNKEN;
 
1439
}
 
1440
 
1415
1441
// Setup background and foreground colours correctly
1416
1442
void wxWindowMSW::SetupColours()
1417
1443
{
1453
1479
    }
1454
1480
#endif // !HAVE_TRACKMOUSEEVENT
1455
1481
 
1456
 
    if (wxUpdateUIEvent::CanUpdate(this))
 
1482
    if (wxUpdateUIEvent::CanUpdate(this) && IsShown())
1457
1483
        UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
1458
1484
}
1459
1485
 
1490
1516
    if ( !m_frozenness++ )
1491
1517
    {
1492
1518
        if ( IsShown() )
1493
 
            SendSetRedraw(GetHwnd(), false);
 
1519
        {
 
1520
            if ( IsTopLevel() )
 
1521
            {
 
1522
                // If this is a TLW, then freeze it's non-TLW children
 
1523
                // instead.  This is needed because on Windows a frozen TLW
 
1524
                // lets window paint and mouse events pass through to other
 
1525
                // Windows below this one in z-order.
 
1526
                for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
 
1527
                      node;
 
1528
                      node = node->GetNext() )
 
1529
                {
 
1530
                    wxWindow *child = node->GetData();
 
1531
                    if ( child->IsTopLevel() )
 
1532
                        continue;
 
1533
                    else
 
1534
                        child->Freeze();
 
1535
                }
 
1536
            }
 
1537
            else // This is not a TLW, so just freeze it.
 
1538
            {
 
1539
                SendSetRedraw(GetHwnd(), false);
 
1540
            }
 
1541
        }
1494
1542
    }
1495
1543
}
1496
1544
 
1502
1550
    {
1503
1551
        if ( IsShown() )
1504
1552
        {
1505
 
            SendSetRedraw(GetHwnd(), true);
1506
 
 
 
1553
            if ( IsTopLevel() )
 
1554
            {
 
1555
                // If this is a TLW, then Thaw it's non-TLW children
 
1556
                // instead.  See Freeze.
 
1557
                for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
 
1558
                      node;
 
1559
                      node = node->GetNext() )
 
1560
                {
 
1561
                    wxWindow *child = node->GetData();
 
1562
                    if ( child->IsTopLevel() )
 
1563
                        continue;
 
1564
                    else
 
1565
                        child->Thaw();
 
1566
                }
 
1567
            }
 
1568
            else // This is not a TLW, so just thaw it.
 
1569
            {
 
1570
                SendSetRedraw(GetHwnd(), true);
 
1571
            }
 
1572
            
1507
1573
            // we need to refresh everything or otherwise the invalidated area
1508
1574
            // is not going to be repainted
1509
1575
            Refresh();
3234
3300
            }
3235
3301
            break;
3236
3302
#endif // __WXWINCE__
 
3303
 
 
3304
#if wxUSE_UXTHEME
 
3305
        // If we want the default themed border then we need to draw it ourselves
 
3306
        case WM_NCCALCSIZE:
 
3307
            {
 
3308
                wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
 
3309
                if (theme && GetBorder() == wxBORDER_THEME)
 
3310
                {
 
3311
                    // first ask the widget to calculate the border size
 
3312
                    rc.result = MSWDefWindowProc(message, wParam, lParam);
 
3313
                    processed = true;
 
3314
 
 
3315
                    // now alter the client size making room for drawing a themed border
 
3316
                    NCCALCSIZE_PARAMS *csparam = NULL;
 
3317
                    RECT rect;
 
3318
                    if (wParam)
 
3319
                    {
 
3320
                        csparam = (NCCALCSIZE_PARAMS*)lParam;
 
3321
                        rect = csparam->rgrc[0];
 
3322
                    }
 
3323
                    else
 
3324
                    {
 
3325
                        rect = *((RECT*)lParam);
 
3326
                    }
 
3327
                    wxUxThemeHandle hTheme(this, L"EDIT");
 
3328
                    RECT rcClient = { 0, 0, 0, 0 };
 
3329
                    wxClientDC dc(this);
 
3330
 
 
3331
                    if (theme->GetThemeBackgroundContentRect(
 
3332
                            hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL,
 
3333
                            &rect, &rcClient) == S_OK)
 
3334
                    {
 
3335
                        InflateRect(&rcClient, -1, -1);
 
3336
                        if (wParam)
 
3337
                            csparam->rgrc[0] = rcClient;
 
3338
                        else
 
3339
                            *((RECT*)lParam) = rcClient;
 
3340
                        rc.result = WVR_REDRAW;
 
3341
                    }
 
3342
                }
 
3343
            }
 
3344
            break;
 
3345
 
 
3346
        case WM_NCPAINT:
 
3347
            {
 
3348
                wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
 
3349
                if (theme && GetBorder() == wxBORDER_THEME)
 
3350
                {
 
3351
                    // first ask the widget to paint its non-client area, such as scrollbars, etc.
 
3352
                    rc.result = MSWDefWindowProc(message, wParam, lParam);
 
3353
                    processed = true;
 
3354
 
 
3355
                    wxUxThemeHandle hTheme(this, L"EDIT");
 
3356
                    wxWindowDC dc(this);
 
3357
 
 
3358
                    // Clip the DC so that you only draw on the non-client area
 
3359
                    RECT rcBorder;
 
3360
                    wxCopyRectToRECT(GetSize(), rcBorder);
 
3361
 
 
3362
                    RECT rcClient;
 
3363
                    theme->GetThemeBackgroundContentRect(
 
3364
                        hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient);
 
3365
                    InflateRect(&rcClient, -1, -1);
 
3366
 
 
3367
                    ::ExcludeClipRect(GetHdcOf(dc), rcClient.left, rcClient.top,
 
3368
                                      rcClient.right, rcClient.bottom);
 
3369
 
 
3370
                    // Make sure the background is in a proper state
 
3371
                    if (theme->IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
 
3372
                    {
 
3373
                        theme->DrawThemeParentBackground(GetHwnd(), GetHdcOf(dc), &rcBorder);
 
3374
                    }
 
3375
 
 
3376
                    // Draw the border
 
3377
                    int nState;
 
3378
                    if ( !IsEnabled() )
 
3379
                        nState = ETS_DISABLED;
 
3380
                    // should we check this?
 
3381
                    //else if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & ES_READONLY)
 
3382
                    //    nState = ETS_READONLY;
 
3383
                    else
 
3384
                        nState = ETS_NORMAL;
 
3385
                    theme->DrawThemeBackground(hTheme, GetHdcOf(dc), EP_EDITTEXT, nState, &rcBorder, NULL);
 
3386
                }
 
3387
            }
 
3388
            break;
 
3389
 
 
3390
#endif // wxUSE_UXTHEME
 
3391
 
3237
3392
    }
3238
3393
 
3239
3394
    if ( !processed )
4413
4568
    eventNc.SetEventObject(this);
4414
4569
    GetEventHandler()->ProcessEvent(eventNc);
4415
4570
 
 
4571
    // don't keep an HRGN we don't need any longer (GetUpdateRegion() can only
 
4572
    // be called from inside the event handlers called above)
 
4573
    m_updateRegion.Clear();
 
4574
 
4416
4575
    return processed;
4417
4576
}
4418
4577
 
5791
5950
    switch (vk)
5792
5951
    {
5793
5952
        case VK_LBUTTON:
5794
 
            if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_RBUTTON; 
 
5953
            if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_RBUTTON;
5795
5954
            break;
5796
5955
        case VK_RBUTTON:
5797
5956
            if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_LBUTTON;