home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xstatic.cpp < prev    next >
C/C++ Source or Header  |  1997-03-07  |  4KB  |  141 lines

  1. #include "XSIcon.h"
  2. #include "XSFrame.h"
  3. #include "XSBitmap.h"
  4. #include "XGroupBx.h"
  5. #include "XSText.h"
  6. #include "xcontrol.h"
  7. #include <stdio.h>
  8.  
  9. XStatic :: XStatic(const HWND hwnd)
  10. {
  11.     winhandle = hwnd;
  12.     WinSetWindowPtr(hwnd, 0, this);
  13. }
  14.  
  15.  
  16. XStatic :: XStatic(const ULONG style, const char *title, const PSZ classname, XWindow * ow, const XRect * r, const LONG id, char *font)
  17. {
  18.    PRES pres;
  19.  
  20.     LONG x = 0, y = 0, cx = 0, cy = 0;
  21.  
  22.     if (r)
  23.     {
  24.         x = r->GetX();
  25.         y = r->GetY();
  26.         cx = r->GetWidth();
  27.         cy = r->GetHeight();
  28.     }
  29.     char buffer[100], *ch;
  30.  
  31.     void *p = NULL;
  32.  
  33.     if (font)
  34.     {
  35.         pres.fcparam.id = PP_FOREGROUNDCOLORINDEX;
  36.         pres.fcparam.cb = sizeof(pres.fcparam.ulColor);
  37.         pres.fcparam.ulColor = 16;
  38.         pres.fntparam.id = PP_FONTNAMESIZE;
  39.         pres.fntparam.cb = 20;
  40.         pres.cb = sizeof(pres.fcparam) + sizeof(pres.fntparam);
  41.         p = (void *) &pres;
  42.         strcpy(pres.fntparam.szFontNameSize, font);
  43.     }
  44.  
  45.     if ((style & SS_ICON || style & SS_BITMAP) && id > 0 && (!(style & SS_TEXT)))
  46.     {
  47.         sprintf(buffer, "#%i", (int) id);
  48.         ch = buffer;
  49.     }
  50.     else
  51.         ch = (char *) title;
  52.  
  53.     OOL_WINDOWHANDLE handle = ow->GetHandle();
  54.  
  55.     winhandle = WinCreateWindow(handle, classname, (PSZ) ch, style, x, y, cx, cy, handle, HWND_TOP, id, NULL, p);
  56.     WinSetWindowPtr(winhandle, 0, this);
  57.  
  58.     XColor color;
  59.  
  60.     ow->GetBackgroundColor(&color);
  61.     SetBackgroundColor(&color);
  62. }
  63.  
  64.  
  65. /*@ XStaticText :: XStaticText(XWindow * w, const char *text, const XRect * r, const LONG style, const LONG id, char *font)
  66. @group constructors/destructors
  67. @remarks Constructs a static text
  68. @parameters <t '°' c=2>
  69.                 °XWindow * owner      °the owner of the icon
  70.                 °char * text                °text to display
  71.             °XRect * rect         °the rectangle
  72.             °LONG style           °the style
  73.             °LONG id              °the id of the icon in the program resources
  74.                 °char * font                °font to use, eg "8.Helv" (default is NULL)
  75.                 </t>
  76. */
  77. XStaticText :: XStaticText(XWindow * w, const char *text, const XRect * r, const LONG style, const LONG id, char *font):XStatic(SS_TEXT | style, (char *) text, WC_STATIC, w, r, id, font)
  78. {
  79. }
  80.  
  81.  
  82. /*@ XStaticIcon :: XStaticIcon(XWindow * w, const XRect * r, const LONG id, const LONG style)
  83. @group constructors/destructors
  84. @remarks Constructs a static icon
  85. @parameters <t '°' c=2>
  86.                 °XWindow * owner      °the owner of the icon
  87.             °XRect * rect         °the rectangle
  88.             °LONG id              °the id of the icon in the program resources
  89.             °LONG style           °the style
  90.                 </t>
  91. */
  92. XStaticIcon :: XStaticIcon(XWindow * w, const XRect * r, const LONG id, const LONG style):XStatic(SS_ICON | WIN_VISIBLE | style, "", WC_STATIC, w, r, id)
  93. {
  94. }
  95.  
  96.  
  97. /*@ XStaticBitmap :: XStaticBitmap(XWindow * w, const XRect * r, const LONG id, const LONG style)
  98. @group constructors/destructors
  99. @remarks Constructs a static bitmap
  100. @parameters <t '°' c=2>
  101.                 °XWindow * owner      °the owner of the bitmap
  102.             °XRect * rect         °the rectangle
  103.             °LONG id              °the id of the bitmap in the program resources
  104.             °LONG style           °the style
  105.                 </t>
  106. */
  107. XStaticBitmap :: XStaticBitmap(XWindow * w, const XRect * r, const LONG id, const LONG style):XStatic(SS_BITMAP | WIN_VISIBLE | style, "", WC_STATIC, w, r, id)
  108. {
  109. }
  110.  
  111.  
  112. /*@ XStaticFrame :: XStaticFrame(XWindow * w, const XRect * r, LONG id)
  113. @group constructors/destructors
  114. @remarks Constructs a static frame
  115. @parameters <t '°' c=2>
  116.                 °XWindow * owner      °the owner of the frame
  117.             °XRect * rect         °the rectangle
  118.                 °LONG id                  °id for the frame
  119.                 </t>
  120. */
  121. XStaticFrame :: XStaticFrame(XWindow * w, const XRect * r, LONG id):XStatic(SS_FGNDFRAME | WIN_VISIBLE, "", WC_STATIC, w, r, id)
  122. {
  123. }
  124.  
  125.  
  126.  
  127. /*@ XGroupBox :: XGroupBox(XWindow * owner, const XRect * rec, const char *string, const LONG id)
  128. @group constructors/destructors
  129. @remarks Constructs a group-box
  130. @parameters <t '°' c=2>
  131.                 °XWindow * owner      °the owner of the box
  132.             °XRect * rect         °the rectangle
  133.             °const char* title    °the title of the group-box
  134.                 </t>
  135. */
  136. XGroupBox :: XGroupBox(XWindow * owner, const XRect * rec, const char *string, const LONG id):XStatic(SS_GROUPBOX | WS_VISIBLE, (char *) string, WC_STATIC, owner, rec, id)
  137. {
  138. }
  139.  
  140.  
  141.