Code in a corner?

Linux specific forum
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Code in a corner?

Post by Berikco »

Well, we all now I'm a little bit lazy....just don't want to reinvent the wheel :)

Anybody has code somewhere in a dark corner of his hard disk for:

- Changing the mouse cursor.
- Set background of ContainerGadget (not with a ImageGadget, but the API Brush way like windows)

And...

How the hell can i make transparent png's using Paint Shop pro ? (on windows)
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: Code in a corner?

Post by dhouston »

Berikco wrote:How the hell can i make transparent png's using Paint Shop pro ? (on windows)
There are numerous PSP tutorials that cover this. Here's one...
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

my psp version was to old :lol:
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

Why you're not using the GIMP?
There is a Windows Version too and creating a transparent PNG can't be easier than with the GIMP.....
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Post by Foz »

Because he is used to working in PSP?

No point halting everything else while you learn another tool when a simple upgrade will fix things for you.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

so... after rebooting from Win to Linux.. here's a way to change the background of EVERY widget as you wish:
I'm using a gtkrc-file to achieve this... there is a way without.. but I'd never used that way...

1st: create a file with the following content:

Code: Select all

pixmap_path "./images"

style "container_style"
{
bg_pixmap[NORMAL] = "my_background.png"
  bg[NORMAL] = {0.755, 0.755, 0.9555}
  fg[NORMAL] = {0.000, 0.000, 0.000}
}

widget "*mycontainer" style "container_style"
adapt the image name and the path to the images.. if in the same directory, imagepath = "."
The image should be seamless as it is used to fill the gadget regardless of it's size

in your code you'll need the following lines
somewhere at startup before creating the window/Gadget

Code: Select all

gtk_rc_parse_(rcfile);including path; best place is in the same dir as the executable
and the following line after the gadget is created

Code: Select all

gtk_widget_set_name_(GadgetID(<your_container_id>),"mycontainer")
if you made changes to your style, use

Code: Select all

gtk_rc_reparse_all()
to re-read all used gtkrc-style files...

that's the easy way to change a widgets background and color... 8)

To set a cursor you'll need the following:

Code: Select all

mycursor=gdk_cursor_new_(#GDK_WATCH )
gdk_window_set_cursor_(WindowID(hwnd) , mycursor)
but I can't get this to work... regarding the GDK documentation that's all you need to change a cursor :roll:
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

SetGadgetColor() ... ;)

About the cursor:
WindowID() returns a GtkWindow, not a GdkWindow pointer.
So to use Gdk functions on it, do somethink like this:

Code: Select all

*Widget.GtkWidget = WindowID(...) ; A GtkWindow is also a GtkWidget
*GdkWindow = *Widget\Window
quidquid Latine dictum sit altum videtur
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

freak wrote:SetGadgetColor() ... ;)
well .. too easy :D

EDIT
uups.. your post is growing... :wink:

ha.. that's it :) :) pointing a gtk window to a gdk window to change the pointer
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Post by Foz »

yup, that works a charm:

Code: Select all

If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  mycursor=gdk_cursor_new_(#GDK_WATCH )
  *Widget.GtkWidget = WindowID(0)
  *GdkWindow = *Widget\Window
  gdk_window_set_cursor_(*GdkWindow , mycursor) 

  Repeat
    EventID = WaitWindowEvent()

    If EventID = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf
  Until Quit = 1
EndIf
End
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

No need for a setgadgetcolor replacement :)

The image is created in memory, so no file can be used.

Now what are the possible build in cursors?

edit: Found the cursors...
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

for all others who might be interestred see:
http://library.gnome.org/devel/gdk/unst ... #GdkCursor
Post Reply