icon_tray.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:8k
- /*
- * ===========================================================================
- * PRODUCTION $Log: icon_tray.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:14:12 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: icon_tray.cpp,v 1000.1 2004/06/01 21:14:12 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Mike DiCuccio
- *
- * File Description:
- * CIconTray -- icon manager widget
- */
- #include <ncbi_pch.hpp>
- #include "icon_tray.hpp"
- #include <FL/Enumerations.H>
- #include <FL/Fl_Pixmap.H>
- #include <FL/Fl_Box.H>
- BEGIN_NCBI_SCOPE
- //
- // our icon image
- //
- static const char* sc_icon_xpm[] = {
- "48 48 18 1",
- " c None",
- ". c #336699",
- "+ c #4D79A6",
- "@ c #7396B9",
- "# c #99B3CC",
- "$ c #CCD9E5",
- "% c #E5ECF2",
- "& c #FFFFFF",
- "* c #A5BCD2",
- "= c #40709F",
- "- c #F2F5F9",
- "; c #D9E2EC",
- "> c #BFCFDF",
- ", c #668CB3",
- "' c #B2C5D9",
- ") c #8DA9C6",
- "! c #80A0BF",
- "~ c #5983AC",
- "................................................",
- "................................................",
- "................................................",
- "................................................",
- "................................................",
- "................................................",
- "..................+@#$%&&.......................",
- "...............@*%&&&&&&&.......................",
- "............=#%&&&&&&&&&&.......................",
- "...........#-&&&&&&&&&&&&.......................",
- ".........=;&&&&&&&&-$>###.......................",
- ".........$&&&&&;#,=..........+@.................",
- ".........&&&&'+...............+#)=..............",
- ".........&&&)...................,$#=............",
- ".........%&&=....................='-!...........",
- ".........,&&!......................!&>=.........",
- "..........,--~......................'&;=........",
- "...........+$-,.....................+&&$........",
- ".............@%#....................,&&&........",
- "...............!>,.................,-&&&........",
- ".................,!~............+!$&&&&-........",
- ".........................=,,)#$%&&&&&&&@........",
- "...................~!*$%&&&&&&&&&&&&&%~.........",
- "...............+!>-&&&&&&&&&&&&&&&&%!...........",
- ".............!>&&&&&&&&&&&&&&&&&-'@.............",
- "...........,%&&&&&&&&&&&&&&&->#~................",
- "..........*&&&&&&&&&&$$*#!,=....................",
- ".........#&&&&&->),=............................",
- ".........-&&&%!..............~!~................",
- ".........&&&;=.................@'!..............",
- ".........$&&@...................=*%,............",
- ".........~-&*.....................,-$+..........",
- "..........~-&~.....................~--~.........",
- "...........+$-,.....................)&-~........",
- ".............!%#....................+&&%........",
- "...............!>,..................#&&&........",
- ".................,),..............+>&&&&........",
- "..............................=,#;&&&&&>........",
- "........................###>$-&&&&&&&&;=........",
- "........................&&&&&&&&&&&&-#..........",
- "........................&&&&&&&&&&%#=...........",
- "........................&&&&&&&;*~..............",
- "........................&&%$#@=.................",
- "................................................",
- "................................................",
- "................................................",
- "................................................",
- "................................................"
- };
- CIconTray::CIconTray(int x, int y, int w, int h, const char* label)
- : Fl_Pack(x, y, w, h, label)
- {
- type(HORIZONTAL);
- }
- void CIconTray::Add(CChildFrame* frame)
- {
- // first, we hide the window
- frame->hide();
- // now, create a new icon group
- // create a group for the icon
- Fl_Group* icon_group = new Fl_Group(0, 0, 72, 72,
- frame->GetTitle()->label());
- icon_group->align(FL_ALIGN_CENTER | FL_ALIGN_BOTTOM | FL_ALIGN_INSIDE);
- icon_group->labelfont(FL_HELVETICA);
- icon_group->labelsize(12);
- icon_group->box(FL_NO_BOX);
- icon_group->resizable(NULL);
- icon_group->callback((Fl_Callback*)&CIconTray::x_StaticCB_Maximize, frame);
- // create an image for the icon itself
- int x_offs = (72 - 48) / 2;
- int y_offs = (72 - 12 - 48) / 2;
- Fl_Group* group = new Fl_Group(x_offs - Fl::box_dx(FL_THIN_UP_BOX),
- y_offs - Fl::box_dx(FL_THIN_UP_BOX),
- 48 + Fl::box_dw(FL_THIN_UP_BOX),
- 48 + Fl::box_dh(FL_THIN_UP_BOX));
- group->box(FL_THIN_UP_BOX);
- group->clear_visible_focus();
- Fl_Box* icon = new Fl_Box(x_offs, y_offs, 48, 48);
- icon->image(new Fl_Pixmap(sc_icon_xpm));
- icon->clear_visible_focus();
- group->end();
- // add the icon group to the next column
- if (m_Columns.size() == 0 ||
- (m_Columns.back()->children() * 72 + 72 > h()) ) {
- Fl_Pack* pack = new Fl_Pack(0, 0, 72, h());
- pack->type(VERTICAL);
- m_Columns.push_back(pack);
- add(pack);
- }
- m_Columns.back()->add(icon_group);
- icon_group->show();
- m_GroupIdx[icon_group] = frame;
- }
- void CIconTray::Remove(CChildFrame* frame)
- {
- _TRACE("CIconTray::Remove(CChildFrame)");
- // restore the window to visibility
- frame->show();
- // and remove from the pack
- }
- void CIconTray::x_Remove(Fl_Group* icon_group)
- {
- _TRACE("CIconTray::Remove(Fl_Group)");
- TGroupIdx::iterator iter = m_GroupIdx.find(icon_group);
- if (iter != m_GroupIdx.end()) {
- Remove(iter->second);
- }
- }
- void CIconTray::x_StaticCB_Maximize(Fl_Widget* w, void* data)
- {
- _TRACE("CIconTray callback...");
- if ( !data || !Fl::event_clicks() ) {
- return;
- }
- CIconTray* tray = reinterpret_cast<CIconTray*> (data);
- tray->x_Remove((Fl_Group*)w);
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: icon_tray.cpp,v $
- * Revision 1000.1 2004/06/01 21:14:12 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4
- *
- * Revision 1.4 2004/05/21 22:27:56 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.3 2003/03/17 19:48:52 dicuccio
- * Fixed xpm specifications to make WorkShop compiler happy.
- *
- * Revision 1.2 2003/03/07 17:49:25 dicuccio
- * Small clean-ups. Added description for each class.
- *
- * Revision 1.1 2003/03/07 17:36:08 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */