⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propform.cpp

📁 wxGTK 是 wxWidgets 的 linux GTK+ (>2.2.3)版本。wxWidgets 是一个跨平台的 GUI 框架
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////// Name:        propform.cpp// Purpose:     Property form classes// Author:      Julian Smart// Modified by:// Created:     04/01/98// RCS-ID:      $Id: propform.cpp,v 1.5 2005/09/23 12:47:38 MR Exp $// Copyright:   (c) Julian Smart// Licence:     wxWindows licence/////////////////////////////////////////////////////////////////////////////// For compilers that support precompilation, includes "wx/wx.h".#include "wx/wxprec.h"#ifdef __BORLANDC__#pragma hdrstop#endif#include "wx/deprecated/setup.h"#if wxUSE_PROPSHEET#ifndef WX_PRECOMP    #include "wx/choice.h"    #include "wx/checkbox.h"    #include "wx/slider.h"    #include "wx/msgdlg.h"#endif#include "wx/deprecated/propform.h"#include <ctype.h>#include <stdlib.h>#include <math.h>#include <string.h>/** Property view*/IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormView, wxPropertyView)BEGIN_EVENT_TABLE(wxPropertyFormView, wxPropertyView)EVT_BUTTON(wxID_OK,          wxPropertyFormView::OnOk)EVT_BUTTON(wxID_CANCEL,      wxPropertyFormView::OnCancel)EVT_BUTTON(wxID_HELP,        wxPropertyFormView::OnHelp)EVT_BUTTON(wxID_PROP_REVERT, wxPropertyFormView::OnRevert)EVT_BUTTON(wxID_PROP_UPDATE, wxPropertyFormView::OnUpdate)END_EVENT_TABLE()bool wxPropertyFormView::sm_dialogCancelled = false;wxPropertyFormView::wxPropertyFormView(wxWindow *propPanel, long flags):wxPropertyView(flags){    m_propertyWindow = propPanel;    m_managedWindow = NULL;    m_windowCloseButton = NULL;    m_windowCancelButton = NULL;    m_windowHelpButton = NULL;    m_detailedEditing = false;}wxPropertyFormView::~wxPropertyFormView(void){}void wxPropertyFormView::ShowView(wxPropertySheet *ps, wxWindow *panel){    m_propertySheet = ps;    AssociatePanel(panel);    //  CreateControls();    //  UpdatePropertyList();}// Update this view of the viewed object, called e.g. by// the object itself.bool wxPropertyFormView::OnUpdateView(void){    return true;}bool wxPropertyFormView::Check(void){    if (!m_propertySheet)        return false;    wxNode *node = m_propertySheet->GetProperties().GetFirst();    while (node)    {        wxProperty *prop = (wxProperty *)node->GetData();        wxPropertyValidator *validator = FindPropertyValidator(prop);        if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))        {            wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;            if (!formValidator->OnCheckValue(prop, this, m_propertyWindow))                return false;        }        node = node->GetNext();    }    return true;}bool wxPropertyFormView::TransferToPropertySheet(void){    if (!m_propertySheet)        return false;    wxNode *node = m_propertySheet->GetProperties().GetFirst();    while (node)    {        wxProperty *prop = (wxProperty *)node->GetData();        wxPropertyValidator *validator = FindPropertyValidator(prop);        if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))        {            wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;            formValidator->OnRetrieveValue(prop, this, m_propertyWindow);        }        node = node->GetNext();    }    return true;}bool wxPropertyFormView::TransferToDialog(void){    if (!m_propertySheet)        return false;    wxNode *node = m_propertySheet->GetProperties().GetFirst();    while (node)    {        wxProperty *prop = (wxProperty *)node->GetData();        wxPropertyValidator *validator = FindPropertyValidator(prop);        if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))        {            wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;            formValidator->OnDisplayValue(prop, this, m_propertyWindow);        }        node = node->GetNext();    }    return true;}bool wxPropertyFormView::AssociateNames(void){    if (!m_propertySheet || !m_propertyWindow)        return false;    wxWindowList::Node  *node = m_propertyWindow->GetChildren().GetFirst();    while (node)    {        wxWindow *win = node->GetData();        if ( win->GetName() != wxEmptyString )        {            wxProperty *prop = m_propertySheet->GetProperty(win->GetName());            if (prop)                prop->SetWindow(win);        }        node = node->GetNext();    }    return true;}bool wxPropertyFormView::OnClose(void){    if (m_propertyWindow->IsKindOf(CLASSINFO(wxPropertyFormPanel)))    {        ((wxPropertyFormPanel*)m_propertyWindow)->SetView(NULL);    }    delete this;    return true;}void wxPropertyFormView::OnOk(wxCommandEvent& WXUNUSED(event)){    // Retrieve the value if any    if (!Check())        return;    sm_dialogCancelled = false;    TransferToPropertySheet();    m_managedWindow->Close(true);}void wxPropertyFormView::OnCancel(wxCommandEvent& WXUNUSED(event)){    sm_dialogCancelled = true;    m_managedWindow->Close(true);}void wxPropertyFormView::OnHelp(wxCommandEvent& WXUNUSED(event)){}void wxPropertyFormView::OnUpdate(wxCommandEvent& WXUNUSED(event)){    if (Check())        TransferToPropertySheet();}void wxPropertyFormView::OnRevert(wxCommandEvent& WXUNUSED(event)){    TransferToDialog();}void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event){    if (!m_propertySheet)        return;    if (win.GetName().empty())        return;    if (wxStrcmp(win.GetName(), wxT("ok")) == 0)        OnOk(event);    else if (wxStrcmp(win.GetName(), wxT("cancel")) == 0)        OnCancel(event);    else if (wxStrcmp(win.GetName(), wxT("help")) == 0)        OnHelp(event);    else if (wxStrcmp(win.GetName(), wxT("update")) == 0)        OnUpdate(event);    else if (wxStrcmp(win.GetName(), wxT("revert")) == 0)        OnRevert(event);    else    {        // Find a validator to route the command to.        wxNode *node = m_propertySheet->GetProperties().GetFirst();        while (node)        {            wxProperty *prop = (wxProperty *)node->GetData();            if (prop->GetWindow() && (prop->GetWindow() == &win))            {                wxPropertyValidator *validator = FindPropertyValidator(prop);                if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))                {                    wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;                    formValidator->OnCommand(prop, this, m_propertyWindow, event);                    return;                }            }            node = node->GetNext();        }    }}// Extend event processing to call OnCommandbool wxPropertyFormView::ProcessEvent(wxEvent& event){    if (wxEvtHandler::ProcessEvent(event))        return true;    else if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxUpdateUIEvent)) && event.GetEventObject())    {        OnCommand(* ((wxWindow*) event.GetEventObject()), (wxCommandEvent&) event);        return true;    }    else        return false;}void wxPropertyFormView::OnDoubleClick(wxControl *item){    if (!m_propertySheet)        return;    // Find a validator to route the command to.    wxNode *node = m_propertySheet->GetProperties().GetFirst();    while (node)    {        wxProperty *prop = (wxProperty *)node->GetData();        if (prop->GetWindow() && ((wxControl *)prop->GetWindow() == item))        {            wxPropertyValidator *validator = FindPropertyValidator(prop);            if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))            {                wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;                formValidator->OnDoubleClick(prop, this, m_propertyWindow);                return;            }        }        node = node->GetNext();    }}/** Property form dialog box*/IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormDialog, wxDialog)BEGIN_EVENT_TABLE(wxPropertyFormDialog, wxDialog)EVT_CLOSE(wxPropertyFormDialog::OnCloseWindow)END_EVENT_TABLE()wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title,                                           const wxPoint& pos, const wxSize& size, long style, const wxString& name):wxDialog(parent, wxID_ANY, title, pos, size, style, name){    m_view = v;    m_view->AssociatePanel(this);    m_view->SetManagedWindow(this);    //  SetAutoLayout(true);}void wxPropertyFormDialog::OnCloseWindow(wxCloseEvent& event){    if (m_view)    {        m_view->OnClose();        m_view = NULL;        this->Destroy();    }    else        event.Veto();}void wxPropertyFormDialog::OnDefaultAction(wxControl *item){    m_view->OnDoubleClick(item);}void wxPropertyFormDialog::OnCommand(wxWindow& win, wxCommandEvent& event){    if ( m_view )        m_view->OnCommand(win, event);}// Extend event processing to search the view's event tablebool wxPropertyFormDialog::ProcessEvent(wxEvent& event){    if ( !m_view || ! m_view->ProcessEvent(event) )        return wxEvtHandler::ProcessEvent(event);    else        return true;}/** Property form panel*/IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormPanel, wxPanel)void wxPropertyFormPanel::OnDefaultAction(wxControl *item){    m_view->OnDoubleClick(item);}void wxPropertyFormPanel::OnCommand(wxWindow& win, wxCommandEvent& event){    m_view->OnCommand(win, event);}// Extend event processing to search the view's event tablebool wxPropertyFormPanel::ProcessEvent(wxEvent& event){    if ( !m_view || ! m_view->ProcessEvent(event) )        return wxEvtHandler::ProcessEvent(event);    else        return true;}/** Property frame*/IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormFrame, wxFrame)BEGIN_EVENT_TABLE(wxPropertyFormFrame, wxFrame)EVT_CLOSE(wxPropertyFormFrame::OnCloseWindow)END_EVENT_TABLE()void wxPropertyFormFrame::OnCloseWindow(wxCloseEvent& event){    if (m_view && m_view->OnClose())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -