]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/statbox.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        msw/statbox.cpp 
   3 // Purpose:     wxStaticBox 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  21     #pragma implementation "statbox.h" 
  24 // For compilers that support precompilation, includes "wx.h". 
  25 #include "wx/wxprec.h" 
  35     #include "wx/dcclient.h" 
  38 #include "wx/statbox.h" 
  39 #include "wx/notebook.h" 
  40 #include "wx/sysopt.h" 
  42 #include "wx/msw/private.h" 
  44 // under CE this style is not defined but we don't need to make static boxes 
  45 // transparent there neither 
  46 #ifndef WS_EX_TRANSPARENT 
  47     #define WS_EX_TRANSPARENT 0 
  50 // ---------------------------------------------------------------------------- 
  52 // ---------------------------------------------------------------------------- 
  54 #if wxUSE_EXTENDED_RTTI 
  55 WX_DEFINE_FLAGS( wxStaticBoxStyle 
) 
  57 wxBEGIN_FLAGS( wxStaticBoxStyle 
) 
  58     // new style border flags, we put them first to 
  59     // use them for streaming out 
  60     wxFLAGS_MEMBER(wxBORDER_SIMPLE
) 
  61     wxFLAGS_MEMBER(wxBORDER_SUNKEN
) 
  62     wxFLAGS_MEMBER(wxBORDER_DOUBLE
) 
  63     wxFLAGS_MEMBER(wxBORDER_RAISED
) 
  64     wxFLAGS_MEMBER(wxBORDER_STATIC
) 
  65     wxFLAGS_MEMBER(wxBORDER_NONE
) 
  67     // old style border flags 
  68     wxFLAGS_MEMBER(wxSIMPLE_BORDER
) 
  69     wxFLAGS_MEMBER(wxSUNKEN_BORDER
) 
  70     wxFLAGS_MEMBER(wxDOUBLE_BORDER
) 
  71     wxFLAGS_MEMBER(wxRAISED_BORDER
) 
  72     wxFLAGS_MEMBER(wxSTATIC_BORDER
) 
  73     wxFLAGS_MEMBER(wxBORDER
) 
  75     // standard window styles 
  76     wxFLAGS_MEMBER(wxTAB_TRAVERSAL
) 
  77     wxFLAGS_MEMBER(wxCLIP_CHILDREN
) 
  78     wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
) 
  79     wxFLAGS_MEMBER(wxWANTS_CHARS
) 
  80     wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
) 
  81     wxFLAGS_MEMBER(wxALWAYS_SHOW_SB 
) 
  82     wxFLAGS_MEMBER(wxVSCROLL
) 
  83     wxFLAGS_MEMBER(wxHSCROLL
) 
  85 wxEND_FLAGS( wxStaticBoxStyle 
) 
  87 IMPLEMENT_DYNAMIC_CLASS_XTI(wxStaticBox
, wxControl
,"wx/statbox.h") 
  89 wxBEGIN_PROPERTIES_TABLE(wxStaticBox
) 
  90     wxPROPERTY( Label
,wxString
, SetLabel
, GetLabel
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) 
  91     wxPROPERTY_FLAGS( WindowStyle 
, wxStaticBoxStyle 
, long , SetWindowStyleFlag 
, GetWindowStyleFlag 
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style 
  96 wxEND_PROPERTIES_TABLE() 
  98 wxBEGIN_HANDLERS_TABLE(wxStaticBox
) 
  99 wxEND_HANDLERS_TABLE() 
 101 wxCONSTRUCTOR_6( wxStaticBox 
, wxWindow
* , Parent 
, wxWindowID 
, Id 
, wxString 
, Label 
, wxPoint 
, Position 
, wxSize 
, Size 
, long , WindowStyle 
) 
 103 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
) 
 106 // ============================================================================ 
 108 // ============================================================================ 
 110 // ---------------------------------------------------------------------------- 
 112 // ---------------------------------------------------------------------------- 
 114 bool wxStaticBox::Create(wxWindow 
*parent
, 
 116                          const wxString
& label
, 
 120                          const wxString
& name
) 
 122     if ( !CreateControl(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) ) 
 125     if ( !MSWCreateControl(wxT("BUTTON"), label
, pos
, size
) ) 
 131 WXDWORD 
wxStaticBox::MSWGetStyle(long style
, WXDWORD 
*exstyle
) const 
 133     long styleWin 
= wxStaticBoxBase::MSWGetStyle(style
, exstyle
); 
 136         *exstyle 
= WS_EX_TRANSPARENT
; 
 138     return styleWin 
| BS_GROUPBOX
; 
 141 wxSize 
wxStaticBox::DoGetBestSize() const 
 144     wxGetCharSize(GetHWND(), &cx
, &cy
, GetFont()); 
 147     GetTextExtent(wxGetWindowText(m_hWnd
), &wBox
, &cy
); 
 150     int hBox 
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
); 
 152     return wxSize(wBox
, hBox
); 
 155 WXLRESULT 
wxStaticBox::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
) 
 158     if ( nMsg 
== WM_NCHITTEST 
) 
 160         // This code breaks some other processing such as enter/leave tracking 
 161         // so it's off by default. 
 163         static int s_useHTClient 
= -1; 
 164         if (s_useHTClient 
== -1) 
 165             s_useHTClient 
= wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient")); 
 166         if (s_useHTClient 
== 1) 
 168             int xPos 
= LOWORD(lParam
);  // horizontal position of cursor 
 169             int yPos 
= HIWORD(lParam
);  // vertical position of cursor 
 171             ScreenToClient(&xPos
, &yPos
); 
 173             // Make sure you can drag by the top of the groupbox, but let 
 174             // other (enclosed) controls get mouse events also 
 176                 return (long)HTCLIENT
; 
 179 #endif // !__WXWINCE__ 
 181     return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
); 
 184 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const 
 186     wxStaticBoxBase::GetBordersForSizer(borderTop
, borderOther
); 
 188     // if not using correct (but backwards cojmpatible) text metrics 
 189     // calculations, we need to add some extra margin or otherwise static box 
 191 #if !wxDIALOG_UNIT_COMPATIBILITY 
 192     if ( !GetLabel().empty() ) 
 193         *borderTop 
+= GetCharHeight()/3; 
 194 #endif // !wxDIALOG_UNIT_COMPATIBILITY 
 197 #endif // wxUSE_STATBOX