CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value);
+CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title);
+
CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id);
//! assigns callback for mouse events
cv::QtFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int /*spacing*/)
{
CvFont f = cvFontQt(nameFont.c_str(), pointSize,color,weight, style);
- return *(cv::QtFont*)(&f);
+ void* pf = &f; // to suppress strict-aliasing
+ return *(cv::QtFont*)pf;
}
void cv::addText( const Mat& img, const String& text, Point org, const QtFont& font)
// version with a more capable one without a need to recompile dependent
// applications or libraries.
+void cv::setWindowTitle(const String&, const String&)
+{
+ CV_Error(Error::StsNotImplemented, "The function is not implemented. "
+ "Rebuild the library with Windows, GTK+ 2.x or Carbon support. "
+ "If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script");
+}
#define CV_NO_GUI_ERROR(funcname) \
cvError( CV_StsError, funcname, \
Q_ARG(double, prop_value));
}
+void cv::setWindowTitle(const String& winname, const String& title)
+{
+ if (!guiMainThread)
+ CV_Error(Error::StsNullPtr, "NULL guiReceiver (please create a window)");
+
+ QMetaObject::invokeMethod(guiMainThread,
+ "setWindowTitle",
+ autoBlockingConnection(),
+ Q_ARG(QString, QString(winname.c_str())),
+ Q_ARG(QString, QString(title.c_str())));
+}
+
void cvSetModeWindow_QT(const char* name, double prop_value)
{
if (temp->type == type_CvWindow)
{
CvWindow* w = (CvWindow*) temp;
- if (w->windowTitle() == name)
+ if (w->objectName() == name)
{
window = w;
break;
if( !window_handle )
CV_Error( CV_StsNullPtr, "NULL window handler" );
- return ((CvWindow*)window_handle)->windowTitle().toLatin1().data();
+ return ((CvWindow*)window_handle)->objectName().toLatin1().data();
}
w->setPropWindow(flags);
}
+void GuiReceiver::setWindowTitle(QString name, QString title)
+{
+ QPointer<CvWindow> w = icvFindWindowByName(name);
+
+ if (!w)
+ {
+ cvNamedWindow(name.toLatin1().data());
+ w = icvFindWindowByName(name);
+ }
+
+ if (!w)
+ return;
+
+ w->setWindowTitle(title);
+}
+
double GuiReceiver::isFullScreen(QString name)
{
//no value pos was saved so we let Qt move the window in the middle of its parent (event ignored).
//then hide will save the last position and thus, we want to retreive it (event accepted).
QPoint mypos(-1, -1);
- QSettings settings("OpenCV2", windowTitle());
+ QSettings settings("OpenCV2", objectName());
mypos = settings.value("pos", mypos).toPoint();
if (mypos.x() >= 0)
void CvWinProperties::hideEvent(QHideEvent* evnt)
{
- QSettings settings("OpenCV2", windowTitle());
+ QSettings settings("OpenCV2", objectName());
settings.setValue("pos", pos()); //there is an offset of 6 pixels (so the window's position is wrong -- why ?)
evnt->accept();
}
CvWinProperties::~CvWinProperties()
{
//clear the setting pos
- QSettings settings("OpenCV2", windowTitle());
+ QSettings settings("OpenCV2", objectName());
settings.remove("pos");
}
//setAttribute(Qt::WA_DeleteOnClose); //in other case, does not release memory
setContentsMargins(0, 0, 0, 0);
setWindowTitle(name);
- setObjectName(name);
+ setObjectName(name);
- setFocus( Qt::PopupFocusReason ); //#1695 arrow keys are not received without the explicit focus
+ setFocus( Qt::PopupFocusReason ); //#1695 arrow keys are not received without the explicit focus
resize(400, 300);
setMinimumSize(1, 1);
}
}
-
void CvWindow::toggleFullScreen(int flags)
{
if (isFullScreen() && flags == CV_WINDOW_NORMAL)
double isFullScreen(QString name);
double getPropWindow(QString name);
void setPropWindow(QString name, double flags );
+ void setWindowTitle(QString name, QString title);
double getRatioWindow(QString name);
void setRatioWindow(QString name, double arg2 );
void saveWindowParameters(QString name);
__END__;
}
+void cv::setWindowTitle(const String& winname, const String& title)
+{
+ CvWindow* window = icvFindWindowByName(winname.c_str());
+
+ if (!window)
+ {
+ namedWindow(winname);
+ window = icvFindWindowByName(winname.c_str());
+ }
+
+ if (!window)
+ CV_Error(Error::StsNullPtr, "NULL window");
+
+ if (noErr != SetWindowTitleWithCFString(window->window, CFStringCreateWithCString(NULL, title.c_str(), kCFStringEncodingASCII)))
+ CV_Error_(Error::StsError, ("Failed to set \"%s\" window title to \"%s\"", winname.c_str(), title.c_str()));
+}
+
CV_IMPL int cvNamedWindow( const char* name, int flags )
{
int result = 0;
__END__;
}
+void cv::setWindowTitle(const String& winname, const String& title)
+{
+ CVWindow *window = cvGetWindow(winname.c_str());
+
+ if (window == NULL)
+ {
+ namedWindow(winname);
+ window = cvGetWindow(winname.c_str());
+ }
+
+ if (window == NULL)
+ CV_Error(Error::StsNullPtr, "NULL window");
+
+ NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
+
+ NSString *windowTitle = [NSString stringWithFormat:@"%s", title.c_str()];
+ [window setTitle:windowTitle];
+
+ [localpool drain];
+}
+
@implementation CVWindow
@synthesize mouseCallback;
__END__;
}
+void cv::setWindowTitle(const String& winname, const String& title)
+{
+ CvWindow* window = icvFindWindowByName(winname.c_str());
+
+ if (!window)
+ {
+ namedWindow(winname);
+ window = icvFindWindowByName(winname.c_str());
+ }
+
+ if (!window)
+ CV_Error(Error::StsNullPtr, "NULL window");
+
+ CV_LOCK_MUTEX();
+ gtk_window_set_title(GTK_WINDOW(window->frame), title.c_str());
+ CV_UNLOCK_MUTEX();
+}
double cvGetPropWindowAutoSize_GTK(const char* name)
{
__END__;
}
+void cv::setWindowTitle(const String& winname, const String& title)
+{
+ CvWindow* window = icvFindWindowByName(winname.c_str());
+
+ if (!window)
+ {
+ namedWindow(winname);
+ window = icvFindWindowByName(winname.c_str());
+ }
+
+ if (!window)
+ CV_Error(Error::StsNullPtr, "NULL window");
+
+ if (!SetWindowText(window->frame, title.c_str()))
+ CV_Error_(Error::StsError, ("Failed to set \"%s\" window title to \"%s\"", winname.c_str(), title.c_str()));
+}
+
double cvGetPropWindowAutoSize_W32(const char* name)
{
double result = -1;