Ejemplo n.º 1
0
void
Operation::draw_patient_info(const Glib::RefPtr<Gtk::PrintContext>& print)
{
	Cairo::RefPtr<Cairo::Context> cairo = print->get_cairo_context();

	Glib::RefPtr<Pango::Layout> layout = print->create_pango_layout();

	Pango::FontDescription font_desc("sans 12");
	layout->set_font_description(font_desc);

	layout->set_width(width_ * Pango::SCALE);

	DICOM::SummaryInfo* info = const_cast<DICOM::SummaryInfo*>(&dicom_info_);
	DICOM::PatientInfo* patient = info->get_patient_info();

	//Set and mark up the text to print:
	Glib::ustring marked_up_form_text;
	Glib::ustring txt = DICOM::format_person_name(patient->get_name());
	marked_up_form_text += "<b>Patient's name</b>: " + txt + "\n";
	marked_up_form_text += "<b>Sex</b>: " + info->get_patient_sex() + "\n";

	DICOM::PatientAge age = info->get_patient_age();
	marked_up_form_text += "<b>Age</b>: " + age.age_string() + "\n\n";

	layout->set_markup(marked_up_form_text);
	layout->show_in_cairo_context(cairo);

	int w, h;
	layout->get_pixel_size( w, h);
	cairo->rel_move_to( 0, h);
	cairo->stroke_preserve();
}
Ejemplo n.º 2
0
  Glib::RefPtr<Pango::Layout> 
  PrintNotesNoteAddin::create_layout_for_paragraph(const Glib::RefPtr<Gtk::PrintContext> & context, 
                                                   Gtk::TextIter p_start,
                                                   Gtk::TextIter p_end,
                                                   int & indentation)
  {
    Glib::RefPtr<Pango::Layout> layout = context->create_pango_layout();

    layout->set_font_description(
      get_window()->editor()->get_pango_context()->get_font_description());
    int start_index = p_start.get_line_index();
    indentation = 0;

    double dpiX = context->get_dpi_x();
    {
      Pango::AttrList attr_list;

      Gtk::TextIter segm_start = p_start;
      Gtk::TextIter segm_end;

      while (segm_start.compare (p_end) < 0) {
        segm_end = segm_start;
        std::list<Pango::Attribute> attrs;
        get_paragraph_attributes (layout, dpiX, indentation,
                                  segm_end, p_end, attrs);

        guint si = (guint) (segm_start.get_line_index() - start_index);
        guint ei = (guint) (segm_end.get_line_index() - start_index);

        for(std::list<Pango::Attribute>::iterator iter = attrs.begin();
            iter != attrs.end(); ++iter) {
          
          Pango::Attribute & a(*iter);
          a.set_start_index(si);
          a.set_end_index(ei);
          attr_list.insert(a);
        }
        segm_start = segm_end;
      }

      layout->set_attributes(attr_list);
    }

    gnote::DepthNoteTag::Ptr depth = get_buffer()->find_depth_tag(p_start);
    if(depth) {
        indentation += ((int) (dpiX / 3)) * depth->get_depth();
    }
    layout->set_width(pango_units_from_double((int)context->get_width() -
                                              m_margin_left - m_margin_right - indentation));
    layout->set_wrap (Pango::WRAP_WORD_CHAR);
    layout->set_text (get_buffer()->get_slice (p_start, p_end, false));
    return layout;
  }
Ejemplo n.º 3
0
  Glib::RefPtr<Pango::Layout> 
  PrintNotesNoteAddin::create_layout_for_timestamp(const Glib::RefPtr<Gtk::PrintContext> & context)
  {
    Glib::ustring timestamp = sharp::DateTime::now().to_string("%c");

    Glib::RefPtr<Pango::Layout> layout = context->create_pango_layout ();
    Pango::FontDescription font_desc = get_window()->editor()->get_pango_context()->get_font_description();
    font_desc.set_style(Pango::STYLE_NORMAL);
    font_desc.set_weight(Pango::WEIGHT_LIGHT);
    layout->set_font_description(font_desc);
    layout->set_width(pango_units_from_double((int) context->get_width()));

    layout->set_alignment(Pango::ALIGN_RIGHT);
    layout->set_text (timestamp);

    return layout;
  }
Ejemplo n.º 4
0
  Glib::RefPtr<Pango::Layout> 
  PrintNotesNoteAddin::create_layout_for_pagenumbers(const Glib::RefPtr<Gtk::PrintContext> & context, 
                                int page_number, int total_pages)
  {
    Glib::RefPtr<Pango::Layout> layout = context->create_pango_layout();
    Pango::FontDescription font_desc = get_window()->editor()->get_pango_context()->get_font_description();
    font_desc.set_style(Pango::STYLE_NORMAL);
    font_desc.set_weight(Pango::WEIGHT_LIGHT);
    layout->set_font_description(font_desc);
    layout->set_width(pango_units_from_double((int)context->get_width()));

    // %1 is the page number, %2 is the total number of pages
    Glib::ustring footer_left = Glib::ustring::compose(_("Page %1 of %2"),
                                  page_number, total_pages);
    layout->set_alignment(Pango::ALIGN_LEFT);
    layout->set_text (footer_left);

    return layout;
  }
Ejemplo n.º 5
0
void
Operation::draw_study_info(const Glib::RefPtr<Gtk::PrintContext>& print)
{ 
	Cairo::RefPtr<Cairo::Context> cairo = print->get_cairo_context();

	Glib::RefPtr<Pango::Layout> layout = print->create_pango_layout();

	Pango::FontDescription font_desc("sans 12");
	layout->set_font_description(font_desc);

	layout->set_width(width_ * Pango::SCALE);

	DICOM::SummaryInfo* info = const_cast<DICOM::SummaryInfo*>(&dicom_info_);
	DICOM::StudyInfo* study = info->get_study_info();

	//Set and mark up the text to print:
	Glib::ustring marked_up_form_text = "<b>Study ID</b>: " + study->get_id() + "\n";

	layout->set_markup(marked_up_form_text);
	layout->show_in_cairo_context(cairo);
	cairo->stroke();

	Glib::ustring txt = DICOM::format_person_name(study->get_operator_name());
	marked_up_form_text = "<b>Operator's name</b>: " + txt + "\t\t\t\n";

	txt = DICOM::format_person_name(study->get_physician_name());
	marked_up_form_text += "<b>Physician's name</b>: " + txt + "\t\t\t\n";

	layout->set_markup(marked_up_form_text);

	int w, h;
	layout->get_pixel_size( w, h);

	cairo->move_to( width_ - w, height_ - h);
	layout->show_in_cairo_context(cairo);

	cairo->stroke();
}