00001
00010
00013 package pkgMcj;
00014 import pkgView.*;
00015
00016 import java.util.*;
00017 import java.text.*;
00018
00020 public class MenuBar {
00021
00022 private RowCol rc;
00023 private int defaultColor, activeColor, numCols;
00024 private boolean isReady = false;
00025
00026 private Vector vector;
00027
00028 private ScreenKit sk = ScreenKit.getSingleton();
00029 private Keyboard kb = Keyboard.getSingleton();
00030 private TextItem titleMcj;
00031 private Mcj mcj;
00032 private DropMenu dm;
00033
00034 private DropMenu leftMenu;
00035 private DropMenu fileMenu;
00036 private DropMenu optMenu;
00037 private DropMenu cmdMenu;
00038 private DropMenu rightMenu;
00039
00040
00050 public MenuBar(Mcj parent){
00051 this.mcj = parent;
00052 rc = new RowCol(this,0,0);
00053 this.numCols = 79;
00054 this.setColors( sk.PAIR_BLACK_CYAN, sk.PAIR_WHITE_BLACK );
00055 vector = new Vector();
00056 titleMcj = new TextItem(" ", numCols);
00057
00058 titleMcj.setText(" MCJ - Midnight Commander in Java [06sep04a] " );
00059
00060 titleMcj.setColors( defaultColor, activeColor);
00061 titleMcj.setPosition(0, 0);
00062 titleMcj.setAttribute(sk.SK_BOLD);
00063 titleMcj.setSelected(false);
00064
00065 leftMenu = new DropMenu( mcj, "Left", 0, 3 );
00066 fileMenu = new DropMenu( mcj, "File", 0, 11 );
00067 cmdMenu = new DropMenu( mcj, "Command", 0, 20 );
00068 optMenu = new DropMenu( mcj, "Options", 0, 32);
00069 rightMenu = new DropMenu( mcj, "Right", 0, 44 );
00070
00071 this.addItem( leftMenu );
00072 this.addItem( fileMenu );
00073 this.addItem( cmdMenu );
00074 this.addItem( optMenu );
00075 this.addItem( rightMenu );
00076
00077 }
00078
00079
00083 public void redraw(){
00084 if( !hasFocus() ){
00085 titleMcj.redraw();
00086 sk.ttyRefresh();
00087 return;
00088 }
00089 sk.ttyDrawHline( rc.yPos,rc.xPos,' ',numCols,defaultColor);
00090 for( int i=0; i < vector.size(); i++ ){
00091 dm = (DropMenu)vector.elementAt(i);
00092 dm.redraw();
00093 }
00094 sk.ttyRefresh();
00095 }
00096
00097
00101 private void addItem( DropMenu dropMenu ){
00102 vector.add(dropMenu);
00103 }
00104
00105
00111 private boolean hasFocus( ){
00112 int tv = mcj.currentMode;
00113
00114 boolean tf = false;
00115 if( tv == mcj.STATE_PULDN ){
00116 tf = true;
00117 }
00118 return tf;
00119 }
00120
00121
00129 public void setColors( int color1, int color2 ){
00130 defaultColor = color1;
00131 activeColor = color2;
00132 }
00133
00134
00141 public boolean checkKey( boolean flag,int keyItem ){
00142 if( flag ) {
00143
00144 return flag;
00145 }
00146
00147
00148
00149 int tv;
00150
00151 if( keyItem == kb.KEY_NEWMODE ){
00152 redraw();
00153 return false;
00154 }
00155
00156 if( keyItem == kb.KEY_F9 ){
00157 tv = mcj.STATE_PULDN;
00158 mcj.setState( tv );
00159 }
00160
00161 if( keyItem == kb.KEY_ESC ){
00162 tv = mcj.STATE_2PL;
00163 mcj.setState( tv );
00164 }
00165
00166
00167
00168
00169
00170
00171 tv = updateTabbing( keyItem );
00172 if( tv != mcj.STATE_NULL ){
00173 redraw();
00174 mcj.setState( tv );
00175 return true;
00176 }
00177 return false;
00178 }
00179
00180
00181
00186 private boolean updateActive(){
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 return false;
00200 }
00201
00202
00209 private int updateTabbing( int k ){
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 return mcj.STATE_NULL;
00223 }
00224
00225
00226
00227 }
00228
00229
00230
00240 class RowCol {
00241
00242 int
00243 yPos,
00244 xPos;
00245
00246
00254 RowCol( MenuBar mb, int y, int x ){
00255 this.setPosition(mb,y,x);
00256 }
00257
00258
00259 private RowCol(){
00260
00261 }
00262
00263
00270 public void setPosition( MenuBar mb, int y, int x){
00271 yPos = y;
00272 xPos = x;
00273 if( yPos < 0 ){
00274 yPos = 0;
00275 }
00276 else{
00277 if( yPos > 79 ){
00278 yPos = 0;
00279 }
00280 }
00281
00282 }
00283
00284 }
00285