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