Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /modeline.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations) (download)
Sat Apr 7 14:27:59 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 4039 byte(s)
Changes around the windows' initialization.

1 bluedwarf 13 # modeline.rb: the module definition of Edmaru::ModeLine
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     require "modeline_element.rb"
21    
22     module Edmaru
23 bluedwarf 5
24     module ModeLine
25    
26     #Construct the modeline instance.
27     #
28 bluedwarf 6 #=== Arguments
29     #_window_ :: The parent window.
30     #_x_ :: The left edge position in the window's parent view.
31     #_y_ :: The right edge position in the window's parent view.
32     #_col_ :: The column size allocated for this modeline.
33     #
34 bluedwarf 5 #=== Warning
35     #This method *MUST* *NOT* be overrided in derived classes.
36     #
37     #=== Return
38     #An initialized instance of ModeLine.
39 bluedwarf 15 def initialize(window)
40 bluedwarf 6 @window = window
41 bluedwarf 5 @elements = Hash.new
42 bluedwarf 6 @elements_order = Array.new
43    
44 bluedwarf 15 init_ui
45 bluedwarf 4 end
46    
47 bluedwarf 5 #The system specific initialization for ModeLine.
48     #
49     #=== Warning
50     #This method *SHOULD* be overrided in derived classes.
51 bluedwarf 15 def init_ui
52 bluedwarf 4 end
53    
54 bluedwarf 5 #Add the specified _element_, an instance of ModeLineElement, to
55     #this ModeLine.
56     #
57     #=== Argument
58     #_element_ :: an instance of ModeLineElement to be added.
59     #
60     #=== Warning
61     #This method *MUST* *NOT* be overrided in derived classes.
62     #
63     #=== Return
64     #_true_ if the addition is succeeded.
65     #_false_ if the _element_'s name has already reserved.
66     def add_element(element)
67     if @elements.include?(element.name)
68     return false
69     end
70    
71     @elements[element.name] = element
72 bluedwarf 6 @elements_order.push(element.name)
73 bluedwarf 4 end
74    
75 bluedwarf 5 #Show the specified element.
76     #
77     #=== Argument
78     #_name_ :: the name of the element.
79     #
80     #=== Warning
81     #This method *MUST* *NOT* be overrided in derived classes.
82     def show_element(name)
83 bluedwarf 6 if !@elements.include?(name) || @elements[name].visible?
84 bluedwarf 5 return
85     end
86    
87     @elements[name].visible = true
88 bluedwarf 6 refresh
89 bluedwarf 4 end
90    
91 bluedwarf 5 #Hide the specified element.
92     #
93     #=== Argument
94     #_name_ :: the name of the element.
95     #
96     #=== Warning
97     #This method *MUST* *NOT* be overrided in derived classes.
98     def hide_element(name)
99 bluedwarf 6 if !@elements.include?(name) || !@elements[name].visible?
100 bluedwarf 5 return
101     end
102    
103     @elements[name].visible = false
104 bluedwarf 15 refresh
105     end
106 bluedwarf 5
107 bluedwarf 15 #Set the text of the specified element.
108     #
109     #=== Warning
110     #This method *MUST* *NOT* be overrided in derived classes.
111     #
112     #=== Argument
113     #_name_ :: the name of this element
114     #_text_ :: a new text to be set as the text of the specified element.
115     def set_element_text(name, text)
116     if !@elements.include?(name) || @elements[name].text == text
117     return
118     end
119    
120     @elements[name].text = text
121 bluedwarf 6 refresh
122 bluedwarf 5 end
123    
124 bluedwarf 15
125 bluedwarf 5 #Get the specified element.
126     #
127     #=== Warning
128     #This method *MUST* *NOT* be overrided in derived classes.
129     #
130     #=== Argument
131     #_name_ :: the name of the element.
132     #
133     #=== Return
134     #An instance of ModeLineElement whose name is the specified name
135     #or _nil_ if the specified name is not registered.
136     def get_element(name)
137     if !@elements.include?(name)
138     return nil
139     end
140    
141     @elements[name]
142     end
143    
144 bluedwarf 6 #Redraws this modeline.
145     #
146     #=== Warning
147     #This method *SHOULD* be overrided in derived classes.
148     def refresh
149     end
150    
151 bluedwarf 5 #Terminate this modeline instance.
152     #
153     #=== Warning
154     #This method *SHOULD* be overrided in derived classes.
155 bluedwarf 4 def terminate
156     end
157     end
158     end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26