~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to clientgui/BOINCHtmlLBox.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///////////////////////////////////////////////////////////////////////////////
 
2
// Name:        wx/htmllbox.cpp
 
3
// Purpose:     wxHtmlListBox is a listbox whose items are wxHtmlCells
 
4
// Author:      Vadim Zeitlin
 
5
// Modified by: Charlie Fenton
 
6
// Created:     31.05.03
 
7
// RCS-ID:      $Id: htmllbox.h 49804 2007-11-10 01:09:42Z VZ $
 
8
// Copyright:   (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
 
9
// Licence:     wxWindows licence
 
10
///////////////////////////////////////////////////////////////////////////////
 
11
 
 
12
// Modified for BOINC from wx/htmllbox.cpp
 
13
 
 
14
 
 
15
// ============================================================================
 
16
// declarations
 
17
// ============================================================================
 
18
 
 
19
// ----------------------------------------------------------------------------
 
20
// headers
 
21
// ----------------------------------------------------------------------------
 
22
 
 
23
#include "stdwx.h"
 
24
#include "BOINCHtmlLBox.h"
 
25
 
 
26
// ----------------------------------------------------------------------------
 
27
// constants
 
28
// ----------------------------------------------------------------------------
 
29
 
 
30
const wxChar BOINCHtmlListBoxNameStr[] = wxT("BOINCHtmlListBox");
 
31
 
 
32
// ============================================================================
 
33
// private classes
 
34
// ============================================================================
 
35
 
 
36
// ----------------------------------------------------------------------------
 
37
// CBOINCHtmlListBoxCache
 
38
// ----------------------------------------------------------------------------
 
39
 
 
40
// this class is used by CBOINCHtmlListBox to cache the parsed representation of
 
41
// the items to avoid doing it anew each time an item must be drawn
 
42
class CBOINCHtmlListBoxCache
 
43
{
 
44
private:
 
45
    // invalidate a single item, used by Clear() and InvalidateRange()
 
46
    void InvalidateItem(size_t n)
 
47
    {
 
48
        m_items[n] = (size_t)-1;
 
49
        delete m_cells[n];
 
50
        m_cells[n] = NULL;
 
51
    }
 
52
 
 
53
public:
 
54
    CBOINCHtmlListBoxCache()
 
55
    {
 
56
        for ( size_t n = 0; n < SIZE; n++ )
 
57
        {
 
58
            m_items[n] = (size_t)-1;
 
59
            m_cells[n] = NULL;
 
60
        }
 
61
 
 
62
        m_next = 0;
 
63
    }
 
64
 
 
65
    ~CBOINCHtmlListBoxCache()
 
66
    {
 
67
        for ( size_t n = 0; n < SIZE; n++ )
 
68
        {
 
69
            delete m_cells[n];
 
70
        }
 
71
    }
 
72
 
 
73
    // completely invalidate the cache
 
74
    void Clear()
 
75
    {
 
76
        for ( size_t n = 0; n < SIZE; n++ )
 
77
        {
 
78
            InvalidateItem(n);
 
79
        }
 
80
    }
 
81
 
 
82
    // return the cached cell for this index or NULL if none
 
83
    wxHtmlCell *Get(size_t item) const
 
84
    {
 
85
        for ( size_t n = 0; n < SIZE; n++ )
 
86
        {
 
87
            if ( m_items[n] == item )
 
88
                return m_cells[n];
 
89
        }
 
90
 
 
91
        return NULL;
 
92
    }
 
93
 
 
94
    // returns true if we already have this item cached
 
95
    bool Has(size_t item) const { return Get(item) != NULL; }
 
96
 
 
97
    // ensure that the item is cached
 
98
    void Store(size_t item, wxHtmlCell *cell)
 
99
    {
 
100
        delete m_cells[m_next];
 
101
        m_cells[m_next] = cell;
 
102
        m_items[m_next] = item;
 
103
 
 
104
        // advance to the next item wrapping around if there are no more
 
105
        if ( ++m_next == SIZE )
 
106
            m_next = 0;
 
107
    }
 
108
 
 
109
    // forget the cached value of the item(s) between the given ones (inclusive)
 
110
    void InvalidateRange(size_t from, size_t to)
 
111
    {
 
112
        for ( size_t n = 0; n < SIZE; n++ )
 
113
        {
 
114
            if ( m_items[n] >= from && m_items[n] <= to )
 
115
            {
 
116
                InvalidateItem(n);
 
117
            }
 
118
        }
 
119
    }
 
120
 
 
121
private:
 
122
    // the max number of the items we cache
 
123
    enum { SIZE = 50 };
 
124
 
 
125
    // the index of the LRU (oldest) cell
 
126
    size_t m_next;
 
127
 
 
128
    // the parsed representation of the cached item or NULL
 
129
    wxHtmlCell *m_cells[SIZE];
 
130
 
 
131
    // the index of the currently cached item (only valid if m_cells != NULL)
 
132
    size_t m_items[SIZE];
 
133
};
 
