home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / UIBORDER.PAK / UIBORDEX.CPP < prev   
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.9 KB  |  117 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1995 by Borland International, All Rights Reserved
  4. //----------------------------------------------------------------------------
  5. #include <owl/pch.h>
  6. #include <owl/applicat.h>
  7. #include <owl/framewin.h>
  8. #include <owl/uihelper.h>
  9. #include <owl/listbox.h>
  10. #include <owl/gdiobjec.h>
  11. #include <winsys/uimetric.h>
  12. #include <stdio.h>
  13.  
  14. //
  15. // class TSampleWindow
  16. // ~~~~~ ~~~~~~~~~~~~~
  17. class TSampleWindow : public TWindow {
  18.   public:
  19.     TSampleWindow();
  20.  
  21.   protected:
  22.     void Paint(TDC& dc, bool erase, TRect& rect);
  23.  
  24.   DECLARE_RESPONSE_TABLE(TSampleWindow);
  25. };
  26.  
  27. DEFINE_RESPONSE_TABLE1(TSampleWindow, TWindow)
  28. END_RESPONSE_TABLE;
  29.  
  30. TSampleWindow::TSampleWindow()
  31. :
  32.   TWindow(0, 0, 0)
  33. {
  34.   Attr.X = 0;
  35.   Attr.Y = 0;
  36.   Attr.W = 240;
  37.   Attr.H = 28 * (10+1) + 20;
  38. //  Attr.ExStyle |= WS_EX_CONTROLPARENT; //WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW;
  39.  
  40.   SetBkgndColor(TColor::Sys3dFace);
  41. }
  42.  
  43. //
  44. // Paint some UI style thingies
  45. //
  46. void
  47. TSampleWindow::Paint(TDC& dc, bool, TRect&)
  48. {
  49.   // Paint some UIBorders
  50.   //
  51.   TRect r(10,10,10+24,10+24);
  52.   TPoint p(0, 28);
  53.   for (int i = TUIBorder::Plain; i <= TUIBorder::WellSet; i++) { 
  54.     static char* label[] = {
  55.       "Plain",
  56.       "Raised",
  57.       "Recessed",
  58.       "Embossed",
  59.       "Grooved",
  60.       "Button Up",
  61.       "Button Down",
  62.       "Window Raised",
  63.       "Window Recessed",
  64.       "Well Set",
  65.       "Button Up (old)",
  66.       "Button Down (old)",
  67.     };
  68.     TUIBorder b(r, TUIBorder::TStyle(i));
  69.     b.Paint(dc);
  70.     if (i == TUIBorder::WndRaised || i == TUIBorder::WndRecessed ||
  71.         i == TUIBorder::WellSet)
  72.       dc.TextRect(b.GetClientRect(), TColor::SysWindow);
  73.     dc.SetBkColor(TColor::Sys3dFace);
  74.     dc.TextOut(r.right + 5, r.top + 5, label[i-TUIBorder::Plain]);
  75.     r += p;
  76.   }
  77.  
  78.   // A Mini Window: Window border + an inset field
  79.   //
  80.   r.right += 10;
  81.   r.bottom += 10;
  82.   TUIBorder b1(r, TUIBorder::WndRaised);
  83.   b1.Paint(dc);
  84.   TUIBorder b2(r.InflatedBy(-TUIMetric::CxFixedFrame,-TUIMetric::CyFixedFrame),
  85.     TUIBorder::WndRecessed);
  86.   b2.Paint(dc);
  87.   dc.TextRect(b2.GetClientRect(), TColor::SysWindow);
  88.  
  89.   // Paint thin divider lines
  90.   //
  91.   TUIBorder b3(TRect(TPoint(5,287),TSize(180,2)), TUIBorder::Recessed);
  92.   b3.Paint(dc);
  93.   TUIBorder b4(TRect(TPoint(150,5),TSize(2,290)), TUIBorder::Recessed);
  94.   b4.Paint(dc);
  95. }
  96.  
  97. //----------------------------------------------------------------------------
  98.  
  99. //
  100. // class TSampleApp
  101. // ~~~~~ ~~~~~~~~~~
  102. class TSampleApp : public TApplication {
  103.   public:
  104.     TSampleApp() : TApplication() {}
  105.     void InitMainWindow() {
  106.       TFrameWindow* frame = new TFrameWindow(0, "UI Border", new TSampleWindow, true);
  107.       frame->Attr.Style &= ~WS_THICKFRAME;
  108.       SetMainWindow(frame);
  109.     }
  110. };
  111.  
  112. int
  113. OwlMain(int /*argc*/, char* /*argv*/ [])
  114. {
  115.   return TSampleApp().Run();
  116. }
  117.