Пример #1
0
    HINTERNET OpenRequest(LPCSTR lpszVerb, LPCSTR lpszObjectName,
                          LPCSTR lpszVersion, LPCSTR lpszReferer,
                          LPCSTR *lplpszAcceptTypes,
                          DWORD dwFlags,
                          DWORD_PTR dwContext) const {
      assert(IsDefined());

      return ::HttpOpenRequestA(Get(),
                                lpszVersion, lpszObjectName,
                                lpszVersion, lpszReferer,
                                lplpszAcceptTypes,
                                dwFlags,
                                dwContext);
    }
Пример #2
0
  /**
   * Returns the position on the screen.
   */
  gcc_pure
  const PixelRect GetScreenPosition() const
  {
    assert(IsDefined());

    PixelRect rc;
#ifndef USE_WINUSER
    rc = GetPosition();
    ToScreen(rc);
#else
    ::GetWindowRect(hWnd, &rc);
#endif
    return rc;
  }
Пример #3
0
void
Brush::Reset()
{
  assert(!IsDefined() || IsScreenInitialized());

  #ifndef USE_GDI
  hollow = true;
  #else
  if (brush != NULL) {
    ::DeleteObject(brush);
    brush = NULL;
  }
  #endif
}
Пример #4
0
//------------------------------------------------------------------------------
void
Canvas::Stretch(int dest_x, int dest_y,
                unsigned dest_width, unsigned dest_height,
                const Bitmap &_src)
  {
#if 0
  assert(IsDefined());
  assert(_src.IsDefined());

  ConstImageBuffer src = _src.GetNative();
  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, 0, 0, src.width, src.height);
#endif
  }
Пример #5
0
void
Canvas::Stretch(int dest_x, int dest_y,
                unsigned dest_width, unsigned dest_height,
                const Bitmap &src,
                int src_x, int src_y,
                unsigned src_width, unsigned src_height)
{
  assert(IsDefined());
  assert(src.IsDefined());

  Stretch(dest_x, dest_y, dest_width, dest_height,
          src.GetNative(),
          src_x, src_y, src_width, src_height);
}
Пример #6
0
bool
FileDescriptor::CreateEventFD(unsigned initval)
{
  assert(!IsDefined());

#ifdef __BIONIC__
  /* Bionic provides the eventfd() function only since Android 2.3,
     therefore we must roll our own system call here */
  fd = syscall(__NR_eventfd2, initval, O_NONBLOCK|O_CLOEXEC);
#else
  fd = ::eventfd(initval, EFD_NONBLOCK|EFD_CLOEXEC);
#endif
  return fd >= 0;
}
Пример #7
0
void
Canvas::Stretch(PixelScalar dest_x, PixelScalar dest_y,
                UPixelScalar dest_width, UPixelScalar dest_height,
                const Bitmap &src,
                PixelScalar src_x, PixelScalar src_y,
                UPixelScalar src_width, UPixelScalar src_height,
                DWORD dwRop)
{
  assert(IsDefined());
  assert(src.IsDefined());

  Stretch(dest_x, dest_y, dest_width, dest_height,
          src.GetNative(), src_x, src_y, src_width, src_height,
          dwRop);
}
Пример #8
0
void
Pen::Reset()
{
  assert(!IsDefined() || IsScreenInitialized());

  if (pen != NULL) {
#ifndef NDEBUG
    bool success =
#endif
      ::DeleteObject(pen);
    assert(success);

    pen = NULL;
  }
}
Пример #9
0
bool
IOThread::Start()
{
  assert(!IsDefined());
  assert(loop.IsEmpty());

  quit = false;

  if (!pipe.Create())
    return false;

  loop.Add(pipe.GetReadFD(), READ, *this);

  return Thread::Start();
}
Пример #10
0
bool
IOThread::Start()
{
  assert(!IsDefined());
  assert(files.empty());

  modified = quit = running = false;

  if (!pipe.Create())
    return false;

  poll.SetMask(pipe.GetReadFD(), Poll::READ);

  return Thread::Start();
}
Пример #11
0
void
DockWindow::SetWidget(Widget *_widget)
{
  assert(IsDefined());
  assert(widget == nullptr);

  widget = _widget;

  if (widget != nullptr) {
    const PixelRect rc = GetClientRect();
    widget->Initialise(*this, rc);
    widget->Prepare(*this, rc);
    widget->Show(rc);
  }
}
Пример #12
0
void
Thread::Join()
{
  assert(IsDefined());
  assert(!IsInside());

#ifdef HAVE_POSIX
  pthread_join(handle, NULL);
  defined = false;
#else
  ::WaitForSingleObject(handle, INFINITE);
  ::CloseHandle(handle);
  handle = NULL;
#endif
}
Пример #13
0
  gcc_pure
  const PixelSize GetSize() const
  {
    assert(IsDefined());

#ifdef USE_GDI
    PixelRect rc = GetClientRect();
    PixelSize s;
    s.cx = rc.right;
    s.cy = rc.bottom;
    return s;
#else
    return size;
#endif
  }
