From fe3032d66691a01d0a970dda3fa33f39b2c4cf5b Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Tue, 9 Jun 2020 09:29:27 -0400 Subject: Added support for quotes that are new in the spec. Looks pretty on Win32, untested in dumb renderer. --- ag_render.f90 | 103 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 40 deletions(-) (limited to 'ag_render.f90') diff --git a/ag_render.f90 b/ag_render.f90 index e98d7b6..fc80295 100644 --- a/ag_render.f90 +++ b/ag_render.f90 @@ -94,7 +94,7 @@ implicit none procedure :: text_height => ag_text_height procedure :: is_text_visible => ag_text_visible - procedure :: draw_porportional => ag_text_draw + procedure :: draw_proportional => ag_text_draw procedure :: preformatted_width => ag_preformatted_width procedure :: preformatted_height => ag_preformatted_height @@ -440,36 +440,46 @@ contains end subroutine ag_new_page - pure function get_font_size(self, heading) + pure function get_font_size(self, text_type) implicit none class(appgraphics_renderer), intent(in)::self - integer, intent(in)::heading + integer, intent(in)::text_type integer::get_font_size get_font_size = self%font_size - if(heading == 1) then + if(text_type == proportional_type_heading_1) then get_font_size = 2*get_font_size - else if(heading > 1) then + else if(text_type > proportional_type_heading_1) then get_font_size = (3*get_font_size)/2 end if end function get_font_size - function ag_text_width(self, text, heading, list_item) + pure function get_indent_margin(self) + implicit none + + type(appgraphics_renderer), intent(in)::self + integer::get_indent_margin + + get_indent_margin = self%font_size + 2*self%bullet_margin + + end function get_indent_margin + + function ag_text_width(self, text, text_type) use appgraphics + use render implicit none class(appgraphics_renderer)::self character(*), intent(in)::text - integer, intent(in), optional::heading - logical, intent(in), optional::list_item + integer, intent(in), optional::text_type integer::ag_text_width integer::font_size font_size = self%font_size - if(present(heading)) then - font_size = get_font_size(self, heading) + if(present(text_type)) then + font_size = get_font_size(self, text_type) end if call settextstyle(self%default_font, HORIZ_DIR, font_size) @@ -481,28 +491,29 @@ contains ag_text_width = ag_text_width + self%left_border + self%right_border - if(present(list_item)) then - if(list_item) then - ag_text_width = ag_text_width + self%font_size/2 + 2*self%bullet_margin + if(present(text_type)) then + if(text_type == proportional_type_list_item) then + ag_text_width = ag_text_width + get_indent_margin(self) + else if(text_type == proportional_type_quotation) then + ag_text_width = ag_text_width + 2 * get_indent_margin(self) end if end if end function ag_text_width - function ag_text_height(self, text, heading, list_item) + function ag_text_height(self, text, text_type) use appgraphics implicit none class(appgraphics_renderer)::self character(*), intent(in)::text - integer, intent(in), optional::heading - logical, intent(in), optional::list_item + integer, intent(in), optional::text_type integer::ag_text_height integer::font_size font_size = self%font_size - if(present(heading)) then - font_size = get_font_size(self, heading) + if(present(text_type)) then + font_size = get_font_size(self, text_type) end if call settextstyle(self%default_font, HORIZ_DIR, font_size) @@ -526,43 +537,55 @@ contains end function ag_text_visible - subroutine ag_text_draw(self, text, heading, list_item) + subroutine ag_text_draw(self, text, text_type) use appgraphics implicit none class(appgraphics_renderer)::self character(*), intent(in)::text - integer, intent(in), optional::heading - logical, intent(in), optional::list_item + integer, intent(in), optional::text_type integer::font_size integer::x, bx, by + integer::font_color font_size = self%font_size - if(present(heading)) then - font_size = get_font_size(self, heading) - - ! The first level 1 heading can be guessed as the page title - if(heading == 1 .and. .not. self%title_guessed) then - call set_window_title(self, text) - self%title_guessed = .true. - end if - end if - + font_color = self%text_color x = self%left_border - if(present(list_item)) then - if(list_item) then - bx = x + self%bullet_margin - by = self%y + self%font_size/4 + + if(present(text_type)) then + font_size = get_font_size(self, text_type) + + select case(text_type) - call setfillstyle(SOLID_FILL, self%text_color) - call bar(bx, by, bx+self%font_size/2, by+self%font_size/2) + case (proportional_type_heading_1) + ! The first level 1 heading can be guessed as the page title + if(.not. self%title_guessed) then + + call set_window_title(self, text) + self%title_guessed = .true. - x = bx + self%bullet_margin + self%font_size/2 - end if + end if + + case (proportional_type_list_item) + ! If a list item, need to draw a box + bx = x + self%bullet_margin + by = self%y + self%font_size/4 + + call setfillstyle(SOLID_FILL, self%text_color) + call bar(bx, by, bx+self%font_size/2, by+self%font_size/2) + + x = get_indent_margin(self) + + case (proportional_type_quotation) + ! Scoot in and draw grey + x = x + get_indent_margin(self) + font_color = DARKGRAY + + end select end if call settextstyle(self%default_font, HORIZ_DIR, font_size) - call setcolor(self%text_color) + call setcolor(font_color) call outtextxy(x, self%y, trim(text)) end subroutine ag_text_draw -- cgit v1.2.3