Example #1
0
bool Icon::Open(int cx, int cy, String dir)
{
	if (windows == NULL)
	{
		windows = new ArrayList<_P<FileWindow> >;
	}
	else
	{
		for (int i = 0; i < windows->get_Count(); i++)
		{
			_P<FileWindow> win = windows->get_Item(i);
			if (!win->get_Visible())
			{
				windows->RemoveAt(i);
				i--;
			}
			else if (win->get_Text() == dir)
			{
				return false;
			}
		}
	}
	
	_P<FileWindow> win = new FileWindow();
	windows->Add(win);
	MonAPI::Message::sendReceive(NULL, gui_server, MSG_GUISERVER_EXPANSIONEFFECT,
		MAKE_DWORD(cx, cy),
		MAKE_DWORD(win->get_X(), win->get_Y()),
		MAKE_DWORD(win->get_Width(), win->get_Height()));
	win->Show();
	win->set_Directory(dir);
	return true;
}
Example #2
0
Size Icon::DrawIcon(_P<Graphics> g, String name, Icons icon, int x, int y, bool emboss, bool selection)
{
	g->DrawImage(icons, x + (ARRANGE_WIDTH - 32) / 2, y, Rectangle(0, 32 * (int)icon, 32, 32));
	_P<Font> f = Control::get_DefaultFont();
	Size ret = g->MeasureString(name, f);
	x += (ARRANGE_WIDTH - ret.Width) / 2;
	Color black = Color::get_Black(), white = Color::get_White();
	int r = x + ret.Width - 1, ly = y + 34 + ret.Height + 1;
	if (emboss)
	{
		g->DrawString(name, f, black, x + 1, y + 34);
		g->DrawString(name, f, black, x - 1, y + 34);
		g->DrawString(name, f, black, x, y + 33);
		g->DrawString(name, f, black, x, y + 35);
		g->DrawString(name, f, white, x, y + 34);
		if (selection)
		{
			g->DrawLine(black, x, ly - 1, r, ly - 1);
			g->DrawLine(white, x, ly    , r, ly    );
			g->DrawLine(black, x, ly + 1, r, ly + 1);
			g->SetPixel(x - 1, ly, black);
			g->SetPixel(r + 1, ly, black);
		}
	}
	else
	{
		g->DrawString(name, f, black, x, y + 34);
		if (selection)
		{
			g->DrawLine(black, x, ly, r, ly);
		}
	}
	return ret;
}
Example #3
0
static void StdoutMessageLoop()
{
    MonAPI::Stream stream;
    MessageInfo msg;
    uint32_t shellServerID;
    if (monapi_name_whereis("/servers/scheme", shellServerID) != M_OK) {
        monapi_fatal("server not found");
    }

    MonAPI::Message::sendReceive(&msg, shellServerID, MSG_CHANGE_OUT_STREAM_BY_HANDLE, stream.handle());
    g_oldStreamOutHandle = msg.arg2;

    MonAPI::terminal::CommandParser* parser = new MonAPI::terminal::CommandParser(g_terminal.get());
    const uint32_t BUFFER_SIZE = 1024;
    for (;;)
    {
        uint8_t buffer[BUFFER_SIZE];
        stream.waitForRead();
        uint32_t size = stream.read(buffer, BUFFER_SIZE);
        if (size == 0) continue;
        buffer[size == BUFFER_SIZE ? BUFFER_SIZE - 1 : size] = '\0';
        // don't display ^EOP
        char* found = MonAPI::strstr_n((char*)buffer, "^EOP", size);
        if (NULL != found)
        {
            memset(found, '\0', 4);
        }

        parser->parse(buffer, size);
        g_terminal->Refresh();
    }
}
Example #4
0
 Form1(String fn, _P<Bitmap> bmp, int x, int y)
 {
     this->set_Text(fn);
     this->set_Location(Point(x, y));
     this->set_ClientSize(Size(bmp->get_Width(), bmp->get_Height()));
     this->bitmap = bmp;
 }
Example #5
0
 void InitializeComponent()
 {
     this->set_ClientSize(Size(Terminal::WIDTH * Terminal::FONT_WIDTH + 4, Terminal::HEIGHT * Terminal::FONT_HEIGHT + 4));
     this->set_Text("Terminal");
     this->set_Opacity(0.8);
     g_terminal = new Terminal();
     g_terminal->set_Bounds(Rectangle(Point::get_Empty(), this->get_ClientSize()));
     this->get_Controls()->Add(g_terminal.get());
 }
void memory_pool_test(_P& memPool) {

  ASSERT_NE(FALSE, memPool.isValid());
  TRACE("Total Size = %u", memPool.total_size());
  TRACE("Free Size = %u", memPool.free_size());

  void* arrMem[2048] = {NULL};
  uint32_t alloc_count = 0;
  {
    void* arrMemCheck[2048] = {NULL};
    for (uint32_t idx = 0; idx < 512; ++idx) {

      void* mem = NULL;
      mem = memPool.get(64);
      if (NULL == mem) {
        TRACE("Total Size = %u", memPool.total_size());
        TRACE("Free Size = %u", memPool.free_size());
        continue;
      }

      arrMem[alloc_count] = mem;
      arrMemCheck[alloc_count] = mem;
      alloc_count++;
    }

    uint32_t reuse_count = 0;
    uint32_t release_count = 0;
    // clear
    for (uint32_t idx = 0; idx < alloc_count; ++idx) {

      void* mem = arrMem[idx];
      ASSERT_NE(NULL, mem);
      memPool.release(mem);
      arrMem[idx] = NULL;

      ++idx;
      ++release_count;
    }
    
    // again
    for (uint32_t idx = 0; idx < 512; ++idx) {

      void* mem = NULL;
      mem = memPool.get(64);
      if (NULL == mem) { continue; }
      if (RC_S_OK == find_memory((const void**)(&arrMemCheck), sizeof(arrMemCheck), mem)) {
        ++reuse_count;
      }

      arrMem[alloc_count] = mem;
      alloc_count++;
    }

    ASSERT_EQ(release_count, reuse_count);
    TRACE("reuse count = %u", reuse_count);
  }

  {
    void* mem = NULL;
    memPool.release(mem);
    mem = NULL;
  }

  {
    void* mem = NULL;
    mem = memPool.get(65*1024);
    //ASSERT_EQ(NULL, mem);
    arrMem[alloc_count] = mem;
    alloc_count++;
  }

  // release all
  {
    for (uint32_t idx = 0; idx < alloc_count; ++idx) {

      void* mem = arrMem[idx];
      if (mem) {
        memPool.release(mem);
      }
    }
  }
}