Search found 13 matches

by Eman
Tue Sep 03, 2019 10:53 am
Forum: C++ Development
Topic: Getting data from clickable panel
Replies: 1
Views: 65

Getting data from clickable panel

Hello, I have class Cell that inherits from wxPanel, and it has its own data members( int x and int y set by i and j in the for loop below) I used Connect to make each cell clicakble and trigger the click event cellsArray[i][j]->Connect(idd, wxEVT_LEFT_DOWN, wxMouseEventHandler(GUI::OnLeftClick),NUL...
by Eman
Mon Sep 02, 2019 11:55 am
Forum: C++ Development
Topic: Adding 2d array of wxPanel to wxGridSizer
Replies: 7
Views: 136

Re: Adding 2d array of wxPanel to wxGridSizer

Thanks a lot for helping It works perfectly. I'm posting the code here to help others: /////////////////////////////////////////////////////////// int row = 8; int col = 8; wxGridSizer *gridM = new wxGridSizer(row,col,0,0); // 2d array of panels wxPanel ***cellsArray = new wxPanel**[row]; // allocat...
by Eman
Mon Sep 02, 2019 9:56 am
Forum: C++ Development
Topic: Adding 2d array of wxPanel to wxGridSizer
Replies: 7
Views: 136

Re: Adding 2d array of wxPanel to wxGridSizer

This line compile and run without any errors, but the border still not appear

Code: Select all

Array[i][j] = new wxPanel(panel, -1, wxDefaultPosition, wxDefaultSize,wxBORDER_SIMPLE);
by Eman
Mon Sep 02, 2019 9:44 am
Forum: C++ Development
Topic: Adding 2d array of wxPanel to wxGridSizer
Replies: 7
Views: 136

Re: Adding 2d array of wxPanel to wxGridSizer

This works! /////////////////////////////////////////////////////////// int row = 2; int col = 4; wxGridSizer *gridM = new wxGridSizer(row,col,0,0); // 2d array of panels wxPanel ***cellsArray = new wxPanel**[row]; // allocate rows for(int i = 0; i < row; i++) { cellsArray[i] = new wxPanel*[col]; //...
by Eman
Mon Sep 02, 2019 9:27 am
Forum: C++ Development
Topic: Adding 2d array of wxPanel to wxGridSizer
Replies: 7
Views: 136

Re: Adding 2d array of wxPanel to wxGridSizer

I searched for this error. It is because the copy constructor of wxPanel is private
Any ideas?
by Eman
Mon Sep 02, 2019 8:22 am
Forum: C++ Development
Topic: Adding 2d array of wxPanel to wxGridSizer
Replies: 7
Views: 136

Re: Adding 2d array of wxPanel to wxGridSizer

Thanks for help /////////////////////////////////////////////////////////// int row = 2; int col = 4; wxGridSizer *gridM = new wxGridSizer(row,col,0,0); // 2d array of panels wxPanel **cellsArray = new wxPanel*[row]; // allocate rows for(int i = 0; i < row; i++) { cellsArray[i] = new wxPanel[col]; /...
by Eman
Sun Sep 01, 2019 3:40 pm
Forum: C++ Development
Topic: Adding 2d array of wxPanel to wxGridSizer
Replies: 7
Views: 136

Adding 2d array of wxPanel to wxGridSizer

Hello, I want to place wxPanels representing a grid map into wxGridSizer int row = 2; int col = 4; wxPanel **cellsArray = new wxPanel*[row]; for(int i = 0; i < row; i++) { cellsArray[i] = new wxPanel[col]; } wxGridSizer *gridM = new wxGridSizer(2,4,0,0); But, adding wxPanel as an element of cellsArr...
by Eman
Sun Sep 01, 2019 1:35 pm
Forum: C++ Development
Topic: Creating Grid
Replies: 9
Views: 155

Re: Creating Grid

main.h #include <wx/wx.h> class MyApp : public wxApp { public: virtual bool OnInit(); }; main.cpp #include "main.h" #include "align.h" IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { Align *align = new Align(wxT("Align")); align->Show(true); return true; } I created class Cell that inherits from wxPane...
by Eman
Sun Sep 01, 2019 1:34 pm
Forum: C++ Development
Topic: Creating Grid
Replies: 9
Views: 155

Re: Creating Grid

align.h #include <wx/wx.h> class Align : public wxFrame { public: Align(const wxString& title); }; aligh.cpp #include "align.h" #include "cell.h" Align::Align(const wxString& title) : wxFrame(NULL, -1, title, wxPoint(-1, -1), wxSize(500, 500)) { wxPanel *panel = new wxPanel(this, -1); wxBoxSizer *v...
by Eman
Sun Sep 01, 2019 1:33 pm
Forum: C++ Development
Topic: Creating Grid
Replies: 9
Views: 155

Re: Creating Grid

I created the following layout:
vboxMap ==> contains the 2d grid in the left
vboxControls ==> contains the (ok & cancel) buttons in the right

Cell.h

Code: Select all

#include <wx/wx.h>

class Cell : public wxPanel
{
public:
    Cell();

};
Cell.cpp

Code: Select all

#include "cell.h"

Cell::Cell()
	:wxPanel()
{
}
by Eman
Sat Aug 31, 2019 3:29 pm
Forum: C++ Development
Topic: Creating Grid
Replies: 9
Views: 155

Re: Creating Grid

doublemax wrote:
Sat Aug 31, 2019 2:29 pm
For smaller grids, you could derive a class from wxPanel to be used for each cell and put them in a wxGrid[Bag]Sizer.
Do you mean using wxGridBagSizer instead of using wxGridSizer?
by Eman
Sat Aug 31, 2019 2:43 pm
Forum: C++ Development
Topic: Creating Grid
Replies: 9
Views: 155

Re: Creating Grid

The grid could be 8X8 or 16X16 or 32X32 or 64X64
by Eman
Sat Aug 31, 2019 2:19 pm
Forum: C++ Development
Topic: Creating Grid
Replies: 9
Views: 155

Creating Grid

Hello, I am not new to C++ but new to wxWidgets. I need to draw a 2d grid such that each cell has a coordinates (1,1) (1,2).... I need the cells to be clickable, so that when a cell is clicked, its coordinate is registered to be used in some calculations. Also, I need to set a color to cells(set col...