1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by: 19990908 : mj
6 // - rename to tabpgwin
7 // - restruction of Variable declaration
8 // - to prevent Warnings under MingW32
9 // Modified by: 19990909 : mj
10 // - mNoVertScroll true = no / false = Original Code
11 // the Original Code Paints a Vertical Scroll in wxPagedWindow
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
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(..)
43 //---------------------------------------------------------------------------
44 // Implementation for class twTabInfo
45 //---------------------------------------------------------------------------
46 IMPLEMENT_DYNAMIC_CLASS( twTabInfo
, wxObject
)
48 //---------------------------------------------------------------------------
49 twTabInfo::twTabInfo()
53 //---------------------------------------------------------------------------
54 int twTabInfo::ImgWidth()
56 if ( mBitMap
.Ok() ) return mBitMap
.GetWidth();
60 //---------------------------------------------------------------------------
61 int twTabInfo::ImgHeight()
64 return mBitMap
.GetHeight();
69 //---------------------------------------------------------------------------
70 int twTabInfo::ImageToTxtGap( int prefGap
)
78 //---------------------------------------------------------------------------
79 bool twTabInfo::HasImg()
84 //---------------------------------------------------------------------------
85 // bool twTabInfo::HasText();
86 unsigned int twTabInfo::HasText()
88 return mText
.Length();
91 //---------------------------------------------------------------------------
92 wxBitmap
& twTabInfo::GetImg()
97 //---------------------------------------------------------------------------
98 wxString
& twTabInfo::GetText()
103 //---------------------------------------------------------------------------
104 wxWindow
& twTabInfo::GetContent()
109 //---------------------------------------------------------------------------
110 // Implementation for class wxTabbedWindow
111 //---------------------------------------------------------------------------
112 IMPLEMENT_DYNAMIC_CLASS( wxTabbedWindow
, wxPanel
)
114 //---------------------------------------------------------------------------
115 BEGIN_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 )
123 //---------------------------------------------------------------------------
124 wxTabbedWindow::wxTabbedWindow()
126 : mpTabScroll ( NULL
),
127 mpHorizScroll( NULL
),
128 mpVertScroll ( NULL
),
136 mFirstTitleGap( 11 ),
138 mBorderOnlyWidth( 8 ),
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
),
148 mLayoutType( wxTITLE_IMG_AND_TEXT
)
151 //---------------------------------------------------------------------------
152 wxTabbedWindow::~wxTabbedWindow()
154 wxObjectList::compatibility_iterator pTab
= mTabs
.GetFirst();
158 delete ((twTabInfo
*)pTab
->GetData());
159 pTab
= pTab
->GetNext();
163 //---------------------------------------------------------------------------
164 void wxTabbedWindow::SizeTabs(int x
,int y
, int width
, int height
, bool WXUNUSED(repant
))
166 wxObjectList::compatibility_iterator pTabNode
= mTabs
.GetFirst();
171 twTabInfo
& info
= *((twTabInfo
*)pTabNode
->GetData());
173 if ( n
== mActiveTab
)
176 //info.mpContent->GetEventHandler()->ProcessEvent( evt );
178 info
.mpContent
->SetSize( x
, y
, width
, height
, 0 );
179 info
.mpContent
->Show(true);
180 info
.mpContent
->Refresh();
185 info
.mpContent
->Show(false);
188 pTabNode
= pTabNode
->GetNext();
193 //---------------------------------------------------------------------------
194 void wxTabbedWindow::AddTab( wxWindow
* pContent
,
196 wxString imageFileName
,
197 wxBitmapType imageType
)
199 twTabInfo
* pTab
= new twTabInfo();
201 pTab
->mpContent
= pContent
;
202 pTab
->mText
= tabText
;
204 if ( wxFileExists( imageFileName
) &&
206 pTab
->mBitMap
.LoadFile( imageFileName
, imageType
) )
208 pTab
->mImageFile
= imageFileName
;
209 pTab
->mImageType
= imageType
;
213 if ( pContent
->GetParent() == NULL
)
214 pContent
->Create( this, wxID_ANY
);
216 mTabs
.Append( (wxObject
*)pTab
);
223 //---------------------------------------------------------------------------
224 void wxTabbedWindow::AddTab( wxWindow
* pContent
,
225 wxString tabText
, wxBitmap
* pImage
)
227 twTabInfo
* pTab
= new twTabInfo();
229 pTab
->mpContent
= pContent
;
230 pTab
->mText
= tabText
;
233 pTab
->mBitMap
= *pImage
;
235 if ( pContent
->GetParent() == NULL
)
236 pContent
->Create( this, wxID_ANY
);
238 mTabs
.Append( (wxObject
*)pTab
);
243 //---------------------------------------------------------------------------
244 void wxTabbedWindow::RemoveTab( int tabNo
)
246 twTabInfo
* pTab
= ((twTabInfo
*)(mTabs
.Item( tabNo
)->GetData()));
247 pTab
->mpContent
->Destroy();
249 mTabs
.Erase( mTabs
.Item( tabNo
) );
250 // if ( mActiveTab >= mTabs.GetCount() );
251 if ( mActiveTab
>= mTabs
.GetCount() )
252 mActiveTab
= mTabs
.GetCount() - 1;
253 SetActiveTab( mActiveTab
);
256 //---------------------------------------------------------------------------
257 int wxTabbedWindow::GetTabCount()
259 return mTabs
.GetCount();
262 //---------------------------------------------------------------------------
263 wxWindow
* wxTabbedWindow::GetTab( int tabNo
)
265 return ((twTabInfo
*)(mTabs
.Item( tabNo
)->GetData()))->mpContent
;
268 //---------------------------------------------------------------------------
269 wxWindow
* wxTabbedWindow::GetActiveTab()
271 // FIMXE:: this is lame
272 return GetTab( mActiveTab
);
275 //---------------------------------------------------------------------------
276 void wxTabbedWindow::SetActiveTab( int tabNo
)
283 //---------------------------------------------------------------------------
284 // width of the decorations border (4 shade-lines), should not be changed
285 //---------------------------------------------------------------------------
288 //---------------------------------------------------------------------------
289 void wxTabbedWindow::DrawShadedRect( int x
, int y
, int width
, int height
,
290 wxPen
& upperPen
, wxPen
& lowerPen
, wxDC
& dc
293 // darw the lightened upper-left sides of the rectangle
295 dc
.SetPen( upperPen
);
296 dc
.DrawLine( x
,y
, x
, y
+ height
- 1 ); // vert
297 dc
.DrawLine( x
,y
, x
+ width
- 1, y
); // horiz
299 // draw the unenlightened lower-right sides of the rectangle
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
306 //---------------------------------------------------------------------------
307 void wxTabbedWindow::DrawDecorations( wxDC
& dc
)
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
315 GetClientSize( &width
, &height
);
317 // check if there's at least a bit of space to draw things
319 if ( width
< mHorizGap
*2 + BORDER_SZ
*2+1 ||
320 height
< mVertGap
*2 + BORDER_SZ
*2+1 + mTitleHeight
324 // step #1 - draw border around the tab content area
326 // setup position for kind of "pencil"
327 int curX
= mHorizGap
;
330 int xSize
= width
- mHorizGap
*2;
331 int ySize
= height
- mVertGap
*2 - mTitleHeight
;
333 // layer 1 (upper white)
334 DrawShadedRect( curX
+0, curY
+0, xSize
-0, ySize
-0,
335 mWhitePen
, mBlackPen
, dc
);
337 // layer 2 (upper gray)
338 DrawShadedRect( curX
+1, curY
+1, xSize
-2-1, ySize
-2-1,
339 mGrayPen
, mGrayPen
, dc
);
341 // layer 3 (upper darkGray)
342 DrawShadedRect( curX
+2, curY
+2, xSize
-3-2, ySize
-3-2,
343 mDarkPen
, mWhitePen
, dc
);
345 // layer 4 (upper black)
346 DrawShadedRect( curX
+3, curY
+3, xSize
-4-3, ySize
-4-3,
347 mBlackPen
, mGrayPen
, dc
);
349 // add non-siemtric layer from the lower-right side (confroming to MFC-look)
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
355 // step #2 - draw tab title bars
357 curX
= mFirstTitleGap
;
358 curY
= height
- mVertGap
- mTitleHeight
;
361 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
365 // "hard-coded metafile" for decorations
367 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
370 ySize
= mTitleHeight
;
372 if ( tabNo
== mActiveTab
)
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 );
379 dc
.SetPen( mWhitePen
);
381 if ( tabNo
== mActiveTab
)
382 dc
.DrawLine( curX
, curY
-2, curX
, curY
+ySize
-2 );
384 dc
.DrawLine( curX
, curY
, curX
, curY
+ySize
-2 );
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 );
393 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-3, curX
+xSize
-2, curY
-1 );
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 );
400 pNode
= pNode
->GetNext();
403 // darw image and (or without) text centered within the
404 // title bar rectangle
406 if ( mLayoutType
!= wxTITLE_BORDER_ONLY
&& tab
.HasImg() )
409 tmpDc
.SelectObject( tab
.GetImg() );
411 dc
.Blit( curX
+ mTitleHorizGap
,
412 curY
+ ( ySize
- tab
.ImgHeight() ) / 2,
419 if ( mLayoutType
== wxTITLE_IMG_AND_TEXT
&& tab
.HasText() )
423 // set select default font of the window into it's device context
424 //dc.SetFont( GetLabelingFont() );
426 dc
.SetTextBackground( GetBackgroundColour() );
428 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
430 x
= curX
+ mTitleHorizGap
+
431 tab
.ImgWidth() + tab
.ImageToTxtGap(mImageTextGap
);
433 dc
.DrawText( tab
.GetText(), x
, curY
+ ( ySize
- h
) / 2 );
437 } // end of `while (pNode)'
438 } // wxTabbedWindow::DrawDecorations()
440 //---------------------------------------------------------------------------
441 int wxTabbedWindow::HitTest( const wxPoint
& pos
)
444 GetClientSize( &width
, &height
);
446 int curX
= mFirstTitleGap
;
447 int curY
= height
- mVertGap
- mTitleHeight
;
450 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
454 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
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
466 pNode
= pNode
->GetNext();
471 } // wxTabbedWindow::HitTest()
473 //---------------------------------------------------------------------------
474 void wxTabbedWindow::HideInactiveTabs( bool andRepaint
)
479 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
484 if ( tabNo
!= mActiveTab
)
486 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
487 tab
.mpContent
->Show(false);
490 pNode
= pNode
->GetNext();
493 } // wxTabbedWindow::HideInactiveTabs()
495 //---------------------------------------------------------------------------
496 wxFont
wxTabbedWindow::GetLabelingFont()
500 font
.SetFaceName(_T("MS Sans Serif"));
502 font
.SetFamily( wxSWISS
);
507 font
.SetPointSize( 8 );
510 font
.RealizeResource();
514 } // wxTabbedWindow::GetLabelingFont()
516 //---------------------------------------------------------------------------
517 void wxTabbedWindow::RecalcLayout(bool andRepaint
)
519 HideInactiveTabs(andRepaint
);
521 // resetup position of the active tab
524 GetClientSize( &width
, &height
);
526 int curX
= mHorizGap
+ BORDER_SZ
;
527 int curY
= mVertGap
+ BORDER_SZ
;
529 int xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2-1;
530 int ySize
= height
- mVertGap
*2 - BORDER_SZ
*2-1 - mTitleHeight
;
532 SizeTabs( curX
, curY
, xSize
, ySize
, andRepaint
);
534 // pass #1 - try to layout assuming it's wxTITLE_IMG_AND_TEXT
536 mLayoutType
= wxTITLE_IMG_AND_TEXT
;
538 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
540 curX
= mFirstTitleGap
; // the left-side gap
545 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
551 // set select default font of the window into it's device context
552 //dc.SetFont( GetLabelingFont() );
554 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
556 tab
.mDims
.x
= w
+ tab
.ImageToTxtGap(mImageTextGap
) +
557 tab
.ImgWidth() + mTitleHorizGap
*2;
559 tab
.mDims
.y
= wxMax( h
, tab
.ImgHeight() ) + mTitleVertGap
*2;
560 mTitleHeight
= wxMax( mTitleHeight
, tab
.mDims
.y
);
564 pNode
= pNode
->GetNext();
567 curX
+= mHorizGap
; // the right-side gap
569 // make all title bars of equel height
571 pNode
= mTabs
.GetFirst();
575 ((twTabInfo
*)(pNode
->GetData()))->mDims
.y
= mTitleHeight
;;
576 pNode
= pNode
->GetNext();
579 // if curX has'nt ran out of bounds, leave TITLE_IMG layout and return
580 if ( curX
< width
- mHorizGap
)
583 // pass #2 - try to layout assuming wxTITLE_IMG_ONLY
585 mLayoutType
= wxTITLE_IMG_ONLY
;
587 pNode
= mTabs
.GetFirst();
589 curX
= mFirstTitleGap
; // the left-side gap
591 int denomiator
= mTabs
.GetCount();
592 if ( denomiator
== 0 )
595 mBorderOnlyWidth
= (width
- mFirstTitleGap
- mHorizGap
) / denomiator
;
599 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
603 tab
.mDims
.x
= tab
.ImgWidth() + mTitleHorizGap
*2;
604 tab
.mDims
.y
= tab
.ImgHeight() + mTitleVertGap
*2;
608 tab
.mDims
.x
= mBorderOnlyWidth
;
609 tab
.mDims
.y
= mTitleHeight
;
614 pNode
= pNode
->GetNext();
617 curX
+= mHorizGap
; // the right-side gap
619 // if curX has'nt ran out of bounds, leave IMG_ONLY layout and return
620 if ( curX
< width
- mHorizGap
)
623 // pass #3 - set the narrowest layout wxTITLE_BORDER_ONLY
625 mLayoutType
= wxTITLE_BORDER_ONLY
;
627 pNode
= mTabs
.GetFirst();
631 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
633 tab
.mDims
.x
= mBorderOnlyWidth
;
634 tab
.mDims
.y
= mTitleHeight
;
636 pNode
= pNode
->GetNext();
638 } // wxTabbedWindow::RecalcLayout()
640 //---------------------------------------------------------------------------
642 //---------------------------------------------------------------------------
643 void wxTabbedWindow::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
646 DrawDecorations( dc
);
649 //---------------------------------------------------------------------------
650 void wxTabbedWindow::OnSize ( wxSizeEvent
& WXUNUSED(event
) )
652 SetBackgroundColour( wxColour( 192,192,192 ) );
656 //---------------------------------------------------------------------------
657 void wxTabbedWindow::OnBkErase( wxEraseEvent
& WXUNUSED(event
) )
662 //---------------------------------------------------------------------------
663 void wxTabbedWindow::OnLButtonDown( wxMouseEvent
& event
)
666 int x
= (int)event
.m_x
;
667 int y
= (int)event
.m_y
;
669 int tabNo
= HitTest( wxPoint(x
,y
) );
673 SetActiveTab( tabNo
);
677 //---------------------------------------------------------------------------
678 // Implementation for class wxPagedWindow
679 //---------------------------------------------------------------------------
680 IMPLEMENT_DYNAMIC_CLASS( wxPagedWindow
, wxTabbedWindow
)
682 //---------------------------------------------------------------------------
683 BEGIN_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
)
692 //---------------------------------------------------------------------------
693 // border for paged-window is 2 shaded-lines
694 //---------------------------------------------------------------------------
698 //---------------------------------------------------------------------------
699 wxPagedWindow::wxPagedWindow()
701 : mScrollEventInProgress( false ),
703 mWhiteBrush( wxColour(255,255,255), wxSOLID
),
704 mGrayBrush ( wxColour(192,192,192), wxSOLID
),
706 mAdjustableTitleRowLen( 300 ),
707 mIsDragged ( false ),
709 mCursorChanged( false ),
710 mResizeCursor ( wxCURSOR_SIZEWE
),
711 mNormalCursor ( wxCURSOR_ARROW
)
715 mNoVertScroll
= true; // Horizontale Scroll abschalten
718 //---------------------------------------------------------------------------
719 wxFont
wxPagedWindow::GetLabelingFont()
724 font
.SetFaceName(_T("Comic Sans MS"));
726 font
.SetFamily( wxSWISS
);
731 font
.SetPointSize( 8 );
736 //---------------------------------------------------------------------------
737 void wxPagedWindow::OnTabAdded( twTabInfo
* WXUNUSED(pInfo
) )
739 int units
= GetWholeTabRowLen() / 20;
741 mpTabScroll
->SetScrollbar( 0, 1, units
, 1, false );
744 //---------------------------------------------------------------------------
745 wxScrollBar
& wxPagedWindow::GetVerticalScrollBar()
747 return *mpVertScroll
;
750 //---------------------------------------------------------------------------
751 wxScrollBar
& wxPagedWindow::GetHorizontalScrollBar()
753 return *mpHorizScroll
;
756 //---------------------------------------------------------------------------
757 int wxPagedWindow::GetWholeTabRowLen()
759 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
765 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
768 pNode
= pNode
->GetNext();
772 } // wxPagedWindow::GetWholeTabRowLen()
774 //---------------------------------------------------------------------------
775 void wxPagedWindow::DrawPaperBar( twTabInfo
& tab
, int x
, int y
,
776 wxBrush
& brush
, wxPen
& pen
, wxDC
& dc
)
780 // draw organizer-style paper outlet
782 poly
[0].x
= x
- mTabTrianGap
;
785 poly
[1].x
= x
+ mTabTrianGap
;
786 poly
[1].y
= y
+ tab
.mDims
.y
-1;
788 poly
[2].x
= x
+ tab
.mDims
.x
- mTabTrianGap
;
789 poly
[2].y
= y
+ tab
.mDims
.y
-1;
791 poly
[3].x
= x
+ tab
.mDims
.x
+ mTabTrianGap
;
795 dc
.SetBrush( brush
);
797 dc
.DrawPolygon( 4, poly
);
801 // set select default font of the window into it's device context
802 //dc.SetFont( GetLabelingFont() );
804 dc
.SetTextBackground( brush
.GetColour() );
806 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
811 tmpDc
.SelectObject( tab
.GetImg() );
813 dc
.Blit( x
+ mTitleHorizGap
,
814 y
+ ( tab
.mDims
.y
- tab
.ImgHeight() ) / 2,
823 int tx
= x
+ mTitleHorizGap
+
824 tab
.ImgWidth() + tab
.ImageToTxtGap(mImageTextGap
);
826 dc
.DrawText( tab
.GetText(), tx
, y
+ ( tab
.mDims
.y
- h
) / 2 );
828 } // wxPagedWindow::DrawPaperBar()
830 //---------------------------------------------------------------------------
831 void wxPagedWindow::DrawDecorations( wxDC
& dc
)
833 // FIXME:: the is big body have to be split!
836 GetClientSize( &width
, &height
);
838 int curX
= mHorizGap
;
841 int xSize
= width
- mHorizGap
*2;
842 int ySize
= height
- mVertGap
*2;
844 DrawShadedRect( curX
, curY
, xSize
, ySize
,
845 mDarkPen
, mWhitePen
, dc
);
847 DrawShadedRect( curX
+1, curY
+1, xSize
-2, ySize
-2,
848 mBlackPen
, mGrayPen
, dc
);
850 // draw inactive tab title bars frist (left-to-right)
852 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
856 curX = mTitleRowStart;
857 curY = height - mVertGap - BORDER_SZ - mTitleHeight;
863 // FOR NOW:: avoid creating bitmap with invalid dimensions
865 if ( mTitleRowLen
< 1 || mTitleHeight
< 1 )
869 wxBitmap
tmpBmp( mTitleRowLen
, mTitleHeight
);
871 tmpDc
.SelectObject( tmpBmp
);
872 tmpDc
.SetPen( mGrayPen
);
873 tmpDc
.SetBrush( mGrayBrush
);
874 tmpDc
.DrawRectangle( 0,0, mTitleRowLen
, mTitleHeight
);
876 tmpDc
.SetDeviceOrigin( mCurentRowOfs
, 0 );
880 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
882 if ( tabNo
!= mActiveTab
)
883 DrawPaperBar( tab
, curX
, curY
, mGrayBrush
, mBlackPen
, tmpDc
);
887 pNode
= pNode
->GetNext();
891 // finally, draw the active tab (white-filled)
893 pNode
= mTabs
.GetFirst();
900 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
902 if ( tabNo
== mActiveTab
)
904 DrawPaperBar( tab
, curX
, curY
, mWhiteBrush
, mBlackPen
, tmpDc
);
906 tmpDc
.SetPen( mWhitePen
);
908 tmpDc
.DrawLine( curX
- mTabTrianGap
+1, curY
,
909 curX
+ tab
.mDims
.x
+ mTabTrianGap
, curY
);
914 pNode
= pNode
->GetNext();
918 // back to initial device origin
920 tmpDc
.SetDeviceOrigin( 0, 0 );
922 // draw resize-hint-stick
924 curX
= mTitleRowLen
- 6;
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
);
932 dc
.Blit( mTitleRowStart
,
933 height
- mVertGap
- BORDER_SZ
- mTitleHeight
,
934 mTitleRowLen
, mTitleHeight
,
935 &tmpDc
, 0,0, wxCOPY
);
936 } // wxPagedWindow::DrawDecorations()
938 //---------------------------------------------------------------------------
939 int wxPagedWindow::HitTest( const wxPoint
& pos
)
941 return wxTabbedWindow::HitTest( pos
);
944 //---------------------------------------------------------------------------
945 void wxPagedWindow::RecalcLayout(bool andRepaint
)
947 mTitleRowLen
= mAdjustableTitleRowLen
;
949 if ( int(mpTabScroll
) == -1 ) return;
951 // scroll bars should be created after Create() for this window is called
955 new wxScrollBar( this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, wxSB_HORIZONTAL
);
958 new wxScrollBar( this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, wxSB_HORIZONTAL
);
959 if (!mNoVertScroll
) // Vertical Scroll (Original)
960 mpVertScroll
= new wxScrollBar( this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, wxSB_VERTICAL
);
964 int units
= GetWholeTabRowLen() / 20;
966 mpTabScroll
->SetScrollbar( 0, 1, units
, 1, false );
969 // resetup position of the active tab
971 int thumbLen
= 16; // FOR NOW:: hardcoded
974 GetClientSize( &width
, &height
);
976 mTitleHeight
= thumbLen
;
978 int curX
= mHorizGap
+ BORDER_SZ
;
979 int curY
= mVertGap
+ BORDER_SZ
;
982 if (!mNoVertScroll
) // Vertical Scroll (Original)
983 xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2 - thumbLen
;
985 xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2;
987 int ySize
= height
- mVertGap
*2 - BORDER_SZ
*2 - mTitleHeight
;
989 SizeTabs( curX
, curY
, xSize
, ySize
, andRepaint
);
991 // setup title bar LINES's horizontal scroll bar
993 curY
= height
- mVertGap
- BORDER_SZ
- thumbLen
;
995 mpTabScroll
->SetSize( curX
, curY
, thumbLen
*2, thumbLen
);
997 // setup view's HORIZONTAL scroll bar
1000 mTitleRowStart
= curX
;
1001 mFirstTitleGap
= curX
+ mCurentRowOfs
+ mTabTrianGap
;
1003 mTitleRowLen
= wxMin( mAdjustableTitleRowLen
,
1004 width
- mHorizGap
- BORDER_SZ
- thumbLen
*4 - curX
);
1006 curX
+= mTitleRowLen
;
1008 if (!mNoVertScroll
) // Vertical Scroll (Original)
1009 mpHorizScroll
->SetSize( curX
, curY
,width
- curX
- mHorizGap
- BORDER_SZ
- thumbLen
, thumbLen
);
1011 mpHorizScroll
->SetSize( curX
, curY
,width
- curX
- mHorizGap
- BORDER_SZ
-4, thumbLen
);
1013 // setup view's VERTICAL scroll bar
1014 if (!mNoVertScroll
) // Vertical Scroll (Original)
1016 curX
= width
- mHorizGap
- BORDER_SZ
- thumbLen
;
1017 curY
= mVertGap
+ BORDER_SZ
;
1018 mpVertScroll
->SetSize( curX
, curY
, thumbLen
,height
- curY
- mVertGap
- BORDER_SZ
- thumbLen
);
1020 // layout tab title bars
1022 mLayoutType
= wxTITLE_IMG_AND_TEXT
;
1024 wxObjectList::compatibility_iterator pNode
= mTabs
.GetFirst();
1028 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->GetData()));
1030 wxWindowDC
dc(this);
1034 // set select default font of the window into it's device context
1035 //dc.SetFont( GetLabelingFont() );
1036 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
1038 tab
.mDims
.x
= w
+ tab
.ImageToTxtGap(mImageTextGap
) +
1039 tab
.ImgWidth() + mTitleHorizGap
*2;
1041 tab
.mDims
.y
= mTitleHeight
;
1043 pNode
= pNode
->GetNext();
1046 // disable title-bar scroller if there's nowhere to scroll to
1048 mpTabScroll
->Enable( mTitleRowLen
< GetWholeTabRowLen() || mCurentRowOfs
< 0 );
1051 //---------------------------------------------------------------------------
1053 //---------------------------------------------------------------------------
1054 void wxPagedWindow::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
1057 DrawDecorations( dc
);
1060 //---------------------------------------------------------------------------
1061 void wxPagedWindow::OnSize ( wxSizeEvent
& event
)
1063 wxTabbedWindow::OnSize(event
);
1066 //---------------------------------------------------------------------------
1067 void wxPagedWindow::OnLButtonDown( wxMouseEvent
& event
)
1069 if ( mCursorChanged
)
1072 mDagOrigin
= event
.m_x
;
1074 mOriginalTitleRowLen
= mAdjustableTitleRowLen
;
1080 wxTabbedWindow::OnLButtonDown( event
);
1082 } // wxPagedWindow::OnLButtonDown()
1084 //---------------------------------------------------------------------------
1085 void wxPagedWindow::OnLButtonUp( wxMouseEvent
& WXUNUSED(event
) )
1090 mCursorChanged
= false;
1091 SetCursor( mNormalCursor
);
1095 } // wxPagedWindow::OnLButtonUp()
1097 //---------------------------------------------------------------------------
1098 void wxPagedWindow::OnMouseMove( wxMouseEvent
& event
)
1101 GetClientSize( &width
, &height
);
1105 int y
= height
- mVertGap
- BORDER_SZ
- mTitleHeight
;
1106 int x
= mTitleRowStart
+ mTitleRowLen
- 6;
1108 if ( event
.m_x
>= x
&& event
.m_y
>= y
&&
1109 event
.m_x
< x
+ 6 &&
1110 event
.m_y
< y
+ mTitleHeight
1113 if ( !mCursorChanged
)
1115 SetCursor( mResizeCursor
);
1117 mCursorChanged
= true;
1121 if ( mCursorChanged
)
1123 SetCursor( mNormalCursor
);
1125 mCursorChanged
= false;
1132 mAdjustableTitleRowLen
= mOriginalTitleRowLen
+ ( event
.m_x
- mDagOrigin
);
1135 if ( mAdjustableTitleRowLen
< 6 ) mAdjustableTitleRowLen
= 6;
1137 wxWindowDC
dc(this);
1138 DrawDecorations( dc
);
1140 RecalcLayout(false);
1145 } // wxPagedWindow::OnMouseMove()
1147 //---------------------------------------------------------------------------
1148 void wxPagedWindow::OnScroll( wxScrollEvent
& event
)
1150 wxScrollBar
* pSender
= (wxScrollBar
*)event
.GetEventObject();
1151 // wxMessageBox("wxPagedWindow::OnScroll","-I->");
1152 if ( pSender
== mpTabScroll
)
1155 int maxUnits
= GetWholeTabRowLen() / 20;
1157 mCurentRowOfs
= -event
.GetPosition()*maxUnits
;
1159 mFirstTitleGap
= mTitleRowStart
+ mCurentRowOfs
+ mTabTrianGap
;
1161 // let' it automatically disable itself if it's time
1162 mpTabScroll
->Enable( mTitleRowLen
< GetWholeTabRowLen() || mCurentRowOfs
< 0 );
1164 // repaint title bars
1165 wxWindowDC
dc(this);
1166 DrawDecorations( dc
);
1170 if ( !mScrollEventInProgress
)
1172 mScrollEventInProgress
= true;
1174 GetActiveTab()->GetEventHandler()->ProcessEvent( event
);
1178 // event bounced back to us, from here we
1179 // know that it has traveled the loop - thus it's processed!
1181 mScrollEventInProgress
= false;
1184 } // wxPagedWindow::OnScroll()
1185 //---------------------------------------------------------------------------