1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vector>
#include "svtools/controldims.hrc"
#include "RemoteDialogClientBox.hxx"
#include "RemoteServer.hxx"
#include "comphelper/processfactory.hxx"
#include "com/sun/star/i18n/CollatorOptions.hpp"
#include "com/sun/star/deployment/DependencyException.hpp"
#include "com/sun/star/deployment/DeploymentException.hpp"
#include <vcl/settings.hxx>
#include <vcl/builderfactory.hxx>
#include "glob.hrc"
using namespace std;
using namespace ::com::sun::star;
namespace sd {
// struct ClientBoxEntry
ClientBoxEntry::ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo ) :
m_bActive( false ),
m_pClientInfo( pClientInfo )
{
}
ClientBoxEntry::~ClientBoxEntry()
{}
void ClientRemovedListener::disposing( lang::EventObject const & rEvt )
throw ( uno::RuntimeException, std::exception )
{
(void) rEvt;
}
ClientRemovedListener::~ClientRemovedListener()
{
}
// ClientBox
ClientBox::ClientBox( vcl::Window* pParent, WinBits nStyle ) :
Control( pParent, nStyle ),
m_bHasScrollBar( false ),
m_bHasActive( false ),
m_bNeedsRecalc( true ),
m_bInCheckMode( false ),
m_bAdjustActive( false ),
m_bInDelete( false ),
m_nActive( 0 ),
m_nTopIndex( 0 ),
m_nActiveHeight( 0 ),
m_nExtraHeight( 2 ),
m_aPinBox( VclPtr<NumericBox>::Create( this, 0 ) ),
m_aDeauthoriseButton( VclPtr<PushButton>::Create( this ) ),
m_aScrollBar( VclPtr<ScrollBar>::Create( this, WB_VERT ) )
{
m_aScrollBar->SetScrollHdl( LINK( this, ClientBox, ScrollHdl ) );
m_aScrollBar->EnableDrag();
m_aPinBox->SetUseThousandSep(false);
m_aDeauthoriseButton->SetText( SD_RESSTR(STR_DEAUTHORISE_CLIENT) );
m_aDeauthoriseButton->SetClickHdl( LINK( this, ClientBox, DeauthoriseHdl ) );
SetPosPixel( Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ) );
long nIconHeight = 2*TOP_OFFSET + SMALL_ICON_SIZE;
long nTitleHeight = 2*TOP_OFFSET + GetTextHeight();
if ( nIconHeight < nTitleHeight )
m_nStdHeight = nTitleHeight;
else
m_nStdHeight = nIconHeight;
m_nStdHeight += GetTextHeight() + TOP_OFFSET;
m_nActiveHeight = m_nStdHeight;
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if( IsControlBackground() )
SetBackground( GetControlBackground() );
else
SetBackground( rStyleSettings.GetFieldColor() );
m_xRemoveListener = new ClientRemovedListener( this );
populateEntries();
Show();
}
VCL_BUILDER_DECL_FACTORY(ClientBox)
{
WinBits nWinStyle = WB_TABSTOP;
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
rRet = VclPtr<ClientBox>::Create(pParent, nWinStyle);
}
Size ClientBox::GetOptimalSize() const
{
return LogicToPixel(Size(200, 140), MAP_APPFONT);
}
ClientBox::~ClientBox()
{
disposeOnce();
}
void ClientBox::dispose()
{
if ( ! m_bInDelete )
DeleteRemoved();
m_bInDelete = true;
m_vEntries.clear();
m_xRemoveListener.clear();
m_aPinBox.disposeAndClear();
m_aDeauthoriseButton.disposeAndClear();
m_aScrollBar.disposeAndClear();
Control::dispose();
}
// Title + description
void ClientBox::CalcActiveHeight( const long nPos )
{
(void) nPos;
const ::osl::MutexGuard aGuard( m_entriesMutex );
// get title height
long aTextHeight;
long nIconHeight = 2*TOP_OFFSET + SMALL_ICON_SIZE;
long nTitleHeight = 2*TOP_OFFSET + GetTextHeight();
if ( nIconHeight < nTitleHeight )
aTextHeight = nTitleHeight;
else
aTextHeight = nIconHeight;
// Text entry height
Size aSize = GetOutputSizePixel();
if ( m_bHasScrollBar )
aSize.Width() -= m_aScrollBar->GetSizePixel().Width();
aSize.Width() -= ICON_OFFSET;
aSize = LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
MapMode( MAP_APPFONT ) );
aTextHeight += aSize.Height();
if ( aTextHeight < m_nStdHeight )
aTextHeight = m_nStdHeight;
m_nActiveHeight = aTextHeight + 2;
}
Rectangle ClientBox::GetEntryRect( const long nPos ) const
{
const ::osl::MutexGuard aGuard( m_entriesMutex );
Size aSize( GetOutputSizePixel() );
if ( m_bHasScrollBar )
aSize.Width() -= m_aScrollBar->GetSizePixel().Width();
if ( m_vEntries[ nPos ]->m_bActive )
aSize.Height() = m_nActiveHeight;
else
aSize.Height() = m_nStdHeight;
Point aPos( 0, -m_nTopIndex + nPos * m_nStdHeight );
if ( m_bHasActive && ( nPos < m_nActive ) )
aPos.Y() += m_nActiveHeight - m_nStdHeight;
return Rectangle( aPos, aSize );
}
void ClientBox::DeleteRemoved()
{
const ::osl::MutexGuard aGuard( m_entriesMutex );
m_bInDelete = true;
if ( ! m_vRemovedEntries.empty() )
{
m_vRemovedEntries.clear();
}
m_bInDelete = false;
}
long ClientBox::GetActiveEntryIndex()
{
if ( m_bHasActive )
return m_nActive;
else
return -1;
}
//This function may be called with nPos < 0
void ClientBox::selectEntry( const long nPos )
{
//ToDo whe should not use the guard at such a big scope here.
//Currently it is used to guard m_vEntries and m_nActive. m_nActive will be
//modified in this function.
//It would be probably best to always use a copy of m_vEntries
//and some other state variables from ClientBox for
//the whole painting operation. See issue i86993
::osl::ClearableMutexGuard guard(m_entriesMutex);
if ( m_bInCheckMode )
return;
if ( m_bHasActive )
{
if ( nPos == m_nActive )
return;
m_bHasActive = false;
m_vEntries[ m_nActive ]->m_bActive = false;
}
if ( ( nPos >= 0 ) && ( nPos < (long) m_vEntries.size() ) )
{
m_bHasActive = true;
m_nActive = nPos;
m_vEntries[ nPos ]->m_bActive = true;
if ( IsReallyVisible() )
{
m_bAdjustActive = true;
}
}
// We empty the pin box now too, just in case the user previously
// entered a pin, but then changed their selected device.
m_aPinBox->SetText( "" );
if ( m_bHasActive )
{
bool bAlreadyAuthorised =
m_vEntries[ m_nActive ]->m_pClientInfo->mbIsAlreadyAuthorised;
if ( bAlreadyAuthorised )
{
m_aDeauthoriseButton->GetFocus();
}
else
{
m_aPinBox->GetFocus();
}
}
if ( IsReallyVisible() )
{
m_bNeedsRecalc = true;
Invalidate();
}
guard.clear();
}
void ClientBox::DrawRow(vcl::RenderContext& rRenderContext, const Rectangle& rRect, const TClientBoxEntry& rEntry)
{
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
if (rEntry->m_bActive)
SetTextColor(rStyleSettings.GetHighlightTextColor());
else
SetTextColor(rStyleSettings.GetFieldTextColor());
if (rEntry->m_bActive)
{
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor());
rRenderContext.DrawRect(rRect);
}
else
{
if(IsControlBackground())
SetBackground(GetControlBackground());
else
SetBackground(rStyleSettings.GetFieldColor());
rRenderContext.SetTextFillColor();
rRenderContext.Erase(rRect);
}
// FIXME: draw bluetooth or wifi icon
Point aPos(rRect.TopLeft());
// Setup fonts
vcl::Font aStdFont(rRenderContext.GetFont());
vcl::Font aBoldFont(aStdFont);
aBoldFont.SetWeight(WEIGHT_BOLD);
rRenderContext.SetFont(aBoldFont);
long aTextHeight = rRenderContext.GetTextHeight();
// Get max title width
long nMaxTitleWidth = rRect.GetWidth() - ICON_OFFSET;
nMaxTitleWidth -= ( 2 * SMALL_ICON_SIZE ) + ( 4 * SPACE_BETWEEN );
long aTitleWidth = rRenderContext.GetTextWidth(rEntry->m_pClientInfo->mName) + (aTextHeight / 3);
aPos = rRect.TopLeft() + Point(ICON_OFFSET, TOP_OFFSET);
if (aTitleWidth > nMaxTitleWidth)
{
aTitleWidth = nMaxTitleWidth - (aTextHeight / 3);
OUString aShortTitle = rRenderContext.GetEllipsisString(rEntry->m_pClientInfo->mName, aTitleWidth );
rRenderContext.DrawText(aPos, aShortTitle);
}
else
rRenderContext.DrawText(aPos, rEntry->m_pClientInfo->mName);
SetFont(aStdFont);
aPos.Y() += aTextHeight;
if (rEntry->m_bActive)
{
OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
DrawText(m_sPinTextRect, sPinText);
}
rRenderContext.SetLineColor(Color(COL_LIGHTGRAY));
rRenderContext.DrawLine(rRect.BottomLeft(), rRect.BottomRight());
}
void ClientBox::RecalcAll()
{
if ( m_bHasActive )
CalcActiveHeight( m_nActive );
SetupScrollBar();
Size aPBSize = LogicToPixel(
Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
MapMode( MAP_APPFONT ) );
m_aPinBox->SetSizePixel( aPBSize );
m_aDeauthoriseButton->SetSizePixel( m_aDeauthoriseButton->GetOptimalSize() );
if ( !m_bHasActive )
{
m_aPinBox->Show( false );
m_aDeauthoriseButton->Show( false );
}
else
{
Rectangle aEntryRect = GetEntryRect( m_nActive );
Size aPinBoxSize( m_aPinBox->GetSizePixel() );
Point aPos( aEntryRect.Left(),
aEntryRect.Bottom() - TOP_OFFSET - aPinBoxSize.Height() );
bool bAlreadyAuthorised = m_vEntries[ m_nActive ]->m_pClientInfo->mbIsAlreadyAuthorised;
if ( !bAlreadyAuthorised )
{
m_sPinTextRect = Rectangle( aPos.X(), aPos.Y(),
aEntryRect.Right(),
aEntryRect.Bottom() - TOP_OFFSET);
OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
aPos = Point( aEntryRect.Left() + GetTextWidth( sPinText ),
aEntryRect.Bottom() - TOP_OFFSET - aPinBoxSize.Height() );
m_aPinBox->SetPosPixel( aPos );
// The text would have it's TOP aligned with the top of
// the pin box -- hence we push it down to align baselines.
m_sPinTextRect += Point( 0, 4 );
}
else
{
aPos += Point( 20, 0 );
m_aDeauthoriseButton->SetPosPixel( aPos );
}
m_aPinBox->Show( !bAlreadyAuthorised );
m_aDeauthoriseButton->Show( bAlreadyAuthorised );
if ( m_bAdjustActive )
{
m_bAdjustActive = false;
// If the top of the selected entry isn't visible, make it visible
if ( aEntryRect.Top() < 0 )
{
m_nTopIndex += aEntryRect.Top();
aEntryRect.Move( 0, -aEntryRect.Top() );
}
// If the bottom of the selected entry isn't visible, make it visible even if now the top
// isn't visible any longer ( the buttons are more important )
Size aOutputSize = GetOutputSizePixel();
if ( aEntryRect.Bottom() > aOutputSize.Height() )
{
m_nTopIndex += ( aEntryRect.Bottom() - aOutputSize.Height() );
aEntryRect.Move( 0, -( aEntryRect.Bottom() - aOutputSize.Height() ) );
}
// If there is unused space below the last entry but all entries don't fit into the box,
// move the content down to use the whole space
const long nTotalHeight = GetTotalHeight();
if ( m_bHasScrollBar && ( aOutputSize.Height() + m_nTopIndex > nTotalHeight ) )
{
long nOffset = m_nTopIndex;
m_nTopIndex = nTotalHeight - aOutputSize.Height();
nOffset -= m_nTopIndex;
aEntryRect.Move( 0, nOffset );
}
if ( m_bHasScrollBar )
m_aScrollBar->SetThumbPos( m_nTopIndex );
}
}
m_bNeedsRecalc = false;
}
bool ClientBox::HandleCursorKey( sal_uInt16 nKeyCode )
{
if ( m_vEntries.empty() )
return true;
long nSelect = 0;
if ( m_bHasActive )
{
long nPageSize = GetOutputSizePixel().Height() / m_nStdHeight;
if ( nPageSize < 2 )
nPageSize = 2;
if ( ( nKeyCode == KEY_DOWN ) || ( nKeyCode == KEY_RIGHT ) )
nSelect = m_nActive + 1;
else if ( ( nKeyCode == KEY_UP ) || ( nKeyCode == KEY_LEFT ) )
nSelect = m_nActive - 1;
else if ( nKeyCode == KEY_HOME )
nSelect = 0;
else if ( nKeyCode == KEY_END )
nSelect = m_vEntries.size() - 1;
else if ( nKeyCode == KEY_PAGEUP )
nSelect = m_nActive - nPageSize + 1;
else if ( nKeyCode == KEY_PAGEDOWN )
nSelect = m_nActive + nPageSize - 1;
}
else // when there is no selected entry, we will select the first or the last.
{
if ( ( nKeyCode == KEY_DOWN ) || ( nKeyCode == KEY_PAGEDOWN ) || ( nKeyCode == KEY_HOME ) )
nSelect = 0;
else if ( ( nKeyCode == KEY_UP ) || ( nKeyCode == KEY_PAGEUP ) || ( nKeyCode == KEY_END ) )
nSelect = m_vEntries.size() - 1;
}
if ( nSelect < 0 )
nSelect = 0;
if ( nSelect >= (long) m_vEntries.size() )
nSelect = m_vEntries.size() - 1;
selectEntry( nSelect );
return true;
}
void ClientBox::Paint(vcl::RenderContext& rRenderContext, const Rectangle &/*rPaintRect*/)
{
if (!m_bInDelete)
DeleteRemoved();
if (m_bNeedsRecalc)
RecalcAll();
Point aStart(0, -m_nTopIndex);
Size aSize(GetOutputSizePixel());
if (m_bHasScrollBar)
aSize.Width() -= m_aScrollBar->GetSizePixel().Width();
const ::osl::MutexGuard aGuard(m_entriesMutex);
typedef std::vector< TClientBoxEntry >::iterator ITER;
for (ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex)
{
aSize.Height() = (*iIndex)->m_bActive ? m_nActiveHeight : m_nStdHeight;
Rectangle aEntryRect(aStart, aSize);
DrawRow(rRenderContext, aEntryRect, *iIndex);
aStart.Y() += aSize.Height();
}
}
long ClientBox::GetTotalHeight() const
{
long nHeight = m_vEntries.size() * m_nStdHeight;
if ( m_bHasActive )
{
nHeight += m_nActiveHeight - m_nStdHeight;
}
return nHeight;
}
void ClientBox::SetupScrollBar()
{
const Size aSize = GetOutputSizePixel();
const long nScrBarSize = GetSettings().GetStyleSettings().GetScrollBarSize();
const long nTotalHeight = GetTotalHeight();
const bool bNeedsScrollBar = ( nTotalHeight > aSize.Height() );
if ( bNeedsScrollBar )
{
if ( m_nTopIndex + aSize.Height() > nTotalHeight )
m_nTopIndex = nTotalHeight - aSize.Height();
m_aScrollBar->SetPosSizePixel( Point( aSize.Width() - nScrBarSize, 0 ),
Size( nScrBarSize, aSize.Height() ) );
m_aScrollBar->SetRangeMax( nTotalHeight );
m_aScrollBar->SetVisibleSize( aSize.Height() );
m_aScrollBar->SetPageSize( ( aSize.Height() * 4 ) / 5 );
m_aScrollBar->SetLineSize( m_nStdHeight );
m_aScrollBar->SetThumbPos( m_nTopIndex );
if ( !m_bHasScrollBar )
m_aScrollBar->Show();
}
else if ( m_bHasScrollBar )
{
m_aScrollBar->Hide();
m_nTopIndex = 0;
}
m_bHasScrollBar = bNeedsScrollBar;
}
void ClientBox::Resize()
{
RecalcAll();
}
long ClientBox::PointToPos( const Point& rPos )
{
long nPos = ( rPos.Y() + m_nTopIndex ) / m_nStdHeight;
if ( m_bHasActive && ( nPos > m_nActive ) )
{
if ( rPos.Y() + m_nTopIndex <= m_nActive*m_nStdHeight + m_nActiveHeight )
nPos = m_nActive;
else
nPos = ( rPos.Y() + m_nTopIndex - (m_nActiveHeight - m_nStdHeight) ) / m_nStdHeight;
}
return nPos;
}
OUString ClientBox::getPin()
{
return OUString::number( m_aPinBox->GetValue() );
}
void ClientBox::MouseButtonDown( const MouseEvent& rMEvt )
{
long nPos = PointToPos( rMEvt.GetPosPixel() );
if ( rMEvt.IsLeft() )
{
if ( rMEvt.IsMod1() && m_bHasActive )
selectEntry( m_vEntries.size() ); // Selecting an not existing entry will deselect the current one
else
selectEntry( nPos );
}
}
bool ClientBox::Notify( NotifyEvent& rNEvt )
{
if ( !m_bInDelete )
DeleteRemoved();
bool bHandled = false;
if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
{
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
sal_uInt16 nKeyCode = aKeyCode.GetCode();
if ( aKeyCode.GetGroup() == KEYGROUP_CURSOR )
bHandled = HandleCursorKey( nKeyCode );
}
if ( rNEvt.GetType() == MouseNotifyEvent::COMMAND )
{
if ( m_bHasScrollBar &&
( rNEvt.GetCommandEvent()->GetCommand() == CommandEventId::Wheel ) )
{
const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
if ( pData->GetMode() == CommandWheelMode::SCROLL )
{
long nThumbPos = m_aScrollBar->GetThumbPos();
if ( pData->GetDelta() < 0 )
m_aScrollBar->DoScroll( nThumbPos + m_nStdHeight );
else
m_aScrollBar->DoScroll( nThumbPos - m_nStdHeight );
bHandled = true;
}
}
}
if ( !bHandled )
return Control::Notify( rNEvt );
else
return true;
}
long ClientBox::addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo )
{
long nPos = 0;
TClientBoxEntry xEntry( new ClientBoxEntry( pClientInfo ) );
::osl::ClearableMutexGuard guard(m_entriesMutex);
if ( m_vEntries.empty() )
{
m_vEntries.push_back( xEntry );
}
else
{
// if ( !FindEntryPos( xEntry, 0, m_vEntries.size()-1, nPos ) )
// {
m_vEntries.insert( m_vEntries.begin()+nPos, xEntry );
// }
// else if ( !m_bInCheckMode )
// {
// OSL_FAIL( "ClientBox::addEntry(): Will not add duplicate entries" );
// }
}
//access to m_nActive must be guarded
if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) )
m_nActive += 1;
guard.clear();
if ( IsReallyVisible() )
Invalidate();
m_bNeedsRecalc = true;
return nPos;
}
void ClientBox::clearEntries()
{
selectEntry( -1 );
m_bHasActive = false;
const ::osl::MutexGuard aGuard( m_entriesMutex );
m_vEntries.clear();
if ( IsReallyVisible() )
Invalidate();
m_bNeedsRecalc = true;
}
void ClientBox::populateEntries()
{
const ::osl::MutexGuard aGuard( m_entriesMutex );
clearEntries();
#ifdef ENABLE_SDREMOTE
RemoteServer::ensureDiscoverable();
vector< ::boost::shared_ptr< ClientInfo > > aClients( RemoteServer::getClients() );
const vector< ::boost::shared_ptr<ClientInfo > >::const_iterator aEnd( aClients.end() );
for ( vector< ::boost::shared_ptr< ClientInfo > >::const_iterator aIt( aClients.begin() );
aIt != aEnd; ++aIt )
{
addEntry( *aIt );
}
#endif
if ( IsReallyVisible() )
Invalidate();
m_bNeedsRecalc = true;
}
void ClientBox::DoScroll( long nDelta )
{
m_nTopIndex += nDelta;
Point aNewSBPt( m_aScrollBar->GetPosPixel() );
Rectangle aScrRect( Point(), GetOutputSizePixel() );
aScrRect.Right() -= m_aScrollBar->GetSizePixel().Width();
Scroll( 0, -nDelta, aScrRect );
m_aScrollBar->SetPosPixel( aNewSBPt );
}
IMPL_LINK( ClientBox, ScrollHdl, ScrollBar*, pScrBar )
{
DoScroll( pScrBar->GetDelta() );
return 1;
}
IMPL_LINK_NOARG_TYPED( ClientBox, DeauthoriseHdl, Button*, void )
{
long aSelected = GetActiveEntryIndex();
if ( aSelected < 0 )
return;
TClientBoxEntry aEntry = GetEntryData(aSelected);
#ifdef ENABLE_SDREMOTE
RemoteServer::deauthoriseClient( aEntry->m_pClientInfo );
#endif
populateEntries();
}
} //namespace dp_gui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|