Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gdi.cpp

Go to the documentation of this file.
00001 
00002 // Name:        gdi.cpp
00003 // Purpose:     wxGdi implementation.
00004 // Author:      Mark McCormack
00005 // Modified by:
00006 // Created:     03/06/04
00007 // RCS-ID:      $Id: gdi.cpp,v 1.6 2005/05/12 14:04:48 frm Exp $
00008 // Copyright:   (c) 2004 Mark McCormack
00009 // Licence:     wxWindows license
00011 
00012 #include <wx/gdi.h>
00013 #include <wx/settings.h>
00014 
00015 const int HEADER_TEXT_INDENT = 4;
00016 
00017 void wxGdiBase::DrawClose( wxDC &dc, wxRect r, wxPen &pen, int size ) {
00018     // draw close image
00019     dc.SetPen( pen );
00020     int dx = (r.width/2)-(size/2);
00021     int dy = (r.height/2)-(size/2);
00022     r.Offset( dx, dy );
00023     r.SetWidth( size-1 );
00024     r.SetHeight( size-1 );
00025     dc.DrawLine( r.GetLeft(), r.GetTop(), r.GetRight(), r.GetBottom() );
00026     dc.DrawLine( r.GetLeft() + 1, r.GetTop(), r.GetRight() + 1, r.GetBottom() );
00027     dc.DrawLine( r.GetLeft(), r.GetBottom() - 1, r.GetRight(), r.GetTop() - 1 );
00028     dc.DrawLine( r.GetLeft() + 1, r.GetBottom() - 1, r.GetRight() + 1, r.GetTop() - 1 );
00029 }
00030 
00031 void wxGdiBase::DrawBackground( wxDC &dc, wxRect &r ) {
00032     // draw background for a window
00033     wxColour back = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
00034     wxBrush brush( back, wxSOLID );
00035     dc.SetBrush( brush );
00036     wxPen pen( back, 1, wxSOLID );
00037     dc.SetPen( pen );
00038     dc.DrawRectangle( r.x, r.y, r.width, r.height );
00039 }
00040 
00041 void wxGdiBase::DrawLabel( wxDC &dc, wxRect r, wxOrientation orientation, const wxString &label, const wxFont &font ) {
00042     // draw text label
00043     dc.SetFont( font );
00044     wxCoord w = 0, h = 0;
00045     dc.GetTextExtent( label, &w, &h );
00046     if( orientation == wxHORIZONTAL ) { 
00047         // horizontal text
00048         r.y += (r.height - h)/2;
00049         r.x += HEADER_TEXT_INDENT;
00050         dc.DrawText( label, r.x, r.y );
00051     }
00052     else {
00053         // vertical text
00054         r.x += (r.width - h)/2;
00055         r.y += r.height - HEADER_TEXT_INDENT;
00056         dc.DrawRotatedText( label, r.x, r.y, 90 );
00057     }
00058 }
00059 
00060 void wxGdiBase::DrawEdge( wxDC &dc, wxRect r, bool invert ) {
00061     // draw a raised/sunken 3D edge
00062     wxColour light = wxSystemSettings::GetColour( wxSYS_COLOUR_3DHIGHLIGHT );
00063     wxColour shadow = wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW );
00064     wxColour back = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
00065     if( invert ) {
00066         light = wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW );
00067         shadow = wxSystemSettings::GetColour( wxSYS_COLOUR_3DHIGHLIGHT );
00068     }
00069     
00070 #ifdef wxUSE_WX24
00071     wxBrush backBrush( back, wxSOLID );  
00072 #else
00073     wxBrush backBrush( back );  
00074 #endif
00075     dc.SetBrush( backBrush );
00076     
00077 #ifdef wxUSE_WX24
00078     wxPen lightPen( light, 1, wxSOLID );
00079 #else
00080     wxPen lightPen( light );
00081 #endif
00082     dc.SetPen( lightPen );
00083     dc.DrawLine( r.GetLeft(), r.GetTop(), r.GetRight(), r.GetTop() );
00084     dc.DrawLine( r.GetLeft(), r.GetTop(), r.GetLeft(), r.GetBottom() );
00085 
00086 #ifdef wxUSE_WX24
00087     wxPen shadowPen( shadow, 1, wxSOLID );
00088 #else
00089     wxPen shadowPen( shadow );
00090 #endif
00091     dc.SetPen( shadowPen );
00092     dc.DrawLine( r.GetLeft(), r.GetBottom(), r.GetRight() + 1, r.GetBottom() );
00093     dc.DrawLine( r.GetRight(), r.GetTop(), r.GetRight(), r.GetBottom() + 1 );
00094 }

Generated on Sat May 14 14:54:39 2005 for wxDockIt by  doxygen 1.4.2