コード例 #1
0
BrushIconBox::BrushIconBox(wxWindow *parent, const TilesetCategory *_tileset, RenderSize rsz) :
	wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL),
	BrushBoxInterface(_tileset),
	icon_size(rsz)
{
	ASSERT(tileset->getType() >= TILESET_UNKNOWN && tileset->getType() <= TILESET_HOUSE);
	int width;
	if(icon_size == RENDER_SIZE_32x32) {
		width = max(g_settings.getInteger(Config::PALETTE_COL_COUNT) / 2 + 1, 1);
	} else {
		width = max(g_settings.getInteger(Config::PALETTE_COL_COUNT) + 1, 1);
	}

	// Create buttons
	wxSizer* stacksizer = newd wxBoxSizer(wxVERTICAL);
	wxSizer* rowsizer = nullptr;
	int item_counter = 0;
	for(BrushVector::const_iterator iter = tileset->brushlist.begin(); iter != tileset->brushlist.end(); ++iter) {
		ASSERT(*iter);
		++item_counter;

		if(!rowsizer) {
			rowsizer = newd wxBoxSizer(wxHORIZONTAL);
		}

		BrushButton* bb = newd BrushButton(this, *iter, rsz);
		rowsizer->Add(bb);
		brush_buttons.push_back(bb);

		if(item_counter % width == 0) { // newd row
			stacksizer->Add(rowsizer);
			rowsizer = nullptr;
		}
	}
	if(rowsizer) {
		stacksizer->Add(rowsizer);
	}

	SetScrollbars(20,20, 8, item_counter/width, 0, 0);
	SetSizer(stacksizer);
}
コード例 #2
0
ファイル: palette_common.cpp プロジェクト: Codex-NG/rme
void BrushToolPanel::LoadAllContents()
{
	if(loaded) return;

	wxSizer* size_sizer = newd wxBoxSizer(wxVERTICAL);;
	wxSizer* sub_sizer = newd wxBoxSizer(wxHORIZONTAL);

	/*RenderSize render_size;
	if(large_icons) {
		// 32x32
		render_size = RENDER_SIZE_32x32;
	} else {
		// 16x16
		render_size = RENDER_SIZE_16x16;
	}*/
	
	if(large_icons) {
		// Create the tool page with 32x32 icons

		ASSERT(gui.optional_brush);
		sub_sizer->Add(optionalBorderButton = newd BrushButton(this, gui.optional_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_OPTIONAL_BORDER_TOOL));
			optionalBorderButton->SetToolTip(wxT("Optional Border Tool"));

		ASSERT(gui.eraser);
		sub_sizer->Add(eraserButton = newd BrushButton(this, gui.eraser, RENDER_SIZE_32x32, PALETTE_TERRAIN_ERASER));
			eraserButton->SetToolTip(wxT("Eraser"));

		ASSERT(gui.pz_brush);
		sub_sizer->Add(pzBrushButton = newd BrushButton(this, gui.pz_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_PZ_TOOL));
			pzBrushButton->SetToolTip(wxT("PZ Tool"));

		ASSERT(gui.rook_brush);
		sub_sizer->Add(nopvpBrushButton = newd BrushButton(this, gui.rook_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_NOPVP_TOOL));
			nopvpBrushButton->SetToolTip(wxT("NO PVP Tool"));

		ASSERT(gui.nolog_brush);
		sub_sizer->Add(nologBrushButton = newd BrushButton(this, gui.nolog_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_NOLOGOUT_TOOL));
			nologBrushButton->SetToolTip(wxT("No Logout Tool"));

		ASSERT(gui.pvp_brush);
		sub_sizer->Add(pvpzoneBrushButton = newd BrushButton(this, gui.pvp_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_PVPZONE_TOOL));
			pvpzoneBrushButton->SetToolTip(wxT("PVP Zone Tool"));
		
		// New row
		size_sizer->Add(sub_sizer);
		sub_sizer = newd wxBoxSizer(wxHORIZONTAL);

		ASSERT(gui.normal_door_brush);
		sub_sizer->Add(normalDoorButton = newd BrushButton(this, gui.normal_door_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_NORMAL_DOOR));
			normalDoorButton->SetToolTip(wxT("Normal Door Tool"));

		ASSERT(gui.locked_door_brush);
		sub_sizer->Add(lockedDoorButton = newd BrushButton(this, gui.locked_door_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_LOCKED_DOOR));
			lockedDoorButton->SetToolTip(wxT("Locked Door Tool"));

		ASSERT(gui.magic_door_brush);
		sub_sizer->Add(magicDoorButton = newd BrushButton(this, gui.magic_door_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_MAGIC_DOOR));
			magicDoorButton->SetToolTip(wxT("Magic Door Tool"));
			
		ASSERT(gui.quest_door_brush);
		sub_sizer->Add(questDoorButton = newd BrushButton(this, gui.quest_door_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_QUEST_DOOR));
			questDoorButton->SetToolTip(wxT("Quest Door Tool"));
			
		ASSERT(gui.hatch_door_brush);
		sub_sizer->Add(hatchDoorButton = newd BrushButton(this, gui.hatch_door_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_HATCH_DOOR));
			hatchDoorButton->SetToolTip(wxT("Hatch Window Tool"));

		ASSERT(gui.window_door_brush);
		sub_sizer->Add(windowDoorButton = newd BrushButton(this, gui.window_door_brush, RENDER_SIZE_32x32, PALETTE_TERRAIN_WINDOW_DOOR));
			windowDoorButton->SetToolTip(wxT("Window Tool"));
	} else {
		// Create the tool page with 16x16 icons
		// Create tool window #1

		ASSERT(gui.optional_brush);
		sub_sizer->Add(optionalBorderButton = newd BrushButton(this, gui.optional_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_OPTIONAL_BORDER_TOOL));
			optionalBorderButton->SetToolTip(wxT("Optional Border Tool"));

		ASSERT(gui.eraser);
		sub_sizer->Add(eraserButton = newd BrushButton(this, gui.eraser, RENDER_SIZE_16x16, PALETTE_TERRAIN_ERASER));
			eraserButton->SetToolTip(wxT("Eraser"));

		sub_sizer->AddSpacer(20);
		
		ASSERT(gui.normal_door_brush);
		sub_sizer->Add(normalDoorButton = newd BrushButton(this, gui.normal_door_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_NORMAL_DOOR));
			normalDoorButton->SetToolTip(wxT("Normal Door Tool"));

		ASSERT(gui.locked_door_brush);
		sub_sizer->Add(lockedDoorButton = newd BrushButton(this, gui.locked_door_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_LOCKED_DOOR));
			lockedDoorButton->SetToolTip(wxT("Locked Door Tool"));
			
		ASSERT(gui.magic_door_brush);
		sub_sizer->Add(magicDoorButton = newd BrushButton(this, gui.magic_door_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_MAGIC_DOOR));
			magicDoorButton->SetToolTip(wxT("Magic Door Tool"));
			
		ASSERT(gui.quest_door_brush);
		sub_sizer->Add(questDoorButton = newd BrushButton(this, gui.quest_door_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_QUEST_DOOR));
			questDoorButton->SetToolTip(wxT("Quest Door Tool"));
			
		ASSERT(gui.hatch_door_brush);
		sub_sizer->Add(hatchDoorButton = newd BrushButton(this, gui.hatch_door_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_HATCH_DOOR));
			hatchDoorButton->SetToolTip(wxT("Hatch Window Tool"));

		ASSERT(gui.window_door_brush);
		sub_sizer->Add(windowDoorButton = newd BrushButton(this, gui.window_door_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_WINDOW_DOOR));
			windowDoorButton->SetToolTip(wxT("Window Tool"));

		// Next row
		size_sizer->Add(sub_sizer);
		sub_sizer = newd wxBoxSizer(wxHORIZONTAL);

		
		ASSERT(gui.pz_brush);
		sub_sizer->Add(pzBrushButton = newd BrushButton(this, gui.pz_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_PZ_TOOL));
			pzBrushButton->SetToolTip(wxT("PZ Tool"));

		ASSERT(gui.rook_brush);
		sub_sizer->Add(nopvpBrushButton = newd BrushButton(this, gui.rook_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_NOPVP_TOOL));
			nopvpBrushButton->SetToolTip(wxT("NO PVP Tool"));

		ASSERT(gui.nolog_brush);
		sub_sizer->Add(nologBrushButton = newd BrushButton(this, gui.nolog_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_NOLOGOUT_TOOL));
			nologBrushButton->SetToolTip(wxT("No Logout Tool"));

		ASSERT(gui.pvp_brush);
		sub_sizer->Add(pvpzoneBrushButton = newd BrushButton(this, gui.pvp_brush, RENDER_SIZE_16x16, PALETTE_TERRAIN_PVPZONE_TOOL));
			pvpzoneBrushButton->SetToolTip(wxT("PVP Zone Tool"));
	}

	size_sizer->Add(sub_sizer);
	SetSizerAndFit(size_sizer);

	loaded = true;
}