[Kde-java] Some questions - long - KScribble in java

Richard Dale kde-java@kde.org
Tue, 12 Feb 2002 12:02:19 +0000


On Tuesday 12 February 2002 9:21 am, KJ P wrote:
> Thanks for the reply and the help.  I posted a longer response last night
> but it is being held because it is over the limit.  I will try to remember
> what I wrote as it was very late.
>
> The other e-mail has all the source attached so if they will allow it you
> will receive the source as well.  If not I will attach it later as I do not
> have the source here at this time.
Please email any long examples to me directly, if they still don't get onto 
the kde-java list.

> > > I can not find BarIcon.  Is it missing or have I missed something.
> >
> >I've had a look - and it is missing because it's a function call rather
> >than a
> >static method of KIconLoader. So that needs to be fixed up by hand - in
> >java
> >the functions at the end of kiconloader.h would appear as KIconLoader
> >static
> >methods.
>
> Instead of KStdAction I decided to go with the BarIcon so that the programs
> are the same for comparison purposes.  This works well but I added 2
> methods to KScribble.java.
>
> One called BarIcon() and another called BarIcon2.
> The BarIcon will return a Pixmap by using the KIconLoader method.  This is
> used in the toolbar().
>
> The BarIcon2 will return a QIconSet by creating a QIconSet and calling
> BarIcon() to load the icons into a set.  This is used in the menubar()
> because I could not get Pixmap version to work properly.  It does work for
> the IconSets.  For the pixmap version the Graphic part was showing up but
> the text part was not.
>
> I can change this to use the KStdAction if you want but for comparison
> reasons I left it using the BarIcon.  If you decide to not implement the
> BarIcon let me know.
Yes, I will - I'll try and do that today.

> > > 2) Does the i18n not exist for java?  KBase.java uses tr() so instead I
> > > wrote an i18n method which calls tr() that way I did not have to change
> >
> >all
> >
> > > the i18n code.  Is the tr() method going to be used instead of the
> > > i18n?
> >
> >Yes, it should be there. I'll add your version if you post it on this list
> >or
> >send it to me.
>
> Sorry for not expaining this correctly.  I added a method to KScribble.java
> like the following:
>
> private String i18n (String lit) {
>    return tr(lit);
>
> }
>
> I do not have cvs setup for KDE.  I am using the sources from the KDE
> WebCVS when I want to look at the sources.  I hope to remedy this soon so I
> can hopefully help you on this instead of just feeding problems to you.
I'll add an i18n() like that to Qt.java.

> >This compiles, but it crashes:
> >
> >private static final int ID_HELP_WHATS_THIS = 1;
> >	...
> >
> >	QToolButton btnwhat = QWhatsThis.whatsThisButton(toolBar());
> >	QToolTip.add(btnwhat, "What's this...?");
> >	toolBar().insertWidget(ID_HELP_WHATS_THIS, btnwhat.sizeHint().width(),
> >btnwhat);
> >
> >I'm investigating what's wrong.
>
> I had not problem with this at all.  It worked beautifully.  Actually it is
> close to what I had but I was missing something.  I should have looked
> closer but was tired.
Good - I seem to have a strange problem with my build of kdelibs/kdejava with 
crashes in QApplication.exec() outside the java code. I don't think it's a 
bug though if the version in HEAD works for you (the KBase example crashes 
for me too at the moment).

> > > I tried the buffer.load( filename, format, conv) method.
>
> The same problem with the buffer.save method.
I'll look at that.

> What I mentioned in the other e-mail about KMainWindow and KTMainWindow
> please ignore for now.  If the other e-mail goes through.  Still off topic
> I know but KTMainWindow doc says it is deprecated but the tutorials for the
> xmlgui still use it.  What is the way to go?
KMainWindow is the one..

> The following are from memory so please excuse me if they are not exactly
> correct.
>
>
> void  viewportDragEnterEvent ( QDragEnterEvent e) {
>   e.accept(QImageDrag.canDecode(e));
>   action = DRAG;
> }
>
> QImageDrag.canDecode(e) crashes with a recursive error 2.  I tried multiple
> ways of doing this but could not get it work.  The canDecode is a static
> method but I tried with instantiating objects as well.  I could not get the
> kscribble.cpp to work either.  It was not crashing but it would hang.
>
> void  viewportDragMoveEvent ( QDragMoveEvent e) {
>   QImage img = new QImage();
>   if ( QImageDrag.decode(e, img) ){
>
> QImageDrag.decode(e,img) crashes with a recursive error 2 as well.  I got
> here because I commented out the   e.accept(QImageDrag.canDecode(e)); in
> the previous just to see what would happen.  I tried multiple was of this
> as well.
>
> Still it was late so could be my fault.
I've been meaning to test dragging for a while, so this code seems a good 
place to start.

> There is also a reference to the following:
> QScrollView::viewportPaintEvent(e);
>
> I did not implement this as I am not sure what it does exactly.  I did read
> the docs but could not figure out if it was needed or not.  If it is it is
> a static method and does not exist in the java bindings as such.  I will
> take a closer look at this later unless you have the time to explain it
> here. Maybe it is a method call that I did not see last night?
I think that's a normal event handler, so you should be able to override it ok 
in java.

> I will send the sources later today.  They are still rough and not really
> ready but at least you will see what I am talking about.
Thanks - please mail them to me direct if too big..

-- Richard