aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ag_render.f90158
1 files changed, 125 insertions, 33 deletions
diff --git a/ag_render.f90 b/ag_render.f90
index 4d9be55..34883e4 100644
--- a/ag_render.f90
+++ b/ag_render.f90
@@ -32,8 +32,13 @@ implicit none
integer, parameter::max_links_displayed = 64
- logical, volatile::closed_browser
- logical, volatile::mouse_clicked
+ integer, volatile::ag_render_event
+
+ 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
type :: link
integer, dimension(4)::location
@@ -43,6 +48,9 @@ implicit none
type, extends(renderer) :: appgraphics_renderer
integer::window_id
+ integer::address_id
+ integer::go_button_id
+ integer::back_button_id
integer::font_size
integer::default_font
@@ -55,6 +63,8 @@ implicit none
integer::link_color
integer::background_color
+ integer::address_bar_height
+
integer::link_count
type(link), dimension(max_links_displayed)::links
@@ -99,29 +109,106 @@ implicit none
contains
subroutine window_closing_callback()
+ use appgraphics, only: stopidle
implicit none
- closed_browser = .true.
+ ag_render_event = ag_render_event_closed
call stopidle()
end subroutine window_closing_callback
- subroutine ag_initialize(self)
+ subroutine back_button_callback()
+ use appgraphics, only: stopidle
+ implicit none
+
+ ag_render_event = ag_render_event_back
+ call stopidle()
+
+ end subroutine back_button_callback
+
+ subroutine go_button_callback()
+ use appgraphics, only: stopidle
+ implicit none
+
+ ag_render_event = ag_render_event_go
+ call stopidle()
+
+ end subroutine go_button_callback
+
+ subroutine mouse_button_callback(x, y)
+ use appgraphics, only: stopidle
+ implicit none
+
+ integer::x, y
+
+ ag_render_event = ag_render_event_mouse
+ call stopidle()
+
+ end subroutine mouse_button_callback
+
+ subroutine draw_address_bar(self)
use appgraphics
implicit none
- class(appgraphics_renderer)::self
+ type(appgraphics_renderer)::self
+
+ integer::x, address_width
+
+ self%address_bar_height = 24
- closed_browser = .false.
- mouse_clicked = .false.
+ ! Set up some address bar colors
+ call setfillstyle(SOLID_FILL, LIGHTGRAY)
+ call setbkcolor(LIGHTGRAY)
+ call setcolor(BLACK)
+ call settextstyle(WINDOWS_FONT, HORIZ_DIR, 12)
+
+ call bar(0, 0, getmaxx(), self%address_bar_height)
+ x = getmaxx()/4 - 40
+ if(self%back_button_id == 0) then
+ self%back_button_id = createbutton(x, 2, 40, 20, "Back", back_button_callback)
+ else
+ call setbuttonposition(self%back_button_id, x, 2, 40, 20)
+ end if
+
+ x = x + 50
+ call outtextxy(x, 5, "Address:")
+
+ x = x + textwidth("Address:") + 5
+ address_width = getmaxx()/2 - textwidth("Address:") - 5
+ if(self%address_id == 0) then
+ self%address_id = createtextbox(x, 2, address_width, 20)
+ else
+ call settextboxposition(self%address_id, x, 2, address_width, 20)
+ end if
+
+ x = x + 10 + address_width
+ if(self%go_button_id == 0) then
+ self%go_button_id = createbutton(x, 2, 40, 20, "Go!", go_button_callback)
+ else
+ call setbuttonposition(self%go_button_id, x, 2, 40, 20)
+ end if
+
+ end subroutine draw_address_bar
+
+ subroutine ag_initialize(self)
+ use appgraphics
+ implicit none
+
+ class(appgraphics_renderer)::self
+
self%window_id = initwindow(default_width, default_height, "LR-87", &
DEFAULT_POSITION, DEFAULT_POSITION, &
.FALSE., .FALSE.)
call setwindowclosecallback(window_closing_callback)
+ call registermousehandler(MOUSE_LB_UP, mouse_button_callback)
- call registermousehandler(MOUSE_LB_UP, mouse_button_clicked)
+ self%address_id = 0
+ self%go_button_id = 0
+ self%back_button_id = 0
+
+ call draw_address_bar(self)
self%background_color = WHITE
self%text_color = BLACK
@@ -161,17 +248,6 @@ contains
end function get_clicked_link
- subroutine mouse_button_clicked(x, y)
- use appgraphics, only: stopidle
- implicit none
-
- integer::x, y
-
- mouse_clicked = .true.
- call stopidle()
-
- end subroutine mouse_button_clicked
-
subroutine ag_prepare_for_layout(self)
use appgraphics
implicit none
@@ -180,6 +256,9 @@ contains
call setbkcolor(self%background_color)
call resetviewport()
+
+ call setviewport(0, self%address_bar_height+1, getmaxx(), getmaxy(), .true.)
+
call clearviewport()
self%link_count = 0
@@ -462,27 +541,36 @@ contains
character(*), intent(out)::text
integer::ag_action
integer::link_clicked
+ integer::ignored
+
+ ag_render_event = ag_render_event_none
! Pass for now...
call startidle(10000)
ag_action = render_action_none
-
- if(closed_browser) then
-
- ag_action = render_action_quit
-
- else if(mouse_clicked) then
-
- link_clicked = get_clicked_link(self)
- if(link_clicked > 0) then
- text = self%links(link_clicked)%url
+ select case (ag_render_event)
+
+ case(ag_render_event_closed)
+ ag_action = render_action_quit
+
+ case(ag_render_event_back)
+ ag_action = render_action_back
+
+ case(ag_render_event_go)
+ ignored = gettextboxcontents(self%address_id, text)
ag_action = render_action_goto
- end if
-
- call clearmouseclick(MOUSE_LB_UP)
+
+ case(ag_render_event_mouse)
+ link_clicked = get_clicked_link(self)
+ if(link_clicked > 0) then
+ text = self%links(link_clicked)%url
+ ag_action = render_action_goto
+ end if
+
+ call clearmouseclick(MOUSE_LB_UP)
- end if
+ end select
end function ag_action
@@ -508,6 +596,10 @@ contains
character(*), intent(in)::text
call setwindowtitle("LR-87 :: "//trim(text))
+
+ if(index(text, "gemini://") > 0) then
+ call settextboxcontents(self%address_id, trim(text))
+ end if
end subroutine ag_report_page