134
 
 
135
// ----------------------------------------------------------------------------
 
136
// CBOINCHtmlListBoxStyle
 
137
// ----------------------------------------------------------------------------
 
138
 
 
139
// just forward wxDefaultHtmlRenderingStyle callbacks to the main class so that
 
140
// they could be overridden by the user code
 
141
class CBOINCHtmlListBoxStyle : public wxDefaultHtmlRenderingStyle
 
142
{
 
143
public:
 
144
    CBOINCHtmlListBoxStyle(const CBOINCHtmlListBox& hlbox) : m_hlbox(hlbox) { }
 
145
 
 
146
    virtual wxColour GetSelectedTextColour(const wxColour& colFg)
 
147
    {
 
148
        return m_hlbox.GetSelectedTextColour(colFg);
 
149
    }
 
150
 
 
151
    virtual wxColour GetSelectedTextBgColour(const wxColour& colBg)
 
152
    {
 
153
        return m_hlbox.GetSelectedTextBgColour(colBg);
 
154
    }
 
155
 
 
156
private:
 
157
    const CBOINCHtmlListBox& m_hlbox;
 
158
 
 
159
    DECLARE_NO_COPY_CLASS(CBOINCHtmlListBoxStyle)
 
160
};
 
161
 
 
162
// ----------------------------------------------------------------------------
 
163
// event tables
 
164
// ----------------------------------------------------------------------------
 
165
 
 
166
BEGIN_EVENT_TABLE(CBOINCHtmlListBox, CBOINCVListBox)
 
167
    EVT_SIZE(CBOINCHtmlListBox::OnSize)
 
168
    EVT_MOTION(CBOINCHtmlListBox::OnMouseMove)
 
169
    EVT_LEFT_DOWN(CBOINCHtmlListBox::OnLeftDown)
 
170
END_EVENT_TABLE()
 
171
 
 
172
// ============================================================================
 
173
// implementation
 
174
// ============================================================================
 
175
 
 
176
IMPLEMENT_ABSTRACT_CLASS(CBOINCHtmlListBox, CBOINCVListBox)
 
177
 
 
178
 
 
179
// ----------------------------------------------------------------------------
 
180
// CBOINCHtmlListBox creation
 
181
// ----------------------------------------------------------------------------
 
182
 
 
183
CBOINCHtmlListBox::CBOINCHtmlListBox()
 
184
    : wxHtmlWindowMouseHelper(this)
 
185
{
 
186
    Init();
 
187
}
 
188
 
 
189
// normal constructor which calls Create() internally
 
190
CBOINCHtmlListBox::CBOINCHtmlListBox(wxWindow *parent,
 
191
                             wxWindowID id,
 
192
                             const wxPoint& pos,
 
193
                             const wxSize& size,
 
194
                             long style,
 
195
                             const wxString& name)
 
196
    : wxHtmlWindowMouseHelper(this)
 
197
{
 
198
    Init();
 
199
 
 
200
    (void)Create(parent, id, pos, size, style, name);
 
201
}
 
202
 
 
203
void CBOINCHtmlListBox::Init()
 
204
{
 
205
    m_htmlParser = NULL;
 
206
    m_htmlRendStyle = new CBOINCHtmlListBoxStyle(*this);
 
207
    m_cache = new CBOINCHtmlListBoxCache;
 
208
}
 
209
 
 
210
bool CBOINCHtmlListBox::Create(wxWindow *parent,
 
211
                           wxWindowID id,
 
212
                           const wxPoint& pos,
 
213
                           const wxSize& size,
 
214
                           long style,
 
215
                           const wxString& name)
 
216
{
 
217
    return CBOINCVListBox::Create(parent, id, pos, size, style, name);
 
218
}
 
219
 
 
220
CBOINCHtmlListBox::~CBOINCHtmlListBox()
 
