]> git.saurik.com Git - wxWidgets.git/blame - demos/dbbrowse/tabpgwin.cpp
Build fix for motif.
[wxWidgets.git] / demos / dbbrowse / tabpgwin.cpp
CommitLineData
b5ffecfc 1/////////////////////////////////////////////////////////////////////////////
9e4d1095 2// Name: tabpgwin.cpp
b5ffecfc
GT
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
829c421b 5// Modified by: 19990908 : mj
b5ffecfc
GT
6// - rename to tabpgwin
7// - restruction of Variable declaration
645889ad 8// - to prevent Warnings under MingW32
829c421b 9// Modified by: 19990909 : mj
5151c7af 10// - mNoVertScroll true = no / false = Original Code
645889ad 11// the Original Code Paints a Vertical Scroll in wxPagedWindow
5151c7af 12// which is not needed in this Version. Use true for this.
b5ffecfc
GT
13// Created: 07/09/98
14// RCS-ID: $Id$
15// Copyright: (c) Aleksandras Gluchovas
16// Licence: wxWindows license
17/////////////////////////////////////////////////////////////////////////////
18
b5ffecfc
GT
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23#pragma hdrstop
24#endif
25
26#ifndef WX_PRECOMP
27#include "wx/wx.h"
28#endif
29
b713f891
WS
30#include "wx/math.h"
31
b5ffecfc
GT
32#include <stdlib.h>
33
34#include "wx/string.h"
35#include "wx/utils.h" // import wxMin/wxMax macros and wxFileExist(..)
36
37#include "tabpgwin.h"
645889ad 38
b5ffecfc
GT
39//---------------------------------------------------------------------------
40// Implementation for class twTabInfo
41//---------------------------------------------------------------------------
42IMPLEMENT_DYNAMIC_CLASS( twTabInfo, wxObject )
645889ad
GT
43
44//---------------------------------------------------------------------------
45twTabInfo::twTabInfo()
46: mpContent( 0 )
b5ffecfc 47{}
645889ad 48
b5ffecfc
GT
49//---------------------------------------------------------------------------
50int twTabInfo::ImgWidth()
51{
645889ad
GT
52 if ( mBitMap.Ok() ) return mBitMap.GetWidth();
53 else return 0;
b5ffecfc 54}
645889ad 55
b5ffecfc
GT
56//---------------------------------------------------------------------------
57int twTabInfo::ImgHeight()
58{
645889ad
GT
59 if ( mBitMap.Ok() )
60 return mBitMap.GetHeight();
61 else
62 return 0;
b5ffecfc 63}
645889ad 64
b5ffecfc
GT
65//---------------------------------------------------------------------------
66int twTabInfo::ImageToTxtGap( int prefGap )
67{
645889ad
GT
68 if ( mBitMap.Ok() )
69 return prefGap;
70 else
71 return 0;
b5ffecfc 72}
645889ad 73
b5ffecfc
GT
74//---------------------------------------------------------------------------
75bool twTabInfo::HasImg()
76{
645889ad 77 return mBitMap.Ok();
b5ffecfc 78}
645889ad 79
b5ffecfc
GT
80//---------------------------------------------------------------------------
81// bool twTabInfo::HasText();
82unsigned int twTabInfo::HasText()
83{
645889ad 84 return mText.Length();
b5ffecfc 85}
645889ad 86
b5ffecfc
GT
87//---------------------------------------------------------------------------
88wxBitmap& twTabInfo::GetImg()
89{
645889ad 90 return mBitMap;
b5ffecfc 91}
645889ad 92
b5ffecfc
GT
93//---------------------------------------------------------------------------
94wxString& twTabInfo::GetText()
95{
645889ad 96 return mText;
b5ffecfc 97}
645889ad 98
b5ffecfc
GT
99//---------------------------------------------------------------------------
100wxWindow& twTabInfo::GetContent()
101{
645889ad 102 return *mpContent;
b5ffecfc 103}
645889ad 104
b5ffecfc
GT
105//---------------------------------------------------------------------------
106// Implementation for class wxTabbedWindow
107//---------------------------------------------------------------------------
108IMPLEMENT_DYNAMIC_CLASS( wxTabbedWindow, wxPanel )
645889ad
GT
109
110//---------------------------------------------------------------------------
111BEGIN_EVENT_TABLE( wxTabbedWindow, wxPanel )
112 EVT_SIZE ( wxTabbedWindow::OnSize )
113 EVT_PAINT( wxTabbedWindow::OnPaint )
114 EVT_LEFT_DOWN( wxTabbedWindow::OnLButtonDown )
115 // TDB:: filciker reduction
116 // EVT_ERASE_BACKGROUND( wxTabbedWindow::OnBkErase )
117END_EVENT_TABLE()
118
119//---------------------------------------------------------------------------
120wxTabbedWindow::wxTabbedWindow()
121
122: mpTabScroll ( NULL ),
123 mpHorizScroll( NULL ),
124 mpVertScroll ( NULL ),
125
126 mVertGap ( 0 ),
127 mHorizGap( 0 ),
128
129 mTitleVertGap ( 3 ),
130 mTitleHorizGap( 4 ),
131 mImageTextGap ( 2 ),
132 mFirstTitleGap( 11 ),
133
134 mBorderOnlyWidth( 8 ),
135
136 mWhitePen( wxColour(255,255,255), 1, wxSOLID ),
137 mGrayPen ( wxColour(192,192,192), 1, wxSOLID ),
138 mDarkPen ( wxColour(128,128,128), 1, wxSOLID ),
139 mBlackPen( wxColour( 0, 0, 0), 1, wxSOLID ),
140
141 // state variables
142 mActiveTab ( 0 ),
143 mTitleHeight( 0 ),
144 mLayoutType( wxTITLE_IMG_AND_TEXT )
b5ffecfc 145{}
645889ad 146
b5ffecfc
GT
147//---------------------------------------------------------------------------
148wxTabbedWindow::~wxTabbedWindow()
149{
8b567f9b 150 wxObjectList::compatibility_iterator pTab = mTabs.GetFirst();
254a2129 151
645889ad 152 while( pTab )
b5ce269b 153 {
74de91cc
JS
154 delete ((twTabInfo*)pTab->GetData());
155 pTab = pTab->GetNext();
b5ce269b 156 }
b5ffecfc 157}
645889ad 158
b5ffecfc 159//---------------------------------------------------------------------------
74de91cc 160void wxTabbedWindow::SizeTabs(int x,int y, int width, int height, bool WXUNUSED(repant))
b5ffecfc 161{
8b567f9b 162 wxObjectList::compatibility_iterator pTabNode = mTabs.GetFirst();
74de91cc 163 size_t n = 0;
254a2129 164
645889ad
GT
165 while( pTabNode )
166 {
74de91cc 167 twTabInfo& info = *((twTabInfo*)pTabNode->GetData());
254a2129 168
645889ad
GT
169 if ( n == mActiveTab )
170 {
171 //wxSizeEvent evt;
172 //info.mpContent->GetEventHandler()->ProcessEvent( evt );
254a2129 173
645889ad 174 info.mpContent->SetSize( x, y, width, height, 0 );
5151c7af 175 info.mpContent->Show(true);
645889ad 176 info.mpContent->Refresh();
254a2129 177
645889ad
GT
178 }
179 else
180 {
5151c7af 181 info.mpContent->Show(false);
645889ad 182 }
254a2129 183
74de91cc 184 pTabNode = pTabNode->GetNext();
645889ad
GT
185 ++n;
186 }
b5ffecfc 187}
645889ad 188
b5ffecfc 189//---------------------------------------------------------------------------
0147a7c1
GD
190void wxTabbedWindow::AddTab( wxWindow* pContent,
191 wxString tabText,
192 wxString imageFileName,
193 wxBitmapType imageType )
b5ffecfc 194{
645889ad 195 twTabInfo* pTab = new twTabInfo();
254a2129 196
645889ad
GT
197 pTab->mpContent = pContent;
198 pTab->mText = tabText;
254a2129 199
645889ad 200 if ( wxFileExists( imageFileName ) &&
254a2129 201
645889ad 202 pTab->mBitMap.LoadFile( imageFileName, imageType ) )
b5ce269b 203 {
645889ad
GT
204 pTab->mImageFile = imageFileName;
205 pTab->mImageType = imageType;
b5ce269b 206 }
254a2129
WS
207
208
645889ad 209 if ( pContent->GetParent() == NULL )
5151c7af 210 pContent->Create( this, wxID_ANY );
254a2129 211
645889ad 212 mTabs.Append( (wxObject*)pTab );
254a2129 213
5151c7af 214 RecalcLayout(true);
254a2129 215
645889ad 216 OnTabAdded( pTab );
b5ffecfc 217}
645889ad 218
b5ffecfc
GT
219//---------------------------------------------------------------------------
220void wxTabbedWindow::AddTab( wxWindow* pContent,
645889ad 221 wxString tabText, wxBitmap* pImage )
b5ffecfc 222{
645889ad 223 twTabInfo* pTab = new twTabInfo();
254a2129 224
645889ad
GT
225 pTab->mpContent = pContent;
226 pTab->mText = tabText;
254a2129 227
645889ad
GT
228 if ( pImage )
229 pTab->mBitMap = *pImage;
254a2129 230
645889ad 231 if ( pContent->GetParent() == NULL )
5151c7af 232 pContent->Create( this, wxID_ANY );
254a2129 233
645889ad 234 mTabs.Append( (wxObject*)pTab );
5151c7af 235 RecalcLayout(true);
645889ad 236 OnTabAdded( pTab );
b5ffecfc 237}
645889ad 238
b5ffecfc
GT
239//---------------------------------------------------------------------------
240void wxTabbedWindow::RemoveTab( int tabNo )
241{
74de91cc 242 twTabInfo* pTab = ((twTabInfo*)(mTabs.Item( tabNo )->GetData()));
645889ad
GT
243 pTab->mpContent->Destroy();
244 delete pTab;
8b567f9b 245 mTabs.Erase( mTabs.Item( tabNo ) );
74de91cc
JS
246 // if ( mActiveTab >= mTabs.GetCount() );
247 if ( mActiveTab >= mTabs.GetCount() )
248 mActiveTab = mTabs.GetCount() - 1;
645889ad 249 SetActiveTab( mActiveTab );
b5ffecfc 250}
645889ad 251
b5ffecfc
GT
252//---------------------------------------------------------------------------
253int wxTabbedWindow::GetTabCount()
254{
74de91cc 255 return mTabs.GetCount();
b5ffecfc 256}
645889ad 257
b5ffecfc
GT
258//---------------------------------------------------------------------------
259wxWindow* wxTabbedWindow::GetTab( int tabNo )
260{
74de91cc 261 return ((twTabInfo*)(mTabs.Item( tabNo )->GetData()))->mpContent;
b5ffecfc 262}
645889ad 263
b5ffecfc
GT
264//---------------------------------------------------------------------------
265wxWindow* wxTabbedWindow::GetActiveTab()
266{
645889ad
GT
267 // FIMXE:: this is lame
268 return GetTab( mActiveTab );
b5ffecfc 269}
645889ad 270
b5ffecfc
GT
271//---------------------------------------------------------------------------
272void wxTabbedWindow::SetActiveTab( int tabNo )
273{
645889ad 274 mActiveTab = tabNo;
5151c7af 275 RecalcLayout(true);
645889ad 276 Refresh();
b5ffecfc 277}
645889ad 278
b5ffecfc
GT
279//---------------------------------------------------------------------------
280// width of the decorations border (4 shade-lines), should not be changed
281//---------------------------------------------------------------------------
282#define BORDER_SZ 4
645889ad 283
b5ffecfc
GT
284//---------------------------------------------------------------------------
285void wxTabbedWindow::DrawShadedRect( int x, int y, int width, int height,
645889ad
GT
286 wxPen& upperPen, wxPen& lowerPen, wxDC& dc
287 )
b5ffecfc 288{
645889ad 289 // darw the lightened upper-left sides of the rectangle
254a2129 290
645889ad
GT
291 dc.SetPen( upperPen );
292 dc.DrawLine( x,y, x, y + height - 1 ); // vert
293 dc.DrawLine( x,y, x + width - 1, y ); // horiz
254a2129 294
645889ad 295 // draw the unenlightened lower-right sides of the rectangle
254a2129 296
645889ad
GT
297 dc.SetPen( lowerPen );
298 dc.DrawLine( x + width - 1, y, x + width - 1, y + height - 1 ); // vert
299 dc.DrawLine( x, y + height - 1, x + width, y + height - 1 ); // horiz
b5ffecfc 300}
645889ad 301
b5ffecfc
GT
302//---------------------------------------------------------------------------
303void wxTabbedWindow::DrawDecorations( wxDC& dc )
304{
645889ad
GT
305 // Protability NOTE::: DrawLine(..) draws a line from the first position,
306 // but not including the point specified by last position.
307 // This way Windows draws lines, not sure how Motif and Gtk
308 // prots behave...
254a2129 309
645889ad
GT
310 int width, height;
311 GetClientSize( &width, &height );
254a2129 312
645889ad 313 // check if there's at least a bit of space to draw things
254a2129 314
645889ad
GT
315 if ( width < mHorizGap*2 + BORDER_SZ*2+1 ||
316 height < mVertGap*2 + BORDER_SZ*2+1 + mTitleHeight
317 )
318 return;
254a2129 319
645889ad 320 // step #1 - draw border around the tab content area
254a2129 321
645889ad
GT
322 // setup position for kind of "pencil"
323 int curX = mHorizGap;
324 int curY = mVertGap;
254a2129 325
645889ad
GT
326 int xSize = width - mHorizGap*2;
327 int ySize = height - mVertGap *2 - mTitleHeight;
254a2129 328
645889ad
GT
329 // layer 1 (upper white)
330 DrawShadedRect( curX+0, curY+0, xSize-0, ySize-0,
331 mWhitePen, mBlackPen, dc );
254a2129 332
645889ad
GT
333 // layer 2 (upper gray)
334 DrawShadedRect( curX+1, curY+1, xSize-2-1, ySize-2-1,
335 mGrayPen, mGrayPen, dc );
254a2129 336
645889ad
GT
337 // layer 3 (upper darkGray)
338 DrawShadedRect( curX+2, curY+2, xSize-3-2, ySize-3-2,
339 mDarkPen, mWhitePen, dc );
254a2129 340
645889ad
GT
341 // layer 4 (upper black)
342 DrawShadedRect( curX+3, curY+3, xSize-4-3, ySize-4-3,
343 mBlackPen, mGrayPen, dc );
254a2129 344
645889ad 345 // add non-siemtric layer from the lower-right side (confroming to MFC-look)
254a2129 346
645889ad
GT
347 dc.SetPen( mDarkPen );
348 dc.DrawLine( curX+1, curY + ySize - 2, curX + xSize - 1, curY + ySize - 2 ); // horiz
349 dc.DrawLine( curX + xSize - 2, curY + 1, curX + xSize - 2, curY + ySize - 2 ); // vert
254a2129 350
645889ad 351 // step #2 - draw tab title bars
254a2129 352
645889ad
GT
353 curX = mFirstTitleGap;
354 curY = height - mVertGap - mTitleHeight;
254a2129 355
74de91cc 356 size_t tabNo = 0;
8b567f9b 357 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
254a2129 358
645889ad 359 while( pNode )
b5ce269b 360 {
645889ad 361 // "hard-coded metafile" for decorations
254a2129 362
74de91cc 363 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 364
645889ad
GT
365 xSize = tab.mDims.x;
366 ySize = mTitleHeight;
254a2129 367
645889ad
GT
368 if ( tabNo == mActiveTab )
369 {
370 dc.SetPen( mGrayPen );
371 dc.DrawLine( curX+1, curY-2, curX+xSize-2, curY-2 );
372 dc.DrawLine( curX+1, curY-1, curX+xSize-2, curY-1 );
373 }
254a2129 374
645889ad 375 dc.SetPen( mWhitePen );
254a2129 376
645889ad
GT
377 if ( tabNo == mActiveTab )
378 dc.DrawLine( curX, curY-2, curX, curY+ySize-2 );
379 else
380 dc.DrawLine( curX, curY, curX, curY+ySize-2 );
254a2129 381
645889ad
GT
382 dc.SetPen( mDarkPen );
383 dc.DrawLine( curX+1, curY+ySize-3, curX+1, curY+ySize-1 ); // to pix down
384 dc.DrawLine( curX+2, curY+ySize-2, curX+xSize-2, curY+ySize-2 );
385 dc.DrawLine( curX+xSize-3, curY+ySize-3, curX+xSize-2, curY+ySize-3 );
386 if ( tabNo == mActiveTab )
387 dc.DrawLine( curX+xSize-2, curY+ySize-3, curX+xSize-2, curY-3 );
388 else
389 dc.DrawLine( curX+xSize-2, curY+ySize-3, curX+xSize-2, curY-1 );
254a2129 390
645889ad
GT
391 dc.SetPen( mBlackPen );
392 dc.DrawLine( curX+xSize-1, curY, curX+xSize-1, curY+ySize-2 );
393 dc.DrawLine( curX+xSize-2, curY+ySize-2, curX+xSize-3, curY+ySize-2 );
394 dc.DrawLine( curX+xSize-3, curY+ySize-1, curX+1, curY+ySize-1 );
254a2129 395
74de91cc 396 pNode = pNode->GetNext();
645889ad 397 ++tabNo;
254a2129 398
645889ad
GT
399 // darw image and (or without) text centered within the
400 // title bar rectangle
254a2129 401
645889ad
GT
402 if ( mLayoutType != wxTITLE_BORDER_ONLY && tab.HasImg() )
403 {
404 wxMemoryDC tmpDc;
405 tmpDc.SelectObject( tab.GetImg() );
254a2129 406
645889ad
GT
407 dc.Blit( curX + mTitleHorizGap,
408 curY + ( ySize - tab.ImgHeight() ) / 2,
409 tab.ImgWidth(),
410 tab.ImgHeight(),
411 &tmpDc, 0, 0, wxCOPY
412 );
413 }
254a2129 414
645889ad
GT
415 if ( mLayoutType == wxTITLE_IMG_AND_TEXT && tab.HasText() )
416 {
417 long x,w,h;
254a2129 418
645889ad
GT
419 // set select default font of the window into it's device context
420 //dc.SetFont( GetLabelingFont() );
254a2129 421
645889ad 422 dc.SetTextBackground( GetBackgroundColour() );
254a2129 423
645889ad 424 dc.GetTextExtent(tab.mText, &w, &h );
254a2129 425
645889ad
GT
426 x = curX + mTitleHorizGap +
427 tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap);
254a2129 428
645889ad
GT
429 dc.DrawText( tab.GetText(), x, curY + ( ySize - h ) / 2 );
430 }
431 curX += xSize;
254a2129 432
b5ce269b 433 } // end of `while (pNode)'
645889ad
GT
434} // wxTabbedWindow::DrawDecorations()
435
b5ffecfc
GT
436//---------------------------------------------------------------------------
437int wxTabbedWindow::HitTest( const wxPoint& pos )
438{
645889ad
GT
439 int width, height;
440 GetClientSize( &width, &height );
254a2129 441
645889ad
GT
442 int curX = mFirstTitleGap;
443 int curY = height - mVertGap - mTitleHeight;
254a2129 444
645889ad 445 int tabNo = 0;
8b567f9b 446 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
254a2129 447
645889ad 448 while( pNode )
b5ce269b 449 {
74de91cc 450 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 451
645889ad
GT
452 // hit test rectangle of the currnet tab title bar
453 if ( pos.x >= curX && pos.x < curX + tab.mDims.x &&
454 pos.y >= curY && pos.y < curY + tab.mDims.y
455 )
456 {
457 return tabNo;
458 }
254a2129 459
645889ad 460 curX += tab.mDims.x;
254a2129 461
74de91cc 462 pNode = pNode->GetNext();
645889ad 463 ++tabNo;
b5ce269b 464 }
254a2129 465
645889ad
GT
466 return -1;
467} // wxTabbedWindow::HitTest()
468
b5ffecfc
GT
469//---------------------------------------------------------------------------
470void wxTabbedWindow::HideInactiveTabs( bool andRepaint )
471{
645889ad
GT
472 if ( !andRepaint )
473 return;
254a2129 474
8b567f9b 475 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
74de91cc 476 size_t tabNo = 0;
254a2129 477
645889ad 478 while( pNode )
b5ce269b 479 {
645889ad
GT
480 if ( tabNo != mActiveTab )
481 {
74de91cc 482 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
5151c7af 483 tab.mpContent->Show(false);
645889ad 484 }
254a2129 485
74de91cc 486 pNode = pNode->GetNext();
645889ad 487 ++tabNo;
b5ce269b 488 }
645889ad
GT
489} // wxTabbedWindow::HideInactiveTabs()
490
b5ffecfc
GT
491//---------------------------------------------------------------------------
492wxFont wxTabbedWindow::GetLabelingFont()
493{
645889ad 494 wxFont font;
b5ffecfc 495#ifdef __WINDOWS__
daf06bb8 496 font.SetFaceName(_T("MS Sans Serif"));
b5ffecfc 497#else
645889ad 498 font.SetFamily( wxSWISS );
b5ffecfc 499#endif
254a2129 500
645889ad
GT
501 font.SetStyle(40);
502 font.SetWeight(40);
503 font.SetPointSize( 8 );
254a2129 504
b5ffecfc 505#ifdef __WINDOWS__
645889ad 506 font.RealizeResource();
b5ffecfc 507#endif
254a2129 508
645889ad
GT
509 return font;
510} // wxTabbedWindow::GetLabelingFont()
511
b5ffecfc
GT
512//---------------------------------------------------------------------------
513void wxTabbedWindow::RecalcLayout(bool andRepaint)
514{
645889ad 515 HideInactiveTabs(andRepaint);
254a2129 516
645889ad 517 // resetup position of the active tab
254a2129 518
645889ad
GT
519 int width, height;
520 GetClientSize( &width, &height );
254a2129 521
645889ad
GT
522 int curX = mHorizGap + BORDER_SZ;
523 int curY = mVertGap + BORDER_SZ;
254a2129 524
645889ad
GT
525 int xSize = width - mHorizGap*2 - BORDER_SZ*2-1;
526 int ySize = height - mVertGap*2 - BORDER_SZ*2-1 - mTitleHeight;
254a2129 527
645889ad 528 SizeTabs( curX, curY, xSize, ySize, andRepaint );
254a2129 529
645889ad 530 // pass #1 - try to layout assuming it's wxTITLE_IMG_AND_TEXT
254a2129 531
645889ad 532 mLayoutType = wxTITLE_IMG_AND_TEXT;
254a2129 533
8b567f9b 534 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
254a2129 535
645889ad
GT
536 curX = mFirstTitleGap; // the left-side gap
537 mTitleHeight = 0;
254a2129 538
645889ad 539 while( pNode )
b5ce269b 540 {
74de91cc 541 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 542
645889ad 543 wxWindowDC dc(this);
254a2129 544
645889ad 545 long w,h;
254a2129 546
645889ad
GT
547 // set select default font of the window into it's device context
548 //dc.SetFont( GetLabelingFont() );
254a2129 549
645889ad 550 dc.GetTextExtent(tab.mText, &w, &h );
254a2129 551
645889ad
GT
552 tab.mDims.x = w + tab.ImageToTxtGap(mImageTextGap) +
553 tab.ImgWidth() + mTitleHorizGap*2;
254a2129 554
645889ad
GT
555 tab.mDims.y = wxMax( h, tab.ImgHeight() ) + mTitleVertGap*2;
556 mTitleHeight = wxMax( mTitleHeight, tab.mDims.y );
254a2129 557
645889ad 558 curX += tab.mDims.x;
254a2129 559
74de91cc 560 pNode = pNode->GetNext();
b5ce269b 561 }
254a2129 562
645889ad 563 curX += mHorizGap; // the right-side gap
254a2129 564
645889ad 565 // make all title bars of equel height
254a2129 566
74de91cc 567 pNode = mTabs.GetFirst();
254a2129 568
645889ad 569 while( pNode )
b5ce269b 570 {
74de91cc
JS
571 ((twTabInfo*)(pNode->GetData()))->mDims.y = mTitleHeight;;
572 pNode = pNode->GetNext();
b5ce269b 573 }
254a2129 574
645889ad
GT
575 // if curX has'nt ran out of bounds, leave TITLE_IMG layout and return
576 if ( curX < width - mHorizGap )
577 return;
254a2129 578
645889ad 579 // pass #2 - try to layout assuming wxTITLE_IMG_ONLY
254a2129 580
645889ad 581 mLayoutType = wxTITLE_IMG_ONLY;
254a2129 582
74de91cc 583 pNode = mTabs.GetFirst();
254a2129 584
645889ad 585 curX = mFirstTitleGap; // the left-side gap
254a2129 586
74de91cc 587 int denomiator = mTabs.GetCount();
645889ad
GT
588 if ( denomiator == 0 )
589 ++denomiator;
254a2129 590
645889ad 591 mBorderOnlyWidth = (width - mFirstTitleGap - mHorizGap) / denomiator;
254a2129 592
645889ad 593 while( pNode )
b5ce269b 594 {
74de91cc 595 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 596
645889ad
GT
597 if ( tab.HasImg() )
598 {
599 tab.mDims.x = tab.ImgWidth() + mTitleHorizGap*2;
600 tab.mDims.y = tab.ImgHeight() + mTitleVertGap*2;
601 }
602 else
603 {
604 tab.mDims.x = mBorderOnlyWidth;
605 tab.mDims.y = mTitleHeight;
606 }
254a2129 607
645889ad 608 curX += tab.mDims.x;
254a2129 609
74de91cc 610 pNode = pNode->GetNext();
b5ce269b 611 }
254a2129 612
645889ad 613 curX += mHorizGap; // the right-side gap
254a2129 614
645889ad
GT
615 // if curX has'nt ran out of bounds, leave IMG_ONLY layout and return
616 if ( curX < width - mHorizGap )
617 return;
254a2129 618
645889ad 619 // pass #3 - set the narrowest layout wxTITLE_BORDER_ONLY
254a2129 620
645889ad 621 mLayoutType = wxTITLE_BORDER_ONLY;
254a2129 622
74de91cc 623 pNode = mTabs.GetFirst();
254a2129 624
645889ad 625 while( pNode )
b5ce269b 626 {
74de91cc 627 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 628
645889ad
GT
629 tab.mDims.x = mBorderOnlyWidth;
630 tab.mDims.y = mTitleHeight;
254a2129 631
74de91cc 632 pNode = pNode->GetNext();
b5ce269b 633 }
645889ad
GT
634} // wxTabbedWindow::RecalcLayout()
635
b5ffecfc
GT
636//---------------------------------------------------------------------------
637// wx event handlers
638//---------------------------------------------------------------------------
74de91cc 639void wxTabbedWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
b5ffecfc 640{
645889ad
GT
641 wxPaintDC dc(this);
642 DrawDecorations( dc );
b5ffecfc 643}
645889ad 644
b5ffecfc 645//---------------------------------------------------------------------------
74de91cc 646void wxTabbedWindow::OnSize ( wxSizeEvent& WXUNUSED(event) )
b5ffecfc 647{
645889ad 648 SetBackgroundColour( wxColour( 192,192,192 ) );
5151c7af 649 RecalcLayout(true);
b5ffecfc 650}
645889ad 651
b5ffecfc 652//---------------------------------------------------------------------------
74de91cc 653void wxTabbedWindow::OnBkErase( wxEraseEvent& WXUNUSED(event) )
b5ffecfc 654{
645889ad 655 // do nothing
b5ffecfc 656}
645889ad 657
b5ffecfc
GT
658//---------------------------------------------------------------------------
659void wxTabbedWindow::OnLButtonDown( wxMouseEvent& event )
660{
645889ad
GT
661 // floats, why?
662 int x = (int)event.m_x;
663 int y = (int)event.m_y;
254a2129 664
645889ad 665 int tabNo = HitTest( wxPoint(x,y) );
254a2129 666
645889ad 667 if ( tabNo != -1 )
b5ce269b 668 {
645889ad 669 SetActiveTab( tabNo );
b5ce269b 670 }
b5ffecfc 671}
645889ad
GT
672
673//---------------------------------------------------------------------------
674// Implementation for class wxPagedWindow
675//---------------------------------------------------------------------------
676IMPLEMENT_DYNAMIC_CLASS( wxPagedWindow, wxTabbedWindow )
677
678//---------------------------------------------------------------------------
679BEGIN_EVENT_TABLE( wxPagedWindow, wxTabbedWindow )
680 EVT_SIZE ( wxPagedWindow::OnSize )
681 EVT_PAINT ( wxPagedWindow::OnPaint )
682 EVT_LEFT_DOWN( wxPagedWindow::OnLButtonDown )
683 EVT_LEFT_UP ( wxPagedWindow::OnLButtonUp )
684 EVT_MOTION ( wxPagedWindow::OnMouseMove )
685 EVT_SCROLL ( wxPagedWindow::OnScroll )
686END_EVENT_TABLE()
687
b5ffecfc 688//---------------------------------------------------------------------------
645889ad 689// border for paged-window is 2 shaded-lines
b5ffecfc 690//---------------------------------------------------------------------------
b5ffecfc
GT
691#undef BORDER_SZ
692#define BORDER_SZ 2
645889ad
GT
693
694//---------------------------------------------------------------------------
695wxPagedWindow::wxPagedWindow()
696
5151c7af 697: mScrollEventInProgress( false ),
645889ad
GT
698 mTabTrianGap(4),
699 mWhiteBrush( wxColour(255,255,255), wxSOLID ),
700 mGrayBrush ( wxColour(192,192,192), wxSOLID ),
701 mCurentRowOfs( 0 ),
702 mAdjustableTitleRowLen( 300 ),
5151c7af 703 mIsDragged ( false ),
645889ad 704 mDagOrigin ( 0 ),
5151c7af 705 mCursorChanged( false ),
645889ad
GT
706 mResizeCursor ( wxCURSOR_SIZEWE ),
707 mNormalCursor ( wxCURSOR_ARROW )
b5ffecfc 708{
645889ad
GT
709 mTitleVertGap = 2;
710 mTitleHorizGap = 10;
5151c7af 711 mNoVertScroll = true; // Horizontale Scroll abschalten
b5ffecfc 712}
645889ad 713
b5ffecfc 714//---------------------------------------------------------------------------
645889ad 715wxFont wxPagedWindow::GetLabelingFont()
b5ffecfc 716{
645889ad 717 wxFont font;
254a2129 718
b5ffecfc 719#ifdef __WINDOWS__
daf06bb8 720 font.SetFaceName(_T("Comic Sans MS"));
b5ffecfc 721#else
645889ad 722 font.SetFamily( wxSWISS );
b5ffecfc 723#endif
254a2129 724
645889ad
GT
725 font.SetStyle(40);
726 font.SetWeight(40);
727 font.SetPointSize( 8 );
254a2129 728
645889ad 729 return font;
b5ffecfc 730}
645889ad 731
b5ffecfc 732//---------------------------------------------------------------------------
74de91cc 733void wxPagedWindow::OnTabAdded( twTabInfo* WXUNUSED(pInfo) )
b5ffecfc 734{
645889ad 735 int units = GetWholeTabRowLen() / 20;
254a2129 736
5151c7af 737 mpTabScroll->SetScrollbar( 0, 1, units, 1, false );
b5ffecfc 738}
645889ad 739
b5ffecfc 740//---------------------------------------------------------------------------
645889ad 741wxScrollBar& wxPagedWindow::GetVerticalScrollBar()
b5ffecfc 742{
645889ad 743 return *mpVertScroll;
b5ffecfc 744}
645889ad 745
b5ffecfc 746//---------------------------------------------------------------------------
645889ad 747wxScrollBar& wxPagedWindow::GetHorizontalScrollBar()
b5ffecfc 748{
645889ad 749 return *mpHorizScroll;
b5ffecfc 750}
645889ad 751
b5ffecfc 752//---------------------------------------------------------------------------
645889ad 753int wxPagedWindow::GetWholeTabRowLen()
b5ffecfc 754{
8b567f9b 755 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
254a2129 756
645889ad 757 int len = 0;
254a2129 758
645889ad 759 while( pNode )
b5ce269b 760 {
74de91cc 761 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 762
645889ad 763 len += tab.mDims.x;
74de91cc 764 pNode = pNode->GetNext();
b5ce269b 765 }
254a2129 766
645889ad
GT
767 return len;
768} // wxPagedWindow::GetWholeTabRowLen()
769
b5ffecfc 770//---------------------------------------------------------------------------
645889ad
GT
771void wxPagedWindow::DrawPaperBar( twTabInfo& tab, int x, int y,
772 wxBrush& brush, wxPen& pen, wxDC& dc )
b5ffecfc 773{
645889ad 774 wxPoint poly[4];
254a2129 775
645889ad 776 // draw organizer-style paper outlet
254a2129 777
645889ad
GT
778 poly[0].x = x - mTabTrianGap;
779 poly[0].y = y;
254a2129 780
645889ad
GT
781 poly[1].x = x + mTabTrianGap;
782 poly[1].y = y + tab.mDims.y-1;
254a2129 783
645889ad
GT
784 poly[2].x = x + tab.mDims.x - mTabTrianGap;
785 poly[2].y = y + tab.mDims.y-1;
254a2129 786
645889ad
GT
787 poly[3].x = x + tab.mDims.x + mTabTrianGap;
788 poly[3].y = y;
254a2129 789
645889ad
GT
790 dc.SetPen( pen );
791 dc.SetBrush( brush );
254a2129 792
645889ad 793 dc.DrawPolygon( 4, poly );
254a2129 794
645889ad 795 long w,h;
254a2129 796
645889ad
GT
797 // set select default font of the window into it's device context
798 //dc.SetFont( GetLabelingFont() );
254a2129 799
645889ad 800 dc.SetTextBackground( brush.GetColour() );
254a2129 801
645889ad 802 dc.GetTextExtent(tab.mText, &w, &h );
254a2129 803
645889ad 804 if ( tab.HasImg() )
b5ce269b 805 {
645889ad
GT
806 wxMemoryDC tmpDc;
807 tmpDc.SelectObject( tab.GetImg() );
254a2129 808
645889ad
GT
809 dc.Blit( x + mTitleHorizGap,
810 y + ( tab.mDims.y - tab.ImgHeight() ) / 2,
811 tab.ImgWidth(),
812 tab.ImgHeight(),
813 &tmpDc, 0, 0, wxCOPY
814 );
b5ce269b 815 }
254a2129 816
645889ad 817 if ( tab.HasText() )
b5ce269b 818 {
645889ad
GT
819 int tx = x + mTitleHorizGap +
820 tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap);
254a2129 821
645889ad 822 dc.DrawText( tab.GetText(), tx, y + ( tab.mDims.y - h ) / 2 );
b5ce269b 823 }
645889ad
GT
824} // wxPagedWindow::DrawPaperBar()
825
b5ffecfc 826//---------------------------------------------------------------------------
645889ad 827void wxPagedWindow::DrawDecorations( wxDC& dc )
b5ffecfc 828{
645889ad
GT
829 // FIXME:: the is big body have to be split!
830
831 int width, height;
832 GetClientSize( &width, &height );
833
834 int curX = mHorizGap;
835 int curY = mVertGap;
836
837 int xSize = width - mHorizGap*2;
838 int ySize = height - mVertGap*2;
839
840 DrawShadedRect( curX, curY, xSize, ySize,
841 mDarkPen, mWhitePen, dc );
842
843 DrawShadedRect( curX+1, curY+1, xSize-2, ySize-2,
844 mBlackPen, mGrayPen, dc );
845
846 // draw inactive tab title bars frist (left-to-right)
847
8b567f9b 848 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
74de91cc 849 size_t tabNo = 0;
645889ad
GT
850
851 /* OLD STUFF::
852 curX = mTitleRowStart;
853 curY = height - mVertGap - BORDER_SZ - mTitleHeight;
854 */
855
856 curX = mTabTrianGap;
857 curY = 0;
858
859 // FOR NOW:: avoid creating bitmap with invalid dimensions
860
861 if ( mTitleRowLen < 1 || mTitleHeight < 1 )
862 return;
863
864 wxMemoryDC tmpDc;
865 wxBitmap tmpBmp( mTitleRowLen, mTitleHeight );
866
867 tmpDc.SelectObject( tmpBmp );
868 tmpDc.SetPen( mGrayPen );
869 tmpDc.SetBrush( mGrayBrush );
870 tmpDc.DrawRectangle( 0,0, mTitleRowLen, mTitleHeight );
871
872 tmpDc.SetDeviceOrigin( mCurentRowOfs, 0 );
873
874 while( pNode )
b5ce269b 875 {
74de91cc 876 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
645889ad
GT
877
878 if ( tabNo != mActiveTab )
879 DrawPaperBar( tab, curX, curY, mGrayBrush, mBlackPen, tmpDc );
880
881 curX += tab.mDims.x;
882
74de91cc 883 pNode = pNode->GetNext();
645889ad 884 ++tabNo;
b5ce269b 885 }
254a2129 886
645889ad 887 // finally, draw the active tab (white-filled)
254a2129 888
74de91cc 889 pNode = mTabs.GetFirst();
645889ad 890 tabNo = 0;
254a2129 891
645889ad 892 curX = mTabTrianGap;
254a2129 893
645889ad 894 while( pNode )
b5ce269b 895 {
74de91cc 896 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 897
645889ad
GT
898 if ( tabNo == mActiveTab )
899 {
900 DrawPaperBar( tab, curX, curY, mWhiteBrush, mBlackPen, tmpDc );
254a2129 901
645889ad 902 tmpDc.SetPen( mWhitePen );
254a2129 903
645889ad
GT
904 tmpDc.DrawLine( curX - mTabTrianGap+1, curY,
905 curX + tab.mDims.x + mTabTrianGap, curY );
906 break;
907 }
908 curX += tab.mDims.x;
254a2129 909
74de91cc 910 pNode = pNode->GetNext();
645889ad 911 ++tabNo;
b5ce269b 912 }
254a2129 913
645889ad 914 // back to initial device origin
254a2129 915
645889ad 916 tmpDc.SetDeviceOrigin( 0, 0 );
254a2129 917
645889ad 918 // draw resize-hint-stick
254a2129 919
645889ad 920 curX = mTitleRowLen - 6;
254a2129 921
645889ad
GT
922 DrawShadedRect( curX+0, 0+0, 6, mTitleHeight, mGrayPen, mBlackPen, tmpDc );
923 DrawShadedRect( curX+1, 0+1, 6-2, mTitleHeight-2, mWhitePen, mDarkPen, tmpDc );
924 DrawShadedRect( curX+2, 0+2, 6-4, mTitleHeight-4, mGrayPen, mGrayPen, tmpDc );
254a2129
WS
925
926
927
645889ad
GT
928 dc.Blit( mTitleRowStart,
929 height - mVertGap - BORDER_SZ - mTitleHeight,
930 mTitleRowLen, mTitleHeight,
931 &tmpDc, 0,0, wxCOPY );
932} // wxPagedWindow::DrawDecorations()
933
b5ffecfc 934//---------------------------------------------------------------------------
645889ad 935int wxPagedWindow::HitTest( const wxPoint& pos )
b5ffecfc 936{
645889ad 937 return wxTabbedWindow::HitTest( pos );
b5ffecfc 938}
645889ad 939
b5ffecfc 940//---------------------------------------------------------------------------
645889ad 941void wxPagedWindow::RecalcLayout(bool andRepaint)
b5ffecfc 942{
645889ad 943 mTitleRowLen = mAdjustableTitleRowLen;
254a2129 944
645889ad 945 if ( int(mpTabScroll) == -1 ) return;
254a2129 946
645889ad
GT
947 // scroll bars should be created after Create() for this window is called
948 if ( !mpTabScroll )
b5ce269b 949 {
645889ad 950 mpTabScroll =
5151c7af 951 new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
254a2129 952
645889ad 953 mpHorizScroll =
5151c7af 954 new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
645889ad 955 if (!mNoVertScroll) // Vertical Scroll (Original)
5151c7af 956 mpVertScroll = new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL );
b5ce269b 957 }
254a2129 958
b5ce269b 959 {
645889ad 960 int units = GetWholeTabRowLen() / 20;
254a2129 961
5151c7af 962 mpTabScroll->SetScrollbar( 0, 1, units, 1, false );
645889ad 963 }
254a2129 964
645889ad 965 // resetup position of the active tab
254a2129 966
645889ad 967 int thumbLen = 16; // FOR NOW:: hardcoded
254a2129 968
645889ad
GT
969 int width, height;
970 GetClientSize( &width, &height );
254a2129 971
645889ad 972 mTitleHeight = thumbLen;
254a2129 973
645889ad
GT
974 int curX = mHorizGap + BORDER_SZ;
975 int curY = mVertGap + BORDER_SZ;
254a2129 976
645889ad
GT
977 int xSize;
978 if (!mNoVertScroll) // Vertical Scroll (Original)
979 xSize = width - mHorizGap*2 - BORDER_SZ*2 - thumbLen;
980 else
981 xSize = width - mHorizGap*2 - BORDER_SZ*2;
254a2129 982
645889ad 983 int ySize = height - mVertGap*2 - BORDER_SZ*2 - mTitleHeight;
254a2129 984
645889ad 985 SizeTabs( curX, curY, xSize, ySize, andRepaint );
254a2129 986
645889ad 987 // setup title bar LINES's horizontal scroll bar
254a2129 988
645889ad 989 curY = height - mVertGap - BORDER_SZ - thumbLen;
254a2129 990
645889ad 991 mpTabScroll->SetSize( curX, curY, thumbLen*2, thumbLen );
254a2129 992
645889ad
GT
993 // setup view's HORIZONTAL scroll bar
994 curX += thumbLen*2;
254a2129 995
645889ad
GT
996 mTitleRowStart = curX;
997 mFirstTitleGap = curX + mCurentRowOfs + mTabTrianGap;
254a2129 998
645889ad
GT
999 mTitleRowLen = wxMin( mAdjustableTitleRowLen,
1000 width - mHorizGap - BORDER_SZ - thumbLen*4 - curX );
254a2129 1001
645889ad 1002 curX += mTitleRowLen;
254a2129 1003
645889ad
GT
1004 if (!mNoVertScroll) // Vertical Scroll (Original)
1005 mpHorizScroll->SetSize( curX, curY,width - curX - mHorizGap - BORDER_SZ - thumbLen, thumbLen );
1006 else
1007 mpHorizScroll->SetSize( curX, curY,width - curX - mHorizGap - BORDER_SZ-4, thumbLen );
254a2129 1008
645889ad
GT
1009 // setup view's VERTICAL scroll bar
1010 if (!mNoVertScroll) // Vertical Scroll (Original)
1011 {
1012 curX = width - mHorizGap - BORDER_SZ - thumbLen;
1013 curY = mVertGap + BORDER_SZ;
1014 mpVertScroll->SetSize( curX, curY, thumbLen,height - curY - mVertGap - BORDER_SZ - thumbLen);
b5ce269b 1015 }
645889ad 1016 // layout tab title bars
254a2129 1017
645889ad 1018 mLayoutType = wxTITLE_IMG_AND_TEXT;
254a2129 1019
8b567f9b 1020 wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
254a2129 1021
645889ad 1022 while( pNode )
b5ce269b 1023 {
74de91cc 1024 twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
254a2129 1025
645889ad 1026 wxWindowDC dc(this);
254a2129 1027
645889ad 1028 long w,h;
254a2129 1029
645889ad
GT
1030 // set select default font of the window into it's device context
1031 //dc.SetFont( GetLabelingFont() );
1032 dc.GetTextExtent(tab.mText, &w, &h );
254a2129 1033
645889ad
GT
1034 tab.mDims.x = w + tab.ImageToTxtGap(mImageTextGap) +
1035 tab.ImgWidth() + mTitleHorizGap*2;
254a2129 1036
645889ad 1037 tab.mDims.y = mTitleHeight;
254a2129 1038
74de91cc 1039 pNode = pNode->GetNext();
b5ce269b 1040 }
254a2129 1041
645889ad 1042 // disable title-bar scroller if there's nowhere to scroll to
254a2129 1043
645889ad 1044 mpTabScroll->Enable( mTitleRowLen < GetWholeTabRowLen() || mCurentRowOfs < 0 );
b5ffecfc 1045}
645889ad 1046
b5ffecfc
GT
1047//---------------------------------------------------------------------------
1048// event handlers
1049//---------------------------------------------------------------------------
74de91cc 1050void wxPagedWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
b5ffecfc 1051{
645889ad
GT
1052 wxPaintDC dc(this);
1053 DrawDecorations( dc );
b5ffecfc 1054}
645889ad 1055
b5ffecfc 1056//---------------------------------------------------------------------------
645889ad 1057void wxPagedWindow::OnSize ( wxSizeEvent& event )
b5ffecfc 1058{
645889ad 1059 wxTabbedWindow::OnSize(event);
b5ffecfc 1060}
645889ad 1061
b5ffecfc 1062//---------------------------------------------------------------------------
645889ad 1063void wxPagedWindow::OnLButtonDown( wxMouseEvent& event )
b5ffecfc 1064{
645889ad 1065 if ( mCursorChanged )
b5ce269b 1066 {
5151c7af 1067 mIsDragged = true;
645889ad 1068 mDagOrigin = event.m_x;
254a2129 1069
645889ad 1070 mOriginalTitleRowLen = mAdjustableTitleRowLen;
254a2129 1071
645889ad 1072 CaptureMouse();
b5ce269b 1073 }
645889ad 1074 else
b5ce269b 1075 {
645889ad 1076 wxTabbedWindow::OnLButtonDown( event );
b5ce269b 1077 }
645889ad
GT
1078} // wxPagedWindow::OnLButtonDown()
1079
b5ffecfc 1080//---------------------------------------------------------------------------
74de91cc 1081void wxPagedWindow::OnLButtonUp( wxMouseEvent& WXUNUSED(event) )
b5ffecfc 1082{
645889ad 1083 if ( mIsDragged )
b5ce269b 1084 {
5151c7af
WS
1085 mIsDragged = false;
1086 mCursorChanged = false;
645889ad 1087 SetCursor( mNormalCursor );
254a2129 1088
645889ad 1089 ReleaseMouse();
b5ce269b 1090 }
645889ad
GT
1091} // wxPagedWindow::OnLButtonUp()
1092
b5ffecfc 1093//---------------------------------------------------------------------------
645889ad 1094void wxPagedWindow::OnMouseMove( wxMouseEvent& event )
b5ffecfc 1095{
645889ad
GT
1096 int width, height;
1097 GetClientSize( &width, &height );
254a2129 1098
645889ad 1099 if ( !mIsDragged )
b5ce269b 1100 {
645889ad
GT
1101 int y = height - mVertGap - BORDER_SZ - mTitleHeight;
1102 int x = mTitleRowStart + mTitleRowLen - 6;
254a2129 1103
645889ad
GT
1104 if ( event.m_x >= x && event.m_y >= y &&
1105 event.m_x < x + 6 &&
1106 event.m_y < y + mTitleHeight
1107 )
1108 {
1109 if ( !mCursorChanged )
1110 {
1111 SetCursor( mResizeCursor );
254a2129 1112
5151c7af 1113 mCursorChanged = true;
645889ad
GT
1114 }
1115 }
1116 else
1117 if ( mCursorChanged )
1118 {
1119 SetCursor( mNormalCursor );
254a2129 1120
5151c7af 1121 mCursorChanged = false;
645889ad 1122 }
b5ce269b 1123 }
645889ad
GT
1124 else
1125 {
1126 if ( mIsDragged )
1127 {
1128 mAdjustableTitleRowLen = mOriginalTitleRowLen + ( event.m_x - mDagOrigin );
254a2129 1129
645889ad
GT
1130 // FOR NOW:: fixed
1131 if ( mAdjustableTitleRowLen < 6 ) mAdjustableTitleRowLen = 6;
254a2129 1132
645889ad
GT
1133 wxWindowDC dc(this);
1134 DrawDecorations( dc );
254a2129 1135
5151c7af 1136 RecalcLayout(false);
254a2129 1137
645889ad
GT
1138 //Refresh();
1139 }
1140 }
1141} // wxPagedWindow::OnMouseMove()
1142
b5ffecfc 1143//---------------------------------------------------------------------------
645889ad 1144void wxPagedWindow::OnScroll( wxScrollEvent& event )
b5ffecfc 1145{
645889ad
GT
1146 wxScrollBar* pSender = (wxScrollBar*)event.GetEventObject();
1147 // wxMessageBox("wxPagedWindow::OnScroll","-I->");
1148 if ( pSender == mpTabScroll )
b5ce269b 1149 {
254a2129 1150
645889ad 1151 int maxUnits = GetWholeTabRowLen() / 20;
254a2129 1152
645889ad 1153 mCurentRowOfs = -event.GetPosition()*maxUnits;
254a2129 1154
645889ad 1155 mFirstTitleGap = mTitleRowStart + mCurentRowOfs + mTabTrianGap;
254a2129 1156
645889ad
GT
1157 // let' it automatically disable itself if it's time
1158 mpTabScroll->Enable( mTitleRowLen < GetWholeTabRowLen() || mCurentRowOfs < 0 );
254a2129 1159
645889ad
GT
1160 // repaint title bars
1161 wxWindowDC dc(this);
1162 DrawDecorations( dc );
b5ce269b 1163 }
b5ce269b 1164 else
645889ad
GT
1165 {
1166 if ( !mScrollEventInProgress )
1167 {
5151c7af 1168 mScrollEventInProgress = true;
254a2129 1169
645889ad
GT
1170 GetActiveTab()->GetEventHandler()->ProcessEvent( event );
1171 }
1172 else
1173 {
1174 // event bounced back to us, from here we
1175 // know that it has traveled the loop - thus it's processed!
254a2129 1176
5151c7af 1177 mScrollEventInProgress = false;
645889ad
GT
1178 }
1179 }
1180} // wxPagedWindow::OnScroll()
b5ffecfc 1181//---------------------------------------------------------------------------
b5ce269b 1182