aboutsummaryrefslogtreecommitdiff
path: root/ag_render.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2020-05-14 17:37:50 -0400
committerJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2020-05-14 17:37:50 -0400
commit899de86b69bc3982b61fc25a8b1c7af74a0f30e9 (patch)
treef9096e19b2cac155557ea5fe256b9ccfd48d18c6 /ag_render.f90
parente43a36b1a00a8b96585a9fb4b622645f9b5eb025 (diff)
downloadLR-87-899de86b69bc3982b61fc25a8b1c7af74a0f30e9.zip
LR-87-899de86b69bc3982b61fc25a8b1c7af74a0f30e9.tar.gz
Added scrolling and status bar to windows GUI renderer
Diffstat (limited to 'ag_render.f90')
-rw-r--r--ag_render.f90101
1 files changed, 95 insertions, 6 deletions
diff --git a/ag_render.f90 b/ag_render.f90
index 34883e4..be21112 100644
--- a/ag_render.f90
+++ b/ag_render.f90
@@ -33,12 +33,14 @@ implicit none
integer, parameter::max_links_displayed = 64
integer, volatile::ag_render_event
+ integer, volatile::scroll_position
integer, parameter::ag_render_event_none = 0
integer, parameter::ag_render_event_closed = 1
integer, parameter::ag_render_event_mouse = 2
integer, parameter::ag_render_event_back = 3
integer, parameter::ag_render_event_go = 4
+ integer, parameter::ag_render_event_scroll = 5
type :: link
integer, dimension(4)::location
@@ -51,6 +53,7 @@ implicit none
integer::address_id
integer::go_button_id
integer::back_button_id
+ integer::scroll_id
integer::font_size
integer::default_font
@@ -64,10 +67,15 @@ implicit none
integer::background_color
integer::address_bar_height
+ integer::scroll_bar_width
+ integer::status_bar_height
integer::link_count
type(link), dimension(max_links_displayed)::links
+ ! Needed to compute document height
+ integer::initial_y
+
contains
procedure :: initialize => ag_initialize
@@ -146,6 +154,17 @@ contains
end subroutine mouse_button_callback
+ subroutine scrolled_callback(x)
+ use appgraphics, only: stopidle
+ implicit none
+
+ integer::x
+ scroll_position = x
+ ag_render_event = ag_render_event_scroll
+ call stopidle()
+
+ end subroutine scrolled_callback
+
subroutine draw_address_bar(self)
use appgraphics
implicit none
@@ -191,6 +210,56 @@ contains
end subroutine draw_address_bar
+ subroutine draw_status_bar(self, text)
+ use appgraphics
+ implicit none
+
+ type(appgraphics_renderer)::self
+ character(*), intent(in)::text
+
+ self%status_bar_height = 16
+
+ call resetviewport()
+
+ call setfillstyle(SOLID_FILL, LIGHTGRAY)
+ call setbkcolor(LIGHTGRAY)
+ call setcolor(BLACK)
+ call settextstyle(WINDOWS_FONT, HORIZ_DIR, 12)
+
+ call bar(0, getmaxy()-self%status_bar_height, getmaxx(), getmaxy())
+ call outtextxy(self%left_border+2, getmaxy()-self%status_bar_height+2, trim(text))
+
+ end subroutine draw_status_bar
+
+ subroutine draw_scroll_bar(self)
+ use appgraphics
+ implicit none
+
+ type(appgraphics_renderer)::self
+
+ integer::h
+
+ self%scroll_bar_width = 15
+ h = getmaxy()-self%address_bar_height-self%status_bar_height
+ if(self%scroll_id == 0) then
+ self%scroll_id = createscrollbar(getmaxx()-self%scroll_bar_width, &
+ self%address_bar_height, &
+ self%scroll_bar_width, &
+ h, &
+ SCROLL_VERTICAL, &
+ scrolled_callback)
+
+ call setscrollrange(self%scroll_id, 0, 100)
+ else
+ call setscrollbarposition(self%scroll_id, &
+ getmaxx()-self%scroll_bar_width, &
+ self%address_bar_height, &
+ self%scroll_bar_width, &
+ h)
+ end if
+
+ end subroutine draw_scroll_bar
+
subroutine ag_initialize(self)
use appgraphics
implicit none
@@ -207,8 +276,11 @@ contains
self%address_id = 0
self%go_button_id = 0
self%back_button_id = 0
+ self%scroll_id = 0
call draw_address_bar(self)
+ call draw_status_bar(self, "Welcome to the LR-87 Gemini Client")
+ call draw_scroll_bar(self)
self%background_color = WHITE
self%text_color = BLACK
@@ -236,7 +308,7 @@ contains
get_clicked_link = -1
mx = mousex()
my = mousey()
-
+ my = my - self%address_bar_height
do i = 1, self%link_count
if(my >= self%links(i)%location(2) .and. my <= self%links(i)%location(4) .and. &
mx >= self%links(i)%location(1) .and. mx <= self%links(i)%location(3)) then
@@ -257,11 +329,16 @@ contains
call setbkcolor(self%background_color)
call resetviewport()
- call setviewport(0, self%address_bar_height+1, getmaxx(), getmaxy(), .true.)
+ call setviewport(0, &
+ self%address_bar_height+1, &
+ getmaxx() - self%scroll_bar_width - 1, &
+ getmaxy() - self%status_bar_height, &
+ .true.)
call clearviewport()
self%link_count = 0
+ self%initial_y = self%y
end subroutine ag_prepare_for_layout
@@ -271,6 +348,8 @@ contains
class(appgraphics_renderer)::self
self%y = 0
+ call setscrollposition(self%scroll_id, 0)
+ ag_render_event = ag_render_event_none
end subroutine ag_new_page
@@ -528,7 +607,7 @@ contains
class(appgraphics_renderer)::self
character(*), intent(in)::text
- ! Pass for now...
+ call draw_status_bar(self, text)
end subroutine ag_draw_status
@@ -543,10 +622,12 @@ contains
integer::link_clicked
integer::ignored
- ag_render_event = ag_render_event_none
+ ! For scrolling
+ integer::doclength
- ! Pass for now...
- call startidle(10000)
+ if(ag_render_event == ag_render_event_none) then
+ call startidle(10000)
+ end if
ag_action = render_action_none
select case (ag_render_event)
@@ -570,8 +651,16 @@ contains
call clearmouseclick(MOUSE_LB_UP)
+ case(ag_render_event_scroll)
+ doclength = self%y - self%initial_y
+ self%y = (doclength * scroll_position) / (-100)
+ ag_action = render_action_layout
+
end select
+ ! We've handled the event here, reset to none
+ ag_render_event = ag_render_event_none
+
end function ag_action
function ag_request_save_filename(self, url, mimetype, filename)