Page 1 of 1
Code in a corner?
Posted: Sat Dec 15, 2007 5:58 pm
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)
Re: Code in a corner?
Posted: Sat Dec 15, 2007 6:48 pm
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...
Posted: Sat Dec 15, 2007 8:47 pm
by Berikco
my psp version was to old

Posted: Sat Dec 15, 2007 9:04 pm
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.....
Posted: Sat Dec 15, 2007 9:43 pm
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.
Posted: Sat Dec 15, 2007 10:27 pm
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
to re-read all used gtkrc-style files...
that's the easy way to change a widgets background and color...
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:
Posted: Sat Dec 15, 2007 10:30 pm
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
Posted: Sat Dec 15, 2007 10:33 pm
by walker
freak wrote:SetGadgetColor() ...

well .. too easy
EDIT
uups.. your post is growing...
ha.. that's it

pointing a gtk window to a gdk window to change the pointer
Posted: Sat Dec 15, 2007 10:38 pm
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
Posted: Sun Dec 16, 2007 12:04 am
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...
Posted: Sun Dec 16, 2007 12:46 am
by walker