221
{
 
222
    delete m_cache;
 
223
 
 
224
    if ( m_htmlParser )
 
225
    {
 
226
        delete m_htmlParser->GetDC();
 
227
        delete m_htmlParser;
 
228
    }
 
229
 
 
230
    delete m_htmlRendStyle;
 
231
}
 
232
 
 
233
// ----------------------------------------------------------------------------
 
234
// CBOINCHtmlListBox appearance
 
235
// ----------------------------------------------------------------------------
 
236
 
 
237
wxColour CBOINCHtmlListBox::GetSelectedTextColour(const wxColour& colFg) const
 
238
{
 
239
    return m_htmlRendStyle->
 
240
                wxDefaultHtmlRenderingStyle::GetSelectedTextColour(colFg);
 
241
}
 
242
 
 
243
wxColour
 
244
CBOINCHtmlListBox::GetSelectedTextBgColour(const wxColour& WXUNUSED(colBg)) const
 
245
{
 
246
    return GetSelectionBackground();
 
247
}
 
248
 
 
249
// ----------------------------------------------------------------------------
 
250
// CBOINCHtmlListBox items markup
 
251
// ----------------------------------------------------------------------------
 
252
 
 
253
wxString CBOINCHtmlListBox::OnGetItemMarkup(size_t n) const
 
254
{
 
255
    // we don't even need to wrap the value returned by OnGetItem() inside
 
256
    // "<html><body>" and "</body></html>" because wxHTML can parse it even
 
257
    // without these tags
 
258
    return OnGetItem(n);
 
259
}
 
260
 
 
261
// ----------------------------------------------------------------------------
 
262
// CBOINCHtmlListBox cache handling
 
263
// ----------------------------------------------------------------------------
 
264
 
 
265
void CBOINCHtmlListBox::CacheItem(size_t n) const
 
266
{
 
267
    if ( !m_cache->Has(n) )
 
268
    {
 
269
        if ( !m_htmlParser )
 
270
        {
 
271
            CBOINCHtmlListBox *self = wxConstCast(this, CBOINCHtmlListBox);
 
272
 
 
273
            self->m_htmlParser = new wxHtmlWinParser(self);
 
274
            m_htmlParser->SetDC(new wxClientDC(self));
 
275
            m_htmlParser->SetFS(&self->m_filesystem);
 
276
#if !wxUSE_UNICODE
 
277
            if (GetFont().Ok())
 
278
                m_htmlParser->SetInputEncoding(GetFont().GetEncoding());
 
279
#endif
 
280
            // use system's default GUI font by default:
 
281
            m_htmlParser->SetStandardFonts();
 
282
        }
 
283
 
 
284
        wxHtmlContainerCell *cell = (wxHtmlContainerCell *)m_htmlParser->
 
285
                Parse(OnGetItemMarkup(n));
 
286
        wxCHECK_RET( cell, _T("wxHtmlParser::Parse() returned NULL?") );
 
287
 
 
288
        // set the cell's ID to item's index so that CellCoordsToPhysical()
 
289
        // can quickly find the item:
 
290
        cell->SetId(wxString::Format(_T("%lu"), (unsigned long)n));
 
291
 
 
292
        cell->Layout(GetClientSize().x - (2 * GetMargins().x));
 
293
 
 
294
        m_cache->Store(n, cell);
 
295
    }
 
296
}
 
297
 
 
298
void CBOINCHtmlListBox::OnSize(wxSizeEvent& event)
 
299
{
 
300
    // we need to relayout all the cached cells
 
301
    m_cache->Clear();
 
302
 
 
303
    event.Skip();
 
304
}
 
305
 
 
306
void CBOINCHtmlListBox::RefreshItem(size_t item)
 
307
{
 
308
    wxRect rect;
 
309
 
 
310
    m_cache->InvalidateRange(item, item);
 
311
 
 
312
    GetItemRect(item, rect);
 
313
    RefreshRect(rect);
 
314
}
 
315
 
 
316
void CBOINCHtmlListBox::RefreshItems(size_t from, size_t to)
 
317
{
 
318
    wxRect rect;
 
319
 
 
320
    m_cache->InvalidateRange(from, to);
 
321
 
 
322
    for (size_t i = from; i <= to; ++i) {
 
323
        GetItemRect(i, rect);
 
324
        RefreshRect(rect);
 
325
    }
 
326
}
 
327
 
 
328
void CBOINCHtmlListBox::SetItemCount(size_t count)
 
329
{
 
330
    // the items are going to change, forget the old ones
 
331
    m_cache->Clear();
 
332
 
 
333
    CBOINCVListBox::SetItemCount(count);
 
334
}
 