Пример #14
0
void
Brush::Reset()
{
  assert(!IsDefined() || IsScreenInitialized());

  if (brush != nullptr) {
#ifndef NDEBUG
    bool success =
#endif
      ::DeleteObject(brush);
    assert(success);

    brush = nullptr;
  }
}
Пример #15
0
void
StandbyThread::WaitStopped()
{
  assert(!IsInside());
  assert(mutex.IsLockedByCurrent());
  assert(stop);

  if (!IsDefined())
    /* was never started */
    return;

  /* mutex must be unlocked because Thread::Join() blocks */
  const ScopeUnlock unlock(mutex);
  Thread::Join();
}
Пример #16
0
void
Canvas::copy(PixelScalar dest_x, PixelScalar dest_y,
             UPixelScalar dest_width, UPixelScalar dest_height,
             HBITMAP src, PixelScalar src_x, PixelScalar src_y,
             DWORD dwRop)
{
  assert(IsDefined());
  assert(src != NULL);

  HDC virtual_dc = GetCompatibleDC();
  HBITMAP old = (HBITMAP)::SelectObject(virtual_dc, src);
  copy(dest_x, dest_y, dest_width, dest_height,
       virtual_dc, src_x, src_y,
       dwRop);
  ::SelectObject(virtual_dc, old);
}
Пример #17
0
void
Canvas::Copy(int dest_x, int dest_y,
             unsigned dest_width, unsigned dest_height,
             HBITMAP src, int src_x, int src_y,
             DWORD dwRop)
{
  assert(IsDefined());
  assert(src != nullptr);

  HDC virtual_dc = GetCompatibleDC();
  HBITMAP old = (HBITMAP)::SelectObject(virtual_dc, src);
  Copy(dest_x, dest_y, dest_width, dest_height,
       virtual_dc, src_x, src_y,
       dwRop);
  ::SelectObject(virtual_dc, old);
}
Пример #18
0
void
Canvas::copy_transparent_white(const Canvas &src)
{
  assert(IsDefined());
  assert(src.IsDefined());

#ifdef _WIN32_WCE
  ::TransparentImage(dc, 0, 0, get_width(), get_height(),
                     src.dc, 0, 0, get_width(), get_height(),
                     COLOR_WHITE);
#else
  ::TransparentBlt(dc, 0, 0, get_width(), get_height(),
                   src.dc, 0, 0, get_width(), get_height(),
                   COLOR_WHITE);
#endif
}
Пример #19
0
void
BufferCanvas::CopyTo(Canvas &other)
{
  assert(IsDefined());
  assert(!active || frame_buffer != nullptr);

#ifdef USE_GLSL
  OpenGL::texture_shader->Use();
#else
  const GLEnable<GL_TEXTURE_2D> scope;
  OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
#endif

  texture->Bind();
  texture->DrawFlipped(other.GetRect(), GetRect());
}
Пример #20
0
bool RegionOfRows::IsInRegion(unsigned int Column,unsigned int Row)const
{
    if (!IsDefined()) return false;			// Can't process an empty region

    // In range of rows ?

    if (!Rows.IsInRange(Row)) return false;	// Row is out of range

    // Row is in range, investigate the columns

    unsigned int RowOffset = Row - Rows.GetStart();

    // Column is in range ?

    return Columns[RowOffset].IsInRange(Column);
}
Пример #21
0
WndProperty *
RowFormWidget::AddSpacer()
{
  assert(IsDefined());

  const PixelRect edit_rc = InitialControlRect(Layout::Scale(6));

  WindowStyle style;
  EditWindowStyle edit_style;
  edit_style.SetVerticalCenter();
  edit_style.SetReadOnly();

  PanelControl &panel = *(PanelControl *)GetWindow();
  WndProperty *edit = new WndProperty(panel, look, _T(""), edit_rc, 0, style, edit_style, NULL);
  Add(edit);
  return edit;
}
Пример #22
0
unsigned int RegionOfRows::GetNumberOfColumnsOnLargestRow() const
{
    if (!IsDefined()) return 0;
    unsigned int MaximumNumberofColumns = 0;
    const ClosedInterval<unsigned int>* MyColumns = GetColumns();
    unsigned int NumberOfRows = Rows.GetSpan() + 1;

    for (unsigned int i=0; i < NumberOfRows;++i)
    {
        unsigned int ColumnsOnRow = MyColumns->GetSpan() + 1;
        if (ColumnsOnRow > MaximumNumberofColumns)  MaximumNumberofColumns = ColumnsOnRow;

        MyColumns++;
    }

    return MaximumNumberofColumns;
}
Пример #23
0
void
TabMenuDisplay::SetCursor(unsigned i)
{
  if (i == cursor)
    return;

  if (IsDefined()) {
    if (SupportsPartialRedraw() &&
        GetPageMainIndex(cursor) == GetPageMainIndex(i)) {
      Invalidate(GetSubMenuButtonSize(cursor));
      Invalidate(GetSubMenuButtonSize(i));
    } else
      Invalidate();
  }

  cursor = i;
}
Пример #24
0
void 
UnitSymbol::Draw(Canvas &canvas, PixelScalar x, PixelScalar y,
                 Color bg_color, Color text_color) const
{
  assert(IsDefined());

  const PixelSize size = GetSize();
  const PixelSize screen_size = GetScreenSize();
  canvas.StretchMono(x, y, screen_size.cx, screen_size.cy,
#if defined(USE_GDI) || defined(ENABLE_OPENGL)
                     bitmap,
#else
                     buffer,
#endif
                     0, 0, size.cx, size.cy,
                     text_color, bg_color);
}
Пример #25
0
bool
EventPipe::Create()
{
  assert(!IsDefined());

#ifdef HAVE_EVENTFD
  return r.CreateEventFD();
#else
  if (!UniqueFileDescriptor::CreatePipe(r, w))
    return false;

  r.SetNonBlocking();
  w.SetNonBlocking();

  return true;
#endif
}
Пример #26
0
int
SocketDescriptor::WaitWritable(int timeout_ms) const
{
  assert(IsDefined());

  fd_set wfds;
  FD_ZERO(&wfds);
  FD_SET(Get(), &wfds);

  struct timeval timeout, *timeout_p = nullptr;
  if (timeout_ms >= 0) {
    timeout.tv_sec = unsigned(timeout_ms) / 1000;
    timeout.tv_usec = (unsigned(timeout_ms) % 1000) * 1000;
    timeout_p = &timeout;
  }

  return select(Get() + 1, nullptr, &wfds, nullptr, timeout_p);
}
Пример #27
0
void
RowFormWidget::AddButton(const TCHAR *label, ActionListener &listener, int id)
{
  assert(IsDefined());

  const PixelRect button_rc =
    InitialControlRect(Layout::GetMinimumControlHeight());

  ButtonWindowStyle button_style;
  button_style.TabStop();
  button_style.multiline();

  ContainerWindow &panel = *(ContainerWindow *)GetWindow();

  WndButton *button = new WndButton(panel, look, label, button_rc, button_style, listener, id);

  Add(Row::Type::BUTTON, button);
}
Пример #28
0
void
Canvas::StretchAnd(int dest_x, int dest_y,
               unsigned dest_width, unsigned dest_height,
               const Bitmap &src, 
               int src_x, int src_y, unsigned src_width, unsigned src_height)
{
  assert(IsDefined());
  assert(src.IsDefined());
  
  ConstImageBuffer srcImg = src.GetNative();  
  
  SDLRasterCanvas canvas(buffer);
  BitAndPixelOperations<ActivePixelTraits> operations;

  canvas.ScaleRectangle(dest_x, dest_y, dest_width, dest_height,
                       srcImg.At(src_x, src_y), srcImg.pitch, src_width, src_height,
                       operations);
}
Пример #29
0
void
Canvas::CopyTransparentWhite(int dest_x, int dest_y,
                             unsigned dest_width, unsigned dest_height,
                             const Canvas &src, int src_x, int src_y)
{
  assert(IsDefined());
  assert(src.IsDefined());

#ifdef _WIN32_WCE
  ::TransparentImage(dc, dest_x, dest_y, dest_width, dest_height,
                     src.dc, src_x, src_y, dest_width, dest_height,
                     COLOR_WHITE);
#else
  ::TransparentBlt(dc, dest_x, dest_y, dest_width, dest_height,
                   src.dc, src_x, src_y, dest_width, dest_height,
                   COLOR_WHITE);
#endif
}
Пример #30
0
void
Window::Destroy()
{
  if (!IsDefined())
    return;

  assert(IsScreenInitialized());
  AssertThread();

#ifndef USE_WINUSER
  OnDestroy();

  size = {0, 0};
#else /* USE_WINUSER */
  ::DestroyWindow(hWnd);
  hWnd = nullptr;
#endif /* USE_WINUSER */
}