| 1 |
bluedwarf |
12 |
# window.rb: the module definition of Edmaru::Window. |
| 2 |
bluedwarf |
10 |
# |
| 3 |
|
|
# Copyright (C) 2007 Takashi Nakamoto |
| 4 |
|
|
# |
| 5 |
|
|
# This program is free software; you can redistribute it and/or modify |
| 6 |
|
|
# it under the terms of the GNU General Public License version 2 as |
| 7 |
|
|
# published by the Free Software Foundation. |
| 8 |
|
|
# |
| 9 |
|
|
# This program is distributed in the hope that it will be useful, but |
| 10 |
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
|
|
# General Public License for more details. |
| 13 |
|
|
# |
| 14 |
|
|
# You should have received a copy of the GNU General Public License |
| 15 |
|
|
# along with this program; if not, write to the Free Software |
| 16 |
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 |
|
|
# 02110-1301 USA. |
| 18 |
|
|
# |
| 19 |
bluedwarf |
4 |
|
| 20 |
bluedwarf |
9 |
require "cursor.rb" |
| 21 |
bluedwarf |
5 |
require "modeline.rb" |
| 22 |
|
|
|
| 23 |
bluedwarf |
4 |
module Edmaru |
| 24 |
bluedwarf |
5 |
|
| 25 |
bluedwarf |
6 |
#Abstract class to implement system specific window. |
| 26 |
bluedwarf |
5 |
module Window |
| 27 |
|
|
|
| 28 |
bluedwarf |
6 |
#Construct a window instance. |
| 29 |
bluedwarf |
5 |
# |
| 30 |
bluedwarf |
6 |
#=== Arguments |
| 31 |
|
|
#_view_ :: The parent view. |
| 32 |
|
|
# |
| 33 |
|
|
#=== Warning |
| 34 |
|
|
#This method *MUST* *NOT* be overrided in derived classes. |
| 35 |
|
|
# |
| 36 |
|
|
#=== Return |
| 37 |
|
|
#An initialized instance of Window. |
| 38 |
bluedwarf |
15 |
def initialize(view) |
| 39 |
bluedwarf |
6 |
@view = view |
| 40 |
bluedwarf |
9 |
@cursor = Cursor.new(0, 0) |
| 41 |
bluedwarf |
17 |
@modeline = Edmaru::SYSTEM_MODELINE.new(self) |
| 42 |
bluedwarf |
9 |
|
| 43 |
bluedwarf |
15 |
init_ui |
| 44 |
bluedwarf |
4 |
end |
| 45 |
|
|
|
| 46 |
bluedwarf |
6 |
#The system specific initialization for this window. |
| 47 |
|
|
# |
| 48 |
|
|
#=== Warning |
| 49 |
|
|
#This method *SHOULD* be overrided in derived classes. |
| 50 |
bluedwarf |
15 |
def init_ui |
| 51 |
bluedwarf |
5 |
end |
| 52 |
|
|
|
| 53 |
bluedwarf |
9 |
#Discard the current buffer and set the specified new buffer. |
| 54 |
|
|
# |
| 55 |
|
|
#=== Argument |
| 56 |
|
|
#_new_buffer_ :: The buffer to be shown in this window. |
| 57 |
|
|
def buffer=(new_buffer) |
| 58 |
|
|
if @buffer != nil |
| 59 |
|
|
@buffer.unlink(self) |
| 60 |
|
|
end |
| 61 |
bluedwarf |
4 |
|
| 62 |
bluedwarf |
9 |
#Linked buffer to this window. |
| 63 |
|
|
@buffer = new_buffer |
| 64 |
|
|
@buffer.link(self) |
| 65 |
|
|
refresh |
| 66 |
bluedwarf |
4 |
end |
| 67 |
|
|
|
| 68 |
bluedwarf |
9 |
def buffer |
| 69 |
|
|
@buffer |
| 70 |
bluedwarf |
4 |
end |
| 71 |
|
|
|
| 72 |
bluedwarf |
15 |
def modeline |
| 73 |
|
|
@modeline |
| 74 |
|
|
end |
| 75 |
|
|
|
| 76 |
bluedwarf |
9 |
#Redraw this window. |
| 77 |
|
|
# |
| 78 |
|
|
#=== Warning |
| 79 |
|
|
#This method *SHOULD* be overrided in derived clases. |
| 80 |
bluedwarf |
4 |
def refresh |
| 81 |
bluedwarf |
9 |
if @buffer == nil |
| 82 |
|
|
return |
| 83 |
|
|
end |
| 84 |
bluedwarf |
4 |
end |
| 85 |
|
|
|
| 86 |
bluedwarf |
6 |
#Terminate this view instance. |
| 87 |
|
|
# |
| 88 |
|
|
#=== Warning |
| 89 |
bluedwarf |
7 |
#This method *MUST* *NOT* be overrided in derived classes. |
| 90 |
bluedwarf |
4 |
def terminate |
| 91 |
bluedwarf |
7 |
@modeline.terminate |
| 92 |
|
|
|
| 93 |
|
|
terminate_ui |
| 94 |
bluedwarf |
4 |
end |
| 95 |
bluedwarf |
7 |
|
| 96 |
|
|
#Free system specific resources. |
| 97 |
|
|
# |
| 98 |
|
|
#=== Warning |
| 99 |
|
|
#This method *SHOULD* be overrided in derived classes. |
| 100 |
|
|
def terminate_ui |
| 101 |
|
|
end |
| 102 |
bluedwarf |
4 |
end |
| 103 |
|
|
end |