mirror of https://github.com/BOINC/boinc.git
[Manager] Make DlgGenericMessage dialog more generic.
This is a preparation for another PR that will utilize this new functionality. Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
This commit is contained in:
parent
31316029d1
commit
0175b24198
|
@ -1,6 +1,6 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2023 University of California
|
||||
// Copyright (C) 2024 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
|
@ -1337,7 +1337,6 @@ void CAdvancedFrame::OnClientShutdown(wxCommandEvent& WXUNUSED(event)) {
|
|||
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
||||
int showDialog = wxGetApp().GetBOINCMGRDisplayShutdownConnectedClientMessage();
|
||||
int doShutdownClient = 0;
|
||||
CDlgGenericMessage dlg(this);
|
||||
wxString strDialogTitle = wxEmptyString;
|
||||
wxString strDialogMessage = wxEmptyString;
|
||||
|
||||
|
@ -1368,13 +1367,13 @@ void CAdvancedFrame::OnClientShutdown(wxCommandEvent& WXUNUSED(event)) {
|
|||
pSkinAdvanced->GetApplicationName().c_str()
|
||||
);
|
||||
|
||||
dlg.SetTitle(strDialogTitle);
|
||||
dlg.m_DialogMessage->SetLabel(strDialogMessage);
|
||||
dlg.Fit();
|
||||
dlg.Centre();
|
||||
CDlgGenericMessageParameters dlgParams;
|
||||
dlgParams.caption = strDialogTitle;
|
||||
dlgParams.message = strDialogMessage;
|
||||
CDlgGenericMessage dlg(this, &dlgParams);
|
||||
|
||||
if (wxID_OK == dlg.ShowModal()) {
|
||||
wxGetApp().SetBOINCMGRDisplayShutdownConnectedClientMessage(!dlg.m_DialogDisableMessage->GetValue());
|
||||
wxGetApp().SetBOINCMGRDisplayShutdownConnectedClientMessage(!dlg.GetDisableMessageValue());
|
||||
doShutdownClient = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2023 University of California
|
||||
// Copyright (C) 2024 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
|
@ -31,6 +31,8 @@
|
|||
////@begin XPM images
|
||||
////@end XPM images
|
||||
|
||||
#define ID_DISABLEDIALOG 10017
|
||||
|
||||
/*!
|
||||
* CDlgGenericMessage type definition
|
||||
*/
|
||||
|
@ -56,25 +58,28 @@ CDlgGenericMessage::CDlgGenericMessage( )
|
|||
{
|
||||
}
|
||||
|
||||
CDlgGenericMessage::CDlgGenericMessage( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
CDlgGenericMessage::CDlgGenericMessage( wxWindow* parent, CDlgGenericMessageParameters* parameters )
|
||||
{
|
||||
Create(parent, id, caption, pos, size, style);
|
||||
m_DialogParent = parent;
|
||||
if (parameters != NULL) {
|
||||
m_DialogParameters = *parameters;
|
||||
}
|
||||
Create();
|
||||
}
|
||||
|
||||
/*!
|
||||
* CDlgFileExit creator
|
||||
*/
|
||||
|
||||
bool CDlgGenericMessage::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
||||
bool CDlgGenericMessage::Create( )
|
||||
{
|
||||
////@begin CDlgGenericMessage member initialisation
|
||||
m_DialogMessage = NULL;
|
||||
m_DialogDisableMessage = NULL;
|
||||
////@end CDlgGenericMessage member initialisation
|
||||
|
||||
////@begin CDlgGenericMessage creation
|
||||
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
|
||||
wxDialog::Create( parent, id, caption, pos, size, style );
|
||||
wxDialog::Create( m_DialogParent, m_DialogParameters.id, m_DialogParameters.caption, m_DialogParameters.pos,
|
||||
m_DialogParameters.size, m_DialogParameters.style );
|
||||
|
||||
CreateControls();
|
||||
GetSizer()->Fit(this);
|
||||
|
@ -102,28 +107,37 @@ void CDlgGenericMessage::CreateControls()
|
|||
wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(1, 0, 0);
|
||||
itemBoxSizer3->Add(itemFlexGridSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
||||
|
||||
m_DialogMessage = new wxStaticText;
|
||||
m_DialogMessage->Create( itemDialog1, wxID_STATIC, _T(""), wxDefaultPosition, wxDefaultSize, 0);
|
||||
itemFlexGridSizer4->Add(m_DialogMessage, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
wxStaticText* dialogMessage = new wxStaticText;
|
||||
dialogMessage->Create( itemDialog1, wxID_STATIC, m_DialogParameters.message, wxDefaultPosition, wxDefaultSize, 0);
|
||||
itemFlexGridSizer4->Add(dialogMessage, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
|
||||
itemFlexGridSizer4->Add(5, 5, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
|
||||
m_DialogDisableMessage = new wxCheckBox;
|
||||
m_DialogDisableMessage->Create( itemDialog1, ID_DISABLEDIALOG, _("Don't show this dialog again."), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
||||
m_DialogDisableMessage->SetValue(false);
|
||||
itemFlexGridSizer4->Add(m_DialogDisableMessage, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
if (m_DialogParameters.showDisableMessage)
|
||||
{
|
||||
m_DialogDisableMessage = new wxCheckBox;
|
||||
m_DialogDisableMessage->Create(itemDialog1, ID_DISABLEDIALOG, _("Don't show this dialog again."), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
|
||||
m_DialogDisableMessage->SetValue(false);
|
||||
itemFlexGridSizer4->Add(m_DialogDisableMessage, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
}
|
||||
|
||||
wxFlexGridSizer* itemFlexGridSizer8 = new wxFlexGridSizer(1, 0, 0);
|
||||
itemFlexGridSizer2->Add(itemFlexGridSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP|wxALL, 5);
|
||||
|
||||
wxButton* itemButton9 = new wxButton;
|
||||
itemButton9->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemButton9->SetDefault();
|
||||
itemFlexGridSizer8->Add(itemButton9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
if (m_DialogParameters.button1.show)
|
||||
{
|
||||
wxButton* itemButton9 = new wxButton;
|
||||
itemButton9->Create( itemDialog1, m_DialogParameters.button1.id, m_DialogParameters.button1.label, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemButton9->SetDefault();
|
||||
itemFlexGridSizer8->Add(itemButton9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
}
|
||||
|
||||
wxButton* itemButton10 = new wxButton;
|
||||
itemButton10->Create( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemFlexGridSizer8->Add(itemButton10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
if (m_DialogParameters.button2.show)
|
||||
{
|
||||
wxButton* itemButton10 = new wxButton;
|
||||
itemButton10->Create( itemDialog1, m_DialogParameters.button2.id, m_DialogParameters.button2.label, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
itemFlexGridSizer8->Add(itemButton10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
}
|
||||
|
||||
////@end CDlgGenericMessage content construction
|
||||
}
|
||||
|
@ -137,6 +151,11 @@ bool CDlgGenericMessage::ShowToolTips()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CDlgGenericMessage::GetDisableMessageValue()
|
||||
{
|
||||
return m_DialogDisableMessage != NULL ? m_DialogDisableMessage->GetValue() : false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Get bitmap resources
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of BOINC.
|
||||
// http://boinc.berkeley.edu
|
||||
// Copyright (C) 2008 University of California
|
||||
// Copyright (C) 2024 University of California
|
||||
//
|
||||
// BOINC is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License
|
||||
|
@ -43,33 +43,46 @@
|
|||
|
||||
////@begin control identifiers
|
||||
#define ID_DIALOG 10000
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
#ifdef __WXMAC__
|
||||
#define SYMBOL_CDLGGENERICMESSAGE_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#else
|
||||
#define SYMBOL_CDLGGENERICMESSAGE_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
|
||||
#endif
|
||||
#define SYMBOL_CDLGGENERICMESSAGE_TITLE _T("")
|
||||
#define SYMBOL_CDLGGENERICMESSAGE_IDNAME ID_DIALOG
|
||||
#define SYMBOL_CDLGGENERICMESSAGE_SIZE wxSize(400, 300)
|
||||
#define SYMBOL_CDLGGENERICMESSAGE_POSITION wxDefaultPosition
|
||||
#define ID_DISABLEDIALOG 10017
|
||||
////@end control identifiers
|
||||
|
||||
/*!
|
||||
* Compatibility
|
||||
*/
|
||||
|
||||
#ifndef wxCLOSE_BOX
|
||||
#define wxCLOSE_BOX 0x1000
|
||||
#endif
|
||||
#ifndef wxFIXED_MINSIZE
|
||||
#define wxFIXED_MINSIZE 0
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* CDlgGenericMessage class declaration
|
||||
*/
|
||||
|
||||
struct CDlgGenericMessageButton
|
||||
{
|
||||
CDlgGenericMessageButton(bool show = true, wxWindowID id = wxID_OK, wxString label = _T("&OK"))
|
||||
{
|
||||
this->show = show;
|
||||
this->id = id;
|
||||
this->label = label;
|
||||
}
|
||||
bool show = true;
|
||||
wxWindowID id = wxID_OK;
|
||||
wxString label = _T("&OK");
|
||||
};
|
||||
|
||||
struct CDlgGenericMessageParameters
|
||||
{
|
||||
wxWindowID id = ID_DIALOG;
|
||||
wxString caption = _T("");
|
||||
wxPoint pos = wxDefaultPosition;
|
||||
wxSize size = wxSize(400, 300);
|
||||
long style = SYMBOL_CDLGGENERICMESSAGE_STYLE;
|
||||
wxString message = _T("");
|
||||
bool showDisableMessage = true;
|
||||
CDlgGenericMessageButton button1 = CDlgGenericMessageButton(true, wxID_OK, _T("&OK"));
|
||||
CDlgGenericMessageButton button2 = CDlgGenericMessageButton(true, wxID_CANCEL, _T("Cancel"));
|
||||
};
|
||||
|
||||
class CDlgGenericMessage: public wxDialog
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( CDlgGenericMessage )
|
||||
|
@ -78,13 +91,7 @@ class CDlgGenericMessage: public wxDialog
|
|||
public:
|
||||
/// Constructors
|
||||
CDlgGenericMessage( );
|
||||
CDlgGenericMessage( wxWindow* parent, wxWindowID id = SYMBOL_CDLGGENERICMESSAGE_IDNAME, const wxString& caption = SYMBOL_CDLGGENERICMESSAGE_TITLE, const wxPoint& pos = SYMBOL_CDLGGENERICMESSAGE_POSITION, const wxSize& size = SYMBOL_CDLGGENERICMESSAGE_SIZE, long style = SYMBOL_CDLGGENERICMESSAGE_STYLE );
|
||||
|
||||
/// Creation
|
||||
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CDLGGENERICMESSAGE_IDNAME, const wxString& caption = SYMBOL_CDLGGENERICMESSAGE_TITLE, const wxPoint& pos = SYMBOL_CDLGGENERICMESSAGE_POSITION, const wxSize& size = SYMBOL_CDLGGENERICMESSAGE_SIZE, long style = SYMBOL_CDLGGENERICMESSAGE_STYLE );
|
||||
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
CDlgGenericMessage( wxWindow* parent, CDlgGenericMessageParameters* parameters = NULL );
|
||||
|
||||
////@begin CDlgGenericMessage event handler declarations
|
||||
|
||||
|
@ -102,10 +109,19 @@ public:
|
|||
/// Should we show tooltips?
|
||||
static bool ShowToolTips();
|
||||
|
||||
////@begin CDlgGenericMessage member variables
|
||||
wxStaticText* m_DialogMessage;
|
||||
wxCheckBox* m_DialogDisableMessage;
|
||||
////@end CDlgGenericMessage member variables
|
||||
bool GetDisableMessageValue();
|
||||
|
||||
private:
|
||||
/// Creation
|
||||
bool Create();
|
||||
/// Creates the controls and sizers
|
||||
void CreateControls();
|
||||
|
||||
////@begin CDlgGenericMessage member variables
|
||||
wxWindow* m_DialogParent;
|
||||
CDlgGenericMessageParameters m_DialogParameters;
|
||||
wxCheckBox* m_DialogDisableMessage = NULL;
|
||||
////@end CDlgGenericMessage member variables
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue