~mapopa/flamerobin/master

« back to all changes in this revision

Viewing changes to src/MultilineEnterDialog.cpp

  • Committer: Michael Hieke
  • Date: 2004-11-22 11:34:42 UTC
  • Revision ID: git-v1:8153b493d66ee7aae55e7b34e0d7bddacf4999ef
Initial revision

svn path=/trunk/flamerobin/; revision=13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  The contents of this file are subject to the Initial Developer's Public
 
3
  License Version 1.0 (the "License"); you may not use this file except in
 
4
  compliance with the License. You may obtain a copy of the License here:
 
5
  http://www.flamerobin.org/license.html.
 
6
 
 
7
  Software distributed under the License is distributed on an "AS IS"
 
8
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 
9
  License for the specific language governing rights and limitations under
 
10
  the License.
 
11
 
 
12
  The Original Code is FlameRobin (TM).
 
13
 
 
14
  The Initial Developer of the Original Code is Milan Babuskov.
 
15
 
 
16
  Portions created by the original developer
 
17
  are Copyright (C) 2004 Milan Babuskov.
 
18
 
 
19
  All Rights Reserved.
 
20
 
 
21
  $Id$
 
22
 
 
23
  Contributor(s): Michael Hieke, Nando Dessena
 
24
*/
 
25
 
 
26
// For compilers that support precompilation, includes "wx/wx.h".
 
27
#include "wx/wxprec.h"
 
28
 
 
29
#ifdef __BORLANDC__
 
30
    #pragma hdrstop
 
31
#endif
 
32
 
 
33
// for all others, include the necessary headers (this file is usually all you
 
34
// need because it includes almost all "standard" wxWindows headers
 
35
#ifndef WX_PRECOMP
 
36
    #include "wx/wx.h"
 
37
#endif
 
38
//-----------------------------------------------------------------------------
 
39
// -*- C++ -*- generated by wxGlade 0.2.2 on Fri Aug 27 10:36:29 2004
 
40
 
 
41
#include <string>
 
42
#include "MultilineEnterDialog.h"
 
43
#include "styleguide.h"
 
44
//-----------------------------------------------------------------------------
 
45
bool GetMultilineTextFromUser(const wxString& caption, wxString& default_value, wxWindow *parent)
 
46
{
 
47
        wxString result(default_value);
 
48
        MultilineEnterDialog med(parent, caption, &result);
 
49
        if (wxOK == med.ShowModal())
 
50
        {
 
51
                default_value = result;
 
52
                return true;
 
53
        }
 
54
 
 
55
        return false;
 
56
}
 
57
//-----------------------------------------------------------------------------
 
58
BEGIN_EVENT_TABLE(MultilineEnterDialog, BaseDialog)
 
59
    EVT_BUTTON(MultilineEnterDialog::ID_button_ok, MultilineEnterDialog::OnOkButtonClick)
 
60
END_EVENT_TABLE()
 
61
//-----------------------------------------------------------------------------
 
62
void MultilineEnterDialog::OnOkButtonClick(wxCommandEvent& WXUNUSED(event))
 
63
{
 
64
        *value = text_ctrl_1->GetValue();
 
65
        EndModal(wxOK);
 
66
}
 
67
//-----------------------------------------------------------------------------
 
68
//void MultilineEnterDialog::OnCancelButtonClick(wxCommandEvent& WXUNUSED(event))
 
69
//-----------------------------------------------------------------------------
 
70
MultilineEnterDialog::MultilineEnterDialog(wxWindow* parent, const wxString& title, wxString* initialText):
 
71
    BaseDialog(parent, -1, title)
 
72
{
 
73
    value = initialText;
 
74
    text_ctrl_1 = new wxTextCtrl(this, -1, *initialText, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
 
75
    button_ok = new wxButton(this, ID_button_ok, _("OK"));
 
76
    button_cancel = new wxButton(this, ID_button_cancel, _("Cancel"));
 
77
    do_layout();
 
78
    button_ok->SetDefault();
 
79
}
 
80
//-----------------------------------------------------------------------------
 
81
void MultilineEnterDialog::do_layout()
 
82
{
 
83
        wxBoxSizer* sizerControls = new wxBoxSizer(wxHORIZONTAL);
 
84
        text_ctrl_1->SetSizeHints(300, 150);
 
85
        text_ctrl_1->SetSize(300, 150);
 
86
        sizerControls->Add(text_ctrl_1, 1, wxEXPAND);
 
87
        wxSizer* sizerButtons = styleguide().createButtonSizer(button_ok, button_cancel);
 
88
        layoutSizers(sizerControls, sizerButtons, true);
 
89
}
 
90
//-----------------------------------------------------------------------------
 
91
const std::string MultilineEnterDialog::getName() const
 
92
{
 
93
    return "MultilineEnterDialog";
 
94
}
 
95
//-----------------------------------------------------------------------------