this_deserves_saving
chamanEiqbal
c_cpp
2 years ago
3.0 kB
18
Indexable
#ifndef FRIENDSPANEL_H
#define FRIENDSPANEL_H
#include <wx/wx.h>
#include <wx/scrolwin.h>
class FriendsPanel : public wxPanel {
public:
FriendsPanel(wxWindow* parent) : wxPanel(parent) {
// Create a box sizer for the main layout
wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
// Create a scrolled window for horizontal scrolling
wxScrolledWindow* scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL);
// Create a box sizer for the scrolled window content
wxBoxSizer* scrolledBoxSizer = new wxBoxSizer(wxHORIZONTAL);
// Add square panels with names to the scrolled window
for (int i = 0; i < 15; ++i) { // You can adjust the number of panels
wxPanel* squarePanel = CreateSquarePanel(scrolledWindow, "Name " + std::to_string(i + 1));
scrolledBoxSizer->Add(squarePanel, 0, wxALL, 10); // Adjust spacing as needed
}
// Set the scrolled box sizer as the sizer for the scrolled window
scrolledWindow->SetSizer(scrolledBoxSizer);
// Set the minimum size of the scrolled window to ensure the horizontal scrollbar
scrolledWindow->SetMinSize(wxSize(400, -1)); // Adjust the width as needed
scrolledWindow->SetScrollRate(10, 0); // Adjust as needed
// Set the background color for the scrolled window
scrolledWindow->SetBackgroundColour(wxColour(0, 0, 0));
// Add the scrolled window to the main box sizer
boxSizer->Add(scrolledWindow, 1, wxEXPAND);
// Set the box sizer as the sizer for the panel
SetSizerAndFit(boxSizer);
// Set the background color for the main panel
SetBackgroundColour(wxColour(0, 0, 0));
}
private:
wxPanel* CreateSquarePanel(wxScrolledWindow* scrolledWindow, const wxString& name) {
// Create a square panel
wxPanel* panel = new wxPanel(scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(100, 100));
panel->SetBackgroundColour(wxColour(25, 25, 25)); // Square panel background color
// Add a text control to display the name
wxStaticText* nameLabel = new wxStaticText(panel, wxID_ANY, name, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
nameLabel->SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
nameLabel->SetForegroundColour(wxColour(100, 209, 10)); // Text color
// Create a box sizer for the square panel with margins
wxBoxSizer* panelSizer = new wxBoxSizer(wxVERTICAL);
panelSizer->Add(nameLabel, 1, wxEXPAND | wxALL, 5); // Margins
// Set the box sizer as the sizer for the panel
panel->SetSizer(panelSizer);
return panel;
}
};
#endif
Editor is loading...