]>
git.saurik.com Git - wxWidgets.git/blob - src/common/dlgcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/dlgcmn.cpp
3 // Purpose: common (to all ports) wxDialog functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "dialogbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/button.h"
33 #include "wx/dialog.h"
34 #include "wx/dcclient.h"
36 #include "wx/settings.h"
37 #include "wx/stattext.h"
39 #include "wx/button.h"
40 #include "wx/containr.h"
44 //--------------------------------------------------------------------------
46 //--------------------------------------------------------------------------
48 // FIXME - temporary hack in absence of wxtopLevelWindow, should be always used
49 #ifdef wxTopLevelWindowNative
50 BEGIN_EVENT_TABLE(wxDialogBase
, wxTopLevelWindow
)
51 WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase
)
54 WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase
)
57 void wxDialogBase::Init()
60 #ifdef wxTopLevelWindowNative // FIXME - temporary hack, should be always used!
61 m_container
.SetContainerWindow(this);
65 #if wxUSE_STATTEXT && wxUSE_TEXTCTRL
67 wxSizer
*wxDialogBase::CreateTextSizer( const wxString
&message
)
69 wxBoxSizer
*box
= new wxBoxSizer( wxVERTICAL
);
71 // get line height for empty lines
73 wxFont
font( GetFont() );
76 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
79 for (size_t pos
= 0; pos
< message
.Len(); pos
++)
81 if (message
[pos
] == wxT('\n'))
85 wxStaticText
*s1
= new wxStaticText( this, -1, line
);
100 // remaining text behind last '\n'
103 wxStaticText
*s2
= new wxStaticText( this, -1, line
);
110 #endif // wxUSE_STATTEXT && wxUSE_TEXTCTRL
114 wxSizer
*wxDialogBase::CreateButtonSizer( long flags
)
116 wxBoxSizer
*box
= new wxBoxSizer( wxHORIZONTAL
);
118 #if defined(__WXMSW__) || defined(__WXMAC__)
119 static const int margin
= 6;
121 static const int margin
= 10;
124 wxButton
*ok
= (wxButton
*) NULL
;
125 wxButton
*cancel
= (wxButton
*) NULL
;
126 wxButton
*yes
= (wxButton
*) NULL
;
127 wxButton
*no
= (wxButton
*) NULL
;
129 // always show an OK button, unless only YES_NO is given
130 if ((flags
& wxYES_NO
) == 0) flags
= flags
| wxOK
;
132 if (flags
& wxYES_NO
)
134 yes
= new wxButton( this, wxID_YES
, _("Yes"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
);
135 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
136 no
= new wxButton( this, wxID_NO
, _("No") ,wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
);
137 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
141 yes
= new wxButton( this, wxID_YES
, _("Yes"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
);
142 box
->Add( yes
, 0, wxLEFT
|wxRIGHT
, margin
);
146 no
= new wxButton( this, wxID_NO
, _("No"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
);
147 box
->Add( no
, 0, wxLEFT
|wxRIGHT
, margin
);
152 ok
= new wxButton( this, wxID_OK
, _("OK"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
);
153 box
->Add( ok
, 0, wxLEFT
|wxRIGHT
, margin
);
156 if (flags
& wxFORWARD
)
157 box
->Add( new wxButton( this, wxID_FORWARD
, _("Forward"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
), 0, wxLEFT
|wxRIGHT
, margin
);
159 if (flags
& wxBACKWARD
)
160 box
->Add( new wxButton( this, wxID_BACKWARD
, _("Backward"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
), 0, wxLEFT
|wxRIGHT
, margin
);
163 box
->Add( new wxButton( this, wxID_SETUP
, _("Setup"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
), 0, wxLEFT
|wxRIGHT
, margin
);
166 box
->Add( new wxButton( this, wxID_MORE
, _("More..."),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
), 0, wxLEFT
|wxRIGHT
, margin
);
169 box
->Add( new wxButton( this, wxID_HELP
, _("Help"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
), 0, wxLEFT
|wxRIGHT
, margin
);
171 if (flags
& wxCANCEL
)
173 cancel
= new wxButton( this, wxID_CANCEL
, _("Cancel"),wxDefaultPosition
,wxDefaultSize
,wxCLIP_SIBLINGS
);
174 box
->Add( cancel
, 0, wxLEFT
|wxRIGHT
, margin
);
177 if (flags
& wxNO_DEFAULT
)
202 #endif // wxUSE_BUTTON