root/BF_GUI_WinMain.cpp

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. AddPanel
  2. RemovePanel
  3. FocusedPanel
  4. PanelByIndexFromList
  5. PanelByIndex
  6. PanelOnTop
  7. PanelRect
  8. InitViews
  9. AttachedToWindow
  10. FrameResized
  11. Spec_MouseDown
  12. MouseDown
  13. MessageReceived
  14. EnablePanels
  15. ShowPanels
  16. QuitRequested
  17. WindowActivated
  18. FrameResized
  19. MessageReceived

   1 #include <stdio.h>
   2 #include <Application.h>
   3 #include <Autolock.h>
   4 
   5 #include "BF_GUI_Misc.h"
   6 
   7 #include "BF_Def.h"
   8 #include "BF_Dict.h"
   9 #include "BF_Roster.h"
  10 #include "BF_Msg.h"
  11 #include "BF_GUI_WinMain.h"
  12 #include "BF_GUI_KeysMenu.h"
  13 #include "BF_GUI_CmdLine.h"
  14 #include "BF_GUI_TopMenu.h"
  15 #include "BF_BetaTesting.h"
  16 //
  17 #include "BF_GUI_OperRoster.h"
  18 //
  19 #include "BF_GUI_FilesPanel.h"
  20 #include "BF_GUI_FtpPanel.h"
  21 #include "BF_GUI_ArcPanel.h"
  22 #include "BF_GUI_ImagePanel.h"
  23 
  24 #include "BF_GUI_SetupDialog.h"
  25 
  26 #include "BF_GUI_OperRoster.h"  
  27 
  28 BWindow                         *poWin=NULL; 
  29 BF_GUI_ViewMain         *poWinView=NULL;
  30 
  31 BF_GUI_ViewMain::BF_GUI_ViewMain(const BRect & o_Rect)
  32 :BView(o_Rect,"win_view",B_FOLLOW_ALL,B_WILL_DRAW|B_FRAME_EVENTS)
  33 {
  34         rgb_color oCol;
  35         RGB_SET(oCol,0,0,0);
  36         SetViewColor(oCol);     
  37         poWinView = this;
  38         poLastFocus = NULL;     
  39         /////   
  40         InitViews();                    
  41         /////
  42         BF_GUI_OperRoster_Init();
  43 }   
  44 
  45 void
  46 BF_GUI_ViewMain::AddPanel(BF_GUI_Panel* po_Panel)    /* [previous][next][first][last][top][bottom][index][help] */
  47 {
  48         ASSERT(po_Panel);       
  49         
  50         BAutolock oLocker(poWin);
  51         if(!oLocker.IsLocked()){                
  52                 return;
  53         }
  54 
  55         // hide old panel //
  56         BF_GUI_Panel*   poLastPanel = PanelOnTop(po_Panel->bWinPos_OnLeft);
  57         bool                    bThisSideInFocus = false;
  58         if(poLastPanel){        
  59                 bThisSideInFocus = poLastPanel->IsFocus();
  60                 if(bThisSideInFocus) MakeFocus(false);
  61                 poLastPanel->Enable(false);
  62                 poLastPanel->Hide();
  63         }
  64 
  65         // add and show new panel //    
  66         BL_Collection *ploPanel = (po_Panel->bWinPos_OnLeft?&loLeftPanel:&loRightPanel);
  67         ASSERT( ploPanel );
  68         
  69         ploPanel->AddItem( po_Panel );
  70         loAllPanel.AddItem( po_Panel );
  71         AddChild ( po_Panel );                  
  72         
  73         if(bThisSideInFocus) po_Panel->MakeFocus(true);
  74 }
  75 
  76 void                            
  77 BF_GUI_ViewMain::RemovePanel(BF_GUI_Panel* po_Panel)    /* [previous][next][first][last][top][bottom][index][help] */
  78 {               
  79         ASSERT(po_Panel);
  80 
  81         BAutolock oLocker(poWin);
  82         
  83         BView *poCurrentFocus = Window()->CurrentFocus();
  84         
  85         bool bOnTop = (po_Panel == PanelOnTop(po_Panel->bWinPos_OnLeft));       
  86         
  87         BL_Collection *ploPanel = (po_Panel->bWinPos_OnLeft?&loLeftPanel:&loRightPanel);
  88         ASSERT(ploPanel);
  89         ploPanel->RemoveItem( po_Panel );               
  90         
  91         po_Panel->RemoveSelf();
  92         loAllPanel.RemoveItem( po_Panel );              
  93         
  94         if(bOnTop){
  95                 BF_GUI_Panel* poLastPanel = PanelOnTop(po_Panel->bWinPos_OnLeft);
  96                 if(!poLastPanel){
  97                         poLastPanel = PanelOnTop(!po_Panel->bWinPos_OnLeft);
  98                 }
  99                 if(poLastPanel){
 100                         poLastPanel->Show();
 101                         poLastPanel->Enable(true);
 102                         if(poCurrentFocus==po_Panel) poLastPanel->MakeFocus();
 103                 };
 104         }
 105         
 106         DELETE(po_Panel);
 107 }
 108 
 109 BF_GUI_Panel*   
 110 BF_GUI_ViewMain::FocusedPanel() const    /* [previous][next][first][last][top][bottom][index][help] */
 111 {
 112         BF_GUI_Panel* po=NULL;
 113         BView *poFocus = poWin->CurrentFocus(); 
 114         if(!poFocus) return NULL;
 115         
 116         po = PanelOnTop(true);
 117         if(po==poFocus) return po;
 118         po = PanelOnTop(false);
 119         if(po==poFocus) return po;
 120         return NULL;
 121 }
 122 
 123 BF_GUI_Panel*           
 124 BF_GUI_ViewMain::PanelByIndexFromList(const BL_Collection & lo_Panel,int i_Index) const    /* [previous][next][first][last][top][bottom][index][help] */
 125 {       
 126         if(i_Index<0) i_Index = loLeftPanel.CountItems()-2;
 127         if(i_Index<0) return NULL;
 128         BF_GUI_Panel *po = (BF_GUI_Panel*)lo_Panel.ItemAt(i_Index);
 129         return po;
 130 }
 131 
 132 BF_GUI_Panel*           
 133 BF_GUI_ViewMain::PanelByIndex(bool b_Left,int i_Index) const    /* [previous][next][first][last][top][bottom][index][help] */
 134 {
 135         if(b_Left)
 136                 return PanelByIndexFromList(loLeftPanel,i_Index);
 137         else
 138                 return PanelByIndexFromList(loRightPanel,i_Index);
 139 }
 140 
 141 
 142 BF_GUI_Panel*           
 143 BF_GUI_ViewMain::PanelOnTop(bool b_Left) const    /* [previous][next][first][last][top][bottom][index][help] */
 144 {
 145         return PanelByIndex(b_Left,b_Left?(loLeftPanel.CountItems()-1):(loRightPanel.CountItems()-1));
 146 }
 147 
 148 const BRect
 149 BF_GUI_ViewMain::PanelRect(bool b_LeftPos) const    /* [previous][next][first][last][top][bottom][index][help] */
 150 {
 151         BRect  oRect(Bounds());
 152         
 153         float fBotHeight = poSysSetup->oFontNode.fHeight + poSysSetup->oFontCMDLine.fHeight;
 154         float fWidthPanel = oRect.Width()/2;
 155 
 156         if(b_LeftPos){          
 157                 oRect.bottom-=fBotHeight;
 158                 oRect.right = oRect.left + fWidthPanel; 
 159         }else{
 160                 oRect.bottom-=fBotHeight;
 161                 oRect.left+=fWidthPanel;
 162                 oRect.right = oRect.left + fWidthPanel; 
 163         }
 164         
 165         return oRect;
 166                         
 167 }
 168 
 169 void
 170 BF_GUI_ViewMain::InitViews()    /* [previous][next][first][last][top][bottom][index][help] */
 171 {                       
 172         //
 173         BRect oRect;    
 174         
 175         /* set command_view */  
 176         
 177         /* BF_MSG_SETUP_UPDATED
 178         oRect = Bounds();
 179         oRect.top = oRect.bottom-fBotHeight;
 180         oRect.bottom-= fBotHeight;
 181         poBackground = new BView(oRect,"background",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM,
 182                 B_WILL_DRAW);   
 183         poBackground->SetViewColor(0,0,0);      
 184         AddChild(poBackground);                         
 185         */
 186         /* make  files panel */         
 187         
 188         //      default left panel              
 189         
 190         BF_GUI_FilesPanel *po1;
 191         po1 = new BF_GUI_FilesPanel(PanelRect(true),BF_PANEL_WINPOS_LEFT);      
 192         AddPanel(po1);  
 193         po1->Calc();
 194                 
 195         //      default right panel             
 196         
 197         /*BF_GUI_FtpPanel *po2;
 198         po2 = new       BF_GUI_FtpPanel(oRect,BF_PANEL_WINPOS_RIGHT);                   
 199         AddPanel(po2,false);    */
 200         /*BF_GUI_ImagePanel *po2;
 201         po2 = new       BF_GUI_ImagePanel(oRect,"image",BF_PANEL_WINPOS_RIGHT);                 
 202         AddPanel(po2,false);    */      
 203                 
 204         BF_GUI_FilesPanel *po2; 
 205         po2 = new BF_GUI_FilesPanel(PanelRect(false),BF_PANEL_WINPOS_RIGHT);    
 206         AddPanel(po2);  
 207         po2->Calc();
 208         
 209         //      
 210         /* make bottom command_line */          
 211         oRect = Bounds();
 212         oRect.bottom -= poSysSetup->oFontNode.fHeight;
 213         oRect.top = oRect.bottom-poSysSetup->oFontCMDLine.fHeight;
 214         AddChild( new BF_GUI_CmdLine(oRect) );
 215 
 216         /* make bottom keys_menu */     
 217         oRect = Bounds();
 218         oRect.top = oRect.bottom-poSysSetup->oFontNode.fHeight+1;
 219         poSysKeysMenu = new BF_GUI_KeysMenu(oRect);
 220         AddChild(poSysKeysMenu);
 221         //
 222         //poPanelLeft->PrepareKeysMenu();
 223         //      
 224         poWin->AddShortcut('n',B_COMMAND_KEY,new BMessage(BF_MSG_MAINVIEW_RUN_BEFAR),this);             
 225         //              
 226 }
 227 
 228 void                            
 229 BF_GUI_ViewMain::AttachedToWindow(void)    /* [previous][next][first][last][top][bottom][index][help] */
 230 {
 231         BF_GUI_FilesPanel *poPanel = NULL;
 232         
 233         poPanel = (BF_GUI_FilesPanel*)PanelOnTop(true);
 234         if(poPanel)     poPanel->Pub_GoPath(poSysSetup->oVars.Loaded()?poSysSetup->oVars.oLPanel.sPath.String():"/boot/home");  
 235         poPanel = (BF_GUI_FilesPanel*)PanelOnTop(false);
 236         if(poPanel)     poPanel->Pub_GoPath(poSysSetup->oVars.Loaded()?poSysSetup->oVars.oRPanel.sPath.String():"/boot/home");  
 237         
 238         poPanel = (BF_GUI_FilesPanel*)PanelOnTop(true);
 239         if(poPanel) poPanel->MakeFocus();
 240         //      
 241         //poPanelLeft->ChangePath(BF_Path("/"));                
 242         ////poPanelRight->ChangePath(BF_Path("/boot/home/mail/BeOS/UserTalks"));
 243         //poPanelRight->ChangePath(BF_Path("/boot/home"));
 244         //              
 245         BView::AttachedToWindow();
 246 
 247         if(iBetaTestingStatus==BF_BETATEST_ASK_KEY) BF_BetaTesting_CheckKey_Start(PanelOnTop(true));
 248 }
 249 
 250 void                            
 251 BF_GUI_ViewMain::FrameResized(float width, float height)    /* [previous][next][first][last][top][bottom][index][help] */
 252 {
 253         //BView::FrameResized(width,height);
 254         //return;
 255 
 256         BMessage oMessage(BF_MSG_VIEW_MAINWIN_RESIZED);
 257         oMessage.AddFloat("width",width);
 258         oMessage.AddFloat("height",height);
 259 
 260         Window()->Lock();
 261         for(int i=0;i<CountChildren();i++){
 262                 //ChildAt(i)->FrameResized(width,height);       
 263                 BMessenger oMessenger(ChildAt(i));
 264                 oMessenger.SendMessage(&oMessage);      
 265         }
 266         Window()->Unlock();
 267         /*
 268         printf("resize\n");
 269         //
 270         Window()->Lock();
 271         BRect oRect=Bounds();
 272         poPanelLeft->ResizeTo(oRect.Width()/2-1,oRect.Height()-CMD_SIZE);
 273         //
 274         oRect=Bounds();
 275         poPanelRight->MoveTo(oRect.Width()/2,0);
 276         poPanelRight->ResizeTo(oRect.Width()/2,oRect.Height()-CMD_SIZE);
 277         Window()->Unlock();
 278         */
 279 }
 280 
 281 void
 282 BF_GUI_ViewMain::Spec_MouseDown(const BPoint & o_Point,BView *po_FromView)    /* [previous][next][first][last][top][bottom][index][help] */
 283 {
 284         BView *poView;
 285         BRect oChildFrame;
 286         for(int iChild=CountChildren()-1;iChild>=0;iChild--){
 287                 poView = ChildAt(iChild);
 288                 if(poView==po_FromView) continue;
 289                 
 290                 oChildFrame = poView->Frame();          
 291                 if(oChildFrame.Contains(o_Point)){
 292                         BPoint oPoint(o_Point);
 293                         oPoint.x -= oChildFrame.left;
 294                         oPoint.y -= oChildFrame.top;                    
 295                         poView->MouseDown(oPoint);
 296                         return;
 297                 }               
 298         }
 299 }
 300 
 301 void                            
 302 BF_GUI_ViewMain::MouseDown(BPoint point)    /* [previous][next][first][last][top][bottom][index][help] */
 303 {
 304         Spec_MouseDown(point,this);
 305 }
 306 
 307 void
 308 BF_GUI_ViewMain::MessageReceived(BMessage * po_Message)     /* [previous][next][first][last][top][bottom][index][help] */
 309 {       
 310         ASSERT(po_Message);
 311 
 312         switch(po_Message->what){       
 313         //////////
 314         case BF_MSG_MAINVIEW_SELECTDICT:
 315                 Action_SelectDict();
 316                 break;
 317         case BF_MSG_MAINVIEW_SELECTDICT_1:
 318                 Action_SelectDict_1(po_Message);
 319                 break;
 320         /////////       
 321         case BF_MSG_SETUP_UPDATED:{                                     
 322                 if(po_Message->HasPointer("BF_GUI_ViewMain::sender")) return;
 323                 BView *poView;
 324                 BMessage oMessage(BF_MSG_SETUP_UPDATED);                
 325                 oMessage.AddPointer("BF_GUI_ViewMain::sender",(void*)this);
 326                 for(int i=0;i<CountChildren();i++){
 327                         poView = ChildAt(i);
 328                         if(!poView) continue;
 329                         BMessenger oMessenger(poView);
 330                         oMessenger.SendMessage(&oMessage);                      
 331                 }
 332                 break;}
 333         /////////       
 334         case BF_MSG_MAINVIEW_COMPART_PANELS:
 335                 Action_Compare_Panels();
 336                 break;
 337         case BF_MSG_MAINVIEW_SELVOL_FINISH:{
 338                 EnablePanels(true);
 339                 
 340                 BView *poView=NULL;
 341                 ASSERT(B_OK==po_Message->FindPointer("bf_panel_focus",(void**)&poView) && poView);
 342                 poView->MakeFocus();
 343                 
 344                 bool bPosLeft;
 345                 ASSERT(B_OK==po_Message->FindBool("bf_bPosLeft",&bPosLeft));                                            
 346                 BF_GUI_Panel *poPanel = PanelByIndex(bPosLeft,0);
 347                 if(!poPanel) return;
 348                 
 349                 // check this panel for top_position
 350                 while(true){
 351                         BF_GUI_Panel *poTopPanel = PanelOnTop(bPosLeft);
 352                         if(poPanel==poTopPanel) break;
 353                         // close top panel
 354                         if(!poTopPanel->Close()) return;
 355                 }
 356                 
 357                 const char *pcPath=NULL;
 358                 if(B_OK!=po_Message->FindString("menu_code",&pcPath) || !pcPath) return;
 359                 
 360                 
 361                 if(strcmp(pcPath,":ftp")==0){
 362                         Action_Open_FtpPanel(bPosLeft);
 363                         break;
 364                 }
 365                 
 366                 BL_String sPath("/");
 367                 sPath<<pcPath;
 368                                 
 369                 BMessage        oMessage(BF_MSG_TO_PANEL_SET_PATH);
 370                 BMessenger      oMessenger(poPanel);
 371                 oMessage.AddString("bf_cPath",sPath.String());
 372                 oMessenger.SendMessage(&oMessage);                                              
 373                 
 374                 break;}
 375         case BF_MSG_MAINVIEW_SELVOL_LEFT:
 376                 Action_SelVolume_Start(true);
 377                 break;
 378         case BF_MSG_MAINVIEW_SELVOL_RIGHT:
 379                 Action_SelVolume_Start(false);
 380                 break;
 381         case BF_MSG_MAINVIEW_MOUNTVOLUMES:
 382                 Action_MountVolumes();
 383                 break;
 384         case BF_MSG_MAINVIEW_ABOUT:{
 385                 BL_List *poList = new BL_List();
 386                 poList->AddItem(new BF_GUI_ViewMenu_Item("cool!","ok"));
 387                 poList->AddItem(new BF_GUI_ViewMenu_Item("sweet!","ok"));
 388                 BF_Dialog_Alert_Sep("About box","BeFAR, developed by Baza & BeRussia Team",
 389                         poList,poWin->CurrentFocus(),"baza@benews.ru  ,  http://www.beos.ru/projects/befar");
 390                 break;}
 391         case BF_MSG_MAINVIEW_EMPTY_TRASH:
 392                 Action_EmptyTrash();
 393                 break;
 394         // oper_roster hide self dialog, show self lenta and requere resize all panel
 395         case BF_MSG_TO_WIN_OPERLENTA_SHOWED:{
 396                 int32 iSizeY = 0;
 397                 ASSERT(B_OK==po_Message->FindInt32("bf_iSizeY",&iSizeY));
 398                 BRect oRect;
 399                 for(int i=0;i<loAllPanel.CountItems();i++){
 400                         BF_GUI_Panel *poPanel = (BF_GUI_Panel*)loAllPanel.ItemAt(i);
 401                         oRect = poPanel->Frame();
 402                         poPanel->ResizeTo(oRect.Width(),oRect.Height()-iSizeY);
 403                 }
 404                 break;}
 405         //
 406         case BF_MSG_MAINVIEW_SAVE_PALLETE:
 407                 Action_LoadSavePalete(false);
 408                 break;
 409         case BF_MSG_MAINVIEW_SAVE_PALLETE_1:
 410                 Action_SavePalete_1(po_Message);
 411                 break;
 412         case BF_MSG_MAINVIEW_LOAD_PALLETE:
 413                 Action_LoadSavePalete(true);
 414                 break;
 415         case BF_MSG_MAINVIEW_LOAD_PALLETE_1:
 416                 Action_LoadPalete_1(po_Message);
 417                 break;
 418         //
 419         case BF_MSG_MAINVIEW_MAINSETUP_SETDEFAULT:{
 420                 poSysSetup->InitDefault();
 421                 BMessenger oMessenger(poWin);
 422                 BMessage   oMessage(BF_MSG_SETUP_UPDATED);
 423                 oMessenger.SendMessage(&oMessage);              
 424                 break;}
 425         case BF_MSG_MAINVIEW_MAINSETUP_LOAD:{
 426                 poSysSetup->Load();
 427                 BMessenger oMessenger(poWin);
 428                 BMessage   oMessage(BF_MSG_SETUP_UPDATED);
 429                 oMessenger.SendMessage(&oMessage);              
 430                 break;}
 431         case BF_MSG_MAINVIEW_MAINSETUP_SAVE:    
 432                 poSysSetup->Save();
 433                 break;
 434         case BF_MSG_MAINVIEW_MAINSETUP_0:
 435                 BF_GUI_SetupDialog_Run( Window()->CurrentFocus() );
 436                 break;  
 437         case BF_MSG_FILEPANEL_BETATEST_INPUTPASSWORD:{
 438                 char *pcValue=NULL;
 439                 ASSERT(B_OK==po_Message->FindString("edit",(const char**)&pcValue) && pcValue);
 440                 BF_BetaTesting_CheckKey_Finish(pcValue);
 441                 //
 442                 EnablePanels(true);             
 443                 BF_GUI_Panel* poPanel = PanelOnTop(true);
 444                 ASSERT(poPanel);
 445                 poPanel->MakeFocus();                   
 446                 break;}
 447         case BF_MSG_MAINVIEW_MOUSE_DOWN:{
 448                 BPoint oPoint;
 449                 BView  *poFromView;
 450                 ASSERT(B_OK==po_Message->FindPoint("bf_point",&oPoint));                
 451                 ASSERT(B_OK==po_Message->FindPointer("bf_view",(void**)&poFromView));
 452                 Spec_MouseDown(oPoint,poFromView);              
 453                 break;}
 454         case BF_MSG_MAINVIEW_RUN_BEFAR:{
 455                 BL_String sPath;
 456                 BF_Path::GetPathForCurrentApp(sPath);   
 457                 BF_Roster_RunFile(sPath.String(),"BeFar");
 458                 break;};
 459         case BF_MSG_SHOWPANELS:{
 460                 bool bShow; 
 461                 ASSERT(B_OK==po_Message->FindBool("bf_bShow",&bShow));
 462                 ShowPanels(bShow);
 463                 break;}
 464         case BF_MSG_ENABLEPANELS:{
 465                 bool bEnable=false;
 466                 ASSERT(B_OK==po_Message->FindBool("bf_bEnable",&bEnable));
 467                 bool bOperRoster;
 468                 ASSERT(B_OK==po_Message->FindBool("bf_bOperRoster",&bOperRoster));              
 469                 EnablePanels(bEnable,bOperRoster);
 470                 break;}         
 471         case BF_MSG_MAINVIEW_ASK_QUIT:{
 472         
 473                 // check setup_style 
 474                 if(!(poSysSetup->MainStyle() & BF_SETUP_MAIN_ASK_EXIT)){
 475                         be_app->PostMessage(B_QUIT_REQUESTED);
 476                         return;
 477                 }       
 478                 // check for existing quit_dialog //            
 479                 if(poLastFocus) break;          
 480                 /* check for view_panel */
 481                 poLastFocus = Window()->CurrentFocus();
 482                 if(!poLastFocus) break;
 483                 {
 484                         BL_String s;
 485                         s = poLastFocus->Name();
 486                         if(s.FindFirst("_panel")<0){
 487                                 poLastFocus = NULL;
 488                                 break;          
 489                         }
 490                 }
 491                 //set  BF_App::bAskedQuit               
 492                 BMessage        oMessage(BF_MSG_MAINVIEW_ANSWER_QUIT);
 493                 oMessage.AddInt32("bf_iAnswer",1);
 494                 BMessenger      oMessenger(be_app);
 495                 oMessenger.SendMessage(&oMessage);
 496                 // make quit_dialog //          
 497                 BL_List *ploMenuItem = new BL_List();
 498                 ploMenuItem->AddItem(new BF_GUI_ViewMenu_Item("Yes",""));
 499                 ploMenuItem->AddItem(new BF_GUI_ViewMenu_Item("No",""));
 500                 BF_Dialog_Alert_Sep("Quit","Really?",ploMenuItem,this,NULL,BF_MSG_MAINVIEW_ANSWER_QUIT);
 501                 break;}         
 502         case BF_MSG_MAINVIEW_ANSWER_QUIT:{
 503                 int32 iResult=-1;
 504                 ASSERT(B_OK==po_Message->FindInt32("menu",&iResult));
 505                 if(iResult==0){
 506                         be_app->PostMessage(B_QUIT_REQUESTED);
 507                 }else{
 508                         //clear BF_App::bAskedQuit              
 509                         BMessage        oMessage(BF_MSG_MAINVIEW_ANSWER_QUIT);
 510                         oMessage.AddInt32("bf_iAnswer",0);
 511                         BMessenger      oMessenger(be_app);
 512                         oMessenger.SendMessage(&oMessage);              
 513                         //              
 514                         BF_GUI_Func_PanelsEnable(true); 
 515                         ASSERT(poLastFocus);
 516                         poLastFocus->MakeFocus(true);
 517                         poLastFocus = NULL;
 518                 }
 519                 break;}
 520         default:
 521                 BView::MessageReceived(po_Message);
 522         }
 523 }
 524 
 525 /*===========================================================================*/
 526 void                            
 527 BF_GUI_ViewMain::EnablePanels(bool b_Enable,bool bOperRoster)    /* [previous][next][first][last][top][bottom][index][help] */
 528 {
 529         BF_GUI_Panel *poPanel;
 530         for(int i=0;i<loAllPanel.CountItems();i++){
 531                 poPanel = (BF_GUI_Panel*)loAllPanel.ItemAt(i);
 532                 poPanel->Enable(b_Enable);              
 533         };      
 534         if(poCmdLine)   poCmdLine->Enable(b_Enable);
 535         if(bOperRoster && poOperRoster) poOperRoster->Enable(b_Enable);
 536 }
 537 
 538 void                            
 539 BF_GUI_ViewMain::ShowPanels(bool b_Show)    /* [previous][next][first][last][top][bottom][index][help] */
 540 {
 541         BView *po;
 542         for(int i=0;i<loAllPanel.CountItems();i++){
 543                 po = ((BView*)loAllPanel.ItemAt(i));
 544                 if(b_Show)      po->Show();     
 545                 else            po->Hide();
 546         };      
 547         if(poCmdLine){
 548                 if(b_Show)      poCmdLine->Show();
 549                 else            poCmdLine->Hide();
 550         }
 551 }
 552 
 553 /*===========================================================================*/
 554 
 555 #include <ListView.h> /// !!!!!!
 556 
 557 /*
 558 class ItemTest:public BListItem{
 559 public:
 560         virtual void            DrawItem(BView *owner,
 561                                                         BRect bounds,
 562                                                         bool complete = false){};
 563 };
 564 */
 565 
 566 BF_GUI_WinMain::BF_GUI_WinMain()
 567 :BWindow(BRect(50,100,700,550), 
 568         (BString("BeFar ")<<VERSION_STRING).String() ,
 569         B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
 570 {       
 571         // load setup // 
 572         poSysSetup = new BF_GUI_Setup();
 573         poSysSetup->Load(false);        
 574         
 575         // load dictionary //
 576         BF_Dict_Load(poSysSetup->sDictFile.String());
 577         
 578         // set new win_frame //
 579         if(poSysSetup->oVars.Loaded()){
 580                 MoveTo(poSysSetup->oVars.oWinFrame.left,poSysSetup->oVars.oWinFrame.top);
 581                 ResizeTo(poSysSetup->oVars.oWinFrame.right-poSysSetup->oVars.oWinFrame.left,poSysSetup->oVars.oWinFrame.bottom-poSysSetup->oVars.oWinFrame.top);
 582         }
 583         poWin = this;
 584         
 585         
 586         
 587         poView = new BF_GUI_ViewMain(Bounds());
 588         AddChild(poView);       
 589         
 590         SetSizeLimits(300.0,10000.0,200.0,10000.0);
 591 }
 592 
 593 BF_GUI_WinMain::~BF_GUI_WinMain()
 594 {
 595         if(poSysSetup->MainStyle() & BF_SETUP_AUTOSAVE) poSysSetup->Save();
 596 }
 597 
 598 bool
 599 BF_GUI_WinMain::QuitRequested()    /* [previous][next][first][last][top][bottom][index][help] */
 600 {       
 601         //be_app->PostMessage(B_QUIT_REQUESTED);                
 602         
 603         BMessage        oMessage(BF_MSG_MAINVIEW_ASK_QUIT);
 604         BMessenger      oMessenger(poWinView);
 605         oMessenger.SendMessage(&oMessage);              
 606         
 607         return false;
 608 }
 609 
 610 void                            
 611 BF_GUI_WinMain::WindowActivated(bool b_Active)    /* [previous][next][first][last][top][bottom][index][help] */
 612 {
 613         //BBitmap *po;
 614         //BF_GUI_GetBitmapFromResources(po,200);
 615 
 616 
 617         if(b_Active){
 618                 BView *poFocus = CurrentFocus();
 619                 if(poFocus){
 620                         BMessenger      oMessenger(poFocus);
 621                         BMessage        oMessage(BF_MSG_TOTAL_WIN_RECEIVE_FOCUS);
 622                         oMessenger.SendMessage(&oMessage);
 623                 }
 624         }
 625 }
 626 
 627 void                            
 628 BF_GUI_WinMain::FrameResized(float width, float height)    /* [previous][next][first][last][top][bottom][index][help] */
 629 {
 630         BWindow::FrameResized(width,height);
 631         //poView->FrameResized(width,height);
 632 }
 633 
 634 void
 635 BF_GUI_WinMain::MessageReceived(BMessage * po_Message)     /* [previous][next][first][last][top][bottom][index][help] */
 636 {       
 637         switch(po_Message->what){
 638         case BF_MSG_SETUP_UPDATED:{
 639                 BView *poView;
 640                 BMessage oMessage(BF_MSG_SETUP_UPDATED);                
 641                 for(int i=0;i<CountChildren();i++){
 642                         poView = ChildAt(i);
 643                         BMessenger oMessenger(poView);
 644                         oMessenger.SendMessage(&oMessage);                      
 645                 }
 646                 break;}
 647         default:
 648                 BWindow::MessageReceived(po_Message);
 649         }
 650 }

/* [previous][next][first][last][top][bottom][index][help] */