]>
git.saurik.com Git - wxWidgets.git/blob - demos/dbbrowse/tabpgwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by: 19990908 : mj10777@gmx.net
6 // - rename to tabpgwin
7 // - restruction of Variable declaration
8 // - to prevent Warnings under MingGW32
9 // Modified by: 19990909 : mj10777@gmx.net
10 // - mNoVertScroll TRUE = no / FALSE = Original Code
11 // the Original Code Paints a Vertical Scroll in wxPaggedWindow
12 // which is not needed in this Version. Use TRUE for this.
15 // Copyright: (c) Aleksandras Gluchovas
16 // Licence: wxWindows license
17 /////////////////////////////////////////////////////////////////////////////
20 #pragma implementation "controlarea.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
38 #include "wx/string.h"
39 #include "wx/utils.h" // import wxMin/wxMax macros and wxFileExist(..)
42 //---------------------------------------------------------------------------
43 // Implementation for class twTabInfo
44 //---------------------------------------------------------------------------
45 IMPLEMENT_DYNAMIC_CLASS( twTabInfo
, wxObject
)
46 //---------------------------------------------------------------------------
47 twTabInfo::twTabInfo()
50 //---------------------------------------------------------------------------
51 twTabInfo::~twTabInfo()
55 //---------------------------------------------------------------------------
56 int twTabInfo::ImgWidth()
58 if ( mBitMap
.Ok() ) return mBitMap
.GetWidth();
61 //---------------------------------------------------------------------------
62 int twTabInfo::ImgHeight()
64 if ( mBitMap
.Ok() ) return mBitMap
.GetHeight();
67 //---------------------------------------------------------------------------
68 int twTabInfo::ImageToTxtGap( int prefGap
)
70 if ( mBitMap
.Ok() ) return prefGap
;
73 //---------------------------------------------------------------------------
74 bool twTabInfo::HasImg()
78 //---------------------------------------------------------------------------
79 // bool twTabInfo::HasText();
80 unsigned int twTabInfo::HasText()
82 return mText
.Length();
84 //---------------------------------------------------------------------------
85 wxBitmap
& twTabInfo::GetImg()
89 //---------------------------------------------------------------------------
90 wxString
& twTabInfo::GetText()
94 //---------------------------------------------------------------------------
95 wxWindow
& twTabInfo::GetContent()
99 //---------------------------------------------------------------------------
100 // Implementation for class wxTabbedWindow
101 //---------------------------------------------------------------------------
102 IMPLEMENT_DYNAMIC_CLASS( wxTabbedWindow
, wxPanel
)
103 //---------------------------------------------------------------------------
104 BEGIN_EVENT_TABLE( wxTabbedWindow
, wxPanel
)
105 EVT_SIZE ( wxTabbedWindow::OnSize
)
106 EVT_PAINT( wxTabbedWindow::OnPaint
)
107 EVT_LEFT_DOWN( wxTabbedWindow::OnLButtonDown
)
108 // TDB:: filciker reduction
109 // EVT_ERASE_BACKGROUND( wxTabbedWindow::OnBkErase )
111 //---------------------------------------------------------------------------
112 wxTabbedWindow::wxTabbedWindow()
114 : mpTabScroll ( NULL
),
115 mpHorizScroll( NULL
),
116 mpVertScroll ( NULL
),
124 mFirstTitleGap( 11 ),
126 mBorderOnlyWidth( 8 ),
128 mWhitePen( wxColour(255,255,255), 1, wxSOLID
),
129 mGrayPen ( wxColour(192,192,192), 1, wxSOLID
),
130 mDarkPen ( wxColour(128,128,128), 1, wxSOLID
),
131 mBlackPen( wxColour( 0, 0, 0), 1, wxSOLID
),
137 mLayoutType( wxTITLE_IMG_AND_TEXT
)
139 //---------------------------------------------------------------------------
140 wxTabbedWindow::~wxTabbedWindow()
142 wxNode
* pTab
= mTabs
.First();
146 delete ((twTabInfo
*)pTab
->Data());
150 //---------------------------------------------------------------------------
151 void wxTabbedWindow::SizeTabs(int x
,int y
, int width
, int height
, bool repant
)
153 wxNode
* pTabNode
= mTabs
.First();
158 twTabInfo
& info
= *((twTabInfo
*)pTabNode
->Data());
160 if ( n
== mActiveTab
)
163 //info.mpContent->GetEventHandler()->ProcessEvent( evt );
165 info
.mpContent
->SetSize( x
, y
, width
, height
, 0 );
166 info
.mpContent
->Show(TRUE
);
167 info
.mpContent
->Refresh();
172 info
.mpContent
->Show(FALSE
);
175 pTabNode
= pTabNode
->Next();
179 //---------------------------------------------------------------------------
180 void wxTabbedWindow::AddTab( wxWindow
* pContent
,
182 wxString imageFileName
,
185 twTabInfo
* pTab
= new twTabInfo();
187 pTab
->mpContent
= pContent
;
188 pTab
->mText
= tabText
;
190 if ( wxFileExists( imageFileName
) &&
192 pTab
->mBitMap
.LoadFile( imageFileName
, imageType
) )
194 pTab
->mImageFile
= imageFileName
;
195 pTab
->mImageType
= imageType
;
199 if ( pContent
->GetParent() == NULL
)
200 pContent
->Create( this, -1 );
202 mTabs
.Append( (wxObject
*)pTab
);
208 //---------------------------------------------------------------------------
209 void wxTabbedWindow::AddTab( wxWindow
* pContent
,
210 wxString tabText
, wxBitmap
* pImage
)
212 twTabInfo
* pTab
= new twTabInfo();
214 pTab
->mpContent
= pContent
;
215 pTab
->mText
= tabText
;
218 pTab
->mBitMap
= *pImage
;
220 if ( pContent
->GetParent() == NULL
)
221 pContent
->Create( this, -1 );
223 mTabs
.Append( (wxObject
*)pTab
);
227 //---------------------------------------------------------------------------
228 void wxTabbedWindow::RemoveTab( int tabNo
)
230 twTabInfo
* pTab
= ((twTabInfo
*)(mTabs
.Nth( tabNo
)->Data()));
231 pTab
->mpContent
->Destroy();
233 mTabs
.DeleteNode( mTabs
.Nth( tabNo
) );
234 // if ( mActiveTab >= mTabs.Number() );
235 if ( mActiveTab
>= mTabs
.Number() )
236 mActiveTab
= mTabs
.Number() - 1;
237 SetActiveTab( mActiveTab
);
239 //---------------------------------------------------------------------------
240 int wxTabbedWindow::GetTabCount()
242 return mTabs
.Number();
244 //---------------------------------------------------------------------------
245 wxWindow
* wxTabbedWindow::GetTab( int tabNo
)
247 return ((twTabInfo
*)(mTabs
.Nth( tabNo
)->Data()))->mpContent
;
249 //---------------------------------------------------------------------------
250 wxWindow
* wxTabbedWindow::GetActiveTab()
252 // FIMXE:: this is lame
253 return GetTab( mActiveTab
);
255 //---------------------------------------------------------------------------
256 void wxTabbedWindow::SetActiveTab( int tabNo
)
262 //---------------------------------------------------------------------------
263 // width of the decorations border (4 shade-lines), should not be changed
264 //---------------------------------------------------------------------------
266 //---------------------------------------------------------------------------
267 void wxTabbedWindow::DrawShadedRect( int x
, int y
, int width
, int height
,
268 wxPen
& upperPen
, wxPen
& lowerPen
, wxDC
& dc
271 // darw the lightened upper-left sides of the rectangle
273 dc
.SetPen( upperPen
);
274 dc
.DrawLine( x
,y
, x
, y
+ height
- 1 ); // vert
275 dc
.DrawLine( x
,y
, x
+ width
- 1, y
); // horiz
277 // draw the unenlightened lower-right sides of the rectangle
279 dc
.SetPen( lowerPen
);
280 dc
.DrawLine( x
+ width
- 1, y
, x
+ width
- 1, y
+ height
- 1 ); // vert
281 dc
.DrawLine( x
, y
+ height
- 1, x
+ width
, y
+ height
- 1 ); // horiz
283 //---------------------------------------------------------------------------
284 void wxTabbedWindow::DrawDecorations( wxDC
& dc
)
286 // Protability NOTE::: DrawLine(..) draws a line from the first position,
287 // but not including the point specified by last position.
288 // This way Windows draws lines, not sure how Motif and Gtk
292 GetClientSize( &width
, &height
);
294 // check if there's at least a bit of space to draw things
296 if ( width
< mHorizGap
*2 + BORDER_SZ
*2+1 ||
297 height
< mVertGap
*2 + BORDER_SZ
*2+1 + mTitleHeight
301 // step #1 - draw border around the tab content area
303 // setup position for kind of "pencil"
304 int curX
= mHorizGap
;
307 int xSize
= width
- mHorizGap
*2;
308 int ySize
= height
- mVertGap
*2 - mTitleHeight
;
310 // layer 1 (upper white)
311 DrawShadedRect( curX
+0, curY
+0, xSize
-0, ySize
-0,
312 mWhitePen
, mBlackPen
, dc
);
314 // layer 2 (upper gray)
315 DrawShadedRect( curX
+1, curY
+1, xSize
-2-1, ySize
-2-1,
316 mGrayPen
, mGrayPen
, dc
);
318 // layer 3 (upper darkGray)
319 DrawShadedRect( curX
+2, curY
+2, xSize
-3-2, ySize
-3-2,
320 mDarkPen
, mWhitePen
, dc
);
322 // layer 4 (upper black)
323 DrawShadedRect( curX
+3, curY
+3, xSize
-4-3, ySize
-4-3,
324 mBlackPen
, mGrayPen
, dc
);
326 // add non-siemtric layer from the lower-right side (confroming to MFC-look)
328 dc
.SetPen( mDarkPen
);
329 dc
.DrawLine( curX
+1, curY
+ ySize
- 2, curX
+ xSize
- 1, curY
+ ySize
- 2 ); // horiz
330 dc
.DrawLine( curX
+ xSize
- 2, curY
+ 1, curX
+ xSize
- 2, curY
+ ySize
- 2 ); // vert
332 // step #2 - draw tab title bars
334 curX
= mFirstTitleGap
;
335 curY
= height
- mVertGap
- mTitleHeight
;
338 wxNode
* pNode
= mTabs
.First();
342 // "hard-coded metafile" for decorations
344 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
347 ySize
= mTitleHeight
;
349 if ( tabNo
== mActiveTab
)
351 dc
.SetPen( mGrayPen
);
352 dc
.DrawLine( curX
+1, curY
-2, curX
+xSize
-2, curY
-2 );
353 dc
.DrawLine( curX
+1, curY
-1, curX
+xSize
-2, curY
-1 );
356 dc
.SetPen( mWhitePen
);
358 if ( tabNo
== mActiveTab
)
359 dc
.DrawLine( curX
, curY
-2, curX
, curY
+ySize
-2 );
361 dc
.DrawLine( curX
, curY
, curX
, curY
+ySize
-2 );
363 dc
.SetPen( mDarkPen
);
364 dc
.DrawLine( curX
+1, curY
+ySize
-3, curX
+1, curY
+ySize
-1 ); // to pix down
365 dc
.DrawLine( curX
+2, curY
+ySize
-2, curX
+xSize
-2, curY
+ySize
-2 );
366 dc
.DrawLine( curX
+xSize
-3, curY
+ySize
-3, curX
+xSize
-2, curY
+ySize
-3 );
367 if ( tabNo
== mActiveTab
)
368 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-3, curX
+xSize
-2, curY
-3 );
370 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-3, curX
+xSize
-2, curY
-1 );
372 dc
.SetPen( mBlackPen
);
373 dc
.DrawLine( curX
+xSize
-1, curY
, curX
+xSize
-1, curY
+ySize
-2 );
374 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-2, curX
+xSize
-3, curY
+ySize
-2 );
375 dc
.DrawLine( curX
+xSize
-3, curY
+ySize
-1, curX
+1, curY
+ySize
-1 );
377 pNode
= pNode
->Next();
380 // darw image and (or without) text centered within the
381 // title bar rectangle
383 if ( mLayoutType
!= wxTITLE_BORDER_ONLY
&& tab
.HasImg() )
386 tmpDc
.SelectObject( tab
.GetImg() );
388 dc
.Blit( curX
+ mTitleHorizGap
,
389 curY
+ ( ySize
- tab
.ImgHeight() ) / 2,
396 if ( mLayoutType
== wxTITLE_IMG_AND_TEXT
&& tab
.HasText() )
400 // set select default font of the window into it's device context
401 //dc.SetFont( GetLabelingFont() );
403 dc
.SetTextBackground( GetBackgroundColour() );
405 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
407 x
= curX
+ mTitleHorizGap
+
408 tab
.ImgWidth() + tab
.ImageToTxtGap(mImageTextGap
);
410 dc
.DrawText( tab
.GetText(), x
, curY
+ ( ySize
- h
) / 2 );
414 } // end of `while (pNode)'
416 //---------------------------------------------------------------------------
417 int wxTabbedWindow::HitTest( const wxPoint
& pos
)
420 GetClientSize( &width
, &height
);
422 int curX
= mFirstTitleGap
;
423 int curY
= height
- mVertGap
- mTitleHeight
;
426 wxNode
* pNode
= mTabs
.First();
430 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
435 // hit test rectangle of the currnet tab title bar
436 if ( pos
.x
>= curX
&& pos
.x
< curX
+ tab
.mDims
.x
&&
437 pos
.y
>= curY
&& pos
.y
< curY
+ tab
.mDims
.y
445 pNode
= pNode
->Next();
451 //---------------------------------------------------------------------------
452 void wxTabbedWindow::HideInactiveTabs( bool andRepaint
)
457 wxNode
* pNode
= mTabs
.First();
462 if ( tabNo
!= mActiveTab
)
464 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
465 tab
.mpContent
->Show(FALSE
);
468 pNode
= pNode
->Next();
472 //---------------------------------------------------------------------------
473 wxFont
wxTabbedWindow::GetLabelingFont()
477 font
.SetFaceName("MS Sans Serif");
479 font
.SetFamily( wxSWISS
);
484 font
.SetPointSize( 8 );
487 font
.RealizeResource();
492 //---------------------------------------------------------------------------
493 void wxTabbedWindow::RecalcLayout(bool andRepaint
)
495 HideInactiveTabs(andRepaint
);
497 // resetup position of the active tab
500 GetClientSize( &width
, &height
);
502 int curX
= mHorizGap
+ BORDER_SZ
;
503 int curY
= mVertGap
+ BORDER_SZ
;
505 int xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2-1;
506 int ySize
= height
- mVertGap
*2 - BORDER_SZ
*2-1 - mTitleHeight
;
508 SizeTabs( curX
, curY
, xSize
, ySize
, andRepaint
);
510 // pass #1 - try to layout assuming it's wxTITLE_IMG_AND_TEXT
512 mLayoutType
= wxTITLE_IMG_AND_TEXT
;
514 wxNode
* pNode
= mTabs
.First();
516 curX
= mFirstTitleGap
; // the left-side gap
521 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
527 // set select default font of the window into it's device context
528 //dc.SetFont( GetLabelingFont() );
530 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
532 tab
.mDims
.x
= w
+ tab
.ImageToTxtGap(mImageTextGap
) +
533 tab
.ImgWidth() + mTitleHorizGap
*2;
535 tab
.mDims
.y
= wxMax( h
, tab
.ImgHeight() ) + mTitleVertGap
*2;
536 mTitleHeight
= wxMax( mTitleHeight
, tab
.mDims
.y
);
540 pNode
= pNode
->Next();
543 curX
+= mHorizGap
; // the right-side gap
545 // make all title bars of equel height
547 pNode
= mTabs
.First();
551 ((twTabInfo
*)(pNode
->Data()))->mDims
.y
= mTitleHeight
;;
552 pNode
= pNode
->Next();
555 // if curX has'nt ran out of bounds, leave TITLE_IMG layout and return
556 if ( curX
< width
- mHorizGap
)
559 // pass #2 - try to layout assuming wxTITLE_IMG_ONLY
561 mLayoutType
= wxTITLE_IMG_ONLY
;
563 pNode
= mTabs
.First();
565 curX
= mFirstTitleGap
; // the left-side gap
567 int denomiator
= mTabs
.Number();
568 if ( denomiator
== 0 ) ++denomiator
;
570 mBorderOnlyWidth
= (width
- mFirstTitleGap
- mHorizGap
) / denomiator
;
574 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
578 tab
.mDims
.x
= tab
.ImgWidth() + mTitleHorizGap
*2;
579 tab
.mDims
.y
= tab
.ImgHeight() + mTitleVertGap
*2;
583 tab
.mDims
.x
= mBorderOnlyWidth
;
584 tab
.mDims
.y
= mTitleHeight
;
589 pNode
= pNode
->Next();
592 curX
+= mHorizGap
; // the right-side gap
594 // if curX has'nt ran out of bounds, leave IMG_ONLY layout and return
595 if ( curX
< width
- mHorizGap
)
598 // pass #3 - set the narrowest layout wxTITLE_BORDER_ONLY
600 mLayoutType
= wxTITLE_BORDER_ONLY
;
602 pNode
= mTabs
.First();
606 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
608 tab
.mDims
.x
= mBorderOnlyWidth
;
609 tab
.mDims
.y
= mTitleHeight
;
611 pNode
= pNode
->Next();
614 //---------------------------------------------------------------------------
616 //---------------------------------------------------------------------------
617 void wxTabbedWindow::OnPaint( wxPaintEvent
& event
)
620 DrawDecorations( dc
);
622 //---------------------------------------------------------------------------
623 void wxTabbedWindow::OnSize ( wxSizeEvent
& event
)
625 SetBackgroundColour( wxColour( 192,192,192 ) );
628 //---------------------------------------------------------------------------
629 void wxTabbedWindow::OnBkErase( wxEraseEvent
& event
)
633 //---------------------------------------------------------------------------
634 void wxTabbedWindow::OnLButtonDown( wxMouseEvent
& event
)
637 int x
= (int)event
.m_x
;
638 int y
= (int)event
.m_y
;
640 int tabNo
= HitTest( wxPoint(x
,y
) );
644 SetActiveTab( tabNo
);
647 //---------------------------------------------------------------------------
648 // Implementation for class wxPaggedWindow
649 //---------------------------------------------------------------------------
650 IMPLEMENT_DYNAMIC_CLASS( wxPaggedWindow
, wxTabbedWindow
)
651 //---------------------------------------------------------------------------
652 BEGIN_EVENT_TABLE( wxPaggedWindow
, wxTabbedWindow
)
653 EVT_SIZE ( wxPaggedWindow::OnSize
)
654 EVT_PAINT ( wxPaggedWindow::OnPaint
)
655 EVT_LEFT_DOWN( wxPaggedWindow::OnLButtonDown
)
656 EVT_LEFT_UP ( wxPaggedWindow::OnLButtonUp
)
657 EVT_MOTION ( wxPaggedWindow::OnMouseMove
)
658 EVT_SCROLL ( wxPaggedWindow::OnScroll
)
660 //---------------------------------------------------------------------------
661 // border for pagged-window is 2 shaded-lines
662 //---------------------------------------------------------------------------
665 //---------------------------------------------------------------------------
666 wxPaggedWindow::wxPaggedWindow()
668 : mScrollEventInProgress( FALSE
),
672 mWhiteBrush( wxColour(255,255,255), wxSOLID
),
673 mGrayBrush ( wxColour(192,192,192), wxSOLID
),
676 mAdjustableTitleRowLen( 300 ),
678 mIsDragged ( FALSE
),
680 mCursorChanged( FALSE
),
681 mResizeCursor ( wxCURSOR_SIZEWE
),
682 mNormalCursor ( wxCURSOR_ARROW
)
686 mNoVertScroll
= TRUE
; // Horizontale Scroll abschalten
688 //---------------------------------------------------------------------------
689 wxPaggedWindow::~wxPaggedWindow()
691 // nothing (base class handles destruction)
693 //---------------------------------------------------------------------------
694 wxFont
wxPaggedWindow::GetLabelingFont()
699 font
.SetFaceName("Comic Sans MS");
701 font
.SetFamily( wxSWISS
);
706 font
.SetPointSize( 8 );
710 //---------------------------------------------------------------------------
711 void wxPaggedWindow::OnTabAdded( twTabInfo
* pInfo
)
713 int units
= GetWholeTabRowLen() / 20;
715 mpTabScroll
->SetScrollbar( 0, 1, units
, 1, FALSE
);
717 //---------------------------------------------------------------------------
718 wxScrollBar
& wxPaggedWindow::GetVerticalScrollBar()
720 return *mpVertScroll
;
722 //---------------------------------------------------------------------------
723 wxScrollBar
& wxPaggedWindow::GetHorizontalScrollBar()
725 return *mpHorizScroll
;
727 //---------------------------------------------------------------------------
728 int wxPaggedWindow::GetWholeTabRowLen()
730 wxNode
* pNode
= mTabs
.First();
736 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
739 pNode
= pNode
->Next();
744 //---------------------------------------------------------------------------
745 void wxPaggedWindow::DrawPaperBar( twTabInfo
& tab
, int x
, int y
,
746 wxBrush
& brush
, wxPen
& pen
, wxDC
& dc
)
750 // draw organizer-style paper outlet
752 poly
[0].x
= x
- mTabTrianGap
;
755 poly
[1].x
= x
+ mTabTrianGap
;
756 poly
[1].y
= y
+ tab
.mDims
.y
-1;
758 poly
[2].x
= x
+ tab
.mDims
.x
- mTabTrianGap
;
759 poly
[2].y
= y
+ tab
.mDims
.y
-1;
761 poly
[3].x
= x
+ tab
.mDims
.x
+ mTabTrianGap
;
765 dc
.SetBrush( brush
);
767 dc
.DrawPolygon( 4, poly
);
771 // set select default font of the window into it's device context
772 //dc.SetFont( GetLabelingFont() );
774 dc
.SetTextBackground( brush
.GetColour() );
776 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
781 tmpDc
.SelectObject( tab
.GetImg() );
783 dc
.Blit( x
+ mTitleHorizGap
,
784 y
+ ( tab
.mDims
.y
- tab
.ImgHeight() ) / 2,
793 int tx
= x
+ mTitleHorizGap
+
794 tab
.ImgWidth() + tab
.ImageToTxtGap(mImageTextGap
);
796 dc
.DrawText( tab
.GetText(), tx
, y
+ ( tab
.mDims
.y
- h
) / 2 );
799 //---------------------------------------------------------------------------
800 void wxPaggedWindow::DrawDecorations( wxDC
& dc
)
802 // FIXME:: the is big body have to be split!
805 GetClientSize( &width
, &height
);
807 int curX
= mHorizGap
;
810 int xSize
= width
- mHorizGap
*2;
811 int ySize
= height
- mVertGap
*2;
813 DrawShadedRect( curX
, curY
, xSize
, ySize
,
814 mDarkPen
, mWhitePen
, dc
);
816 DrawShadedRect( curX
+1, curY
+1, xSize
-2, ySize
-2,
817 mBlackPen
, mGrayPen
, dc
);
819 // draw inactive tab title bars frist (left-to-right)
821 wxNode
* pNode
= mTabs
.First();
825 curX = mTitleRowStart;
826 curY = height - mVertGap - BORDER_SZ - mTitleHeight;
832 // FOR NOW:: avoid creating bitmap with invalid dimensions
834 if ( mTitleRowLen
< 1 || mTitleHeight
< 1 ) return;
837 wxBitmap
tmpBmp( mTitleRowLen
, mTitleHeight
);
839 tmpDc
.SelectObject( tmpBmp
);
840 tmpDc
.SetPen( mGrayPen
);
841 tmpDc
.SetBrush( mGrayBrush
);
842 tmpDc
.DrawRectangle( 0,0, mTitleRowLen
, mTitleHeight
);
844 tmpDc
.SetDeviceOrigin( mCurentRowOfs
, 0 );
848 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
850 if ( tabNo
!= mActiveTab
)
852 DrawPaperBar( tab
, curX
, curY
, mGrayBrush
, mBlackPen
, tmpDc
);
856 pNode
= pNode
->Next();
860 // finally, draw the active tab (white-filled)
862 pNode
= mTabs
.First();
869 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
871 if ( tabNo
== mActiveTab
)
873 DrawPaperBar( tab
, curX
, curY
, mWhiteBrush
, mBlackPen
, tmpDc
);
875 tmpDc
.SetPen( mWhitePen
);
877 tmpDc
.DrawLine( curX
- mTabTrianGap
+1, curY
,
878 curX
+ tab
.mDims
.x
+ mTabTrianGap
, curY
);
883 pNode
= pNode
->Next();
887 // back to initial device origin
889 tmpDc
.SetDeviceOrigin( 0, 0 );
891 // draw resize-hint-stick
893 curX
= mTitleRowLen
- 6;
895 DrawShadedRect( curX
+0, 0+0, 6, mTitleHeight
, mGrayPen
, mBlackPen
, tmpDc
);
896 DrawShadedRect( curX
+1, 0+1, 6-2, mTitleHeight
-2, mWhitePen
, mDarkPen
, tmpDc
);
897 DrawShadedRect( curX
+2, 0+2, 6-4, mTitleHeight
-4, mGrayPen
, mGrayPen
, tmpDc
);
901 dc
.Blit( mTitleRowStart
,
902 height
- mVertGap
- BORDER_SZ
- mTitleHeight
,
903 mTitleRowLen
, mTitleHeight
,
904 &tmpDc
, 0,0, wxCOPY
);
906 //---------------------------------------------------------------------------
907 int wxPaggedWindow::HitTest( const wxPoint
& pos
)
909 return wxTabbedWindow::HitTest( pos
);
911 //---------------------------------------------------------------------------
912 void wxPaggedWindow::RecalcLayout(bool andRepaint
)
914 mTitleRowLen
= mAdjustableTitleRowLen
;
916 if ( int(mpTabScroll
) == -1 ) return;
918 // scroll bars should be created after Create() for this window is called
922 new wxScrollBar( this, -1, wxDefaultPosition
, wxDefaultSize
, wxSB_HORIZONTAL
);
925 new wxScrollBar( this, -1, wxDefaultPosition
, wxDefaultSize
, wxSB_HORIZONTAL
);
926 if (!mNoVertScroll
) // Vertical Scroll (Original)
927 mpVertScroll
= new wxScrollBar( this, -1, wxDefaultPosition
, wxDefaultSize
, wxSB_VERTICAL
);
931 int units
= GetWholeTabRowLen() / 20;
933 mpTabScroll
->SetScrollbar( 0, 1, units
, 1, FALSE
);
936 // resetup position of the active tab
938 int thumbLen
= 16; // FOR NOW:: hardcoded
941 GetClientSize( &width
, &height
);
943 mTitleHeight
= thumbLen
;
945 int curX
= mHorizGap
+ BORDER_SZ
;
946 int curY
= mVertGap
+ BORDER_SZ
;
949 if (!mNoVertScroll
) // Vertical Scroll (Original)
950 xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2 - thumbLen
;
952 xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2;
954 int ySize
= height
- mVertGap
*2 - BORDER_SZ
*2 - mTitleHeight
;
956 SizeTabs( curX
, curY
, xSize
, ySize
, andRepaint
);
958 // setup title bar LINES's horizontal scroll bar
960 curY
= height
- mVertGap
- BORDER_SZ
- thumbLen
;
962 mpTabScroll
->SetSize( curX
, curY
, thumbLen
*2, thumbLen
);
964 // setup view's HORIZONTAL scroll bar
967 mTitleRowStart
= curX
;
968 mFirstTitleGap
= curX
+ mCurentRowOfs
+ mTabTrianGap
;
970 mTitleRowLen
= wxMin( mAdjustableTitleRowLen
,
971 width
- mHorizGap
- BORDER_SZ
- thumbLen
*4 - curX
);
973 curX
+= mTitleRowLen
;
975 if (!mNoVertScroll
) // Vertical Scroll (Original)
976 mpHorizScroll
->SetSize( curX
, curY
,width
- curX
- mHorizGap
- BORDER_SZ
- thumbLen
, thumbLen
);
978 mpHorizScroll
->SetSize( curX
, curY
,width
- curX
- mHorizGap
- BORDER_SZ
-4, thumbLen
);
980 // setup view's VERTICAL scroll bar
981 if (!mNoVertScroll
) // Vertical Scroll (Original)
983 curX
= width
- mHorizGap
- BORDER_SZ
- thumbLen
;
984 curY
= mVertGap
+ BORDER_SZ
;
985 mpVertScroll
->SetSize( curX
, curY
, thumbLen
,height
- curY
- mVertGap
- BORDER_SZ
- thumbLen
);
987 // layout tab title bars
989 mLayoutType
= wxTITLE_IMG_AND_TEXT
;
991 wxNode
* pNode
= mTabs
.First();
995 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
1001 // set select default font of the window into it's device context
1002 //dc.SetFont( GetLabelingFont() );
1003 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
1005 tab
.mDims
.x
= w
+ tab
.ImageToTxtGap(mImageTextGap
) +
1006 tab
.ImgWidth() + mTitleHorizGap
*2;
1008 tab
.mDims
.y
= mTitleHeight
;
1010 pNode
= pNode
->Next();
1013 // disable title-bar scroller if there's nowhere to scroll to
1015 mpTabScroll
->Enable( mTitleRowLen
< GetWholeTabRowLen() || mCurentRowOfs
< 0 );
1017 //---------------------------------------------------------------------------
1019 //---------------------------------------------------------------------------
1020 void wxPaggedWindow::OnPaint( wxPaintEvent
& event
)
1023 DrawDecorations( dc
);
1025 //---------------------------------------------------------------------------
1026 void wxPaggedWindow::OnSize ( wxSizeEvent
& event
)
1028 wxTabbedWindow::OnSize(event
);
1030 //---------------------------------------------------------------------------
1031 void wxPaggedWindow::OnLButtonDown( wxMouseEvent
& event
)
1033 if ( mCursorChanged
)
1036 mDagOrigin
= event
.m_x
;
1038 mOriginalTitleRowLen
= mAdjustableTitleRowLen
;
1044 wxTabbedWindow::OnLButtonDown( event
);
1047 //---------------------------------------------------------------------------
1048 void wxPaggedWindow::OnLButtonUp( wxMouseEvent
& event
)
1053 mCursorChanged
= FALSE
;
1054 SetCursor( mNormalCursor
);
1059 //---------------------------------------------------------------------------
1060 void wxPaggedWindow::OnMouseMove( wxMouseEvent
& event
)
1063 GetClientSize( &width
, &height
);
1067 int y
= height
- mVertGap
- BORDER_SZ
- mTitleHeight
;
1068 int x
= mTitleRowStart
+ mTitleRowLen
- 6;
1070 if ( event
.m_x
>= x
&& event
.m_y
>= y
&&
1071 event
.m_x
< x
+ 6 &&
1072 event
.m_y
< y
+ mTitleHeight
1075 if ( !mCursorChanged
)
1077 SetCursor( mResizeCursor
);
1079 mCursorChanged
= TRUE
;
1083 if ( mCursorChanged
)
1085 SetCursor( mNormalCursor
);
1087 mCursorChanged
= FALSE
;
1093 mAdjustableTitleRowLen
= mOriginalTitleRowLen
+ ( event
.m_x
- mDagOrigin
);
1096 if ( mAdjustableTitleRowLen
< 6 ) mAdjustableTitleRowLen
= 6;
1098 wxWindowDC
dc(this);
1099 DrawDecorations( dc
);
1101 RecalcLayout(FALSE
);
1106 //---------------------------------------------------------------------------
1107 void wxPaggedWindow::OnScroll( wxScrollEvent
& event
)
1110 wxScrollBar
* pSender
= (wxScrollBar
*)event
.GetEventObject();
1111 // wxMessageBox("wxPaggedWindow::OnScroll","-I->");
1112 if ( pSender
== mpTabScroll
)
1115 int maxUnits
= GetWholeTabRowLen() / 20;
1117 mCurentRowOfs
= -event
.GetPosition()*maxUnits
;
1119 mFirstTitleGap
= mTitleRowStart
+ mCurentRowOfs
+ mTabTrianGap
;
1121 // let' it automatically disable itself if it's time
1122 mpTabScroll
->Enable( mTitleRowLen
< GetWholeTabRowLen() || mCurentRowOfs
< 0 );
1124 // repaint title bars
1125 wxWindowDC
dc(this);
1126 DrawDecorations( dc
);
1129 if ( !mScrollEventInProgress
)
1131 mScrollEventInProgress
= TRUE
;
1133 GetActiveTab()->GetEventHandler()->ProcessEvent( event
);
1137 // event bounced back to us, from here we
1138 // know that it has traveled the loop - thus it's processed!
1140 mScrollEventInProgress
= FALSE
;
1143 //---------------------------------------------------------------------------