]>
git.saurik.com Git - wxWidgets.git/blob - utils/framelayout/src/controlarea.cpp
046131ce5c643607de55ab336913e6b4e02b54e7
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "controlarea.h"
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
31 #include "wx/string.h"
32 #include "wx/utils.h" // import wxMin/wxMax macros and wxFileExist(..)
34 #include "controlarea.h"
37 /***** Implementation for class twTabInfo *****/
39 IMPLEMENT_DYNAMIC_CLASS( twTabInfo
, wxObject
)
41 twTabInfo::twTabInfo()
45 twTabInfo::~twTabInfo()
50 int twTabInfo::ImgWidth()
52 if ( mBitMap
.Ok() ) return mBitMap
.GetWidth();
56 int twTabInfo::ImgHeight()
58 if ( mBitMap
.Ok() ) return mBitMap
.GetHeight();
62 int twTabInfo::ImageToTxtGap( int prefGap
)
64 if ( mBitMap
.Ok() ) return prefGap
;
68 bool twTabInfo::HasImg()
73 bool twTabInfo::HasText()
75 return mText
.Length();
78 wxBitmap
& twTabInfo::GetImg()
83 wxString
& twTabInfo::GetText()
88 wxWindow
& twTabInfo::GetContent()
93 /***** Implementation for class wxTabbedWindow *****/
95 IMPLEMENT_DYNAMIC_CLASS( wxTabbedWindow
, wxPanel
)
97 BEGIN_EVENT_TABLE( wxTabbedWindow
, wxPanel
)
99 EVT_SIZE ( wxTabbedWindow::OnSize
)
100 EVT_PAINT( wxTabbedWindow::OnPaint
)
101 EVT_LEFT_DOWN( wxTabbedWindow::OnLButtonDown
)
103 // TDB:: filciker reduction
104 // EVT_ERASE_BACKGROUND( wxTabbedWindow::OnBkErase )
108 wxTabbedWindow::wxTabbedWindow()
110 : mpTabScroll ( NULL
),
111 mpHorizScroll( NULL
),
112 mpVertScroll ( NULL
),
120 mFirstTitleGap( 11 ),
122 mBorderOnlyWidth( 8 ),
124 mWhitePen( wxColour(255,255,255), 1, wxSOLID
),
125 mLightPen( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHIGHLIGHT
), 1, wxSOLID
),
126 mGrayPen ( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
), 1, wxSOLID
),
127 mDarkPen ( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW
), 1, wxSOLID
),
128 mBlackPen( wxColour( 0, 0, 0), 1, wxSOLID
),
134 mLayoutType( wxTITLE_IMG_AND_TEXT
)
137 wxTabbedWindow::~wxTabbedWindow()
139 wxNode
* pTab
= mTabs
.First();
143 delete ((twTabInfo
*)pTab
->Data());
149 void wxTabbedWindow::SizeTabs(int x
,int y
, int width
, int height
, bool repant
)
151 wxNode
* pTabNode
= mTabs
.First();
156 twTabInfo
& info
= *((twTabInfo
*)pTabNode
->Data());
158 if ( n
== mActiveTab
)
161 //info.mpContent->GetEventHandler()->ProcessEvent( evt );
163 info
.mpContent
->SetSize( x
, y
, width
, height
, 0 );
164 info
.mpContent
->Show(TRUE
);
165 info
.mpContent
->Refresh();
170 info
.mpContent
->Show(FALSE
);
173 pTabNode
= pTabNode
->Next();
178 void wxTabbedWindow::AddTab( wxWindow
* pContent
,
180 wxString imageFileName
,
183 twTabInfo
* pTab
= new twTabInfo();
185 pTab
->mpContent
= pContent
;
186 pTab
->mText
= tabText
;
188 if ( wxFileExists( imageFileName
) &&
190 pTab
->mBitMap
.LoadFile( imageFileName
, imageType
) )
192 pTab
->mImageFile
= imageFileName
;
193 pTab
->mImageType
= imageType
;
196 bool ok
= pTab
->mBitMap
.Ok();
198 if ( pContent
->GetParent() == NULL
)
200 pContent
->Create( this, -1 );
202 mTabs
.Append( (wxObject
*)pTab
);
209 void wxTabbedWindow::AddTab( wxWindow
* pContent
,
213 twTabInfo
* pTab
= new twTabInfo();
215 pTab
->mpContent
= pContent
;
216 pTab
->mText
= tabText
;
218 if ( pImage
) pTab
->mBitMap
= *pImage
;
220 if ( pContent
->GetParent() == NULL
)
222 pContent
->Create( this, -1 );
224 mTabs
.Append( (wxObject
*)pTab
);
233 void wxTabbedWindow::RemoveTab( int tabNo
)
235 twTabInfo
* pTab
= ((twTabInfo
*)(mTabs
.Nth( tabNo
)->Data()));
237 pTab
->mpContent
->Destroy();
241 mTabs
.DeleteNode( mTabs
.Nth( tabNo
) );
243 if ( mActiveTab
>= mTabs
.Number() );
245 mActiveTab
= mTabs
.Number() - 1;
247 SetActiveTab( mActiveTab
);
250 int wxTabbedWindow::GetTabCount()
252 return mTabs
.Number();
255 wxWindow
* wxTabbedWindow::GetTab( int tabNo
)
257 return ((twTabInfo
*)(mTabs
.Nth( tabNo
)->Data()))->mpContent
;
260 wxWindow
* wxTabbedWindow::GetActiveTab()
262 // FIMXE:: this is lame
264 return GetTab( mActiveTab
);
267 void wxTabbedWindow::SetActiveTab( int tabNo
)
276 // width of the decorations border (4 shade-lines), should not be changed
280 void wxTabbedWindow::DrawShadedRect( int x
, int y
, int width
, int height
,
281 wxPen
& upperPen
, wxPen
& lowerPen
, wxDC
& dc
284 // darw the lightened upper-left sides of the rectangle
286 dc
.SetPen( upperPen
);
287 dc
.DrawLine( x
,y
, x
, y
+ height
- 1 ); // vert
288 dc
.DrawLine( x
,y
, x
+ width
- 1, y
); // horiz
290 // draw the unenlightened lower-right sides of the rectangle
292 dc
.SetPen( lowerPen
);
293 dc
.DrawLine( x
+ width
- 1, y
, x
+ width
- 1, y
+ height
- 1 ); // vert
294 dc
.DrawLine( x
, y
+ height
- 1, x
+ width
, y
+ height
- 1 ); // horiz
297 void wxTabbedWindow::DrawDecorations( wxDC
& dc
)
299 // Protability NOTE::: DrawLine(..) draws a line from the first position,
300 // but not including the point specified by last position.
301 // This way Windows draws lines, not sure how Motif and Gtk
305 GetClientSize( &width
, &height
);
307 // check if there's at least a bit of space to draw things
309 if ( width
< mHorizGap
*2 + BORDER_SZ
*2+1 ||
310 height
< mVertGap
*2 + BORDER_SZ
*2+1 + mTitleHeight
314 // step #1 - draw border around the tab content area
316 // setup position for kind of "pencil"
317 int curX
= mHorizGap
;
320 int xSize
= width
- mHorizGap
*2;
321 int ySize
= height
- mVertGap
*2 - mTitleHeight
;
323 // layer 1 (upper white)
324 DrawShadedRect( curX
+0, curY
+0, xSize
-0, ySize
-0,
325 mLightPen
, mBlackPen
, dc
);
327 // layer 2 (upper gray)
328 DrawShadedRect( curX
+1, curY
+1, xSize
-2-1, ySize
-2-1,
329 mGrayPen
, mGrayPen
, dc
);
331 // layer 3 (upper darkGray)
332 DrawShadedRect( curX
+2, curY
+2, xSize
-3-2, ySize
-3-2,
333 mDarkPen
, mLightPen
, dc
);
335 // layer 4 (upper black)
336 DrawShadedRect( curX
+3, curY
+3, xSize
-4-3, ySize
-4-3,
337 mBlackPen
, mGrayPen
, dc
);
339 // add non-siemtric layer from the lower-right side (confroming to MFC-look)
341 dc
.SetPen( mDarkPen
);
342 dc
.DrawLine( curX
+1, curY
+ ySize
- 2, curX
+ xSize
- 1, curY
+ ySize
- 2 ); // horiz
343 dc
.DrawLine( curX
+ xSize
- 2, curY
+ 1, curX
+ xSize
- 2, curY
+ ySize
- 2 ); // vert
345 // step #2 - draw tab title bars
347 curX
= mFirstTitleGap
;
348 curY
= height
- mVertGap
- mTitleHeight
;
351 wxNode
* pNode
= mTabs
.First();
355 // "hard-coded metafile" for decorations
357 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
360 ySize
= mTitleHeight
;
362 if ( tabNo
== mActiveTab
)
364 dc
.SetPen( mGrayPen
);
365 dc
.DrawLine( curX
+1, curY
-2, curX
+xSize
-2, curY
-2 );
366 dc
.DrawLine( curX
+1, curY
-1, curX
+xSize
-2, curY
-1 );
369 dc
.SetPen( mLightPen
);
371 if ( tabNo
== mActiveTab
)
372 dc
.DrawLine( curX
, curY
-2, curX
, curY
+ySize
-2 );
374 dc
.DrawLine( curX
, curY
, curX
, curY
+ySize
-2 );
376 dc
.SetPen( mDarkPen
);
377 dc
.DrawLine( curX
+1, curY
+ySize
-3, curX
+1, curY
+ySize
-1 ); // to pix down
378 dc
.DrawLine( curX
+2, curY
+ySize
-2, curX
+xSize
-2, curY
+ySize
-2 );
379 dc
.DrawLine( curX
+xSize
-3, curY
+ySize
-3, curX
+xSize
-2, curY
+ySize
-3 );
380 if ( tabNo
== mActiveTab
)
381 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-3, curX
+xSize
-2, curY
-3 );
383 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-3, curX
+xSize
-2, curY
-1 );
385 dc
.SetPen( mBlackPen
);
386 dc
.DrawLine( curX
+xSize
-1, curY
, curX
+xSize
-1, curY
+ySize
-2 );
387 dc
.DrawLine( curX
+xSize
-2, curY
+ySize
-2, curX
+xSize
-3, curY
+ySize
-2 );
388 dc
.DrawLine( curX
+xSize
-3, curY
+ySize
-1, curX
+1, curY
+ySize
-1 );
390 pNode
= pNode
->Next();
393 // darw image and (or without) text centered within the
394 // title bar rectangle
396 if ( mLayoutType
!= wxTITLE_BORDER_ONLY
&& tab
.HasImg() )
399 tmpDc
.SelectObject( tab
.GetImg() );
401 dc
.Blit( curX
+ mTitleHorizGap
,
402 curY
+ ( ySize
- tab
.ImgHeight() ) / 2,
405 &tmpDc
, 0, 0, wxCOPY
,true
409 if ( mLayoutType
== wxTITLE_IMG_AND_TEXT
&& tab
.HasText() )
413 // set select default font of the window into it's device context
414 dc
.SetFont( GetLabelingFont() );
416 dc
.SetTextBackground( GetBackgroundColour() );
418 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
420 x
= curX
+ mTitleHorizGap
+
421 tab
.ImgWidth() + tab
.ImageToTxtGap(mImageTextGap
);
423 dc
.DrawText( tab
.GetText(), x
, curY
+ ( ySize
- h
) / 2 );
427 } // end of `while (pNode)'
430 int wxTabbedWindow::HitTest( const wxPoint
& pos
)
433 GetClientSize( &width
, &height
);
435 int curX
= mFirstTitleGap
;
436 int curY
= height
- mVertGap
- mTitleHeight
;
439 wxNode
* pNode
= mTabs
.First();
446 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
451 // hit test rectangle of the currnet tab title bar
452 if ( pos
.x
>= curX
&& pos
.x
< curX
+ tab
.mDims
.x
&&
453 pos
.y
>= curY
&& pos
.y
< curY
+ tab
.mDims
.y
461 pNode
= pNode
->Next();
468 void wxTabbedWindow::HideInactiveTabs( bool andRepaint
)
473 wxNode
* pNode
= mTabs
.First();
478 if ( tabNo
!= mActiveTab
)
480 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
481 tab
.mpContent
->Show(FALSE
);
484 pNode
= pNode
->Next();
489 wxFont
wxTabbedWindow::GetLabelingFont()
494 font
.SetFaceName("MS Sans Serif");
496 font
.SetFamily( wxDEFAULT
);
499 font
.SetStyle(wxNORMAL
);
500 font
.SetWeight(wxNORMAL
);
501 font
.SetPointSize( 8 );
504 font
.RealizeResource();
509 return wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
);
512 void wxTabbedWindow::RecalcLayout(bool andRepaint
)
514 HideInactiveTabs(andRepaint
);
516 // resetup position of the active tab
519 GetClientSize( &width
, &height
);
521 int curX
= mHorizGap
+ BORDER_SZ
;
522 int curY
= mVertGap
+ BORDER_SZ
;
524 int xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2-1;
525 int ySize
= height
- mVertGap
*2 - BORDER_SZ
*2-1 - mTitleHeight
;
527 SizeTabs( curX
, curY
, xSize
, ySize
, andRepaint
);
529 // pass #1 - try to layout assuming it's wxTITLE_IMG_AND_TEXT
531 mLayoutType
= wxTITLE_IMG_AND_TEXT
;
533 wxNode
* pNode
= mTabs
.First();
535 curX
= mFirstTitleGap
; // the left-side gap
540 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
546 // set select default font of the window into it's device context
547 dc
.SetFont( GetLabelingFont() );
549 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
551 tab
.mDims
.x
= w
+ tab
.ImageToTxtGap(mImageTextGap
) +
552 tab
.ImgWidth() + mTitleHorizGap
*2;
554 tab
.mDims
.y
= wxMax( h
, tab
.ImgHeight() ) + mTitleVertGap
*2;
555 mTitleHeight
= wxMax( mTitleHeight
, tab
.mDims
.y
);
559 pNode
= pNode
->Next();
562 curX
+= mHorizGap
; // the right-side gap
564 // make all title bars of equel height
566 pNode
= mTabs
.First();
570 ((twTabInfo
*)(pNode
->Data()))->mDims
.y
= mTitleHeight
;;
571 pNode
= pNode
->Next();
574 // if curX has'nt ran out of bounds, leave TITLE_IMG layout and return
575 if ( curX
< width
- mHorizGap
)
578 // pass #2 - try to layout assuming wxTITLE_IMG_ONLY
580 mLayoutType
= wxTITLE_IMG_ONLY
;
582 pNode
= mTabs
.First();
584 curX
= mFirstTitleGap
; // the left-side gap
586 int denomiator
= mTabs
.Number();
587 if ( denomiator
== 0 ) ++denomiator
;
589 mBorderOnlyWidth
= (width
- mFirstTitleGap
- mHorizGap
) / denomiator
;
593 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
597 tab
.mDims
.x
= tab
.ImgWidth() + mTitleHorizGap
*2;
598 tab
.mDims
.y
= tab
.ImgHeight() + mTitleVertGap
*2;
602 tab
.mDims
.x
= mBorderOnlyWidth
;
603 tab
.mDims
.y
= mTitleHeight
;
608 pNode
= pNode
->Next();
611 curX
+= mHorizGap
; // the right-side gap
613 // if curX has'nt ran out of bounds, leave IMG_ONLY layout and return
614 if ( curX
< width
- mHorizGap
)
617 // pass #3 - set the narrowest layout wxTITLE_BORDER_ONLY
619 mLayoutType
= wxTITLE_BORDER_ONLY
;
621 pNode
= mTabs
.First();
625 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
627 tab
.mDims
.x
= mBorderOnlyWidth
;
628 tab
.mDims
.y
= mTitleHeight
;
630 pNode
= pNode
->Next();
636 void wxTabbedWindow::OnPaint( wxPaintEvent
& event
)
639 DrawDecorations( dc
);
642 void wxTabbedWindow::OnSize ( wxSizeEvent
& event
)
644 SetBackgroundColour( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
) );
648 void wxTabbedWindow::OnBkErase( wxEraseEvent
& event
)
653 void wxTabbedWindow::OnLButtonDown( wxMouseEvent
& event
)
656 int x
= (int)event
.m_x
;
657 int y
= (int)event
.m_y
;
659 int tabNo
= HitTest( wxPoint(x
,y
) );
663 SetActiveTab( tabNo
);
667 /***** Implementation for class wxPaggedWindow *****/
669 IMPLEMENT_DYNAMIC_CLASS( wxPaggedWindow
, wxTabbedWindow
)
671 BEGIN_EVENT_TABLE( wxPaggedWindow
, wxTabbedWindow
)
672 EVT_SIZE ( wxPaggedWindow::OnSize
)
673 EVT_PAINT ( wxPaggedWindow::OnPaint
)
674 EVT_LEFT_DOWN( wxPaggedWindow::OnLButtonDown
)
675 EVT_LEFT_UP ( wxPaggedWindow::OnLButtonUp
)
676 EVT_MOTION ( wxPaggedWindow::OnMouseMove
)
677 EVT_SCROLL ( wxPaggedWindow::OnScroll
)
680 // border for pagged-window is 2 shaded-lines
685 wxPaggedWindow::wxPaggedWindow()
687 : mScrollEventInProgress( FALSE
),
691 mWhiteBrush( wxColour(255,255,255), wxSOLID
),
692 mGrayBrush ( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
), wxSOLID
),
695 mAdjustableTitleRowLen( 300 ),
697 mIsDragged ( FALSE
),
699 mCursorChanged( FALSE
),
700 mResizeCursor ( wxCURSOR_SIZEWE
),
701 mNormalCursor ( wxCURSOR_ARROW
)
707 wxPaggedWindow::~wxPaggedWindow()
709 // nothing (base class handles destruction)
712 wxFont
wxPaggedWindow::GetLabelingFont()
718 font
.SetFaceName("Arial");
720 font
.SetFamily( wxDEFAULT
);
723 font
.SetStyle(wxNORMAL
);
724 font
.SetWeight(wxNORMAL
);
725 font
.SetPointSize( 8 );
728 bool success
= font
.RealizeResource();
733 return wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
);
736 void wxPaggedWindow::OnTabAdded( twTabInfo
* pInfo
)
738 int units
= GetWholeTabRowLen() / 20;
740 mpTabScroll
->SetScrollbar( 0, 1, units
, 1, FALSE
);
743 wxScrollBar
& wxPaggedWindow::GetVerticalScrollBar()
745 return *mpVertScroll
;
748 wxScrollBar
& wxPaggedWindow::GetHorizontalScrollBar()
750 return *mpHorizScroll
;
754 int wxPaggedWindow::GetWholeTabRowLen()
756 wxNode
* pNode
= mTabs
.First();
762 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
765 pNode
= pNode
->Next();
771 void wxPaggedWindow::DrawPaperBar( twTabInfo
& tab
, int x
, int y
,
772 wxBrush
& brush
, wxPen
& pen
, wxDC
& dc
)
776 // draw organizer-style paper outlet
778 poly
[0].x
= x
- mTabTrianGap
;
781 poly
[1].x
= x
+ mTabTrianGap
;
782 poly
[1].y
= y
+ tab
.mDims
.y
-1;
784 poly
[2].x
= x
+ tab
.mDims
.x
- mTabTrianGap
;
785 poly
[2].y
= y
+ tab
.mDims
.y
-1;
787 poly
[3].x
= x
+ tab
.mDims
.x
+ mTabTrianGap
;
791 dc
.SetBrush( brush
);
793 dc
.DrawPolygon( 4, poly
);
797 // set select default font of the window into it's device context
798 dc
.SetFont( GetLabelingFont() );
800 dc
.SetTextBackground( brush
.GetColour() );
802 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
807 tmpDc
.SelectObject( tab
.GetImg() );
809 dc
.Blit( x
+ mTitleHorizGap
,
810 y
+ ( tab
.mDims
.y
- tab
.ImgHeight() ) / 2,
813 &tmpDc
, 0, 0, wxCOPY
,true
819 int tx
= x
+ mTitleHorizGap
+
820 tab
.ImgWidth() + tab
.ImageToTxtGap(mImageTextGap
);
822 dc
.DrawText( tab
.GetText(), tx
, y
+ ( tab
.mDims
.y
- h
) / 2 );
826 void wxPaggedWindow::DrawDecorations( wxDC
& dc
)
828 // FIXME:: the is big body have to be split!
831 GetClientSize( &width
, &height
);
833 int curX
= mHorizGap
;
836 int xSize
= width
- mHorizGap
*2;
837 int ySize
= height
- mVertGap
*2;
839 DrawShadedRect( curX
, curY
, xSize
, ySize
,
840 mDarkPen
, mLightPen
, dc
);
842 DrawShadedRect( curX
+1, curY
+1, xSize
-2, ySize
-2,
843 mBlackPen
, mGrayPen
, dc
);
845 // draw inactive tab title bars frist (left-to-right)
847 wxNode
* pNode
= mTabs
.First();
851 curX = mTitleRowStart;
852 curY = height - mVertGap - BORDER_SZ - mTitleHeight;
858 // FOR NOW:: avoid creating bitmap with invalid dimensions
860 if ( mTitleRowLen
< 1 || mTitleHeight
< 1 ) return;
863 wxBitmap
tmpBmp( mTitleRowLen
, mTitleHeight
);
865 tmpDc
.SelectObject( tmpBmp
);
866 tmpDc
.SetPen( mGrayPen
);
867 tmpDc
.SetBrush( mGrayBrush
);
868 tmpDc
.DrawRectangle( 0,0, mTitleRowLen
, mTitleHeight
);
870 tmpDc
.SetDeviceOrigin( mCurentRowOfs
, 0 );
874 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
876 if ( tabNo
!= mActiveTab
)
878 DrawPaperBar( tab
, curX
, curY
, mGrayBrush
, mBlackPen
, tmpDc
);
882 pNode
= pNode
->Next();
886 // finally, draw the active tab (white-filled)
888 pNode
= mTabs
.First();
895 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
897 if ( tabNo
== mActiveTab
)
899 DrawPaperBar( tab
, curX
, curY
, mWhiteBrush
, mBlackPen
, tmpDc
);
901 tmpDc
.SetPen( mLightPen
);
903 tmpDc
.DrawLine( curX
- mTabTrianGap
+1, curY
,
904 curX
+ tab
.mDims
.x
+ mTabTrianGap
, curY
);
909 pNode
= pNode
->Next();
913 // back to initial device origin
915 tmpDc
.SetDeviceOrigin( 0, 0 );
917 // draw resize-hint-stick
919 curX
= mTitleRowLen
- 6;
921 DrawShadedRect( curX
+0, 0+0, 6, mTitleHeight
, mGrayPen
, mBlackPen
, tmpDc
);
922 DrawShadedRect( curX
+1, 0+1, 6-2, mTitleHeight
-2, mLightPen
, mDarkPen
, tmpDc
);
923 DrawShadedRect( curX
+2, 0+2, 6-4, mTitleHeight
-4, mGrayPen
, mGrayPen
, tmpDc
);
927 dc
.Blit( mTitleRowStart
,
928 height
- mVertGap
- BORDER_SZ
- mTitleHeight
,
929 mTitleRowLen
, mTitleHeight
,
930 &tmpDc
, 0,0, wxCOPY
);
933 int wxPaggedWindow::HitTest( const wxPoint
& pos
)
935 return wxTabbedWindow::HitTest( pos
);
938 void wxPaggedWindow::RecalcLayout(bool andRepaint
)
940 mTitleRowLen
= mAdjustableTitleRowLen
;
942 if ( int(mpTabScroll
) == -1 ) return;
944 // scroll bars should be created after Create() for this window is called
948 new wxScrollBar( this, -1, wxDefaultPosition
, wxDefaultSize
, wxSB_HORIZONTAL
);
951 new wxScrollBar( this, -1, wxDefaultPosition
, wxDefaultSize
, wxSB_HORIZONTAL
);
954 new wxScrollBar( this, -1, wxDefaultPosition
, wxDefaultSize
, wxSB_VERTICAL
);
958 int units
= GetWholeTabRowLen() / 20;
960 mpTabScroll
->SetScrollbar( 0, 1, units
, 1, FALSE
);
963 // resetup position of the active tab
965 int thumbLen
= 16; // FOR NOW:: hardcoded
968 GetClientSize( &width
, &height
);
970 mTitleHeight
= thumbLen
;
972 int curX
= mHorizGap
+ BORDER_SZ
;
973 int curY
= mVertGap
+ BORDER_SZ
;
975 int xSize
= width
- mHorizGap
*2 - BORDER_SZ
*2 - thumbLen
;
977 int ySize
= height
- mVertGap
*2 - BORDER_SZ
*2 - mTitleHeight
;
979 SizeTabs( curX
, curY
, xSize
, ySize
, andRepaint
);
981 // setup title bar LINES's horizontal scroll bar
983 curY
= height
- mVertGap
- BORDER_SZ
- thumbLen
;
985 mpTabScroll
->SetSize( curX
, curY
, thumbLen
*2, thumbLen
);
987 // setup view's HORIZONTAL scroll bar
991 mTitleRowStart
= curX
;
992 mFirstTitleGap
= curX
+ mCurentRowOfs
+ mTabTrianGap
;
994 mTitleRowLen
= wxMin( mAdjustableTitleRowLen
,
995 width
- mHorizGap
- BORDER_SZ
- thumbLen
*4 - curX
);
997 curX
+= mTitleRowLen
;
999 mpHorizScroll
->SetSize( curX
, curY
,
1000 width
- curX
- mHorizGap
- BORDER_SZ
- thumbLen
,
1004 // setup view's VERTICAL scroll bar
1006 curX
= width
- mHorizGap
- BORDER_SZ
- thumbLen
;
1008 curY
= mVertGap
+ BORDER_SZ
;
1010 mpVertScroll
->SetSize( curX
, curY
, thumbLen
,
1011 height
- curY
- mVertGap
- BORDER_SZ
- thumbLen
1014 // layout tab title bars
1016 mLayoutType
= wxTITLE_IMG_AND_TEXT
;
1018 wxNode
* pNode
= mTabs
.First();
1022 twTabInfo
& tab
= *((twTabInfo
*)(pNode
->Data()));
1024 wxWindowDC
dc(this);
1028 // set select default font of the window into it's device context
1029 dc
.SetFont( GetLabelingFont() );
1030 dc
.GetTextExtent(tab
.mText
, &w
, &h
);
1032 tab
.mDims
.x
= w
+ tab
.ImageToTxtGap(mImageTextGap
) +
1033 tab
.ImgWidth() + mTitleHorizGap
*2;
1035 tab
.mDims
.y
= mTitleHeight
;
1037 pNode
= pNode
->Next();
1040 // disable title-bar scroller if there's nowhere to scroll to
1042 mpTabScroll
->Enable( mTitleRowLen
< GetWholeTabRowLen() || mCurentRowOfs
< 0 );
1047 void wxPaggedWindow::OnPaint( wxPaintEvent
& event
)
1050 DrawDecorations( dc
);
1053 void wxPaggedWindow::OnSize ( wxSizeEvent
& event
)
1055 wxTabbedWindow::OnSize(event
);
1058 void wxPaggedWindow::OnLButtonDown( wxMouseEvent
& event
)
1060 if ( mCursorChanged
)
1063 mDagOrigin
= event
.m_x
;
1065 mOriginalTitleRowLen
= mAdjustableTitleRowLen
;
1071 wxTabbedWindow::OnLButtonDown( event
);
1075 void wxPaggedWindow::OnLButtonUp( wxMouseEvent
& event
)
1080 mCursorChanged
= FALSE
;
1081 SetCursor( mNormalCursor
);
1087 void wxPaggedWindow::OnMouseMove( wxMouseEvent
& event
)
1090 GetClientSize( &width
, &height
);
1094 int y
= height
- mVertGap
- BORDER_SZ
- mTitleHeight
;
1095 int x
= mTitleRowStart
+ mTitleRowLen
- 6;
1097 if ( event
.m_x
>= x
&& event
.m_y
>= y
&&
1098 event
.m_x
< x
+ 6 &&
1099 event
.m_y
< y
+ mTitleHeight
1102 if ( !mCursorChanged
)
1104 SetCursor( mResizeCursor
);
1106 mCursorChanged
= TRUE
;
1110 if ( mCursorChanged
)
1112 SetCursor( mNormalCursor
);
1114 mCursorChanged
= FALSE
;
1120 mAdjustableTitleRowLen
= mOriginalTitleRowLen
+ ( event
.m_x
- mDagOrigin
);
1123 if ( mAdjustableTitleRowLen
< 6 ) mAdjustableTitleRowLen
= 6;
1125 wxWindowDC
dc(this);
1126 DrawDecorations( dc
);
1128 RecalcLayout(FALSE
);
1134 void wxPaggedWindow::OnScroll( wxScrollEvent
& event
)
1136 int cmd
= event
.m_commandInt
;
1138 wxScrollBar
* pSender
= (wxScrollBar
*)event
.GetEventObject();
1140 if ( pSender
== mpTabScroll
)
1142 int maxLen
= GetWholeTabRowLen();
1144 int maxUnits
= GetWholeTabRowLen() / 20;
1146 mCurentRowOfs
= -event
.GetPosition()*maxUnits
;
1148 mFirstTitleGap
= mTitleRowStart
+ mCurentRowOfs
+ mTabTrianGap
;
1150 // let' it automatically disable itself if it's time
1151 mpTabScroll
->Enable( mTitleRowLen
< GetWholeTabRowLen() || mCurentRowOfs
< 0 );
1153 // repaint title bars
1154 wxWindowDC
dc(this);
1155 DrawDecorations( dc
);
1158 if ( !mScrollEventInProgress
)
1160 mScrollEventInProgress
= TRUE
;
1162 GetActiveTab()->GetEventHandler()->ProcessEvent( event
);
1166 // event bounced back to us, from here we
1167 // know that it has traveled the loop - thus it's processed!
1169 mScrollEventInProgress
= FALSE
;