Develop and Download Open Source Software

Browse Subversion Repository

Contents of /modeline.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (show annotations) (download)
Wed Apr 4 18:10:10 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 3105 byte(s)
The new implementation of MiniWindow.

1
2 require "modeline_element.rb"
3
4 module Edmaru
5
6 module ModeLine
7
8 #Construct the modeline instance.
9 #
10 #=== Arguments
11 #_window_ :: The parent window.
12 #_x_ :: The left edge position in the window's parent view.
13 #_y_ :: The right edge position in the window's parent view.
14 #_col_ :: The column size allocated for this modeline.
15 #
16 #=== Warning
17 #This method *MUST* *NOT* be overrided in derived classes.
18 #
19 #=== Return
20 #An initialized instance of ModeLine.
21 def initialize(window, x, y, col)
22 @window = window
23 @col = col
24 @elements = Hash.new
25 @elements_order = Array.new
26
27 init_ui(x, y, col)
28 end
29
30 #The system specific initialization for ModeLine.
31 #
32 #=== Arguments
33 #_x_ :: The left edge position in the window's parent view.
34 #_y_ :: The right edge position in the window's parent view.
35 #_col_ :: The column size allocated for this modeline.
36 #
37 #=== Warning
38 #This method *SHOULD* be overrided in derived classes.
39 def init_ui(x, y, col)
40 end
41
42 #Add the specified _element_, an instance of ModeLineElement, to
43 #this ModeLine.
44 #
45 #=== Argument
46 #_element_ :: an instance of ModeLineElement to be added.
47 #
48 #=== Warning
49 #This method *MUST* *NOT* be overrided in derived classes.
50 #
51 #=== Return
52 #_true_ if the addition is succeeded.
53 #_false_ if the _element_'s name has already reserved.
54 def add_element(element)
55 if @elements.include?(element.name)
56 return false
57 end
58
59 @elements[element.name] = element
60 @elements_order.push(element.name)
61 end
62
63 #Show the specified element.
64 #
65 #=== Argument
66 #_name_ :: the name of the element.
67 #
68 #=== Warning
69 #This method *MUST* *NOT* be overrided in derived classes.
70 def show_element(name)
71 if !@elements.include?(name) || @elements[name].visible?
72 return
73 end
74
75 @elements[name].visible = true
76
77 refresh
78 end
79
80 #Hide the specified element.
81 #
82 #=== Argument
83 #_name_ :: the name of the element.
84 #
85 #=== Warning
86 #This method *MUST* *NOT* be overrided in derived classes.
87 def hide_element(name)
88 if !@elements.include?(name) || !@elements[name].visible?
89 return
90 end
91
92 @elements[name].visible = false
93
94 refresh
95 end
96
97 #Get the specified element.
98 #
99 #=== Warning
100 #This method *MUST* *NOT* be overrided in derived classes.
101 #
102 #=== Argument
103 #_name_ :: the name of the element.
104 #
105 #=== Return
106 #An instance of ModeLineElement whose name is the specified name
107 #or _nil_ if the specified name is not registered.
108 def get_element(name)
109 if !@elements.include?(name)
110 return nil
111 end
112
113 @elements[name]
114 end
115
116 #Redraws this modeline.
117 #
118 #=== Warning
119 #This method *SHOULD* be overrided in derived classes.
120 def refresh
121 end
122
123 #Terminate this modeline instance.
124 #
125 #=== Warning
126 #This method *SHOULD* be overrided in derived classes.
127 def terminate
128 end
129 end
130 end

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