Comments (5)
I think that should be wxPen, not wxBrush, and wxClientDC, however it doesn't make any difference.
<?php
$width = 180;
$height = 100;
$frame = new wxFrame(null, wxID_TOP, "Title", wxDefaultPosition, new wxSize($width, $height), ~wxCAPTION );
$panel = new wxPanel($frame, wxID_ANY, wxDefaultPosition, new wxSize($width, $height));
$chart = new wxClientDC($panel);
$chart->SetPen(new wxPen(new wxColour(255, 255, 255)));
$timer = new wxTimer();
$timer->Connect(wxEVT_TIMER, array(wxID_TOP, "refresh"));
$timer->Start(1000);
$frame->Show();
wxEntry();
function OnInit() {}
function OnExit() {}
//
function refresh()
{ global $chart, $height, $width ;
for($row=0; $row<$height; $row++)
{ for($col=0; $col<$width; $col++)
{ $chart->DrawPoint($col, $row);
}
}
}
?>
from wxphp.
Here I modified your sample to make it work:
<?php
$width = 180;
$height = 100;
$frame = new wxFrame(null, wxID_TOP, "Title", wxDefaultPosition, new wxSize($width, $height), ~wxCAPTION );
$panel = new wxPanel($frame, wxID_ANY, wxDefaultPosition, new wxSize($width, $height));
$panel->Connect(wxEVT_PAINT, array(null, "paint"));
$frame->Maximize(false);
$frame->Show();
wxEntry();
function OnInit() {}
function OnExit() {}
function paint(wxPaintEvent $event)
{
global $panel, $width, $height;
$dc = new wxPaintDC($panel);
$dc->SetPen(new wxPen(new wxColour(0xFF, 0, 0)));
for($row=0; $row<$height; $row++)
{ for($col=0; $col<$width; $col++)
{
$dc->DrawPoint($col, $row);
}
}
}
?>
from wxphp.
by the way I just did 2 commits:
-
Add support for wxNonOwnedWindow::SetShape which allows to create free form windows.
-
Disabled error messages when OnInit and OnExit can't be called, so now this short code samples can skip the following bits:
function OnInit() {}
function OnExit() {}
from wxphp.
I didn't put the ctor in the event handler because some forum comment said it wouldn't get destroyed and by repeated calling eventually you would run out of memory, but maybe that was due to the specific OOP structure of that example.
What is the event that wxEVT_PAINT is trapping? wxWidgets says wxPanel's events are wxNavigationKeyEvent, so if you don't touch the keyboard or mouse I would have thought it wouldn't fire.
Anyway I want the wxTimer event to be the trigger for updating the chart (I didn't mention that before). It seems to work with wxPaintDC, even though its not now in a wxEVT_PAINT handler, but it also works with wxClientDC, as expected.
All working fine now, many thanks again.
from wxphp.
- The $dc object is automatically destroyed when it goes out of scope so don't worry about that one.
- The wxEVT_PAINT is triggered everytime that the panel needs to be rendered. Examples: when drawing the element for the first time, when moving the window around, if the panel gets behind some element and then on the front again, if the element gets resized, etc...
- You can add a wxTimer that calls $frame->Refresh() or $panel->Refresh(), and that would force a paint event even if not required.
from wxphp.
Related Issues (20)
- wxDatePickerCtrl error on x64 windows build HOT 18
- Tooltips created in wxFormBuilder crash wxPHP HOT 1
- PHP Exceptions not working
- Build for php 7.0 version HOT 2
- xbindkeys and wxTextCtrl()
- Ubuntu 16.04 drops php5 support HOT 7
- macOS build - missing wxwidgets.so HOT 11
- AppImage needs exif extension HOT 3
- Request appimage built with PHP 7.1.0
- How can generate an `.exe` ms window file from `wxphp` php files? HOT 1
- WxPHP for PHP 7 HOT 122
- Difference from WinBinder HOT 6
- wxphp.org is down
- wxHtmlWindow::LoadFile() parameters, LoadPage($url)
- how to hide shell/cmd? HOT 3
- wxDataviewlistctrl method missing HOT 3
- internal zval's can't be arrays, objects or resources HOT 8
- initial set up for first wxphp
- Trying to compile HOT 5
- wxphp doesn't compile - lot of coding errors HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wxphp.