void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height, double dpi) { m_width = Width; m_height = Height; m_dpi = dpi; m_OK = true; m_clipUniqueId = 0; m_clipNestingLevel = 0; m_mm_to_pix_x = dpi/25.4; m_mm_to_pix_y = dpi/25.4; m_backgroundBrush = *wxTRANSPARENT_BRUSH; m_textForegroundColour = *wxBLACK; m_textBackgroundColour = *wxWHITE; m_colour = wxColourDisplay(); m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; m_graphics_changed = true; ////////////////////code here m_bmp_handler = NULL; m_outfile = new wxFileOutputStream(filename); m_OK = m_outfile->IsOk(); if (m_OK) { m_filename = filename; m_sub_images = 0; wxString s; s = wxT("<?xml version=\"1.0\" standalone=\"no\"?>\n"); write(s); s = wxT("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\"\n"); write(s); s = wxT("\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"); write(s); s = wxT("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"); write(s); s.Printf( wxT(" width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d \">\n"), NumStr(float(Width)/dpi*2.54), NumStr(float(Height)/dpi*2.54), Width, Height ); write(s); s = wxT("<title>SVG Picture created as ") + wxFileName(filename).GetFullName() + wxT(" </title>\n"); write(s); s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>\n"); write(s); s = wxT("<g style=\"fill:black; stroke:black; stroke-width:1\">\n"); write(s); } }
void wxSVGFileDC::Init (wxString f, int Width, int Height, float dpi) { //set up things first wxDCBase does all this? m_width = Width ; m_height = Height ; m_clipping = FALSE; m_OK = TRUE; m_mm_to_pix_x = dpi/25.4; m_mm_to_pix_y = dpi/25.4; m_signX = m_signY = 1; m_userScaleX = m_userScaleY = m_deviceOriginX = m_deviceOriginY = 0; m_OriginX = m_OriginY = 0; m_logicalOriginX = m_logicalOriginY = 0; m_logicalScaleX = m_logicalScaleY = 0 ; m_scaleX = m_scaleY = 1.0 ; m_logicalFunction = wxCOPY; m_backgroundMode = wxTRANSPARENT; m_mappingMode = wxMM_TEXT; m_backgroundBrush = *wxTRANSPARENT_BRUSH; m_textForegroundColour = *wxBLACK; m_textBackgroundColour = *wxWHITE; m_colour = wxColourDisplay(); m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; m_graphics_changed = TRUE ; ////////////////////code here m_outfile = new wxFileOutputStream(f) ; m_OK = m_outfile->Ok (); if (m_OK) { m_filename = f ; m_sub_images = 0 ; wxString s ; s = wxT("<?xml version=\"1.0\" standalone=\"no\"?>") ; s = s + newline ; write(s); s = wxT("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" ") + newline ; write(s); s = wxT("\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"> ")+ newline ; write(s); s.Printf ( wxT("<svg width=\"%.2gcm\" height=\"%.2gcm\" viewBox=\"0 0 %d %d \"> \n"), float(Width)/dpi*2.54, float(Height)/dpi*2.54, Width, Height ); write(s); s = wxT("<title>SVG Picture created as ") + wxFileNameFromPath(f) + wxT(" </title>") + newline ; write(s); s = wxString (wxT("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxT(" </desc>")+ newline ; write(s); s = wxT("<g style=\"fill:black; stroke:black; stroke-width:1\">") + newline ; write(s); } }
// Read the poetry buffer, either for finding the size // or for writing to a bitmap (not to the window directly, // since that displays messily) // If DrawIt is true, we draw, otherwise we just determine the // size the window should be. void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) { int i = pages[current_page]; int ch = -1; int y = 0; int j; wxChar *line_ptr; int curr_width = 0; bool page_break = false; int width = 0; int height = 0; if (DrawIt) { y = (*max_y - poem_height)/2; width = *max_x; height = *max_y; } if (DrawIt && wxColourDisplay()) { dc->SetBrush(*wxLIGHT_GREY_BRUSH); dc->SetPen(*wxGREY_PEN); dc->DrawRectangle(0, 0, width, height); dc->SetBackgroundMode(wxTRANSPARENT); } // See what ACTUAL char height is if(m_normalFont) dc->SetFont(*m_normalFont); wxCoord xx; wxCoord yy; dc->GetTextExtent(wxT("X"), &xx, &yy); char_height = (int)yy; if (current_page == 0) { m_title = wxEmptyString; } else if (!m_title.empty()) { dc->SetFont(* m_boldFont); dc->GetTextExtent(m_title, &xx, &yy); FindMax(&curr_width, (int)xx); if (DrawIt) { int x = (width - xx)/2; dc->SetFont(* m_boldFont); // Change text to BLACK! dc->SetTextForeground(* wxBLACK); dc->DrawText(m_title, x, y); // Change text to WHITE! dc->SetTextForeground(* wxWHITE); dc->DrawText(m_title, x-SHADOW_OFFSET, y-SHADOW_OFFSET); } y += char_height; y += char_height; } while (ch != 0 && !page_break) { j = 0; #if defined(__WXMSW__) || defined(__WXMAC__) while (((ch = poem_buffer[i]) != 13) && (ch != 0)) #else while (((ch = poem_buffer[i]) != 10) && (ch != 0)) #endif { line[j] = (wxChar)ch; j ++; i ++; } #if defined(__WXMSW__) || defined(__WXMAC__) if (ch == 13) #else if (ch == 10) #endif { ch = -1; i ++; #if defined(__WXMSW__) || defined(__WXMAC__) // Add another to skip the linefeed i ++; #endif // If a single newline on its own, put a space in if (j == 0) { line[j] = ' '; j ++; line[j] = 0; } } if (j > 0) { line[j] = 0; if (line[0] == '@') { switch (line[1]) { case 'P': paging = true; page_break = true; break; case 'T': dc->SetFont(* m_boldFont); line_ptr = line+3; m_title = line_ptr; m_title << wxT(" (cont'd)"); dc->GetTextExtent(line_ptr, &xx, &yy); FindMax(&curr_width, (int)xx); if (DrawIt) { int x = (width - xx)/2; dc->SetFont(* m_boldFont); // Change text to BLACK! dc->SetTextForeground(* wxBLACK); dc->DrawText(line_ptr, x, y); // Change text to WHITE! dc->SetTextForeground(* wxWHITE); dc->DrawText(line_ptr, x-SHADOW_OFFSET, y-SHADOW_OFFSET); dc->SetTextForeground(* wxWHITE); } break; case 'A': line_ptr = line+3; dc->SetFont(* m_italicFont); dc->GetTextExtent(line_ptr, &xx, &yy); FindMax(&curr_width, (int)xx); if (DrawIt) { int x = (width - xx)/2; dc->SetTextForeground(* wxBLACK); dc->DrawText(line_ptr, x, y); } break; // Default: just ignore this line default: y -= char_height; } } else { dc->SetFont(* m_normalFont); dc->GetTextExtent(line, &xx, &yy); FindMax(&curr_width, (int)xx); if (DrawIt) { int x = (int)((width - xx)/2.0); dc->SetFont(* m_normalFont); dc->SetTextForeground(* wxBLACK); dc->DrawText(line, x, y); } } } y += char_height; } // Write (cont'd) if (page_break) { const wxChar *cont = wxT("(cont'd)"); dc->SetFont(* m_normalFont); dc->GetTextExtent(cont, &xx, &yy); FindMax(&curr_width, (int)xx); if (DrawIt) { int x = (int)((width - xx)/2.0); dc->SetFont(* m_normalFont); dc->SetTextForeground(* wxBLACK); dc->DrawText(cont, x, y); } y += 2*char_height; } *max_x = (int)curr_width; *max_y = (int)(y-char_height); if (page_break) pages[current_page+1] = i; else paging = false; if (DrawIt) { // Draw dark grey thick border if (wxColourDisplay()) { dc->SetBrush(*wxGREY_BRUSH); dc->SetPen(*wxGREY_PEN); // Left side dc->DrawRectangle(0, 0, THIN_LINE_BORDER, height); // Top side dc->DrawRectangle(THIN_LINE_BORDER, 0, width-THIN_LINE_BORDER, THIN_LINE_BORDER); // Right side dc->DrawRectangle(width-THIN_LINE_BORDER, THIN_LINE_BORDER, width, height-THIN_LINE_BORDER); // Bottom side dc->DrawRectangle(THIN_LINE_BORDER, height-THIN_LINE_BORDER, width-THIN_LINE_BORDER, height); } // Draw border // Have grey background, plus 3-d border - // One black rectangle. // Inside this, left and top sides - dark grey. Bottom and right - // white. // Change pen to black dc->SetPen(*wxBLACK_PEN); dc->DrawLine(THIN_LINE_BORDER, THIN_LINE_BORDER, width-THIN_LINE_BORDER, THIN_LINE_BORDER); dc->DrawLine(width-THIN_LINE_BORDER, THIN_LINE_BORDER, width-THIN_LINE_BORDER, height-THIN_LINE_BORDER); dc->DrawLine(width-THIN_LINE_BORDER, height-THIN_LINE_BORDER, THIN_LINE_BORDER, height-THIN_LINE_BORDER); dc->DrawLine(THIN_LINE_BORDER, height-THIN_LINE_BORDER, THIN_LINE_BORDER, THIN_LINE_BORDER); // Right and bottom white lines - 'grey' (black!) if // we're running on a mono display. if (wxColourDisplay()) dc->SetPen(*wxWHITE_PEN); else dc->SetPen(*wxBLACK_PEN); dc->DrawLine(width-THICK_LINE_BORDER, THICK_LINE_BORDER, width-THICK_LINE_BORDER, height-THICK_LINE_BORDER); dc->DrawLine(width-THICK_LINE_BORDER, height-THICK_LINE_BORDER, THICK_LINE_BORDER, height-THICK_LINE_BORDER); // Left and top grey lines dc->SetPen(*wxBLACK_PEN); dc->DrawLine(THICK_LINE_BORDER, height-THICK_LINE_BORDER, THICK_LINE_BORDER, THICK_LINE_BORDER); dc->DrawLine(THICK_LINE_BORDER, THICK_LINE_BORDER, width-THICK_LINE_BORDER, THICK_LINE_BORDER); // Draw icons dc->DrawIcon(* m_corners[0], 0, 0); dc->DrawIcon(* m_corners[1], int(width-32), 0); int y2 = height - 32; int x2 = (width-32); dc->DrawIcon(* m_corners[2], 0, y2); dc->DrawIcon(* m_corners[3], x2, y2); } }
bool screenIsMonochrome(Widget* widget) { return wxColourDisplay(); }