2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * $TOG: ViewMsgDialog.C /main/6 1998/01/28 18:35:43 mgreess $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
45 #include <Xm/ScrolledW.h>
46 #include <Xm/DialogS.h>
49 #include <Xm/Protocols.h>
50 #include <Xm/AtomMgr.h>
54 #include "MainWindow.h"
55 #include "ViewMsgDialog.h"
56 #include "RoamMenuWindow.h"
60 #include "Attachment.h"
63 #include "DtMailHelp.hh"
65 // Need the XmTextEditor. Will eventually need the HP-Editor here!
66 //#include "XmTextEditor.h"
68 #include "DtMailEditor.hh"
70 extern nl_catd DtMailMsgCat;
72 //#include "CDEM_CoeEd.hh"
75 // The WM_CLASS_NAME of a VMD is DtMail_SecWin.
76 // SQE's test suites depend on the WM_CLASS_NAME being a
77 // constant. If you are going to change the name, talk to SQE
78 // and get their consent for whatever change you are making.
80 ViewMsgDialog::ViewMsgDialog (RoamMenuWindow *parent, WidgetClass wc) :
81 DialogShell ("DtMail_SecWin", parent, wc)
90 _edit_select_all = NULL;
92 _attach_save_as = NULL;
93 _attach_select_all = NULL;
95 _attachmentActionsList = NULL;
96 _attachmentMenu = NULL;
97 _attachmentMenuList = NULL;
98 _attachmentPopupMenuList = NULL;
99 _textPopupMenuList = NULL;
107 _about_mailer = NULL;
111 assert( theApplication != NULL );
116 ViewMsgDialog::~ViewMsgDialog()
123 delete _edit_select_all;
125 delete _attach_save_as;
126 delete _attach_select_all;
128 delete _attachmentActionsList;
129 delete _attachmentMenuList;
130 delete _attachmentPopupMenuList;
131 delete _textPopupMenuList;
139 ViewMsgDialog::createWorkArea ( Widget shell )
142 Widget form = XtCreateWidget(
143 "Work_Area", xmFormWidgetClass,
146 _main = XtVaCreateManagedWidget ("separateViewWindow",
147 xmMainWindowWidgetClass,
149 XmNleftAttachment, XmATTACH_FORM,
150 XmNtopAttachment, XmATTACH_FORM,
151 XmNbottomAttachment, XmATTACH_FORM,
152 XmNrightAttachment, XmATTACH_FORM,
155 Widget form1 = XtCreateWidget("Work_Area", xmFormWidgetClass,
157 printHelpId("form", form1);
158 /* add help callback */
159 // XtAddCallback(form1, XmNhelpCallback, HelpCB, helpId);
162 my_editor = new DtMailEditor(form1, this);
163 my_editor->initialize();
165 my_editor->attachArea()->setOwnerShell(this);
167 Widget wid = my_editor->container();
170 XmNrightAttachment,XmATTACH_FORM,
171 XmNleftAttachment,XmATTACH_FORM,
172 XmNtopAttachment,XmATTACH_FORM,
173 XmNbottomAttachment, XmATTACH_FORM,
176 XtManageChild(form1);
182 ViewMsgDialog::propsChanged(void)
187 ViewMsgDialog::text(const char *text, const unsigned long len)
190 my_editor->textEditor()->set_contents(text, len);
195 ViewMsgDialog::append( const char *text, const unsigned long len ){
197 my_editor->textEditor()->append_to_contents(text, len);
201 ViewMsgDialog::popped_down()
208 ViewMsgDialog::popped_up()
211 Dimension width, height;
213 text = _parent->get_editor()->container();
221 XmNx, _parent->x() + (_parent->width() / 2),
222 XmNy, _parent->y() + (_parent->height() /2),
228 // SR - added the messages below
231 ViewMsgDialog::initialize()
234 DialogShell::initialize();
236 _menuBar = new MenuBar ( _main, "menubar" );
238 XtVaSetValues ( _main,
239 XmNmenuBar, _menuBar->baseWidget(),
242 this->construct_edit_menu();
243 this->construct_text_popup();
244 this->construct_attachment_menu();
245 this->construct_attachment_popup();
246 this->construct_help_menu();
250 _genDialog = new DtMailGenDialog("Dialog", _main);
252 XtManageChild(_main);
257 ViewMsgDialog::quit()
259 _parent->unregisterDialog(this);
264 ViewMsgDialog::raise()
266 XRaiseWindow(XtDisplay(_w), XtWindow(_w));
270 ViewMsgDialog::get_editor()
278 ViewMsgDialog::auto_show_cursor_off()
281 my_editor->textEditor()->auto_show_cursor_off();
286 ViewMsgDialog::auto_show_cursor_restore()
289 my_editor->textEditor()->auto_show_cursor_restore();
294 ViewMsgDialog::set_to_top()
297 my_editor->textEditor()->set_to_top();
302 ViewMsgDialog::text_selected()
305 // turn on sensitivity for Cut/Clear/Copy/Paste/Delete
310 ViewMsgDialog::text_unselected()
313 // turn off sensitivity for those items
319 ViewMsgDialog::attachment_selected()
321 _attach_save_as->activate();
326 ViewMsgDialog::all_attachments_selected()
328 _attach_save_as->deactivate();
329 if (_attachmentActionsList != NULL) {
330 _menuBar->removeCommands(_attachmentMenu, _attachmentActionsList);
331 _menuPopupAtt->removeCommands(_attachmentPopupMenu,
332 _attachmentActionsList);
333 delete _attachmentActionsList;
334 _attachmentActionsList = NULL;
339 ViewMsgDialog::all_attachments_deselected()
341 _attach_save_as->deactivate();
342 if (_attachmentActionsList != NULL) {
343 _menuBar->removeCommands(_attachmentMenu, _attachmentActionsList);
344 _menuPopupAtt->removeCommands(_attachmentPopupMenu,
345 _attachmentActionsList);
346 delete _attachmentActionsList;
347 _attachmentActionsList = NULL;
352 ViewMsgDialog::construct_edit_menu()
357 _edit_copy = new EditCopyCmd(
359 GETMSG(DT_catd, 1, 161, "Copy"),
364 _edit_select_all = new EditSelectAllCmd(
366 GETMSG(DT_catd, 1, 162, "Select All"),
371 cmdList = new CmdList("Edit", GETMSG(DT_catd, 1, 163, "Edit"));
372 cmdList->add(_edit_copy);
373 cmdList->add(_edit_select_all);
375 _menuBar->addCommands(cmdList);
380 ViewMsgDialog::construct_attachment_menu()
383 // Separator for menu items
384 SeparatorCmd *separator = new SeparatorCmd("Separator", "Separator", TRUE );
386 _attach_save_as = new SaveAttachCmd (
388 GETMSG(DT_catd, 1, 164, "Save As..."),
389 GETMSG(DT_catd, 1, 165, "Mailer - Attachments - Save As"),
391 ViewMsgDialog::save_attachment_callback,
395 _attach_select_all = new SelectAllAttachsCmd(
397 GETMSG(DT_catd, 1, 166, "Select All"),
400 _attachmentMenuList = new CmdList(
402 GETMSG(DT_catd, 1, 167, "Attachments") );
404 _attachmentMenuList->add(_attach_save_as);
405 _attachmentMenuList->add(_attach_select_all);
407 _attachmentMenu = _menuBar->addCommands(_attachmentMenuList);
412 ViewMsgDialog::construct_attachment_popup(void)
414 _attachmentPopupMenuList = new CmdList( "AttachmentsPopup", "AttachmentsPopup");
416 LabelCmd *title = new LabelCmd (
417 "Mailer - Attachments",
418 GETMSG(DT_catd, 1, 168, "Mailer - Attachments"), TRUE);
419 SeparatorCmd *separator = new SeparatorCmd("Separator","Separator", TRUE );
421 _attachmentPopupMenuList->add(title);
422 _attachmentPopupMenuList->add(separator);
423 _attachmentPopupMenuList->add(_attach_save_as);
424 _attachmentPopupMenuList->add(_attach_select_all);
425 _menuPopupAtt = new MenuBar(my_editor->attachArea()->getClipWindow(),
426 "ViewMsgAttachmentPopup", XmMENU_POPUP);
427 _attachmentPopupMenu = _menuPopupAtt->addCommands(_attachmentPopupMenuList,
428 FALSE, XmMENU_POPUP);
432 ViewMsgDialog::construct_text_popup(void)
434 if (theApplication->bMenuButton() != Button3)
437 _textPopupMenuList = new CmdList("TextPopup", "TextPopup");
439 LabelCmd *title = new LabelCmd (
441 GETMSG(DT_catd, 1, 169, "Mailer - Text"), TRUE);
442 SeparatorCmd *separator = new SeparatorCmd("Separator", "Separator", TRUE );
444 _textPopupMenuList->add(title);
445 _textPopupMenuList->add(separator);
446 _textPopupMenuList->add(_edit_copy);
447 _textPopupMenuList->add(_edit_select_all);
449 Widget parent = my_editor->textEditor()->get_editor();
450 _menuPopupText = new MenuBar(parent, "ViewMsgTextPopup", XmMENU_POPUP);
451 _textPopupMenu = _menuPopupText->addCommands(_textPopupMenuList,
452 FALSE, XmMENU_POPUP);
458 ViewMsgDialog::construct_help_menu()
462 // Separator for menu items
464 SeparatorCmd *separator= new SeparatorCmd("Separator", "Separator", TRUE );
465 _overview = new OnAppCmd("Overview", GETMSG(DT_catd, 1, 170, "Overview"),
467 _tasks = new TasksCmd("Tasks", GETMSG(DT_catd, 1, 171, "Tasks"),
469 _reference = new ReferenceCmd("Reference",
470 GETMSG(DT_catd, 1, 172, "Reference"),
472 _on_item = new OnItemCmd("On Item",
473 GETMSG(DT_catd, 1, 173, "On Item"),
475 _using_help = new UsingHelpCmd("Using Help",
476 GETMSG(DT_catd, 1, 174, "Using Help"),
478 cmdList = new CmdList( "Help", GETMSG(DT_catd, 1, 175, "Help") );
479 cmdList->add ( _overview );
480 cmdList->add ( separator );
481 cmdList->add ( _tasks );
482 cmdList->add ( _reference );
483 cmdList->add ( separator );
484 cmdList->add ( _on_item );
485 cmdList->add ( separator );
486 cmdList->add ( _using_help );
487 cmdList->add ( separator );
489 _about_mailer = new RelNoteCmd("About Mailer",
490 GETMSG(DT_catd, 1, 176, "About Mailer..."),
492 cmdList->add ( _about_mailer );
494 // Make help menu show up on right side of menubar.
495 _menuBar->addCommands ( cmdList, TRUE );
500 ViewMsgDialog::save_attachment_callback(
505 DtMailEnv mail_error;
507 // Initialize the mail_error.
511 ViewMsgDialog *obj = (ViewMsgDialog *) client_data;
513 obj->save_selected_attachment(selection);
518 ViewMsgDialog::save_selected_attachment(
523 DtMailEnv mail_error;
526 DtMailEditor *editor = this->get_editor();
527 AttachArea *attacharea = editor->attachArea();
528 Attachment *attachment = attacharea->getSelectedAttachment();
530 // Get selected attachment, if none selected, then return.
531 if ( attachment == NULL ) {
532 // Let User know that no attachment has been selected???
537 _genDialog->setToErrorDialog(
538 GETMSG(DT_catd, 1, 177, "Mailer"),
539 GETMSG(DT_catd, 2, 20, "An attachment needs to be selected before issuing the\n\"Save As\" command to save to a file.") );
540 helpId = DTMAILHELPSELECTATTACH;
541 answer = _genDialog->post_and_return(
542 GETMSG(DT_catd, 3, 75, "OK"), helpId );
546 attachment->saveToFile(mail_error, selection);
548 if (mail_error.isSet()) {
555 ViewMsgDialog::manage()
559 Dimension width, height;
561 text = _parent->get_editor()->container();
569 XmNx, _parent->x() + (_parent->width() / 2),
570 XmNy, _parent->y() + (_parent->height() /2),
573 DialogShell::manage();
578 ViewMsgDialog::addAttachmentActions(
585 AttachmentActionCmd *attachActionCmd;
587 if (_attachmentActionsList == NULL) {
588 _attachmentActionsList = new CmdList("AttachmentActions",
589 "AttachmentActions");
592 _menuBar->removeCommands(_attachmentMenu, _attachmentActionsList);
593 _menuPopupAtt->removeCommands(_attachmentPopupMenu,
594 _attachmentActionsList);
595 delete _attachmentActionsList;
596 _attachmentActionsList = new CmdList("AttachmentActions",
597 "AttachmentActions");
601 for (i = 0; i < indx; i++) {
602 anAction = actions[i];
603 actionLabel = DtActionLabel(anAction); // get the localized action label
604 attachActionCmd = new AttachmentActionCmd(
609 _attachmentActionsList->add(attachActionCmd);
612 _attachmentMenu = _menuBar->addCommands(
614 _attachmentActionsList
617 _attachmentPopupMenu = _menuPopupAtt->addCommands(
618 _attachmentPopupMenu,
619 _attachmentActionsList);
625 ViewMsgDialog::removeAttachmentActions()
628 // Stubbed out for now
632 ViewMsgDialog::invokeAttachmentAction(
636 DtMailEditor *editor = this->get_editor();
637 AttachArea *attacharea = editor->attachArea();
638 Attachment *attachment = attacharea->getSelectedAttachment();
640 attachment->invokeAction(index);
645 ViewMsgDialog::selectAllAttachments()
648 DtMailEditor *editor = this->get_editor();
649 AttachArea *attachArea = editor->attachArea();
651 attachArea->selectAllAttachments();
656 ViewMsgDialog::activate_default_attach_menu()
658 _attach_select_all->activate();
662 ViewMsgDialog::deactivate_default_attach_menu()
664 _attach_select_all->deactivate();
669 ViewMsgDialog::showAttachArea()
671 DtMailEditor *editor = this->get_editor();
672 editor->showAttachArea();
676 ViewMsgDialog::hideAttachArea()
678 DtMailEditor *editor = this->get_editor();
679 editor->hideAttachArea();
684 ViewMsgDialog::attachmentFeedback(
692 this->normalCursor();