1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
//----------------------------------------------------------------------------------------
// Name: ol_dialog.cpp
// Purpose: Insert an ordered list (ol) dialog
// Author: Robert O'Connor
// Modified by:
// Created: 2001/01/02
// Copyright: (c) Robert O'Connor ( rob@medicalmnemonics.com )
// Licence: GPL
// RCS-ID: $Id: ol_dialog.cpp,v 1.9 2004/01/04 00:57:49 robertoconnor Exp $
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
// GCC implementation
//----------------------------------------------------------------------------------------
#if defined(__GNUG__) && ! defined(__APPLE__)
#pragma implementation "ol_dialog.h"
#endif
//----------------------------------------------------------------------------------------
// Setup information
//----------------------------------------------------------------------------------------
#include "setup.h"
//----------------------------------------------------------------------------------------
// Begin feature removal condition
//----------------------------------------------------------------------------------------
#if ( setupUSE_INTEGRATED_HTML_EDITOR )
//----------------------------------------------------------------------------------------
// Standard wxWindows headers
//----------------------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// For all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
//----------------------------------------------------------------------------------------
// Header of this .cpp file
//----------------------------------------------------------------------------------------
#include "ol_dialog.h"
//----------------------------------------------------------------------------------------
// Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
//----------------------------------------------------------------------------------------
#include "wx/spinctrl.h" // wxSpinCtrl
// ---------------------------------------------------------------------------------------
#include "wx/xrc/xmlres.h" // XRC XML resouces
// ---------------------------------------------------------------------------------------
#include "utils_controls.h"
#include "help_controller.h"
//----------------------------------------------------------------------------------------
// Event table: connect the events to the handler functions to process them
//----------------------------------------------------------------------------------------
BEGIN_EVENT_TABLE( ol_dialog, wxDialog )
EVT_UPDATE_UI( XRCID( "ol_dialog_specify_start_checkbox" ), ol_dialog::on_update_ui_specify_start_checkbox )
EVT_BUTTON( wxID_HELP_CONTEXT, ol_dialog::on_help_button )
EVT_BUTTON( wxID_OK, ol_dialog::OnOK )
END_EVENT_TABLE()
//----------------------------------------------------------------------------------------
// Non-event handler functions
//----------------------------------------------------------------------------------------
// Constructor
ol_dialog::ol_dialog( wxWindow* parent )
{
wxXmlResource::Get()->LoadDialog( this, parent, "ol_dialog" );
XRCCTRL( *this, "ol_dialog_enumeration_choice", wxChoice )->SetSelection( 0 );
}
// Destructor
ol_dialog::~ol_dialog()
{
}
void ol_dialog::transfer_to( wxString& starting_text, wxString& ending_text )
{
starting_text = m_starting_text;
ending_text = m_ending_text;
}
//----------------------------------------------------------------------------------------
// Event handlers
//----------------------------------------------------------------------------------------
void ol_dialog::on_update_ui_specify_start_checkbox( wxUpdateUIEvent &event )
{
bool enabled;
enabled = XRCCTRL( *this, "ol_dialog_specify_start_checkbox", wxCheckBox )
->GetValue();
XRCCTRL( *this, "ol_dialog_start_at_spinctrl", wxSpinCtrl )
->Enable( enabled );
}
// Override wxDialog's default behavior for clicking an OK button.
void ol_dialog::OnOK( wxCommandEvent& event )
{
wxString output_string;
wxString buf;
output_string = "<ol";
bool specify_start = XRCCTRL( *this, "ol_dialog_specify_start_checkbox", wxCheckBox )->GetValue();
if ( specify_start )
{
int start_spin_value = XRCCTRL( *this, "ol_dialog_start_at_spinctrl", wxSpinCtrl )->GetValue();
buf.Printf( wxT( " start=\"%d" ), start_spin_value );
output_string += buf;
output_string += '\"';
}
int enumeration_value = XRCCTRL( *this, "ol_dialog_enumeration_choice", wxChoice )->GetSelection();
wxString enumeration_string;
// Case 0 is 'Default'
switch ( enumeration_value )
{
case 1:
enumeration_string = "A";
break;
case 2:
enumeration_string = "a";
break;
case 3:
enumeration_string = "I";
break;
case 4:
enumeration_string = "i";
break;
}
if ( enumeration_value != 0 )
{
output_string += " type=\"" + enumeration_string + "\"";
}
bool compact = XRCCTRL( *this, "ol_dialog_compact_checkbox", wxCheckBox )->GetValue();
if ( compact )
{
output_string += " compact";
}
output_string += ">\n";
// Store the starting and ending strings as class members, ready to be transferred
// by transfer_to(...) method.
m_starting_text = output_string;
m_ending_text = "</ol>";
// Get rid of the modal dialog. Not transferring any info from this modal's control
// to a parent dialog, so don't have to bother with wxWindow::Validate or
// wxWindow::TransferDataFromWindow.
EndModal( wxID_OK );
}
void ol_dialog::on_help_button( wxCommandEvent &event )
{
#if ( setupUSE_ONLINE_HELP )
help_controller::get()->show_help_topic( plkrHELP_ID_OL_DIALOG );
#endif
}
//----------------------------------------------------------------------------------------
// End feature removal condition
//----------------------------------------------------------------------------------------
#endif // setupUSE_INTEGRATED_HTML_EDITOR
|