335
 
 
336
// ----------------------------------------------------------------------------
 
337
// CBOINCHtmlListBox implementation of CBOINCVListBox pure virtuals
 
338
// ----------------------------------------------------------------------------
 
339
 
 
340
void CBOINCHtmlListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
 
341
{
 
342
    CacheItem(n);
 
343
 
 
344
    wxHtmlCell *cell = m_cache->Get(n);
 
345
    wxCHECK_RET( cell, _T("this cell should be cached!") );
 
346
 
 
347
    wxHtmlRenderingInfo htmlRendInfo;
 
348
 
 
349
    // draw the selected cell in selected state
 
350
    if ( IsSelected(n) )
 
351
    {
 
352
        wxHtmlSelection htmlSel;
 
353
        htmlSel.Set(wxPoint(0,0), cell, wxPoint(INT_MAX, INT_MAX), cell);
 
354
        htmlRendInfo.SetSelection(&htmlSel);
 
355
        if ( m_htmlRendStyle )
 
356
            htmlRendInfo.SetStyle(m_htmlRendStyle);
 
357
        htmlRendInfo.GetState().SetSelectionState(wxHTML_SEL_IN);
 
358
    }
 
359
 
 
360
    // note that we can't stop drawing exactly at the window boundary as then
 
361
    // even the visible cells part could be not drawn, so always draw the
 
362
    // entire cell
 
363
    cell->Draw(dc,
 
364
               rect.x + CELL_BORDER, rect.y + CELL_BORDER,
 
365
               0, INT_MAX, htmlRendInfo);
 
366
}
 
367
 
 
368
wxCoord CBOINCHtmlListBox::OnMeasureItem(size_t n) const
 
369
{
 
370
    CacheItem(n);
 
371
 
 
372
    wxHtmlCell *cell = m_cache->Get(n);
 
373
    wxCHECK_MSG( cell, 0, _T("this cell should be cached!") );
 
374
 
 
375
    return cell->GetHeight() + cell->GetDescent() + (2 * CELL_BORDER);
 
376
}
 
377
 
 
378
wxCoord CBOINCHtmlListBox::GetMaxItemWidth() const
 
379
{
 
380
    wxCoord w, maxWidth = 0;
 
381
    size_t n = GetItemCount();
 
382
    for (size_t i = 0; i < n; ++i) {
 
383
        CacheItem(i);
 
384
        wxHtmlCell *cell = m_cache->Get(i);
 
385
        w = cell->GetWidth();
 
386
        if (w > maxWidth) maxWidth = w;
 
387
    }
 
388
    return maxWidth;
 
389
}
 
390
 
 
391
// ----------------------------------------------------------------------------
 
392
// CBOINCHtmlListBox implementation of wxHtmlListBoxWinInterface
 
393
// ----------------------------------------------------------------------------
 
394
 
 
395
void CBOINCHtmlListBox::SetHTMLWindowTitle(const wxString& WXUNUSED(title))
 
396
{
 
397
    // nothing to do
 
398
}
 
399
 
 
400
void CBOINCHtmlListBox::OnHTMLLinkClicked(const wxHtmlLinkInfo& link)
 
401
{
 
402
    OnLinkClicked(GetItemForCell(link.GetHtmlCell()), link);
 
403
}
 
404
 
 
405
void CBOINCHtmlListBox::OnLinkClicked(size_t WXUNUSED(n),
 
406
                                  const wxHtmlLinkInfo& link)
 
407
{
 
408
    wxHtmlLinkEvent event(GetId(), link);
 
409
    GetEventHandler()->ProcessEvent(event);
 
410
}
 
411
 
 
412
wxHtmlOpeningStatus
 
413
CBOINCHtmlListBox::OnHTMLOpeningURL(wxHtmlURLType WXUNUSED(type),
 
414
                                const wxString& WXUNUSED(url),
 
415
                                wxString *WXUNUSED(redirect)) const
 
416
{
 
417
    return wxHTML_OPEN;
 
418
}
 
419
 
 
420
wxPoint CBOINCHtmlListBox::HTMLCoordsToWindow(wxHtmlCell *cell,
 
421
                                          const wxPoint& pos) const
 
422
{
 
423
    return CellCoordsToPhysical(pos, cell);
 
424
}
 
425
 
 
426
wxWindow* CBOINCHtmlListBox::GetHTMLWindow() { return this; }
 
427
 
 
428
wxColour CBOINCHtmlListBox::GetHTMLBackgroundColour() const
 
