File: toolbar.hh

package info (click to toggle)
sapphire 0.15.8-9.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 448 kB
  • ctags: 850
  • sloc: cpp: 6,490; makefile: 102; sh: 77
file content (150 lines) | stat: -rw-r--r-- 4,448 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * Copyright (C) 1999,2000,2001 Frank Hale
 * frankhale@yahoo.com
 * http://sapphire.sourceforge.net/
 *
 * Updated: 3 Nov 2001
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */


#ifndef _TOOLBAR_HH_
#define _TOOLBAR_HH_

// Toolbar menu is a combination of your icon and root menus. 
class ToolbarMenu : public BaseMenu
{
public:
	ToolbarMenu();
	
	// addMenu inserts an already created menu into the Toolbar menu
	// the idea is that the toolbar menu will be a combination of your
	// icon menu, root menu, and in the future the workspace menu.
	void addMenu(char *title, BaseMenu *sub);
	
};

// The declaration of the Toolbar class. This class describes all the code
// used to maintain a toolbar in Sapphire.
class Toolbar 
{
private: /* variables */
	Pixmap frame_pix;
	Pixmap clock_pix;
	Pixmap button_pix;
	Pixmap root_pix;

	XSetWindowAttributes attrib;
	unsigned long create_mask;

	struct Frame {
		Window window;
		int x,y;
		unsigned int width,height;
	};
	
	Frame frame;
	
	// This describes the default button width/height used by the toolbar. I have
	// adopted the size as 15 pixels for both width and height for buttons. That goes
	// for toolbar buttons aswell.
	int default_button_width;
	int default_button_height;

	// This describes the width of the font used to calculate the size of the clock 
	// window. Its also used in order to place the clock on the toolbar so that its
	// fully visible.
	int font_width;

	// This is the current set of widgets on the toolbar.
	Widget startmenu;
	Widget clock;
	Widget cycleUp;
	Widget cycleDown;
	
	// Used to hold 
	char *Month[12];

	// Represents the toolbar menu
	ToolbarMenu *tm;
	
	// Is the toolbarMenuVisible? 
	bool toolbarMenuVisible;

public: /* member functions */

	// Toolbar constructor this creates the Sapphire toolbar.
	Toolbar();
	
	// Destructor takes care of clean up (ie. deleting the pixmaps, detroying windows
	// no longer needed, and removing images from the image cache.
	~Toolbar();

	// lets another class gain access to the toolbar menu.
	ToolbarMenu *getToolbarMenu() const { return tm; } 

	// If things change then we need to reconfigure
	void reconfigure();
	
	void do_button_press_event(XButtonEvent *e);
	void handle_expose_event(XExposeEvent *e);	
	
	void redraw();	
	void checkClock(bool redraw=False);
	
	void hideToolbar();
	void showToolbar();
	
	// I use this to reset the start button if you select the menu
	// from the root background. If the menu is popped up on the start
	// menu then we have to reset and hide that menu since it contains the same
	// menu's as the ones which pops up when you right click or middle click
	// on the root window.
	void setStartMenuButtonStateNotPressed();
	void changeTheme();	

	//void desktopChanged();
private:
	
	// The next set of 5 functions create the windows which are associated with
	// the Sapphire toolbar.
	void createToolbarWindow();
	void createClockWindow();
	void createCycleUpButtonWindow();
	void createCycleDownButtonWindow();
	void createStartMenuButtonWindow();;
	
	// The next 4 functions are used to create the images and pixmaps which are 
	// used to make the toolbar look cool.
	void createToolBarImage();
	void createButtonImage();
	void createClockImage();
	void createRootImage();
	
	// The next 3 functions are button handler functions. These dispatch the code
	// which executes the various functions the toolbar offers.
	void popup_toolbar_menu();
	void cycle_windows_up();
	void cycle_windows_down();

	// This function draws the start menu button in two different states. 
	// 
	// 	- pointing up
	//	- pointing down
	void drawStartMenuButton();
};

#endif