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