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

📄 basic.cpp

📁 wxGTK 是 wxWidgets 的 linux GTK+ (>2.2.3)版本。wxWidgets 是一个跨平台的 GUI 框架
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  SetTextColour(m_textColourName);  clause->GetAttributeValue(_T("region_name"), m_regionName);  clause->GetAttributeValue(_T("brush_colour"), brush_string);  clause->GetAttributeValue(_T("pen_width"), pen_width);  clause->GetAttributeValue(_T("pen_style"), pen_style);  clause->GetAttributeValue(_T("brush_style"), brush_style);  int iVal = (int) m_attachmentMode;  clause->GetAttributeValue(_T("use_attachments"), iVal);  m_attachmentMode = iVal;  clause->GetAttributeValue(_T("sensitivity"), m_sensitivity);  iVal = (int) m_spaceAttachments;  clause->GetAttributeValue(_T("space_attachments"), iVal);  m_spaceAttachments = (iVal != 0);  iVal = (int) m_fixedWidth;  clause->GetAttributeValue(_T("fixed_width"), iVal);  m_fixedWidth = (iVal != 0);  iVal = (int) m_fixedHeight;  clause->GetAttributeValue(_T("fixed_height"), iVal);  m_fixedHeight = (iVal != 0);  clause->GetAttributeValue(_T("format_mode"), m_formatMode);  clause->GetAttributeValue(_T("shadow_mode"), m_shadowMode);  iVal = m_branchNeckLength;  clause->GetAttributeValue(_T("neck_length"), iVal);  m_branchNeckLength = iVal;  iVal = m_branchStemLength;  clause->GetAttributeValue(_T("stem_length"), iVal);  m_branchStemLength = iVal;  iVal = m_branchSpacing;  clause->GetAttributeValue(_T("branch_spacing"), iVal);  m_branchSpacing = iVal;  clause->GetAttributeValue(_T("branch_style"), m_branchStyle);  iVal = (int) m_centreResize;  clause->GetAttributeValue(_T("centre_resize"), iVal);  m_centreResize = (iVal != 0);  iVal = (int) m_maintainAspectRatio;  clause->GetAttributeValue(_T("maintain_aspect_ratio"), iVal);  m_maintainAspectRatio = (iVal != 0);  iVal = (int) m_highlighted;  clause->GetAttributeValue(_T("hilite"), iVal);  m_highlighted = (iVal != 0);  clause->GetAttributeValue(_T("rotation"), m_rotation);  if (pen_string == wxEmptyString)    pen_string = _T("BLACK");  if (brush_string == wxEmptyString)    brush_string = _T("WHITE");  if (pen_string.GetChar(0) == '#')  {    wxColour col(oglHexToColour(pen_string.After('#')));    m_pen = wxThePenList->FindOrCreatePen(col, pen_width, pen_style);  }  else    m_pen = wxThePenList->FindOrCreatePen(pen_string, pen_width, pen_style);  if (!m_pen)    m_pen = wxBLACK_PEN;  if (brush_string.GetChar(0) == '#')  {    wxColour col(oglHexToColour(brush_string.After('#')));    m_brush = wxTheBrushList->FindOrCreateBrush(col, brush_style);  }  else    m_brush = wxTheBrushList->FindOrCreateBrush(brush_string, brush_style);  if (!m_brush)    m_brush = wxWHITE_BRUSH;  int point_size = 10;  clause->GetAttributeValue(_T("point_size"), point_size);  SetFont(oglMatchFont(point_size));  // Read user-defined attachment points, if any  wxExpr *attachmentList = clause->AttributeValue(_T("user_attachments"));  if (attachmentList)  {    wxExpr *pointExpr = attachmentList->GetFirst();    while (pointExpr)    {      wxExpr *idExpr = pointExpr->Nth(0);      wxExpr *xExpr = pointExpr->Nth(1);      wxExpr *yExpr = pointExpr->Nth(2);      if (idExpr && xExpr && yExpr)      {        wxAttachmentPoint *point = new wxAttachmentPoint;        point->m_id = (int)idExpr->IntegerValue();        point->m_x = xExpr->RealValue();        point->m_y = yExpr->RealValue();        m_attachmentPoints.Append((wxObject *)point);      }      pointExpr = pointExpr->GetNext();    }  }  // Read text regions  ReadRegions(clause);}void wxShape::ReadRegions(wxExpr *clause){  ClearRegions();  // region1 = (regionName regionText x y width height minWidth minHeight proportionX proportionY  //            formatMode fontSize fontFamily fontStyle fontWeight textColour)  int regionNo = 1;  wxChar regionNameBuf[20];  wxChar textNameBuf[20];  wxExpr *regionExpr;  wxExpr *textExpr = NULL;  wxSprintf(regionNameBuf, _T("region%d"), regionNo);  wxSprintf(textNameBuf, _T("text%d"), regionNo);  m_formatted = true;  // Assume text is formatted unless we prove otherwise  while ((regionExpr = clause->AttributeValue(regionNameBuf)) != NULL)  {    /*     * Get the region information     *     */    wxString regionName = wxEmptyString;    wxString regionText = wxEmptyString;    double x = 0.0;    double y = 0.0;    double width = 0.0;    double height = 0.0;    double minWidth = 5.0;    double minHeight = 5.0;    double m_regionProportionX = -1.0;    double m_regionProportionY = -1.0;    int formatMode = FORMAT_NONE;    int fontSize = 10;    int fontFamily = wxSWISS;    int fontStyle = wxNORMAL;    int fontWeight = wxNORMAL;    wxString regionTextColour = wxEmptyString;    wxString penColour = wxEmptyString;    int penStyle = wxSOLID;    if (regionExpr->Type() == wxExprList)    {      wxExpr *nameExpr = regionExpr->Nth(0);      wxExpr *textExpr = regionExpr->Nth(1);      wxExpr *xExpr = regionExpr->Nth(2);      wxExpr *yExpr = regionExpr->Nth(3);      wxExpr *widthExpr = regionExpr->Nth(4);      wxExpr *heightExpr = regionExpr->Nth(5);      wxExpr *minWidthExpr = regionExpr->Nth(6);      wxExpr *minHeightExpr = regionExpr->Nth(7);      wxExpr *propXExpr = regionExpr->Nth(8);      wxExpr *propYExpr = regionExpr->Nth(9);      wxExpr *formatExpr = regionExpr->Nth(10);      wxExpr *sizeExpr = regionExpr->Nth(11);      wxExpr *familyExpr = regionExpr->Nth(12);      wxExpr *styleExpr = regionExpr->Nth(13);      wxExpr *weightExpr = regionExpr->Nth(14);      wxExpr *colourExpr = regionExpr->Nth(15);      wxExpr *penColourExpr = regionExpr->Nth(16);      wxExpr *penStyleExpr = regionExpr->Nth(17);      regionName = nameExpr->StringValue();      regionText = textExpr->StringValue();      x = xExpr->RealValue();      y = yExpr->RealValue();      width = widthExpr->RealValue();      height = heightExpr->RealValue();      minWidth = minWidthExpr->RealValue();      minHeight = minHeightExpr->RealValue();      m_regionProportionX = propXExpr->RealValue();      m_regionProportionY = propYExpr->RealValue();      formatMode = (int) formatExpr->IntegerValue();      fontSize = (int)sizeExpr->IntegerValue();      fontFamily = (int)familyExpr->IntegerValue();      fontStyle = (int)styleExpr->IntegerValue();      fontWeight = (int)weightExpr->IntegerValue();      if (colourExpr)      {        regionTextColour = colourExpr->StringValue();      }      else        regionTextColour = _T("BLACK");      if (penColourExpr)        penColour = penColourExpr->StringValue();      if (penStyleExpr)        penStyle = (int)penStyleExpr->IntegerValue();    }    wxFont *font = wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight);    wxShapeRegion *region = new wxShapeRegion;    region->SetProportions(m_regionProportionX, m_regionProportionY);    region->SetFont(font);    region->SetSize(width, height);    region->SetPosition(x, y);    region->SetMinSize(minWidth, minHeight);    region->SetFormatMode(formatMode);    region->SetPenStyle(penStyle);    if (penColour != wxEmptyString)      region->SetPenColour(penColour);    region->m_textColour = regionTextColour;    region->m_regionText = regionText;    region->m_regionName = regionName;    m_regions.Append(region);    /*     * Get the formatted text strings     *     */    textExpr = clause->AttributeValue(textNameBuf);    if (textExpr && (textExpr->Type() == wxExprList))    {      wxExpr *node = textExpr->value.first;      while (node)      {        wxExpr *string_expr = node;        double the_x = 0.0;        double the_y = 0.0;        wxString the_string = wxEmptyString;        // string_expr can either be a string, or a list of        // 3 elements: x, y, and string.        if (string_expr->Type() == wxExprString)        {          the_string = string_expr->StringValue();          m_formatted = false;        }        else if (string_expr->Type() == wxExprList)        {          wxExpr *first = string_expr->value.first;          wxExpr *second = first ? first->next : (wxExpr*) NULL;          wxExpr *third = second ? second->next : (wxExpr*) NULL;          if (first && second && third &&              (first->Type() == wxExprReal || first->Type() == wxExprInteger) &&              (second->Type() == wxExprReal || second->Type() == wxExprInteger) &&              third->Type() == wxExprString)          {            if (first->Type() == wxExprReal)              the_x = first->RealValue();            else the_x = (double)first->IntegerValue();            if (second->Type() == wxExprReal)              the_y = second->RealValue();            else the_y = (double)second->IntegerValue();            the_string = third->StringValue();          }        }        if (the_string)        {          wxShapeTextLine *line =              new wxShapeTextLine(the_x, the_y, the_string);          region->m_formattedText.Append(line);        }        node = node->next;      }    }    regionNo ++;    wxSprintf(regionNameBuf, _T("region%d"), regionNo);    wxSprintf(textNameBuf, _T("text%d"), regionNo);  }  // Compatibility: check for no regions (old file).  // Lines and divided rectangles must deal with this compatibility  // theirselves. Composites _may_ not have any regions anyway.  if ((m_regions.GetCount() == 0) &&      !this->IsKindOf(CLASSINFO(wxLineShape)) && !this->IsKindOf(CLASSINFO(wxDividedShape)) &&      !this->IsKindOf(CLASSINFO(wxCompositeShape)))  {    wxShapeRegion *newRegion = new wxShapeRegion;    newRegion->SetName(_T("0"));    m_regions.Append((wxObject *)newRegion);    if (m_text.GetCount() > 0)    {      newRegion->ClearText();      wxNode *node = m_text.GetFirst();      while (node)      {        wxShapeTextLine *textLine = (wxShapeTextLine *)node->GetData();        wxNode *next = node->GetNext();        newRegion->GetFormattedText().Append((wxObject *)textLine);        delete node;        node = next;      }    }  }}#endifvoid wxShape::Copy(wxShape& copy){  copy.m_id = m_id;  copy.m_xpos = m_xpos;  copy.m_ypos = m_ypos;  copy.m_pen = m_pen;  copy.m_brush = m_brush;  copy.m_textColour = m_textColour;  copy.m_centreResize = m_centreResize;  copy.m_maintainAspectRatio = m_maintainAspectRatio;  copy.m_attachmentMode = m_attachmentMode;  copy.m_spaceAttachments = m_spaceAttachments;  copy.m_highlighted = m_highlighted;  copy.m_rotation = m_rotation;  copy.m_textColourName = m_textColourName;  copy.m_regionName = m_regionName;  copy.m_sensitivity = m_sensitivity;  copy.m_draggable = m_draggable;  copy.m_fixedWidth = m_fixedWidth;  copy.m_fixedHeight = m_fixedHeight;  copy.m_formatMode = m_formatMode;  copy.m_drawHandles = m_drawHandles;  copy.m_visible = m_visible;  copy.m_shadowMode = m_shadowMode;  copy.m_shadowOffsetX = m_shadowOffsetX;  copy.m_shadowOffsetY = m_shadowOffsetY;  copy.m_shadowBrush = m_shadowBrush;  copy.m_branchNeckLength = m_branchNeckLength;  copy.m_branchStemLength = m_branchStemLength;  copy.m_branchSpacing = m_branchSpacing;  // Copy text regions  copy.ClearRegions();  wxNode *node = m_regions.GetFirst();  while (node)  {    wxShapeRegion *region = (wxShapeRegion *)node->GetData();    wxShapeRegion *newRegion = new wxShapeRegion(*region);    copy.m_regions.Append(newRegion);    node = node->GetNext();  }  // Copy attachments  copy.ClearAttachments();  node = m_attachmentPoints.GetFirst();  while (node)  {    wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData();    wxAttachmentPoint *newPoint = new wxAttachmentPoint;    newPoint->m_id = point->m_id;    newPoint->m_x = point->m_x;    newPoint->m_y = point->m_y;    copy.m_attachmentPoints.Append((wxObject *)newPoint);    node = node->GetNext();  }  // Copy lines  copy.m_lines.Clear();  node = m_lines.GetFirst();  while (node)  {    wxLineShape* line = (wxLineShape*) node->GetData();    copy.m_lines.Append(line);    node = node->GetNext();  }}// Create and return a new, fully copied object.wxShape *wxShape::CreateNewCopy(bool resetMapping, bool recompute){  if (resetMapping)    oglObjectCopyMapping.Clear();  wxShape* newObject = (wxShape*) GetClassInfo()->CreateObject();  wxASSERT( (newObject != NULL) );  wxASSERT( (newObject->IsKindOf(CLASSINFO(wxShape))) );  Copy(*newObject);  if (GetEventHandler() != this)  {    wxShapeEvtHandler* newHandler = GetEventHandler()->CreateNewCopy();    newObject->SetEventHandler(newHandler);    newObject->SetPreviousHandler(NULL);    newHandler->SetPreviousHandler(newObject);    newHandler->SetShape(newObject);  }  if (recompute)    newObject->Recompute();  return newObject;}// Does the copying for this object, including copying event// handler data if any. Calls the virtual Copy function.void wxShape::CopyWithHandler(wxShape& copy){    Copy(copy);    if (GetEventHandler() != this)    {        wxASSERT( copy.GetEventHandler() != NULL );        wxASSERT( copy.GetEventHandler() != (&copy) );        wxASSERT( GetEventHandler()->GetClassInfo() == copy.GetEventHandler()->GetClassInfo() );        GetEventHandler()->CopyData(* (copy.GetEventHandler()));    }}// Default - make 6 control pointsvoid wxShape::MakeControlPoints(){  double maxX, maxY, minX, minY;  GetBoundingBoxMax(&maxX, &maxY);  GetBoundingBoxMin(&minX, &minY);  double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2);  double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2);  // Offsets from main object  double top = (double)(- (heightMin / 2.0));  double bottom = (double)(heightMin / 2.0 + (maxY - minY));  double left = (double)(- (widthMin / 2.0));  double right = (double)(widthMin / 2.0 + (maxX - minX));  wxControlPoint *control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, left, top,                                           CONTROL_POINT_DIAGONAL);  m_canvas->AddShape(control);  m_controlPoints.Append(control);  control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, 0, top,                                           CONTROL_POINT_VERTICAL);  m_canvas->AddShape(control);  m_controlPoints.Append(control);  control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, right, top,                                           CONTROL_POINT_DIAGONAL);  m_canvas->AddShape(control);  m_controlPoints.Append(control);  control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, right, 0,                                           CONTROL_POINT_HORIZONTAL);  m_canvas->AddShape(control);  m_controlPoints.Append(control);  control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, right, bottom,                                           CONTROL_POINT_DIAGONAL);  m_canvas->AddShape(control);  m_controlPoints.Append(control);  control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, 0, bottom,                                           CONTROL_POINT_VERTICAL);  m_canvas->AddShape(control);  m_controlPoints.Append(control);  control = new 

⌨️ 快捷键说明

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