root/_FilesPanel/BF_GUI_FilesPanel_InfoPanel.cpp

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

DEFINITIONS

This source file includes following definitions.
  1. DrawPanel
  2. Action_Friend_NewCursor
  3. MessageReceived

   1 #include "stdio.h"
   2 
   3 #include "BF_Dict.h"
   4 #include "BF_Roster.h"
   5 #include "BF_Msg.h"
   6 #include "BF_GUI_DlgViews.h"
   7 #include "BF_GUI_KeysMenu.h"
   8 
   9 #include "BF_GUI_FilesPanel_InfoPanel.h"
  10 
  11 #include "BF_Roster.h"
  12 
  13 
  14 
  15   
  16 BF_GUI_FilesPanel_InfoPanel::BF_GUI_FilesPanel_InfoPanel(
  17         const   BRect & o_Rect,
  18         bool    b_WinPos_OnLeft
  19 ):BF_GUI_Panel(o_Rect,"info",b_WinPos_OnLeft) 
  20 {
  21         bNodeReady = false;
  22         SetHeader(BF_DictAt(BF_DICT_INFOPANEL_TITLE));
  23 }
  24 
  25 
  26 void                                    
  27 BF_GUI_FilesPanel_InfoPanel::DrawPanel(BRect &o_Rect)    /* [previous][next][first][last][top][bottom][index][help] */
  28 {
  29         BF_GUI_Panel::DrawPanel(o_Rect);
  30         
  31         float   fHeight = poSysSetup->oFontNode.fHeight;
  32         /* draw header */       
  33         //DrawHeader(IsFocus());
  34         /* draw bottom */       
  35         DrawBottom("", TRUE);
  36         //////////////////////////////////////////////////
  37         if(!bNodeReady) return;
  38         
  39         float           fy = HeaderHeight() + fHeight;
  40         BPoint          o,o1,o2;
  41         BL_String       s,s1;
  42         BRect           oRect;
  43         
  44         
  45         poRender->SetHighColor(SYS_COLOR(BF_COLOR_NODE));
  46         poRender->SetLowColor(SYS_COLOR(BF_COLOR_BACK));        
  47         /* draw icon */ 
  48         if(oNode.poLIcon){
  49                 o.Set(10,fy);
  50                 poRender->SetDrawingMode(B_OP_ALPHA);           
  51                 poRender->DrawBitmap(oNode.poLIcon,o);
  52                 poRender->SetDrawingMode(B_OP_COPY);                            
  53         }       
  54         /* draw file name */    
  55         o.Set(50,fy+poSysSetup->oFontToolView.fAscent);
  56         s="";
  57         s<<oNode.sName;
  58         poRender->DrawString(s.String(),o);
  59         fy += fHeight+5;
  60         /* draw path */
  61         o.Set(50,fy+poSysSetup->oFontToolView.fAscent);
  62         s="";
  63         s<<oPath.Path();
  64         poRender->DrawString(s.String(),o);
  65         fy += fHeight+5;        
  66         /* draw size */
  67         o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
  68         s=BF_DictAt(BF_DICT_INFOPANEL_SIZE);
  69         s1=oNode.iSize;
  70         s1.SetDigits();
  71         s<<s1;
  72         poRender->DrawString(s.String(),o);
  73         fy += fHeight+5;        
  74         /* draw date */
  75         o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
  76         s=BF_DictAt(BF_DICT_INFOPANEL_DATE);
  77         char pcBuffer[200]="";
  78         {
  79                 tm* puTime = localtime(&oNode.uCreateTime);; 
  80                 if(puTime){
  81                         sprintf(pcBuffer,"%i.%i.%i",
  82                                 puTime->tm_mday,
  83                                 puTime->tm_mon+1,
  84                                 puTime->tm_year+1900);                          
  85                 }
  86         }
  87         s<<pcBuffer;
  88         poRender->DrawString(s.String(),o);
  89         fy += fHeight+5;                
  90         /* draw perms */
  91         s=BF_DictAt(BF_DICT_INFOPANEL_PERMS);
  92         oNode.PermsTo(s1);
  93         s<<s1;
  94         o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
  95         poRender->DrawString(s.String(),o);
  96         fy += fHeight+5;
  97         /* draw mime_type */
  98         s=BF_DictAt(BF_DICT_INFOPANEL_MIME);
  99         s<<oNode.sType;
 100         o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
 101         poRender->DrawString(s.String(),o);
 102         fy += fHeight+5;                
 103         /* draw line */
 104         oRect = poRender->Bounds();
 105         o1.x = 5;
 106         o1.y = fy;
 107         o2 = o1;
 108         o2.x =  oRect.Width()-10;       
 109         poRender->SetHighColor(SYS_COLOR(BF_COLOR_FRAME));
 110         poRender->StrokeLine(o1,o2);    
 111         fy += 5;
 112         /////////////////////// draw curr volume /////////////
 113         poRender->SetHighColor(SYS_COLOR(BF_COLOR_NODE));
 114         poRender->SetLowColor(SYS_COLOR(BF_COLOR_BACK));
 115         /* draw icon */ 
 116         if(oVol.poLIcon){
 117                 o.Set(10,fy);
 118                 poRender->SetDrawingMode(B_OP_ALPHA);           
 119                 poRender->DrawBitmap(oVol.poLIcon,o);
 120                 poRender->SetDrawingMode(B_OP_COPY);                            
 121         }       
 122         /* draw file name */    
 123         o.Set(50,fy+poSysSetup->oFontToolView.fAscent);
 124         s="";
 125         s<<oVol.sName;
 126         poRender->DrawString(s.String(),o);
 127         fy += fHeight*2+5*2;
 128         
 129         if(oVol.bLoadedOk)
 130         {               
 131                 o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
 132                 s=BF_DictAt(BF_DICT_INFOPANEL_CAPACITY);
 133                 s1=oVol.iCapacity;
 134                 s1.SetDigits();
 135                 s<<s1;
 136                 poRender->DrawString(s.String(),o);
 137                 fy += fHeight+5;                
 138                 //
 139                 o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
 140                 s=BF_DictAt(BF_DICT_INFOPANEL_FREEBYTES);
 141                 s1=oVol.iFree;
 142                 s1.SetDigits();
 143                 s<<s1;
 144                 poRender->DrawString(s.String(),o);
 145                 fy += fHeight+5;                
 146                 // removable
 147                 if(oVol.bRemovable){
 148                         o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
 149                         s=BF_DictAt(BF_DICT_INFOPANEL_REMOVEABLE);
 150                         poRender->DrawString(s.String(),o);
 151                         fy += fHeight+5;                
 152                 }
 153                 // readonly
 154                 if(oVol.bRemovable){
 155                         o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
 156                         s=BF_DictAt(BF_DICT_READONLY);
 157                         poRender->DrawString(s.String(),o);
 158                         fy += fHeight+5;                        
 159                 }
 160         }else{
 161                 o.Set(10,fy+poSysSetup->oFontToolView.fAscent);
 162                 s=BF_DictAt(BF_DICT_CANTLOADINFO);
 163                 poRender->DrawString(s.String(),o);
 164                 fy += fHeight+5;                        
 165         }
 166 }
 167 
 168 void
 169 BF_GUI_FilesPanel_InfoPanel::Action_Friend_NewCursor(const char *pc_NodePath,const char *pc_NodeName,int32 i_NodeType)    /* [previous][next][first][last][top][bottom][index][help] */
 170 {
 171         if(pc_NodePath && pc_NodeName){
 172                 // load path
 173                 BF_Path oPath(pc_NodePath);
 174                 oNode.sName = pc_NodeName;                      
 175                 bNodeReady = true;              
 176                 BF_Roster_ReloadNode(oPath.Path(),&oNode,BF_ROSTER_LOAD_LICON|BF_ROSTER_LOAD_TYPE|BF_ROSTER_LOAD_PERMS);                
 177 
 178                 // load current volume
 179                 oVol.Load(oPath.GetVolume().String(),BF_ROSTER_LOAD_LICON);
 180         }else{
 181                 bNodeReady = false;             
 182         }
 183         if(Parent()) Invalidate();
 184 }
 185 
 186 void                                    
 187 BF_GUI_FilesPanel_InfoPanel::MessageReceived(BMessage* po_Message)    /* [previous][next][first][last][top][bottom][index][help] */
 188 {
 189         switch(po_Message->what){
 190         default:
 191                 BF_GUI_Panel::MessageReceived(po_Message);
 192         }
 193 }
 194 
 195 /*              
 196 void                                    
 197 BF_GUI_FilesPanel_InfoPanel::SetNode(const char *pc_File)
 198 {
 199         if(pc_File){
 200                 BF_Path oPath;
 201 
 202                 ASSERT(po_Node);
 203                 oNode.Set(po_Node);
 204                 oPath.Set(o_Path);
 205                 bNodeReady = true;              
 206                 BF_Roster_ReloadNode(&oPath,&oNode,BF_ROSTER_LOAD_LICON|BF_ROSTER_LOAD_TYPE|BF_ROSTER_LOAD_PERMS);
 207                 //
 208                 // load vol  //
 209                 BL_String sVol;
 210                 oPath.GetVolume(sVol,true);
 211                 oVol.sName = sVol;
 212                 BF_Roster_ReloadNode(NULL,&oVol,BF_ROSTER_LOAD_LICON);
 213                 //
 214                 oVol.LoadInfo();
 215         }else{
 216                 bNodeReady = false;
 217         }
 218         if(Parent()) Invalidate();
 219 }

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