home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xtoolbar.cpp < prev    next >
C/C++ Source or Header  |  1997-04-05  |  18KB  |  754 lines

  1. #include "XToolBar.h"
  2. #include "XFrmWnd.h"
  3. #include "XRect.h"
  4. #include "XFrame.h"
  5. #include "XColor.h"
  6. #include "XGraphDv.H"
  7. #include "XLine.h"
  8. #include "XCntrEvn.h"
  9. #include "XMousHdl.h"
  10. #include "XMousevn.h"
  11. #include "XReslib.h"
  12. #include "xmsgbox.h"
  13. #include "stdlib.h"
  14.  
  15.  
  16. /*@ 
  17. @class XToolBar
  18. @parent XWindow
  19. @type overview
  20. @symbol _
  21. @remarks XToolBar represents a toolbar for framewindows. You can attach every type of control to it.
  22. */
  23.  
  24.  
  25. class ToolBarParent:public XFrameWindow
  26. {
  27.     friend XToolBar;
  28.     XToolBar *toolBar;
  29.     BOOL init;
  30.         public:
  31.         ToolBarParent(const XResource * r, const XRect * rec, XToolBar * t);
  32.     BOOL QueryForClose()
  33.     {
  34.         Show(FALSE);
  35.         return FALSE;
  36.     }
  37.     void DoMove(void);
  38. };
  39.  
  40.  
  41. void ToolBarParent::DoMove(void)
  42. {
  43.     if (init)
  44.         return;
  45.  
  46.     XRect rect1, rect3;
  47.  
  48.     toolBar->frame->GetSize(&rect1);
  49.     GetSize(&rect3);
  50.     if (rect3.GetX() > rect1.GetX() + 50 && rect3.GetX() < rect1.GetX() + rect1.GetWidth() - 50 && (rect3.GetY() + rect3.GetHeight()) < rect1.GetY() + rect1.GetHeight() && (rect3.GetY() + rect3.GetHeight()) > rect1.GetY() + rect1.GetHeight() - 50)
  51.     {
  52.         toolBar->style = TB_TOP;
  53.         toolBar->Attach();
  54.         clientWindow = NULL;
  55.         delete this;
  56.     }
  57.     else if (rect3.GetX() > rect1.GetX() + 50 && rect3.GetX() < rect1.GetX() + rect1.GetWidth() - 50 && rect3.GetY() + rect3.GetHeight() > rect1.GetY() && rect3.GetY() + rect3.GetHeight() < rect1.GetY() + 50)
  58.     {
  59.         toolBar->style = TB_BOTTOM;
  60.         toolBar->Attach();
  61.         clientWindow = NULL;
  62.         delete this;
  63.     }
  64.     else if (rect3.GetX() > rect1.GetX() && rect3.GetX() < rect1.GetX() + 50 && rect3.GetY() > rect1.GetY() && rect3.GetY() < rect1.GetY() + rect1.GetHeight())
  65.     {
  66.         toolBar->style = TB_LEFT;
  67.         toolBar->Attach();
  68.         clientWindow = NULL;
  69.         delete this;
  70.     }
  71.     else if (rect3.GetX() < rect1.GetX() + rect1.GetWidth() && rect3.GetX() > rect1.GetX() + rect1.GetWidth() - 50 && rect3.GetY() > rect1.GetY() && rect3.GetY() < rect1.GetY() + rect1.GetHeight())
  72.     {
  73.         toolBar->style = TB_RIGHT;
  74.         toolBar->Attach();
  75.         clientWindow = NULL;
  76.         delete this;
  77.     }
  78.  
  79. }
  80.  
  81.  
  82. ToolBarParent :: ToolBarParent(const XResource * r, const XRect * rec, XToolBar * t):XFrameWindow(r, "", FRM_TITLEBAR | FRM_BORDER | FRM_SYSMENU | WIN_VISIBLE, rec)
  83. {
  84.     t->cutWindow = this;
  85.  
  86.     init = TRUE;
  87.     toolBar = t;
  88.     WinSetParent(t->GetHandle(), frameWin->GetHandle(), TRUE);
  89.     SetClient(t);
  90.     Activate();
  91.  
  92.     init = FALSE;
  93. }
  94.  
  95.  
  96. class ToolBarHandler:public XMouseHandler
  97. {
  98.     BOOL btn;
  99.     XPoint p;
  100.         public:
  101.         ToolBarHandler(const XWindow * w):XMouseHandler(w)
  102.     {
  103.         btn = FALSE;
  104.     }
  105.     BOOL HandleEvent(XMouseEvent *);
  106. };
  107.  
  108.  
  109. BOOL ToolBarHandler::HandleEvent(XMouseEvent * e)
  110. {
  111.     switch (e->GetEventID())
  112.     {
  113.         case MOU_BTN1DOWN:
  114.         btn = TRUE;
  115.         p = e->p;
  116.         break;
  117.     case MOU_MOVE:
  118.         if (btn == TRUE)
  119.         {
  120.             if (e->p.GetX() > p.GetX() + 5 || e->p.GetX() < p.GetX() - 5)
  121.             {
  122.                 XToolBar *t = (XToolBar *) GetWindow();
  123.  
  124.                 if (t->GetCutWindow() == NULL)
  125.                     t->Cut();
  126.                 btn = FALSE;
  127.             }
  128.         }
  129.         break;
  130.     default:
  131.         btn = FALSE;
  132.         break;
  133.     }
  134.     return FALSE;
  135. }
  136.  
  137.  
  138. void XToolBar::Attach(void)
  139. {
  140.     frame->frameWin->AddFrameControl(this);
  141.  
  142.     WinSetParent(winhandle, frame->frame, TRUE);
  143.     WinSetOwner(winhandle, frame->frame);
  144.  
  145. //   hdl = new ToolBarHandler(this);
  146.  
  147.     LONG x = borderSize, y = borderSize;
  148.     XRect rect;
  149.     int width = 0, height = 0;
  150.  
  151.     if (style & TB_RIGHT || style & TB_LEFT)
  152.     {
  153.         for (int i = 0; i < clients; i++)
  154.         {
  155.             clientArray[i]->clientWin->GetSize(&rect);
  156.             if (clientArray[i]->group)
  157.                 x = borderSize;
  158.             if (x + clientArray[i]->xOffset + rect.GetWidth() > width)
  159.                 width = x + clientArray[i]->xOffset + rect.GetWidth() + borderSize;
  160.             x += clientArray[i]->xOffset + rect.GetWidth();
  161.         }
  162.         cx = width;
  163.     }
  164.     else
  165.     {
  166.         int yy = 0;
  167.  
  168.         for (int i = 0; i < clients; i++)
  169.         {
  170.             char className[10];
  171.  
  172.             WinQueryClassName(clientArray[i]->clientWin->GetHandle(), 10, (PCH) className);
  173.             className[0] = ' ';
  174.             if (atol(className) == 2)
  175.             {
  176.                 if (yy < borderSize * 2 + 25)
  177.                     yy = borderSize * 2 + 25;
  178.             }
  179.             else
  180.             {
  181.                 clientArray[i]->clientWin->GetSize(&rect);
  182.                 if (yy < rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset)
  183.                     yy = rect.GetHeight() + borderSize * 2 + clientArray[i]->yOffset;
  184.             }
  185.         }
  186.         cy = yy;
  187.     }
  188.  
  189.     cutWindow = NULL;
  190.  
  191.     XRect rect2;
  192.  
  193.     frame->GetSize(&rect2);
  194.     rect2.SetHeight(rect2.GetHeight() - 1);
  195.     frame->SetSize(&rect2);
  196. }
  197.  
  198.  
  199. void XToolBar::Cut(void)
  200. {
  201.     XRect rect2;
  202.  
  203.     frame->frameWin->RemoveFrameControl(this);
  204.  
  205.     frame->GetSize(&rect2);
  206.     rect2.SetHeight(rect2.GetHeight() + 1);
  207.     frame->SetSize(&rect2);
  208.  
  209.     XResourceLibrary resLib(frame->GetProcess());
  210.     XResource res(0, &resLib);
  211.  
  212.     XPoint p;
  213.  
  214.     GetPointerPos(&p);
  215.     GetSize(&rect2);
  216.     rect2.SetX(p.GetX() - 30);
  217.  
  218.     ULONG width = 0, hight = 0, lowest = 0;
  219.     XRect rect;
  220.  
  221.     for (int i = 0; i < clients; i++)
  222.     {
  223.         clientArray[i]->clientWin->GetSize(&rect);
  224.         if (rect.GetX() + rect.GetWidth() > width)
  225.             width = rect.GetX() + rect.GetWidth();
  226.         if (lowest == 0)
  227.             lowest = rect.GetY();
  228.         if (rect.GetY() < lowest)
  229.             lowest = rect.GetY();
  230.     }
  231.  
  232.     rect2.SetWidth(width + borderSize);
  233.  
  234.     rect2.SetHeight(rect2.GetHeight() + borderSize - lowest);
  235.  
  236.     rect2.SetY(p.GetY() - rect2.GetHeight());
  237.  
  238.     LONG y = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
  239.  
  240.     y += WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER);
  241.     rect2.SetHeight(rect2.GetHeight() + y);
  242.     rect2.SetY(rect2.GetY() - y);
  243.  
  244.     cutWindow = new ToolBarParent(&res, &rect2, this);
  245. }
  246.  
  247.  
  248. /*@ XToolBar::Draw(void)
  249. @group display
  250. @remarks Redraw the toolbar.
  251. */
  252. void XToolBar::Draw(void)
  253. {
  254.     if (graph)
  255.         graph->Draw();
  256.     HENUM e;
  257.     HWND hwnd;
  258.  
  259.     e = WinBeginEnumWindows(winhandle);
  260.     while ((hwnd = WinGetNextWindow(e)) != 0)
  261.         WinInvalidateRegion(hwnd, NULLHANDLE, TRUE);
  262.     WinEndEnumWindows(e);
  263. }
  264.  
  265.  
  266. BOOL XToolBar::DoCommand(LONG com)
  267. {
  268.     return frame->DoCommand(com);
  269. }
  270.  
  271.  
  272. void XToolBar::DoControl(XControlEvent * e)
  273. {
  274.     frame->DoControl(e);
  275. }
  276.  
  277.  
  278. void XToolBar::DoSize(XSize * s)
  279. {
  280.     cx = s->GetWidth();
  281.     if (line2)
  282.     {
  283.         line2->SetWidth(cx - 1);
  284.         XPoint p(0, s->GetHeight() - 1);
  285.         line2->Move(&p);
  286. //        line2->SetHeight(0);//test
  287.         line1->SetHeight(s->GetHeight());
  288.         line3->SetHeight(s->GetHeight());
  289.         p.Set(cx - 1, 0);
  290.         line3->Move(&p);
  291. //        line3->SetWidth(0);//test
  292.         line4->SetWidth(cx - 1);
  293.     }
  294.     ReSize();
  295. }
  296.  
  297.  
  298. /*@ XToolBar::GetBackgroundColor(XColor * col)
  299. @group display
  300. @remarks Returns the background color
  301. @parameters XColor * colorBuffer         buffer which will get the color
  302. */
  303. void XToolBar::GetBackgroundColor(XColor * col)
  304. {
  305.     graph->GetBackgroundColor(col);
  306. }
  307.  
  308.  
  309. /*@ XToolBar::SetBackgroundColor(const XColor * col)
  310. @group display
  311. @remarks Set the background color
  312. @parameters XColor * colorBuffer         the new color
  313. */
  314. void XToolBar::SetBackgroundColor(const XColor * col)
  315. {
  316.     graph->SetBackgroundColor(col);
  317. }
  318.  
  319.  
  320. /*@ XToolBar::RemoveWindow(const XWindow * w, const BOOL redraw)
  321. @group adding/removing windows
  322. @remarks Removes a window attached to the toolbar
  323. @parameters XWindow * theWindow          window to remove<BR>
  324.            BOOL redraw                  recalculate the position of other attached windows
  325. @returns    BOOL                         success
  326. */
  327. BOOL XToolBar::RemoveWindow(const XWindow * w, const BOOL redraw)
  328. {
  329.     SHORT i, j;
  330.     XRect or;
  331.  
  332.     for (i = 0; i < clients; i++)
  333.     {
  334.         if (clientArray[i]->clientWin == w)
  335.         {
  336.             EnableWindowUpdate(FALSE);
  337.             clientArray[i]->clientWin->GetSize(&or);
  338.             clientArray[i]->clientWin->Show(FALSE);
  339.             free(clientArray[i]);
  340.             for (j = i; j < clients - 1; j++)
  341.             {
  342.                 clientArray[j] = clientArray[j + 1];
  343.                 if (redraw)
  344.                 {
  345.                     XRect r;
  346.  
  347.                     clientArray[j]->clientWin->GetSize(&r);
  348.                     r.SetX(r.GetX() - or.GetWidth());
  349.                     clientArray[j]->clientWin->SetSize(&r);
  350.                 }
  351.             }
  352.             clients -= 1;
  353.             clientArray = (clientWin **) realloc(clientArray, clients * sizeof(clientWin *));
  354.             EnableWindowUpdate();
  355.             return TRUE;
  356.         }
  357.     }
  358.     return FALSE;
  359. }
  360.  
  361.  
  362. /*@ XToolBar::AddWindow(const XWindow * w, const BOOL newGroup, const BOOL adjustSize, const XWindow * insertBehind, const LONG x, LONG y)
  363. @group adding/removing windows
  364. @remarks Attach a window to the toolbar.
  365. @parameters  <t '°' c=2>
  366.                 °XWindow * theWindow          °window to add
  367.             °BOOL newGroup                °with this window a new group starts
  368.             °BOOL adjustSize              °recalculate the hight of the toolbar
  369.                                          depending on the dimensions of theWindow
  370.             °XWindow * insertBehind       °insert theWindow behind this window
  371.             °LONG xOffset                 °x-offset of the window
  372.             °LONG yOffset                 °y-offset of the window (usefull for XComboBox)
  373.                 </t>
  374. @returns     BOOL                         success
  375. */
  376. void XToolBar::AddWindow(const XWindow * w, const BOOL newGroup, const BOOL adjustSize, const XWindow * insertBehind, const LONG x, LONG y)
  377. {
  378.     XRect r;
  379.     LONG xo = borderSize;
  380.     LONG y0 = 0, xMax = 0;
  381.     SHORT ins = clients;
  382.  
  383.     EnableWindowUpdate(FALSE);
  384.  
  385.     clients += 1;
  386.     clientArray = (clientWin **) realloc(clientArray, clients * sizeof(clientWin *));
  387.  
  388.     if (clients > 1)
  389.     {
  390.         if (insertBehind)
  391.         {
  392.             SHORT i, j;
  393.  
  394.             for (i = 0; i < clients - 1; i++)
  395.             {
  396.                 if (clientArray[i]->clientWin == insertBehind)
  397.                 {
  398.                     clientArray[i]->clientWin->GetSize(&r);
  399.                     SHORT xDiff = r.GetX() + r.GetWidth() + x;
  400.  
  401.                     if (newGroup)
  402.                     {
  403.                         if (style & TB_LEFT || style & TB_RIGHT)
  404.                             goto newG;
  405.                         xDiff += spacing;
  406.                     }
  407.                     ins = i + 1;
  408.                     xo = xDiff;
  409.                     XRect r2;
  410.  
  411.                     w->GetSize(&r2);
  412.                     if (style & TB_LEFT || style & TB_RIGHT)
  413.                         y += clientArray[i]->yOffset;
  414.                     xDiff = r2.GetWidth();
  415.  
  416.                     for (j = clients - 1; j > i + 1; j--)
  417.                     {
  418.                         clientArray[j] = clientArray[j - 1];
  419.                         clientArray[j]->clientWin->GetSize(&r2);
  420.                         r2.SetX(r2.GetX() + xDiff);
  421.                         if (r2.GetX() + r2.GetWidth() > xMax)
  422.                             xMax = r2.GetX() + r2.GetWidth();
  423.                         r2.SetY(y);
  424.                         clientArray[j]->clientWin->SetSize(&r2);
  425.                     }
  426.  
  427.                     goto mark1;
  428.                 }
  429.             }
  430.         }
  431.         else
  432.         {
  433.     newG:
  434.             if (style & TB_LEFT || style & TB_RIGHT)
  435.             {
  436.                 y0 = 0;
  437.                 for (SHORT i = 0; i < clients - 1; i++)
  438.                 {
  439.                     clientArray[i]->clientWin->GetSize(&r);
  440.                     if (r.GetY() < y0)
  441.                         y0 = r.GetY();
  442.                     xo = r.GetX() + r.GetWidth();
  443.                 }
  444.                 y0 += borderSize;
  445.                 if (newGroup)
  446.                 {
  447.                     xo = borderSize;
  448.                     y0 += r.GetHeight() + spacing;
  449.                 }
  450.                 else if (clients > 1)
  451.                     y0 += r.GetHeight();
  452.             }
  453.             else
  454.             {
  455.                 if (clients > 1)
  456.                     clientArray[clients - 2]->clientWin->GetSize(&r);
  457.                 xo = r.GetX() + r.GetWidth();
  458.             }
  459.             if (newGroup)
  460.             {
  461.                 if (style & TB_TOP || style & TB_BOTTOM)
  462.                     xo += spacing;
  463.                 else
  464.                     y0 -= spacing;
  465.             }
  466.             y += y0;
  467.         }
  468.     }
  469. mark1:
  470.  
  471.     clientArray[ins] = (clientWin *) calloc(sizeof(clientWin), 1);
  472.  
  473.     clientArray[ins]->clientWin = (XWindow *) w;
  474.     clientArray[ins]->yOffset = y;
  475.     clientArray[ins]->xOffset = x;
  476.     clientArray[ins]->group = newGroup;
  477.  
  478.     if (adjustSize)
  479.     {
  480.         XRect rec;
  481.  
  482.         w->GetSize(&rec);
  483.         if (style & TB_TOP || style & TB_BOTTOM)
  484.         {
  485.             if (rec.GetHeight() > cy - 1 * borderSize)
  486.             {
  487.                 cy = rec.GetHeight() + 2 * borderSize;
  488.                 SetHeight(cy);
  489.                 ReSize();
  490.             }
  491.         }
  492.         else
  493.         {
  494.             if (rec.GetWidth() + x + xo > cx - borderSize || xMax > cy)
  495.             {
  496.                 if (xMax)
  497.                     cx = xMax + borderSize;
  498.                 else
  499.                     cx = rec.GetWidth() + x + xo + borderSize;
  500.                 SetHeight(cy);
  501.                 ReSize();
  502.             }
  503.         }
  504.     }
  505.  
  506.     w->GetSize(&r);
  507.  
  508.     r.SetX(xo + x);
  509.     r.SetY(cy - borderSize + y - r.GetHeight());
  510.     w->SetSize(&r);
  511.  
  512.     EnableWindowUpdate();
  513. }
  514.  
  515.  
  516. /*@ XToolBar::ReSize(void)
  517. @group sizing
  518. @remarks The positions of the attached windows are recalculated.
  519. */
  520. void XToolBar::ReSize(void)
  521. {
  522.     int i;
  523.     XRect rect2, rect;
  524.  
  525.     GetSize(&rect2);
  526.  
  527.     int x = borderSize;
  528.  
  529.     if (style & TB_RIGHT || style & TB_LEFT)
  530.     {
  531.         int y = rect2.GetHeight() - borderSize;
  532.  
  533.         for (i = 0; i < clients; i++)
  534.         {
  535.             clientArray[i]->clientWin->GetSize(&rect);
  536.             if (clientArray[i]->group == TRUE)
  537.             {
  538.                 x = borderSize;
  539.                 char className[10];
  540.  
  541.                 WinQueryClassName(clientArray[i]->clientWin->GetHandle(), 10, (PCH) className);
  542.                 className[0] = ' ';
  543.                 if (atol(className) == 2)
  544.                 {
  545.                     if (i > 0)
  546.                         y -= (25 + clientArray[i]->yOffset + spacing);
  547.                     else
  548.                         y -= (25 + clientArray[i]->yOffset);
  549.                     rect.SetY(y + 25 + clientArray[i]->yOffset - rect.GetHeight());
  550.                 }
  551.                 else
  552.                 {
  553.                     if (i > 0)
  554.                         y -= (rect.GetHeight() + clientArray[i]->yOffset + spacing);
  555.                     else
  556.                         y -= (rect.GetHeight() + clientArray[i]->yOffset - borderSize);
  557.                     rect.SetY(y + clientArray[i]->yOffset);
  558.                 }
  559.             }
  560.             else
  561.             {
  562.                 if (i == 0)
  563.                     y -= (rect.GetHeight() + clientArray[i]->yOffset);
  564.                 else
  565.                     rect.SetY(y + clientArray[i]->yOffset);
  566.             }
  567.             rect.SetX(x + clientArray[i]->xOffset);
  568.             x += rect.GetWidth() + clientArray[i]->xOffset;
  569.             clientArray[i]->clientWin->SetSize(&rect);
  570.         }
  571.     }
  572.     else
  573.     {
  574.         for (i = 0; i < clients; i++)
  575.         {
  576.             clientArray[i]->clientWin->GetSize(&rect);
  577.             rect.SetY(rect2.GetHeight() - rect.GetHeight() + clientArray[i]->yOffset - borderSize);
  578.  
  579.             if (clientArray[i]->group == TRUE && i > 0)
  580.                 x += spacing;
  581.  
  582.             rect.SetX(x + clientArray[i]->xOffset);
  583.             x += rect.GetWidth() + clientArray[i]->xOffset;
  584.             clientArray[i]->clientWin->SetSize(&rect);
  585.         }
  586.     }
  587. }
  588.  
  589.  
  590. /*@ XToolBar :: XToolBar(const XFrameWindow * fr, const ULONG sty, const ULONG id, const USHORT ySize, const USHORT groupSpace)
  591. @group constructors/destructors
  592. @remarks Creates a toolbar
  593. @parameters <t '°' c=2>
  594.                 °XFrameWindow * parent        °framewindow wich gets the toolbar
  595.             °ULONG style                  °the style of the toolbar, possible values are:
  596.                                                         <t '°' c=2>
  597.                                             °TB_TOP      °toolbar is on the top of the framwindow
  598.                                             °TB_BOTTOM   °toolbar is on the bottom of the framwindow
  599.                                             °TB_LEFT     °toolbar is on the left side of the framwindow
  600.                                             °TB_RIGHT    °toolbar is on the right side of the framwindow
  601.                                             °TB_RIPABLE  °the user can rip the toolbar
  602.                                                         </t>
  603.                                          default is TB_TOP
  604.             °ULONG id                     °window-ID, default is 0
  605.             °USHORT ySize                 °hight of the toolbar in pixels, default is 20
  606.             °USHORT groupSpace            °size between window-groups in pixels, default is 15
  607.                 </t>
  608. */
  609. XToolBar :: XToolBar(const XFrameWindow * fr, const ULONG sty, const ULONG id, const USHORT ySize, const USHORT groupSpace):XFrameControl(fr, sty, id)
  610. {
  611.     cx = 30;
  612.     graph = new XGraphicDevice(this);
  613.     XColor col(COL_PALEGRAY);
  614.  
  615.     graph->SetBackgroundColor(&col);
  616.  
  617.     if (style & TB_RIPABLE)
  618.         hdl = new ToolBarHandler(this);
  619.     else
  620.         hdl = NULL;
  621.  
  622.     spacing = groupSpace;
  623.     frame = (XFrameWindow *) fr;
  624.     borderSize = 5;
  625.     clients = 0;
  626.     clientArray = NULL;
  627.  
  628.     if (!(style & TB_NOBORDER))
  629.     {
  630.         XColor colWhite(COL_WHITE);
  631.         XPoint p1(0, 0), p2(0, cy - 2);
  632.  
  633.         line1 = new XLine(graph, &p1, &p2);
  634.         line1->SetColor(&colWhite);
  635.         p1.Set(cx - 1, cy - 2);
  636.         line2 = new XLine(graph, &p2, &p1);
  637.         line2->SetColor(&colWhite);
  638.         p2.Set(cx - 1, 0);
  639.         line3 = new XLine(graph, &p2, &p1);
  640.         XColor colGray(COL_DARKGRAY);
  641.  
  642.         line3->SetColor(&colGray);
  643.         p1.Set(0, 0);
  644.         line4 = new XLine(graph, &p1, &p2);
  645.         line4->SetColor(&colGray);
  646.     }
  647.  
  648.     cy = ySize;
  649.  
  650.     SetHeight(cy);
  651. }
  652.  
  653.  
  654. /*@ XToolBar::SetBorderSize(const USHORT border)
  655. @group sizing
  656. @remarks Set the size between the border of the toolbar and the attached windows
  657. @parameters USHORT borderSize            size of border in pixels
  658. */
  659. void XToolBar::SetBorderSize(const USHORT border)
  660. {
  661.     borderSize = border;
  662. }
  663.  
  664.  
  665. /*@ XToolBar::Show(const BOOL show)
  666. @group display
  667. @remarks Show/hide the toolbar
  668. @parameters BOOL show            TRUE=show, FALSE=hide
  669. */
  670. void XToolBar::Show(const BOOL show)
  671. {
  672.     if (cutWindow)
  673.     {
  674.         cutWindow->Show(show);
  675.         return;
  676.     }
  677.     if (show)
  678.     {
  679.         WinShowWindow(winhandle, TRUE);
  680.         SetHeight(cy);
  681.     }
  682.     else
  683.     {
  684.         WinShowWindow(winhandle, FALSE);
  685.         SetHeight(0);
  686.     }
  687. }
  688.  
  689.  
  690. /*@ XToolBar::SetHeight(const USHORT y)
  691. @group sizing
  692. @remarks Set the hight of the toolbar
  693. @parameters USHORT ySize                 the new hight in pixels
  694. */
  695. BOOL XToolBar::SetHeight(const USHORT y)
  696. {
  697.     SWP swp[200];
  698.  
  699.     if (IsVisible())
  700.         cy = y;
  701.  
  702.     if (line1)
  703.     {
  704.         line1->SetHeight(y - 2);
  705.         XPoint p(0, y - 2);
  706.  
  707.         line2->Move(&p);
  708.         p.Set(cx - 1, 0);
  709.         line3->Move(&p);
  710.         line3->SetHeight(y - 2);
  711.     }
  712.     if (frame && frame->frameWin)
  713.     {
  714.         SWP swp2;
  715.  
  716.         WinQueryWindowPos(frame->winhandle, &swp2);
  717.         WinSetWindowPos(frame->winhandle, HWND_TOP, 0, 0, swp2.cx - cx, swp2.cy - y, SWP_SIZE | SWP_SHOW | SWP_ZORDER);
  718.  
  719.         SHORT res = SHORT1FROMMR(WinSendMsg(frame->frameWin->winhandle, WM_QUERYFRAMECTLCOUNT, 0, 0));
  720.  
  721.         WinSendMsg(frame->frameWin->winhandle, WM_FORMATFRAME, MPFROMP(swp), 0);
  722.  
  723.         SHORT i;
  724.  
  725.         for (i = 0; i < res; i++)
  726.         {
  727.             if (swp[i].hwnd != 0)
  728.                 WinSetWindowPos(swp[i].hwnd, swp[i].hwndInsertBehind, swp[i].x, swp[i].y, swp[i].cx, swp[i].cy, swp[i].fl);
  729.         }
  730.  
  731.         if (frame->clientWindow == NULL)
  732.             WinInvalidateRegion(frame->winhandle, NULLHANDLE, TRUE);
  733.  
  734.         return TRUE;
  735.     }
  736.     else
  737.         return FALSE;
  738. }
  739.  
  740.  
  741. /*@ XToolBar :: ~XToolBar()
  742. @group constructors/destructors
  743. @remarks Destructor, every attached window is destroyed and the destructors of the
  744. windows are called.
  745. */
  746. XToolBar :: ~XToolBar()
  747. {
  748.     WinDestroyWindow(winhandle);
  749.     for (int i = 0; i < clients; i++)
  750.         free(clientArray[i]);
  751.     free(clientArray);
  752.     delete graph;
  753. }
  754.