]> git.saurik.com Git - wxWidgets.git/blob - src/mac/stattext.cpp
Whole lotta stuff for wxPlotWindow,
[wxWidgets.git] / src / mac / stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stattext.cpp
3 // Purpose: wxStaticText
4 // Author: AUTHOR
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "stattext.h"
14 #endif
15
16 #include "wx/app.h"
17 #include "wx/stattext.h"
18
19 #include <stdio.h>
20
21 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
22
23 #include <wx/mac/uma.h>
24
25 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
26 EVT_PAINT(wxStaticText::OnPaint)
27 END_EVENT_TABLE()
28
29 bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
30 const wxString& label,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style,
34 const wxString& name)
35 {
36 SetName(name);
37 m_backgroundColour = parent->GetBackgroundColour() ;
38 m_foregroundColour = parent->GetForegroundColour() ;
39
40 if ( id == -1 )
41 m_windowId = (int)NewControlId();
42 else
43 m_windowId = id;
44
45 m_windowStyle = style;
46 m_label = label ;
47
48 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
49 SetSizeOrDefault( size ) ;
50
51 return ret;
52 }
53
54 void wxStaticText::OnPaint( wxPaintEvent &event )
55 {
56 wxPaintDC dc(this);
57 PrepareDC(dc);
58 dc.Clear() ;
59 dc.DrawText( m_label , 0 , 0 ) ;
60 }
61
62 wxSize wxStaticText::DoGetBestSize() const
63 {
64 int x , y ;
65 GetTextExtent( m_label , &x , &y ) ;
66 return wxSize( x , y ) ;
67 }
68
69 void wxStaticText::SetLabel(const wxString& st , bool resize )
70 {
71 SetTitle( st ) ;
72 m_label = st ;
73 if ( resize )
74 SetSizeOrDefault() ;
75 else
76 Refresh() ;
77 }
78 /*
79 void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags)
80 {
81 wxControl::SetSize( x , y , width , height , sizeFlags ) ;
82 }
83
84 bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
85 const wxString& label,
86 const wxPoint& pos,
87 const wxSize& size,
88 long style,
89 const wxString& name)
90 {
91 Rect bounds ;
92 Str255 title ;
93
94 MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ;
95
96 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
97 kControlStaticTextProc , (long) this ) ;
98 ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) title[0] , (char*) &title[1] ) ;
99
100 MacPostControlCreate() ;
101
102 return TRUE;
103 }
104
105 void wxStaticText::SetLabel(const wxString& st , bool resize )
106 {
107 SetTitle( st ) ;
108 wxString label ;
109
110 if( wxApp::s_macDefaultEncodingIsPC )
111 label = wxMacMakeMacStringFromPC( st ) ;
112 else
113 label = st ;
114
115 ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ;
116 Refresh() ;
117 }
118 */
119