aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/wnd/wndclass/sepwnd.cpp
blob: da45b11b3e6c97a497efb81e1ab29eb769218ae6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <precomp.h>

#include <tataki/bitmap/bitmap.h>
#include <api/wnd/basewnd.h>
#include "sepwnd.h"
#include <tataki/canvas/canvas.h>
#include <api/wnd/PaintCanvas.h>

SepWnd::SepWnd() {
  bitmap = NULL;
  orientation = SEP_UNKNOWN;
}

SepWnd::~SepWnd() {
  if (bitmap) delete bitmap;
}

int SepWnd::onPaint(Canvas *canvas) {

  PaintBltCanvas paintcanvas;
  if (canvas == NULL) {
    if (!paintcanvas.beginPaintNC(this)) return 0;
    canvas = &paintcanvas;
  }


  if (!bitmap) {
    switch (orientation) {
      case SEP_VERTICAL:
        bitmap = new SkinBitmap(L"studio.FrameVerticalDivider");
        break;
      case SEP_HORIZONTAL:
        bitmap = new SkinBitmap(L"studio.FrameHorizontalDivider");
        break;
      case SEP_UNKNOWN:
        return 1;
    }
    ASSERT(bitmap != NULL);
  }
  RECT r;
  getClientRect(&r);
  RenderBaseTexture(canvas, r);
  if (bitmap) {
    bitmap->stretchToRectAlpha(canvas, &r, 128);
  }
  return 1;
}

int SepWnd::setOrientation(int which) {
  orientation = which;
  return 1;  
}

int SepWnd::onInit() {
  SEPWND_PARENT::onInit();
  return 1;
}

void SepWnd::freeResources() {
  SEPWND_PARENT::freeResources();
  if (bitmap) delete bitmap;
  bitmap = NULL;
}