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

📄 prop.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////// Name:        prop.cpp// Purpose:     Propert sheet classes implementation// Author:      Julian Smart// Modified by:// Created:     04/01/98// RCS-ID:      $Id: prop.cpp,v 1.8 2006/04/14 19:56:03 ABX 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#endif#include "wx/debug.h"#include "wx/deprecated/prop.h"#include <ctype.h>#include <stdlib.h>#include <math.h>#include <string.h>#if !WXWIN_COMPATIBILITY_2_4static inline wxChar* copystring(const wxChar* s)    { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); }#endifIMPLEMENT_DYNAMIC_CLASS(wxPropertyValue, wxObject)wxPropertyValue::wxPropertyValue(void){  m_type = wxPropertyValueNull;  m_next = NULL;  m_last = NULL;  m_value.first = NULL;  m_clientData = NULL;  m_modifiedFlag = false;}wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom)    : wxObject(){  m_value.string = (wxChar*) NULL;  m_modifiedFlag = false;  Copy((wxPropertyValue& )copyFrom);}wxPropertyValue::wxPropertyValue(const wxChar *val){  m_modifiedFlag = false;  m_type = wxPropertyValueString;  m_value.string = copystring(val);  m_clientData = NULL;  m_next = NULL;  m_last = NULL;}wxPropertyValue::wxPropertyValue(const wxString& val){  m_modifiedFlag = false;  m_type = wxPropertyValueString;  m_value.string = copystring(val.c_str());  m_clientData = NULL;  m_next = NULL;  m_last = NULL;}wxPropertyValue::wxPropertyValue(long the_integer){  m_modifiedFlag = false;  m_type = wxPropertyValueInteger;  m_value.integer = the_integer;  m_clientData = NULL;  m_next = NULL;}wxPropertyValue::wxPropertyValue(bool val){  m_modifiedFlag = false;  m_type = wxPropertyValuebool;  m_value.integer = val;  m_clientData = NULL;  m_next = NULL;}wxPropertyValue::wxPropertyValue(float the_real){  m_modifiedFlag = false;  m_type = wxPropertyValueReal;  m_value.real = the_real;  m_clientData = NULL;  m_next = NULL;}wxPropertyValue::wxPropertyValue(double the_real){  m_modifiedFlag = false;  m_type = wxPropertyValueReal;  m_value.real = (float)the_real;  m_clientData = NULL;  m_next = NULL;}// Pointer versions: we have a pointer to the real C++ value.wxPropertyValue::wxPropertyValue(wxChar **val){  m_modifiedFlag = false;  m_type = wxPropertyValueStringPtr;  m_value.stringPtr = val;  m_clientData = NULL;  m_next = NULL;  m_last = NULL;}wxPropertyValue::wxPropertyValue(long *val){  m_modifiedFlag = false;  m_type = wxPropertyValueIntegerPtr;  m_value.integerPtr = val;  m_clientData = NULL;  m_next = NULL;}wxPropertyValue::wxPropertyValue(bool *val){  m_modifiedFlag = false;  m_type = wxPropertyValueboolPtr;  m_value.boolPtr = val;  m_clientData = NULL;  m_next = NULL;}wxPropertyValue::wxPropertyValue(float *val){  m_modifiedFlag = false;  m_type = wxPropertyValueRealPtr;  m_value.realPtr = val;  m_clientData = NULL;  m_next = NULL;}wxPropertyValue::wxPropertyValue(wxList *the_list){  m_modifiedFlag = false;  m_type = wxPropertyValueList;  m_clientData = NULL;  m_last = NULL;  m_value.first = NULL;  wxObjectList::compatibility_iterator node = the_list->GetFirst();  while (node)  {    wxPropertyValue *expr = (wxPropertyValue *)node->GetData();    Append(expr);    node = node->GetNext();  }  delete the_list;}wxPropertyValue::wxPropertyValue(wxStringList *the_list){  m_modifiedFlag = false;  m_type = wxPropertyValueList;  m_clientData = NULL;  m_last = NULL;  m_value.first = NULL;  wxStringList::compatibility_iterator node = the_list->GetFirst();  while (node)  {    wxString s = node->GetData();    Append(new wxPropertyValue(s));    node = node->GetNext();  }  delete the_list;}wxPropertyValue::~wxPropertyValue(void){  switch (m_type)  {    case wxPropertyValueInteger:    case wxPropertyValuebool:    case wxPropertyValueReal:    {     break;    }   case wxPropertyValueString:   {     delete[] m_value.string;     break;   }   case wxPropertyValueList:   {     wxPropertyValue *expr = m_value.first;     while (expr)     {       wxPropertyValue *expr1 = expr->m_next;       delete expr;       expr = expr1;     }     break;   }   default:   case wxPropertyValueNull: break;  }}void wxPropertyValue::Append(wxPropertyValue *expr){  m_modifiedFlag = true;  if (!m_value.first)    m_value.first = expr;  if (m_last)    m_last->m_next = expr;  m_last = expr;}void wxPropertyValue::Insert(wxPropertyValue *expr){  m_modifiedFlag = true;  expr->m_next = m_value.first;  m_value.first = expr;  if (!m_last)    m_last = expr;}// Delete from listvoid wxPropertyValue::Delete(wxPropertyValue *node){  wxPropertyValue *expr = GetFirst();  wxPropertyValue *previous = NULL;  while (expr && (expr != node))  {    previous = expr;    expr = expr->GetNext();  }  if (expr)  {    if (previous)      previous->m_next = expr->m_next;    // If node was the first in the list,    // make the list point to the NEXT one.    if (GetFirst() == expr)    {      m_value.first = expr->m_next;    }    // If node was the last in the list,    // make the list 'last' pointer point to the PREVIOUS one.    if (GetLast() == expr)    {      if (previous)        m_last = previous;      else        m_last = NULL;    }    m_modifiedFlag = true;    delete expr;  }}void wxPropertyValue::ClearList(void){  wxPropertyValue *val = GetFirst();  if (val)    m_modifiedFlag = true;  while (val)  {    wxPropertyValue *next = val->GetNext();    delete val;    val = next;  }  m_value.first = NULL;  m_last = NULL;}wxPropertyValue *wxPropertyValue::NewCopy(void) const{  switch (m_type)  {    case wxPropertyValueInteger:      return new wxPropertyValue(m_value.integer);    case wxPropertyValuebool:      return new wxPropertyValue((bool) (m_value.integer != 0));    case wxPropertyValueReal:      return new wxPropertyValue(m_value.real);    case wxPropertyValueString:      return new wxPropertyValue(m_value.string);    case wxPropertyValueList:    {      wxPropertyValue *expr = m_value.first;      wxPropertyValue *new_list = new wxPropertyValue;      new_list->SetType(wxPropertyValueList);      while (expr)      {        wxPropertyValue *expr2 = expr->NewCopy();        new_list->Append(expr2);        expr = expr->m_next;      }      return new_list;    }   case wxPropertyValueIntegerPtr:     return new wxPropertyValue(m_value.integerPtr);   case wxPropertyValueRealPtr:     return new wxPropertyValue(m_value.realPtr);   case wxPropertyValueboolPtr:     return new wxPropertyValue(m_value.boolPtr);   case wxPropertyValueStringPtr:     return new wxPropertyValue(m_value.stringPtr);   case wxPropertyValueNull:    wxFAIL_MSG( wxT("Should never get here!\n" ) );    break;  }  return NULL;}void wxPropertyValue::Copy(wxPropertyValue& copyFrom){  if (m_type == wxPropertyValueString)  {    delete[] m_value.string ;    m_value.string = NULL;  }  m_type = copyFrom.Type();  switch (m_type)  {    case wxPropertyValueInteger:      (*this) = copyFrom.IntegerValue();      return ;    case wxPropertyValueReal:      (*this) = copyFrom.RealValue();      return ;    case wxPropertyValueString:      (*this) = wxString(copyFrom.StringValue());      return ;    case wxPropertyValuebool:      (*this) = copyFrom.BoolValue();      return ;    // Pointers    case wxPropertyValueboolPtr:      (*this) = copyFrom.BoolValuePtr();      return ;    case wxPropertyValueRealPtr:      (*this) = copyFrom.RealValuePtr();      return ;    case wxPropertyValueIntegerPtr:      (*this) = copyFrom.IntegerValuePtr();      return ;    case wxPropertyValueStringPtr:    {      wxChar** s = copyFrom.StringValuePtr();#if 0      // what is this? are you trying to assign a bool or a string?  VA can't figure it out..#if defined(__VISAGECPP__) || defined( __VISUALC__ )      (*this) = s;#else      (*this) = s != 0;#endif#endif // if 0      (*this) = (bool)(s != 0);      return ;    }    case wxPropertyValueList:    {      m_value.first = NULL;      m_next = NULL;      m_last = NULL;      wxPropertyValue *expr = copyFrom.m_value.first;      while (expr)      {        wxPropertyValue *expr2 = expr->NewCopy();        Append(expr2);        expr = expr->m_next;      }      return;    }   case wxPropertyValueNull:    wxFAIL_MSG( wxT("Should never get here!\n" ) );    break;  }}// Return nth argument of a clause (starting from 1)wxPropertyValue *wxPropertyValue::Arg(wxPropertyValueType type, int arg) const{  wxPropertyValue *expr = m_value.first;  for (int i = 1; i < arg; i++)    if (expr)      expr = expr->m_next;  if (expr && (expr->m_type == type))    return expr;  else    return NULL;}// Return nth argument of a list expression (starting from zero)wxPropertyValue *wxPropertyValue::Nth(int arg) const{  if (m_type != wxPropertyValueList)    return NULL;  wxPropertyValue *expr = m_value.first;  for (int i = 0; i < arg; i++)    if (expr)      expr = expr->m_next;    else return NULL;  if (expr)    return expr;  else    return NULL;}  // Returns the number of elements in a list expressionint wxPropertyValue::Number(void) const{  if (m_type != wxPropertyValueList)    return 0;  int i = 0;  wxPropertyValue *expr = m_value.first;  while (expr)  {    expr = expr->m_next;    i ++;  }  return i;}void wxPropertyValue::WritePropertyClause(wxString& stream)  // Write this expression as a top-level clause{  if (m_type != wxPropertyValueList)    return;  wxPropertyValue *node = m_value.first;  if (node)  {    node->WritePropertyType(stream);    stream.Append( wxT("(") );    node = node->m_next;    bool first = true;    while (node)    {      if (!first)        stream.Append( wxT("  ") );      node->WritePropertyType(stream);      node = node->m_next;      if (node)        stream.Append( wxT(",\n" ) );      first = false;    }    stream.Append( wxT(").\n\n") );  }}void wxPropertyValue::WritePropertyType(wxString& stream)    // Write as any other subexpression{  wxString tmp;  switch (m_type)  {    case wxPropertyValueInteger:    {      tmp.Printf( wxT("%ld"), m_value.integer );      stream.Append( tmp );      break;    }    case wxPropertyValueIntegerPtr:    {      tmp.Printf( wxT("%ld"), *m_value.integerPtr );      stream.Append( tmp );      break;    }    case wxPropertyValuebool:    {      if (m_value.integer)        stream.Append( wxT("True") );      else        stream.Append( wxT("False") );      break;    }    case wxPropertyValueboolPtr:    {      if (*m_value.integerPtr)        stream.Append( wxT("True") );      else        stream.Append( wxT("False") );      break;    }    case wxPropertyValueReal:    {      double d = m_value.real;      tmp.Printf( wxT("%.6g"), d );      stream.Append( tmp );      break;    }    case wxPropertyValueRealPtr:    {      double d = *m_value.realPtr;      tmp.Printf( wxT("%.6g"), d );      stream.Append( tmp );      break;    }    case wxPropertyValueString:    {      stream.Append( m_value.string );      break;    }    case wxPropertyValueStringPtr:    {      wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );      /*      int i;      int len = strlen(*(m_value.stringPtr));      for (i = 0; i < len; i++)      {        char ch = *(m_value.stringPtr)[i];      }      */      break;    }    case wxPropertyValueList:    {      if (!m_value.first)        stream.Append( wxT("[]") );      else      {        wxPropertyValue *expr = m_value.first;        stream.Append( wxT("[") );        while (expr)        {          expr->WritePropertyType(stream);          expr = expr->m_next;          if (expr)        stream.Append( wxT(", ") );        }        stream.Append( wxT("]") );      }      break;    }   case wxPropertyValueNull: break;  }}wxString wxPropertyValue::GetStringRepresentation(void){  wxString str;  WritePropertyType(str);  return str;

⌨️ 快捷键说明

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