429
{
 
430
    return GetBackgroundColour();
 
431
}
 
432
 
 
433
void CBOINCHtmlListBox::SetHTMLBackgroundColour(const wxColour& WXUNUSED(clr))
 
434
{
 
435
    // nothing to do
 
436
}
 
437
 
 
438
void CBOINCHtmlListBox::SetHTMLBackgroundImage(const wxBitmap& WXUNUSED(bmpBg))
 
439
{
 
440
    // nothing to do
 
441
}
 
442
 
 
443
void CBOINCHtmlListBox::SetHTMLStatusText(const wxString& WXUNUSED(text))
 
444
{
 
445
    // nothing to do
 
446
}
 
447
 
 
448
wxCursor CBOINCHtmlListBox::GetHTMLCursor(HTMLCursor type) const
 
449
{
 
450
    // we don't want to show text selection cursor in listboxes
 
451
    if (type == HTMLCursor_Text)
 
452
        return wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor_Default);
 
453
 
 
454
    // in all other cases, use the same cursor as wxHtmlWindow:
 
455
    return wxHtmlWindow::GetDefaultHTMLCursor(type);
 
456
}
 
457
 
 
458
// ----------------------------------------------------------------------------
 
459
// CBOINCHtmlListBox utilities
 
460
// ----------------------------------------------------------------------------
 
461
 
 
462
int CBOINCHtmlListBox::HitTest(const wxPoint& pos)
 
463
{
 
464
    if ( CBOINCVListBox::HitTest(pos) == wxNOT_FOUND )
 
465
        return wxNOT_FOUND;
 
466
 
 
467
    int x, y;
 
468
    size_t n = GetItemCount();
 
469
    wxRect r;
 
470
 
 
471
    GetViewStart(&x, &y);
 
472
    wxPoint p(-x*PIXELS_PER_HORIZONTAL_SCROLL_UNIT, -y*PIXELS_PER_VERTICAL_SCROLL_UNIT);
 
473
    p.y -= GetMargins().y + CELL_BORDER;
 
474
    p.x += GetMargins().x - CELL_BORDER;
 
475
 
 
476
    r.SetTopLeft(p);
 
477
    r.SetHeight(0);
 
478
    for (size_t i = 0; i < n; ++i) {
 
479
        CacheItem(i);
 
480
        wxHtmlCell *aCell = m_cache->Get(i);
 
481
        r.height = OnGetItemHeight(i);
 
482
        r.width = aCell->GetWidth();
 
483
        if (r.Contains(pos)) {
 
484
            // convert mouse coordinates to coords relative to item's wxHtmlCell:
 
485
            return i;
 
486
        }
 
487
        r.y += r.height; // + (2 * GetMargins().y);
 
488
    }
 
489
    return wxNOT_FOUND;
 
490
}
 
491
 
 
492
void CBOINCHtmlListBox::GetItemRect(size_t item, wxRect& rect)
 
493
{
 
494
    wxPoint pos = GetRootCellCoords(item);
 
495
    pos.x += GetMargins().x - CELL_BORDER;
 
496
    pos.y -= GetMargins().y + CELL_BORDER;
 
497
    rect.SetTopLeft(pos);
 
498
    CacheItem(item);
 
499
    wxHtmlCell *cell = m_cache->Get(item);
 
500
    rect.height = OnGetItemHeight(item);
 
501
    rect.width = cell->GetWidth();
 
502
}
 
503
 
 
504
bool CBOINCHtmlListBox::IsVisible(size_t item)
 
505
{
 
506
    wxRect rect;
 
507
    
 
508
    GetItemRect(item, rect);
 
509
    
 
510
    return (rect.Intersects(GetRect()));
 
511
}
 
512
 
 
513
// ----------------------------------------------------------------------------
 
514
// CBOINCHtmlListBox handling of HTML links
 
515
// ----------------------------------------------------------------------------
 
516
 
 
517
wxPoint CBOINCHtmlListBox::GetRootCellCoords(size_t n) const
 
518
{
 
519
    int x, y;
 
520
//    wxPoint pos(GetMargins().x - CELL_BORDER, -GetMargins().y - CELL_BORDER);
 
521
    wxPoint pos(0, 0);
 
522
    
 
523
    for (size_t i = 0; i < n; ++i) {
 
524
        pos.y += OnGetItemHeight(i);
 
525
    }
 
526
    GetViewStart(&x, &y);
 
527
    pos.x -= x*PIXELS_PER_HORIZONTAL_SCROLL_UNIT;
 
528
    pos.y -= y*PIXELS_PER_VERTICAL_SCROLL_UNIT;
 
529
    return pos;
 
530
}
 
