home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / Composer / CFormattingToolBar.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  3.9 KB  |  125 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "CFormattingToolBar.h"
  20. #include "CEditView.h"
  21. #include "resgui.h"
  22. #include "edt.h"
  23.  
  24. CFormattingToolBar::CFormattingToolBar(LStream * inStream) 
  25.                             : CPatternBevelView(inStream)
  26. {
  27. }
  28.  
  29. CFormattingToolBar::~CFormattingToolBar()
  30. {
  31.     mEditView = NULL;
  32. }
  33.  
  34. void CFormattingToolBar::FinishCreateSelf()
  35. {
  36.     if ( GetSuperView() )
  37.     {
  38.         // get SuperView (we start with "this" so we're guaranteed non-0)
  39.         LView *superView = (LView *)this;
  40.         while (superView->GetSuperView() != NULL)
  41.             superView = superView->GetSuperView();
  42.         
  43.         mEditView = dynamic_cast<CEditView*>(superView->FindPaneByID( CEditView::pane_ID ));
  44.     }
  45.     else
  46.         mEditView = dynamic_cast<CEditView*>(FindPaneByID( CEditView::pane_ID ));
  47.  
  48.     // if we have a mailcompose window show insert object popup menu
  49.     // check for presence of insert menu within CFormattingToolBar
  50.     LPane *pane = FindPaneByID('InsO');
  51.     if ( pane )
  52.     {
  53.         CMailEditView *mailview = dynamic_cast<CMailEditView*>( mEditView );
  54.         if ( mailview )
  55.             pane->Show();
  56.         else
  57.             pane->Hide();
  58.     }
  59.     
  60.     UReanimator::LinkListenerToControls(this, this, 11616);
  61. }
  62.  
  63. void CFormattingToolBar::ListenToMessage( MessageT inMessage, void* ioParam )
  64. {
  65.     PaneIDT paneID = CEditView::pane_ID;
  66.     
  67.     if ( mEditView == NULL )
  68.         return;
  69.     
  70.     if ( inMessage == 'Para' )
  71.     {
  72.         switch  (*(long*)ioParam)
  73.         {
  74.             case 1:        inMessage = cmd_Format_Paragraph_Normal;        break;
  75.             case 2:        inMessage = cmd_Format_Paragraph_Head1;            break;
  76.             case 3:        inMessage = cmd_Format_Paragraph_Head2;            break;
  77.             case 4:        inMessage = cmd_Format_Paragraph_Head3;            break;
  78.             case 5:        inMessage = cmd_Format_Paragraph_Head4;            break;
  79.             case 6:        inMessage = cmd_Format_Paragraph_Head5;            break;
  80.             case 7:        inMessage = cmd_Format_Paragraph_Head6;            break;
  81.             case 8:        inMessage = cmd_Format_Paragraph_Address;        break;
  82.             case 9:        inMessage = cmd_Format_Paragraph_Formatted;        break;
  83.             case 10:    inMessage = cmd_Format_Paragraph_List_Item;        break;
  84.             case 11:    inMessage = cmd_Format_Paragraph_Desc_Title;    break;
  85.             case 12:    inMessage = cmd_Format_Paragraph_Desc_Text;        break;
  86.         }
  87.     }
  88.     else if ( inMessage == 'Size' )
  89.     {
  90.         switch  (*(long*)ioParam)
  91.         {
  92.             case 1:        inMessage = cmd_Format_Font_Size_N2;    break;
  93.             case 2:        inMessage = cmd_Format_Font_Size_N1;    break;
  94.             case 3:        inMessage = cmd_Format_Font_Size_0;        break;
  95.             case 4:        inMessage = cmd_Format_Font_Size_P1;    break;
  96.             case 5:        inMessage = cmd_Format_Font_Size_P2;    break;
  97.             case 6:        inMessage = cmd_Format_Font_Size_P3;    break;
  98.             case 7:        inMessage = cmd_Format_Font_Size_P4;    break;
  99.         }
  100.     }
  101.     else if ( inMessage == 'Algn' )
  102.     {
  103.         switch  (*(long*)ioParam)
  104.         {
  105.             case 1:        inMessage = cmd_JustifyLeft;    break;
  106.             case 2:        inMessage = cmd_JustifyCenter;    break;
  107.             case 3:        inMessage = cmd_JustifyRight;    break;
  108.         }
  109.     }
  110.     else if ( inMessage == 'InsO' )
  111.     {
  112.         switch  (*(long*)ioParam)
  113.         {
  114.             case 1:        inMessage = cmd_Insert_Link;    break;
  115.             case 2:        inMessage = cmd_Insert_Target;    break;
  116.             case 3:        inMessage = cmd_Insert_Image;    break;
  117.             case 4:        inMessage = cmd_Insert_Line;    break;
  118.             case 5:        inMessage = cmd_Insert_Table;    break;
  119.         }
  120.     }
  121.  
  122.     mEditView->ObeyCommand( inMessage, ioParam );
  123. }
  124.  
  125.