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
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// hdRemoveDeleteDialog.cpp - Utility dialog class to allow user to select between delete / remove a figure
//
//////////////////////////////////////////////////////////////////////////
#include "pgAdmin3.h"
// wxWindows headers
#include <wx/wx.h>
#include <wx/statline.h>
// App headers
#include "hotdraw/utilities/hdRemoveDeleteDialog.h"
IMPLEMENT_CLASS( hdRemoveDeleteDialog, wxDialog )
BEGIN_EVENT_TABLE(hdRemoveDeleteDialog, wxDialog)
EVT_BUTTON(DD_REMOVE, hdRemoveDeleteDialog::OnRemove)
EVT_BUTTON(DD_DELETE, hdRemoveDeleteDialog::OnDelete)
EVT_BUTTON(wxID_CANCEL, hdRemoveDeleteDialog::OnCancel)
END_EVENT_TABLE()
hdRemoveDeleteDialog::hdRemoveDeleteDialog( const wxString &message,
const wxString &caption,
wxWindow *parent, bool allowRemove
)
{
allowRemoveButton = allowRemove;
SetFont(settings->GetSystemFont());
Init();
Create(parent, wxID_ANY, message, caption);
cancelButton->SetFocus();
}
hdRemoveDeleteDialog::~hdRemoveDeleteDialog()
{
if(staticText)
delete staticText;
if(staticText2)
delete staticText2;
if(staticText3)
delete staticText3;
if(line)
delete line;
if(removeButton)
delete removeButton;
if(deleteButton)
delete deleteButton;
if(cancelButton)
delete cancelButton;
}
hdRemoveDeleteDialog::hdRemoveDeleteDialog()
{
Init();
}
void hdRemoveDeleteDialog::Init( )
{
}
// Creation
bool hdRemoveDeleteDialog::Create( wxWindow *parent,
wxWindowID id,
const wxString &caption,
const wxString &message
)
{
SetFont(settings->GetSystemFont());
if (!wxDialog::Create( parent, id, message, wxDefaultPosition, wxDefaultSize, wxCAPTION))
return false;
CreateControls(caption);
// This fits the dialog to the minimum size dictated by
// the sizers
GetSizer()->Fit(this);
// This ensures that the dialog cannot be sized smaller
// than the minimum size
GetSizer()->SetSizeHints(this);
// Centre the dialog on the parent or (if none) screen
Centre();
return true;
}
// Creates the controls and sizers
void hdRemoveDeleteDialog::CreateControls(const wxString &message)
{
// A top-level sizer
topSizer = new wxBoxSizer(wxVERTICAL );
this->SetSizer(topSizer);
topSizer->AddSpacer(10);
//Message Sizer
messageSizer = new wxBoxSizer(wxHORIZONTAL );
topSizer->Add(messageSizer);
messageSizer->AddSpacer(25);
staticText = new wxStaticText(this, wxID_STATIC, message, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
messageSizer->Add(staticText, 0, wxALIGN_CENTER, 5);
messageSizer->AddSpacer(45);
// Add important user info
wxString info = _(" Choose Remove from Diagram to remove only from current diagram. ");
wxString info2 = _(" Choose Remove from Model to delete permanently. ");
this->SetForegroundColour(wxColour(wxT("GREY")));
staticText2 = new wxStaticText(this, wxID_STATIC, info, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
topSizer->Add(staticText2, 0, wxALIGN_LEFT, 5);
staticText3 = new wxStaticText(this, wxID_STATIC, info2, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
topSizer->Add(staticText3, 0, wxALIGN_LEFT, 5);
// A space and a dividing line before the Remove Delete and Cancel buttons
topSizer->AddSpacer(10);
line = new wxStaticLine ( this, wxID_STATIC,
wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
topSizer->Add(line, 0, wxGROW | wxALL, 5);
//Buttons Sizer
buttonsSizer = new wxBoxSizer(wxHORIZONTAL );
topSizer->Add(buttonsSizer, 0, wxALIGN_CENTER, 5);
removeButton = new wxButton ( this, DD_REMOVE, wxT("&Remove from Diagram"),
wxDefaultPosition, wxDefaultSize, 0 );
if(!allowRemoveButton)
removeButton->Enable(false);
buttonsSizer->Add(removeButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
deleteButton = new wxButton ( this, DD_DELETE, wxT("&Remove from Model"),
wxDefaultPosition, wxDefaultSize, 0 );
buttonsSizer->Add(deleteButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
cancelButton = new wxButton ( this, wxID_CANCEL, wxT("&Cancel"),
wxDefaultPosition, wxDefaultSize, 0 );
buttonsSizer->Add(cancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
topSizer->AddSpacer(10);
}
void hdRemoveDeleteDialog::OnRemove(wxCommandEvent &WXUNUSED(event))
{
EndModal( DD_REMOVE );
}
void hdRemoveDeleteDialog::OnDelete(wxCommandEvent &WXUNUSED(event))
{
EndModal( DD_DELETE );
}
void hdRemoveDeleteDialog::OnCancel(wxCommandEvent &WXUNUSED(event))
{
EndModal( wxID_CANCEL );
}
|