531
 
 
532
bool CBOINCHtmlListBox::PhysicalCoordsToCell(wxPoint& pos, wxHtmlCell*& cell) const
 
533
{
 
534
    if ( CBOINCVListBox::HitTest(pos) == wxNOT_FOUND )
 
535
        return false;
 
536
 
 
537
    int x, y;
 
538
    size_t n = GetItemCount();
 
539
    wxRect r;
 
540
    wxPoint p(CELL_BORDER, CELL_BORDER);
 
541
    
 
542
    p += GetMargins();
 
543
 
 
544
    GetViewStart(&x, &y);
 
545
    p.x -= x*PIXELS_PER_HORIZONTAL_SCROLL_UNIT;
 
546
    p.y -= y*PIXELS_PER_VERTICAL_SCROLL_UNIT;
 
547
    r.SetTopLeft(p);
 
548
    r.SetHeight(0);
 
549
    for (size_t i = 0; i < n; ++i) {
 
550
        CacheItem(i);
 
551
        wxHtmlCell *aCell = m_cache->Get(i);
 
552
        r.height = aCell->GetHeight() + aCell->GetDescent() + (2 * CELL_BORDER);
 
553
        r.width = aCell->GetWidth();
 
554
        if (r.Contains(pos)) {
 
555
            cell = aCell;
 
556
            // convert mouse coordinates to coords relative to item's wxHtmlCell:
 
557
            pos -= r.GetTopLeft();
 
558
            return true;
 
559
        }
 
560
        r.y += r.height + (2 * GetMargins().y);
 
561
    }
 
562
    
 
563
    return false;
 
564
}
 
565
 
 
566
size_t CBOINCHtmlListBox::GetItemForCell(const wxHtmlCell *cell) const
 
567
{
 
568
    wxCHECK_MSG( cell, 0, _T("no cell") );
 
569
 
 
570
    cell = cell->GetRootCell();
 
571
 
 
572
    wxCHECK_MSG( cell, 0, _T("no root cell") );
 
573
 
 
574
    // the cell's ID contains item index, see CacheItem():
 
575
    unsigned long n;
 
576
    if ( !cell->GetId().ToULong(&n) )
 
577
    {
 
578
        wxFAIL_MSG( _T("unexpected root cell's ID") );
 
579
        return 0;
 
580
    }
 
581
 
 
582
    return n;
 
583
}
 
584
 
 
585
wxPoint
 
586
CBOINCHtmlListBox::CellCoordsToPhysical(const wxPoint& pos, wxHtmlCell *cell) const
 
587
{
 
588
    return pos + GetRootCellCoords(GetItemForCell(cell));
 
589
}
 
590
 
 
591
void CBOINCHtmlListBox::OnInternalIdle()
 
592
{
 
593
    CBOINCVListBox::OnInternalIdle();
 
594
 
 
595
    if ( wxHtmlWindowMouseHelper::DidMouseMove() )
 
596
    {
 
597
        wxPoint pos = ScreenToClient(wxGetMousePosition());
 
598
        wxHtmlCell *cell;
 
599
 
 
600
        if ( !PhysicalCoordsToCell(pos, cell) )
 
601
            return;
 
602
 
 
603
        wxHtmlWindowMouseHelper::HandleIdle(cell, pos);
 
604
    }
 
605
}
 
606
 
 
607
void CBOINCHtmlListBox::OnMouseMove(wxMouseEvent& event)
 
608
{
 
609
    wxHtmlWindowMouseHelper::HandleMouseMoved();
 
610
    event.Skip();
 
611
}
 
612
 
 
613
void CBOINCHtmlListBox::OnLeftDown(wxMouseEvent& event)
 
614
{
 
615
    wxPoint pos = event.GetPosition();
 
616
    wxHtmlCell *cell;
 
617
 
 
618
    if ( !PhysicalCoordsToCell(pos, cell) )
 
619
    {
 
620
        event.Skip();
 
621
        return;
 
622
    }
 
623
 
 
624
    if ( !wxHtmlWindowMouseHelper::HandleMouseClick(cell, pos, event) )
 
625
    {
 
626
        // no link was clicked, so let the listbox code handle the click (e.g.
 
627
        // by selecting another item in the list):
 
628
        event.Skip();
 
629
    }
 
630
}